aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds2021-04-26 11:14:21 -0700
committerLinus Torvalds2021-04-26 11:14:21 -0700
commit8900d92fd666d936a7bfb4c567ac26736a414fb4 (patch)
tree19c37bab5adc8d40d825cb629edf0e8a337955a2 /drivers
parentc01c0716ccf5db2086d9693033472f37de96a699 (diff)
parentc295d3007ff63064181befa734d9705dfc10b396 (diff)
Merge tag 'staging-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging/IIO driver updates from Greg KH: "Here is the big set of staging and IIO driver updates for 5.13-rc1. Lots of little churn in here, and some larger churn as well. Major things are: - removal of wimax drivers, no one has this hardware anymore for this failed "experiment". - removal of the Google gasket driver, turns out no one wanted to maintain it or cares about it anymore, so they asked for it to be removed. - comedi finally moves out of the staging directory into drivers/comedi This is one of the oldest kernel subsystems around, being created in the 2.0 kernel days, and was one of the first things added to drivers/staging/ when that was created over 15 years ago. It should have been moved out of staging a long time ago, it's well maintained and used by loads of different devices in the real world every day. Nice to see this finally happen. - so many tiny coding style cleanups it's not funny. Perfect storm of at least 2 different intern project application deadlines combined to provide a huge number of new contributions in this area from people learning how to do kernel development. Great job to everyone involved here. There's also the normal updates for IIO drivers with new IIO drivers and updates all over that subsystem. All of these have been in linux-next for a while with no reported issues" * tag 'staging-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (907 commits) staging: octeon: Use 'for_each_child_of_node' Staging: rtl8723bs: rtw_xmit: fixed tabbing issue staging: rtl8188eu: remove unused function parameters staging: rtl8188eu: cmdThread is a task_struct staging: rtl8188eu: remove constant variable and dead code staging: rtl8188eu: change bLeisurePs' type to bool staging: rtl8723bs: remove empty #ifdef block staging: rtl8723bs: remove unused DBG_871X_LEVEL macro declarations staging: rtl8723bs: split too long line staging: rtl8723bs: fix indentation in if block staging: rtl8723bs: fix code indent issue staging: rtl8723bs: replace DBG_871X_LEVEL logs with netdev_*() staging: rtl8192e: indent statement properly staging: rtl8723bs: Remove led_blink_hdl() and everything related staging: comedi: move out of staging directory staging: rtl8723bs: remove sdio_drv_priv structure staging: rtl8723bs: remove unused argument in function staging: rtl8723bs: remove DBG_871X_SEL_NL macro declaration staging: rtl8723bs: replace DBG_871X_SEL_NL with netdev_dbg() staging: rtl8723bs: fix indentation issue introduced by long line split ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/comedi/Kconfig (renamed from drivers/staging/comedi/Kconfig)33
-rw-r--r--drivers/comedi/Makefile (renamed from drivers/staging/comedi/Makefile)0
-rw-r--r--drivers/comedi/TODO (renamed from drivers/staging/comedi/TODO)0
-rw-r--r--drivers/comedi/comedi.h (renamed from drivers/staging/comedi/comedi.h)0
-rw-r--r--drivers/comedi/comedi_buf.c (renamed from drivers/staging/comedi/comedi_buf.c)52
-rw-r--r--drivers/comedi/comedi_fops.c (renamed from drivers/staging/comedi/comedi_fops.c)0
-rw-r--r--drivers/comedi/comedi_internal.h (renamed from drivers/staging/comedi/comedi_internal.h)0
-rw-r--r--drivers/comedi/comedi_pci.c (renamed from drivers/staging/comedi/comedi_pci.c)0
-rw-r--r--drivers/comedi/comedi_pci.h (renamed from drivers/staging/comedi/comedi_pci.h)0
-rw-r--r--drivers/comedi/comedi_pcmcia.c (renamed from drivers/staging/comedi/comedi_pcmcia.c)0
-rw-r--r--drivers/comedi/comedi_pcmcia.h (renamed from drivers/staging/comedi/comedi_pcmcia.h)0
-rw-r--r--drivers/comedi/comedi_usb.c (renamed from drivers/staging/comedi/comedi_usb.c)0
-rw-r--r--drivers/comedi/comedi_usb.h (renamed from drivers/staging/comedi/comedi_usb.h)0
-rw-r--r--drivers/comedi/comedidev.h (renamed from drivers/staging/comedi/comedidev.h)0
-rw-r--r--drivers/comedi/comedilib.h (renamed from drivers/staging/comedi/comedilib.h)0
-rw-r--r--drivers/comedi/drivers.c (renamed from drivers/staging/comedi/drivers.c)0
-rw-r--r--drivers/comedi/drivers/8255.c (renamed from drivers/staging/comedi/drivers/8255.c)0
-rw-r--r--drivers/comedi/drivers/8255.h (renamed from drivers/staging/comedi/drivers/8255.h)0
-rw-r--r--drivers/comedi/drivers/8255_pci.c (renamed from drivers/staging/comedi/drivers/8255_pci.c)0
-rw-r--r--drivers/comedi/drivers/Makefile (renamed from drivers/staging/comedi/drivers/Makefile)0
-rw-r--r--drivers/comedi/drivers/addi_apci_1032.c (renamed from drivers/staging/comedi/drivers/addi_apci_1032.c)0
-rw-r--r--drivers/comedi/drivers/addi_apci_1500.c (renamed from drivers/staging/comedi/drivers/addi_apci_1500.c)0
-rw-r--r--drivers/comedi/drivers/addi_apci_1516.c (renamed from drivers/staging/comedi/drivers/addi_apci_1516.c)0
-rw-r--r--drivers/comedi/drivers/addi_apci_1564.c (renamed from drivers/staging/comedi/drivers/addi_apci_1564.c)0
-rw-r--r--drivers/comedi/drivers/addi_apci_16xx.c (renamed from drivers/staging/comedi/drivers/addi_apci_16xx.c)2
-rw-r--r--drivers/comedi/drivers/addi_apci_2032.c (renamed from drivers/staging/comedi/drivers/addi_apci_2032.c)0
-rw-r--r--drivers/comedi/drivers/addi_apci_2200.c (renamed from drivers/staging/comedi/drivers/addi_apci_2200.c)0
-rw-r--r--drivers/comedi/drivers/addi_apci_3120.c (renamed from drivers/staging/comedi/drivers/addi_apci_3120.c)0
-rw-r--r--drivers/comedi/drivers/addi_apci_3501.c (renamed from drivers/staging/comedi/drivers/addi_apci_3501.c)0
-rw-r--r--drivers/comedi/drivers/addi_apci_3xxx.c (renamed from drivers/staging/comedi/drivers/addi_apci_3xxx.c)0
-rw-r--r--drivers/comedi/drivers/addi_tcw.h (renamed from drivers/staging/comedi/drivers/addi_tcw.h)0
-rw-r--r--drivers/comedi/drivers/addi_watchdog.c (renamed from drivers/staging/comedi/drivers/addi_watchdog.c)0
-rw-r--r--drivers/comedi/drivers/addi_watchdog.h (renamed from drivers/staging/comedi/drivers/addi_watchdog.h)0
-rw-r--r--drivers/comedi/drivers/adl_pci6208.c (renamed from drivers/staging/comedi/drivers/adl_pci6208.c)0
-rw-r--r--drivers/comedi/drivers/adl_pci7x3x.c (renamed from drivers/staging/comedi/drivers/adl_pci7x3x.c)0
-rw-r--r--drivers/comedi/drivers/adl_pci8164.c (renamed from drivers/staging/comedi/drivers/adl_pci8164.c)0
-rw-r--r--drivers/comedi/drivers/adl_pci9111.c (renamed from drivers/staging/comedi/drivers/adl_pci9111.c)0
-rw-r--r--drivers/comedi/drivers/adl_pci9118.c (renamed from drivers/staging/comedi/drivers/adl_pci9118.c)0
-rw-r--r--drivers/comedi/drivers/adq12b.c (renamed from drivers/staging/comedi/drivers/adq12b.c)0
-rw-r--r--drivers/comedi/drivers/adv_pci1710.c (renamed from drivers/staging/comedi/drivers/adv_pci1710.c)0
-rw-r--r--drivers/comedi/drivers/adv_pci1720.c (renamed from drivers/staging/comedi/drivers/adv_pci1720.c)0
-rw-r--r--drivers/comedi/drivers/adv_pci1723.c (renamed from drivers/staging/comedi/drivers/adv_pci1723.c)0
-rw-r--r--drivers/comedi/drivers/adv_pci1724.c (renamed from drivers/staging/comedi/drivers/adv_pci1724.c)0
-rw-r--r--drivers/comedi/drivers/adv_pci1760.c (renamed from drivers/staging/comedi/drivers/adv_pci1760.c)0
-rw-r--r--drivers/comedi/drivers/adv_pci_dio.c (renamed from drivers/staging/comedi/drivers/adv_pci_dio.c)1
-rw-r--r--drivers/comedi/drivers/aio_aio12_8.c (renamed from drivers/staging/comedi/drivers/aio_aio12_8.c)0
-rw-r--r--drivers/comedi/drivers/aio_iiro_16.c (renamed from drivers/staging/comedi/drivers/aio_iiro_16.c)0
-rw-r--r--drivers/comedi/drivers/amcc_s5933.h (renamed from drivers/staging/comedi/drivers/amcc_s5933.h)0
-rw-r--r--drivers/comedi/drivers/amplc_dio200.c (renamed from drivers/staging/comedi/drivers/amplc_dio200.c)0
-rw-r--r--drivers/comedi/drivers/amplc_dio200.h (renamed from drivers/staging/comedi/drivers/amplc_dio200.h)0
-rw-r--r--drivers/comedi/drivers/amplc_dio200_common.c (renamed from drivers/staging/comedi/drivers/amplc_dio200_common.c)0
-rw-r--r--drivers/comedi/drivers/amplc_dio200_pci.c (renamed from drivers/staging/comedi/drivers/amplc_dio200_pci.c)0
-rw-r--r--drivers/comedi/drivers/amplc_pc236.c (renamed from drivers/staging/comedi/drivers/amplc_pc236.c)0
-rw-r--r--drivers/comedi/drivers/amplc_pc236.h (renamed from drivers/staging/comedi/drivers/amplc_pc236.h)0
-rw-r--r--drivers/comedi/drivers/amplc_pc236_common.c (renamed from drivers/staging/comedi/drivers/amplc_pc236_common.c)0
-rw-r--r--drivers/comedi/drivers/amplc_pc263.c (renamed from drivers/staging/comedi/drivers/amplc_pc263.c)0
-rw-r--r--drivers/comedi/drivers/amplc_pci224.c (renamed from drivers/staging/comedi/drivers/amplc_pci224.c)0
-rw-r--r--drivers/comedi/drivers/amplc_pci230.c (renamed from drivers/staging/comedi/drivers/amplc_pci230.c)0
-rw-r--r--drivers/comedi/drivers/amplc_pci236.c (renamed from drivers/staging/comedi/drivers/amplc_pci236.c)0
-rw-r--r--drivers/comedi/drivers/amplc_pci263.c (renamed from drivers/staging/comedi/drivers/amplc_pci263.c)0
-rw-r--r--drivers/comedi/drivers/c6xdigio.c (renamed from drivers/staging/comedi/drivers/c6xdigio.c)0
-rw-r--r--drivers/comedi/drivers/cb_das16_cs.c (renamed from drivers/staging/comedi/drivers/cb_das16_cs.c)0
-rw-r--r--drivers/comedi/drivers/cb_pcidas.c (renamed from drivers/staging/comedi/drivers/cb_pcidas.c)0
-rw-r--r--drivers/comedi/drivers/cb_pcidas64.c (renamed from drivers/staging/comedi/drivers/cb_pcidas64.c)5
-rw-r--r--drivers/comedi/drivers/cb_pcidda.c (renamed from drivers/staging/comedi/drivers/cb_pcidda.c)0
-rw-r--r--drivers/comedi/drivers/cb_pcimdas.c (renamed from drivers/staging/comedi/drivers/cb_pcimdas.c)0
-rw-r--r--drivers/comedi/drivers/cb_pcimdda.c (renamed from drivers/staging/comedi/drivers/cb_pcimdda.c)0
-rw-r--r--drivers/comedi/drivers/comedi_8254.c (renamed from drivers/staging/comedi/drivers/comedi_8254.c)0
-rw-r--r--drivers/comedi/drivers/comedi_8254.h (renamed from drivers/staging/comedi/drivers/comedi_8254.h)0
-rw-r--r--drivers/comedi/drivers/comedi_8255.c (renamed from drivers/staging/comedi/drivers/comedi_8255.c)0
-rw-r--r--drivers/comedi/drivers/comedi_bond.c (renamed from drivers/staging/comedi/drivers/comedi_bond.c)0
-rw-r--r--drivers/comedi/drivers/comedi_isadma.c (renamed from drivers/staging/comedi/drivers/comedi_isadma.c)0
-rw-r--r--drivers/comedi/drivers/comedi_isadma.h (renamed from drivers/staging/comedi/drivers/comedi_isadma.h)0
-rw-r--r--drivers/comedi/drivers/comedi_parport.c (renamed from drivers/staging/comedi/drivers/comedi_parport.c)0
-rw-r--r--drivers/comedi/drivers/comedi_test.c (renamed from drivers/staging/comedi/drivers/comedi_test.c)0
-rw-r--r--drivers/comedi/drivers/contec_pci_dio.c (renamed from drivers/staging/comedi/drivers/contec_pci_dio.c)0
-rw-r--r--drivers/comedi/drivers/dac02.c (renamed from drivers/staging/comedi/drivers/dac02.c)0
-rw-r--r--drivers/comedi/drivers/daqboard2000.c (renamed from drivers/staging/comedi/drivers/daqboard2000.c)0
-rw-r--r--drivers/comedi/drivers/das08.c (renamed from drivers/staging/comedi/drivers/das08.c)0
-rw-r--r--drivers/comedi/drivers/das08.h (renamed from drivers/staging/comedi/drivers/das08.h)0
-rw-r--r--drivers/comedi/drivers/das08_cs.c (renamed from drivers/staging/comedi/drivers/das08_cs.c)0
-rw-r--r--drivers/comedi/drivers/das08_isa.c (renamed from drivers/staging/comedi/drivers/das08_isa.c)0
-rw-r--r--drivers/comedi/drivers/das08_pci.c (renamed from drivers/staging/comedi/drivers/das08_pci.c)0
-rw-r--r--drivers/comedi/drivers/das16.c (renamed from drivers/staging/comedi/drivers/das16.c)0
-rw-r--r--drivers/comedi/drivers/das16m1.c (renamed from drivers/staging/comedi/drivers/das16m1.c)0
-rw-r--r--drivers/comedi/drivers/das1800.c (renamed from drivers/staging/comedi/drivers/das1800.c)0
-rw-r--r--drivers/comedi/drivers/das6402.c (renamed from drivers/staging/comedi/drivers/das6402.c)0
-rw-r--r--drivers/comedi/drivers/das800.c (renamed from drivers/staging/comedi/drivers/das800.c)2
-rw-r--r--drivers/comedi/drivers/dmm32at.c (renamed from drivers/staging/comedi/drivers/dmm32at.c)0
-rw-r--r--drivers/comedi/drivers/dt2801.c (renamed from drivers/staging/comedi/drivers/dt2801.c)0
-rw-r--r--drivers/comedi/drivers/dt2811.c (renamed from drivers/staging/comedi/drivers/dt2811.c)0
-rw-r--r--drivers/comedi/drivers/dt2814.c (renamed from drivers/staging/comedi/drivers/dt2814.c)152
-rw-r--r--drivers/comedi/drivers/dt2815.c (renamed from drivers/staging/comedi/drivers/dt2815.c)0
-rw-r--r--drivers/comedi/drivers/dt2817.c (renamed from drivers/staging/comedi/drivers/dt2817.c)0
-rw-r--r--drivers/comedi/drivers/dt282x.c (renamed from drivers/staging/comedi/drivers/dt282x.c)0
-rw-r--r--drivers/comedi/drivers/dt3000.c (renamed from drivers/staging/comedi/drivers/dt3000.c)0
-rw-r--r--drivers/comedi/drivers/dt9812.c (renamed from drivers/staging/comedi/drivers/dt9812.c)0
-rw-r--r--drivers/comedi/drivers/dyna_pci10xx.c (renamed from drivers/staging/comedi/drivers/dyna_pci10xx.c)0
-rw-r--r--drivers/comedi/drivers/fl512.c (renamed from drivers/staging/comedi/drivers/fl512.c)0
-rw-r--r--drivers/comedi/drivers/gsc_hpdi.c (renamed from drivers/staging/comedi/drivers/gsc_hpdi.c)0
-rw-r--r--drivers/comedi/drivers/icp_multi.c (renamed from drivers/staging/comedi/drivers/icp_multi.c)0
-rw-r--r--drivers/comedi/drivers/ii_pci20kc.c (renamed from drivers/staging/comedi/drivers/ii_pci20kc.c)0
-rw-r--r--drivers/comedi/drivers/jr3_pci.c (renamed from drivers/staging/comedi/drivers/jr3_pci.c)0
-rw-r--r--drivers/comedi/drivers/jr3_pci.h (renamed from drivers/staging/comedi/drivers/jr3_pci.h)0
-rw-r--r--drivers/comedi/drivers/ke_counter.c (renamed from drivers/staging/comedi/drivers/ke_counter.c)0
-rw-r--r--drivers/comedi/drivers/me4000.c (renamed from drivers/staging/comedi/drivers/me4000.c)0
-rw-r--r--drivers/comedi/drivers/me_daq.c (renamed from drivers/staging/comedi/drivers/me_daq.c)0
-rw-r--r--drivers/comedi/drivers/mf6x4.c (renamed from drivers/staging/comedi/drivers/mf6x4.c)0
-rw-r--r--drivers/comedi/drivers/mite.c (renamed from drivers/staging/comedi/drivers/mite.c)0
-rw-r--r--drivers/comedi/drivers/mite.h (renamed from drivers/staging/comedi/drivers/mite.h)0
-rw-r--r--drivers/comedi/drivers/mpc624.c (renamed from drivers/staging/comedi/drivers/mpc624.c)0
-rw-r--r--drivers/comedi/drivers/multiq3.c (renamed from drivers/staging/comedi/drivers/multiq3.c)0
-rw-r--r--drivers/comedi/drivers/ni_6527.c (renamed from drivers/staging/comedi/drivers/ni_6527.c)0
-rw-r--r--drivers/comedi/drivers/ni_65xx.c (renamed from drivers/staging/comedi/drivers/ni_65xx.c)0
-rw-r--r--drivers/comedi/drivers/ni_660x.c (renamed from drivers/staging/comedi/drivers/ni_660x.c)0
-rw-r--r--drivers/comedi/drivers/ni_670x.c (renamed from drivers/staging/comedi/drivers/ni_670x.c)0
-rw-r--r--drivers/comedi/drivers/ni_at_a2150.c (renamed from drivers/staging/comedi/drivers/ni_at_a2150.c)0
-rw-r--r--drivers/comedi/drivers/ni_at_ao.c (renamed from drivers/staging/comedi/drivers/ni_at_ao.c)0
-rw-r--r--drivers/comedi/drivers/ni_atmio.c (renamed from drivers/staging/comedi/drivers/ni_atmio.c)0
-rw-r--r--drivers/comedi/drivers/ni_atmio16d.c (renamed from drivers/staging/comedi/drivers/ni_atmio16d.c)0
-rw-r--r--drivers/comedi/drivers/ni_daq_700.c (renamed from drivers/staging/comedi/drivers/ni_daq_700.c)0
-rw-r--r--drivers/comedi/drivers/ni_daq_dio24.c (renamed from drivers/staging/comedi/drivers/ni_daq_dio24.c)0
-rw-r--r--drivers/comedi/drivers/ni_labpc.c (renamed from drivers/staging/comedi/drivers/ni_labpc.c)0
-rw-r--r--drivers/comedi/drivers/ni_labpc.h (renamed from drivers/staging/comedi/drivers/ni_labpc.h)0
-rw-r--r--drivers/comedi/drivers/ni_labpc_common.c (renamed from drivers/staging/comedi/drivers/ni_labpc_common.c)0
-rw-r--r--drivers/comedi/drivers/ni_labpc_cs.c (renamed from drivers/staging/comedi/drivers/ni_labpc_cs.c)0
-rw-r--r--drivers/comedi/drivers/ni_labpc_isadma.c (renamed from drivers/staging/comedi/drivers/ni_labpc_isadma.c)0
-rw-r--r--drivers/comedi/drivers/ni_labpc_isadma.h (renamed from drivers/staging/comedi/drivers/ni_labpc_isadma.h)0
-rw-r--r--drivers/comedi/drivers/ni_labpc_pci.c (renamed from drivers/staging/comedi/drivers/ni_labpc_pci.c)0
-rw-r--r--drivers/comedi/drivers/ni_labpc_regs.h (renamed from drivers/staging/comedi/drivers/ni_labpc_regs.h)0
-rw-r--r--drivers/comedi/drivers/ni_mio_common.c (renamed from drivers/staging/comedi/drivers/ni_mio_common.c)0
-rw-r--r--drivers/comedi/drivers/ni_mio_cs.c (renamed from drivers/staging/comedi/drivers/ni_mio_cs.c)0
-rw-r--r--drivers/comedi/drivers/ni_pcidio.c (renamed from drivers/staging/comedi/drivers/ni_pcidio.c)0
-rw-r--r--drivers/comedi/drivers/ni_pcimio.c (renamed from drivers/staging/comedi/drivers/ni_pcimio.c)0
-rw-r--r--drivers/comedi/drivers/ni_routes.c (renamed from drivers/staging/comedi/drivers/ni_routes.c)0
-rw-r--r--drivers/comedi/drivers/ni_routes.h (renamed from drivers/staging/comedi/drivers/ni_routes.h)0
-rw-r--r--drivers/comedi/drivers/ni_routing/README (renamed from drivers/staging/comedi/drivers/ni_routing/README)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes.h (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes.h)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/all.h (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/all.h)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6070e.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6070e.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6220.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6220.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6221.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6221.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6229.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6229.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6251.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6251.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6254.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6254.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6259.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6259.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6534.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6534.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6602.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6602.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6713.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6713.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6723.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6723.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6733.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6733.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6030e.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6030e.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6224.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6224.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6225.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6225.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6251.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6251.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6733.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6733.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pxie-6251.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxie-6251.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pxie-6535.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxie-6535.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_device_routes/pxie-6738.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxie-6738.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_route_values.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_route_values.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_route_values.h (renamed from drivers/staging/comedi/drivers/ni_routing/ni_route_values.h)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_route_values/all.h (renamed from drivers/staging/comedi/drivers/ni_routing/ni_route_values/all.h)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_route_values/ni_660x.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_route_values/ni_660x.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_route_values/ni_eseries.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_route_values/ni_eseries.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/ni_route_values/ni_mseries.c (renamed from drivers/staging/comedi/drivers/ni_routing/ni_route_values/ni_mseries.c)0
-rw-r--r--drivers/comedi/drivers/ni_routing/tools/.gitignore (renamed from drivers/staging/comedi/drivers/ni_routing/tools/.gitignore)0
-rw-r--r--drivers/comedi/drivers/ni_routing/tools/Makefile (renamed from drivers/staging/comedi/drivers/ni_routing/tools/Makefile)0
-rw-r--r--drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c (renamed from drivers/staging/comedi/drivers/ni_routing/tools/convert_c_to_py.c)0
-rwxr-xr-xdrivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py (renamed from drivers/staging/comedi/drivers/ni_routing/tools/convert_csv_to_c.py)0
-rwxr-xr-xdrivers/comedi/drivers/ni_routing/tools/convert_py_to_csv.py (renamed from drivers/staging/comedi/drivers/ni_routing/tools/convert_py_to_csv.py)0
-rw-r--r--drivers/comedi/drivers/ni_routing/tools/csv_collection.py (renamed from drivers/staging/comedi/drivers/ni_routing/tools/csv_collection.py)0
-rwxr-xr-xdrivers/comedi/drivers/ni_routing/tools/make_blank_csv.py (renamed from drivers/staging/comedi/drivers/ni_routing/tools/make_blank_csv.py)0
-rw-r--r--drivers/comedi/drivers/ni_routing/tools/ni_names.py (renamed from drivers/staging/comedi/drivers/ni_routing/tools/ni_names.py)0
-rw-r--r--drivers/comedi/drivers/ni_stc.h (renamed from drivers/staging/comedi/drivers/ni_stc.h)0
-rw-r--r--drivers/comedi/drivers/ni_tio.c (renamed from drivers/staging/comedi/drivers/ni_tio.c)0
-rw-r--r--drivers/comedi/drivers/ni_tio.h (renamed from drivers/staging/comedi/drivers/ni_tio.h)0
-rw-r--r--drivers/comedi/drivers/ni_tio_internal.h (renamed from drivers/staging/comedi/drivers/ni_tio_internal.h)0
-rw-r--r--drivers/comedi/drivers/ni_tiocmd.c (renamed from drivers/staging/comedi/drivers/ni_tiocmd.c)0
-rw-r--r--drivers/comedi/drivers/ni_usb6501.c (renamed from drivers/staging/comedi/drivers/ni_usb6501.c)0
-rw-r--r--drivers/comedi/drivers/pcl711.c (renamed from drivers/staging/comedi/drivers/pcl711.c)0
-rw-r--r--drivers/comedi/drivers/pcl724.c (renamed from drivers/staging/comedi/drivers/pcl724.c)0
-rw-r--r--drivers/comedi/drivers/pcl726.c (renamed from drivers/staging/comedi/drivers/pcl726.c)0
-rw-r--r--drivers/comedi/drivers/pcl730.c (renamed from drivers/staging/comedi/drivers/pcl730.c)0
-rw-r--r--drivers/comedi/drivers/pcl812.c (renamed from drivers/staging/comedi/drivers/pcl812.c)0
-rw-r--r--drivers/comedi/drivers/pcl816.c (renamed from drivers/staging/comedi/drivers/pcl816.c)0
-rw-r--r--drivers/comedi/drivers/pcl818.c (renamed from drivers/staging/comedi/drivers/pcl818.c)0
-rw-r--r--drivers/comedi/drivers/pcm3724.c (renamed from drivers/staging/comedi/drivers/pcm3724.c)0
-rw-r--r--drivers/comedi/drivers/pcmad.c (renamed from drivers/staging/comedi/drivers/pcmad.c)0
-rw-r--r--drivers/comedi/drivers/pcmda12.c (renamed from drivers/staging/comedi/drivers/pcmda12.c)0
-rw-r--r--drivers/comedi/drivers/pcmmio.c (renamed from drivers/staging/comedi/drivers/pcmmio.c)0
-rw-r--r--drivers/comedi/drivers/pcmuio.c (renamed from drivers/staging/comedi/drivers/pcmuio.c)0
-rw-r--r--drivers/comedi/drivers/plx9052.h (renamed from drivers/staging/comedi/drivers/plx9052.h)0
-rw-r--r--drivers/comedi/drivers/plx9080.h (renamed from drivers/staging/comedi/drivers/plx9080.h)0
-rw-r--r--drivers/comedi/drivers/quatech_daqp_cs.c (renamed from drivers/staging/comedi/drivers/quatech_daqp_cs.c)0
-rw-r--r--drivers/comedi/drivers/rtd520.c (renamed from drivers/staging/comedi/drivers/rtd520.c)0
-rw-r--r--drivers/comedi/drivers/rti800.c (renamed from drivers/staging/comedi/drivers/rti800.c)0
-rw-r--r--drivers/comedi/drivers/rti802.c (renamed from drivers/staging/comedi/drivers/rti802.c)0
-rw-r--r--drivers/comedi/drivers/s526.c (renamed from drivers/staging/comedi/drivers/s526.c)0
-rw-r--r--drivers/comedi/drivers/s626.c (renamed from drivers/staging/comedi/drivers/s626.c)0
-rw-r--r--drivers/comedi/drivers/s626.h (renamed from drivers/staging/comedi/drivers/s626.h)0
-rw-r--r--drivers/comedi/drivers/ssv_dnp.c (renamed from drivers/staging/comedi/drivers/ssv_dnp.c)0
-rw-r--r--drivers/comedi/drivers/tests/Makefile (renamed from drivers/staging/comedi/drivers/tests/Makefile)3
-rw-r--r--drivers/comedi/drivers/tests/comedi_example_test.c (renamed from drivers/staging/comedi/drivers/tests/example_test.c)10
-rw-r--r--drivers/comedi/drivers/tests/ni_routes_test.c (renamed from drivers/staging/comedi/drivers/tests/ni_routes_test.c)120
-rw-r--r--drivers/comedi/drivers/tests/unittest.h (renamed from drivers/staging/comedi/drivers/tests/unittest.h)2
-rw-r--r--drivers/comedi/drivers/usbdux.c (renamed from drivers/staging/comedi/drivers/usbdux.c)0
-rw-r--r--drivers/comedi/drivers/usbduxfast.c (renamed from drivers/staging/comedi/drivers/usbduxfast.c)0
-rw-r--r--drivers/comedi/drivers/usbduxsigma.c (renamed from drivers/staging/comedi/drivers/usbduxsigma.c)0
-rw-r--r--drivers/comedi/drivers/vmk80xx.c (renamed from drivers/staging/comedi/drivers/vmk80xx.c)0
-rw-r--r--drivers/comedi/drivers/z8536.h (renamed from drivers/staging/comedi/drivers/z8536.h)0
-rw-r--r--drivers/comedi/kcomedilib/Makefile (renamed from drivers/staging/comedi/kcomedilib/Makefile)0
-rw-r--r--drivers/comedi/kcomedilib/kcomedilib_main.c (renamed from drivers/staging/comedi/kcomedilib/kcomedilib_main.c)0
-rw-r--r--drivers/comedi/proc.c (renamed from drivers/staging/comedi/proc.c)0
-rw-r--r--drivers/comedi/range.c (renamed from drivers/staging/comedi/range.c)0
-rw-r--r--drivers/counter/104-quad-8.c653
-rw-r--r--drivers/counter/Kconfig14
-rw-r--r--drivers/counter/Makefile1
-rw-r--r--drivers/counter/interrupt-cnt.c244
-rw-r--r--drivers/counter/stm32-lptimer-cnt.c297
-rw-r--r--drivers/firmware/arm_scmi/driver.c2
-rw-r--r--drivers/hwmon/ntc_thermistor.c27
-rw-r--r--drivers/iio/Kconfig2
-rw-r--r--drivers/iio/Makefile2
-rw-r--r--drivers/iio/accel/Kconfig18
-rw-r--r--drivers/iio/accel/Makefile2
-rw-r--r--drivers/iio/accel/adis16201.c2
-rw-r--r--drivers/iio/accel/adxl372.c2
-rw-r--r--drivers/iio/accel/bma180.c3
-rw-r--r--drivers/iio/accel/bma220_spi.c2
-rw-r--r--drivers/iio/accel/bmc150-accel-core.c19
-rw-r--r--drivers/iio/accel/bmi088-accel-core.c567
-rw-r--r--drivers/iio/accel/bmi088-accel-spi.c83
-rw-r--r--drivers/iio/accel/bmi088-accel.h18
-rw-r--r--drivers/iio/accel/cros_ec_accel_legacy.c2
-rw-r--r--drivers/iio/accel/da280.c2
-rw-r--r--drivers/iio/accel/da311.c2
-rw-r--r--drivers/iio/accel/dmard10.c2
-rw-r--r--drivers/iio/accel/hid-sensor-accel-3d.c23
-rw-r--r--drivers/iio/accel/kxcjk-1013.c16
-rw-r--r--drivers/iio/accel/mc3230.c2
-rw-r--r--drivers/iio/accel/mma7660.c2
-rw-r--r--drivers/iio/accel/mma8452.c47
-rw-r--r--drivers/iio/accel/mxc4005.c1
-rw-r--r--drivers/iio/accel/sca3000.c27
-rw-r--r--drivers/iio/accel/ssp_accel_sensor.c14
-rw-r--r--drivers/iio/accel/stk8312.c3
-rw-r--r--drivers/iio/accel/stk8ba50.c3
-rw-r--r--drivers/iio/adc/Kconfig16
-rw-r--r--drivers/iio/adc/Makefile1
-rw-r--r--drivers/iio/adc/ad7124.c459
-rw-r--r--drivers/iio/adc/ad7292.c2
-rw-r--r--drivers/iio/adc/ad7298.c6
-rw-r--r--drivers/iio/adc/ad7476.c18
-rw-r--r--drivers/iio/adc/ad7606.c1
-rw-r--r--drivers/iio/adc/ad7766.c16
-rw-r--r--drivers/iio/adc/ad7768-1.c1
-rw-r--r--drivers/iio/adc/ad7887.c6
-rw-r--r--drivers/iio/adc/ad7923.c47
-rw-r--r--drivers/iio/adc/ad799x.c6
-rw-r--r--drivers/iio/adc/ad_sigma_delta.c13
-rw-r--r--drivers/iio/adc/adi-axi-adc.c14
-rw-r--r--drivers/iio/adc/at91_adc.c3
-rw-r--r--drivers/iio/adc/cpcap-adc.c2
-rw-r--r--drivers/iio/adc/exynos_adc.c4
-rw-r--r--drivers/iio/adc/ina2xx-adc.c14
-rw-r--r--drivers/iio/adc/max1027.c1
-rw-r--r--drivers/iio/adc/mt6360-adc.c3
-rw-r--r--drivers/iio/adc/nau7802.c6
-rw-r--r--drivers/iio/adc/npcm_adc.c15
-rw-r--r--drivers/iio/adc/palmas_gpadc.c18
-rw-r--r--drivers/iio/adc/spear_adc.c20
-rw-r--r--drivers/iio/adc/stm32-adc.c39
-rw-r--r--drivers/iio/adc/stm32-dfsdm-adc.c10
-rw-r--r--drivers/iio/adc/sun4i-gpadc-iio.c4
-rw-r--r--drivers/iio/adc/ti-adc084s021.c6
-rw-r--r--drivers/iio/adc/ti-ads131e08.c948
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c18
-rw-r--r--drivers/iio/adc/xilinx-xadc-core.c1
-rw-r--r--drivers/iio/buffer/industrialio-buffer-dmaengine.c35
-rw-r--r--drivers/iio/buffer/industrialio-triggered-buffer.c10
-rw-r--r--drivers/iio/buffer/kfifo_buf.c45
-rw-r--r--drivers/iio/cdc/Kconfig17
-rw-r--r--drivers/iio/cdc/Makefile6
-rw-r--r--drivers/iio/cdc/ad7150.c673
-rw-r--r--drivers/iio/chemical/atlas-sensor.c1
-rw-r--r--drivers/iio/chemical/bme680_i2c.c3
-rw-r--r--drivers/iio/chemical/bme680_spi.c3
-rw-r--r--drivers/iio/chemical/ccs811.c1
-rw-r--r--drivers/iio/chemical/scd30_core.c17
-rw-r--r--drivers/iio/chemical/scd30_serial.c2
-rw-r--r--drivers/iio/common/Kconfig1
-rw-r--r--drivers/iio/common/Makefile1
-rw-r--r--drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c3
-rw-r--r--drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c3
-rw-r--r--drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c33
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-attributes.c83
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.c4
-rw-r--r--drivers/iio/common/scmi_sensors/Kconfig18
-rw-r--r--drivers/iio/common/scmi_sensors/Makefile5
-rw-r--r--drivers/iio/common/scmi_sensors/scmi_iio.c672
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_buffer.c2
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_trigger.c4
-rw-r--r--drivers/iio/dac/Kconfig5
-rw-r--r--drivers/iio/dac/ad5064.c2
-rw-r--r--drivers/iio/dac/ad5360.c2
-rw-r--r--drivers/iio/dac/ad5380.c2
-rw-r--r--drivers/iio/dac/ad5446.c2
-rw-r--r--drivers/iio/dac/ad5504.c6
-rw-r--r--drivers/iio/dac/ad5624r_spi.c4
-rw-r--r--drivers/iio/dac/ad5686.c14
-rw-r--r--drivers/iio/dac/ad5686.h2
-rw-r--r--drivers/iio/dac/ad5696-i2c.c6
-rw-r--r--drivers/iio/dac/ad5755.c4
-rw-r--r--drivers/iio/dac/ad5758.c2
-rw-r--r--drivers/iio/dac/ad5766.c2
-rw-r--r--drivers/iio/dac/ad5770r.c4
-rw-r--r--drivers/iio/dac/ad5791.c4
-rw-r--r--drivers/iio/dac/ad7303.c2
-rw-r--r--drivers/iio/dac/ltc2632.c4
-rw-r--r--drivers/iio/dac/max517.c10
-rw-r--r--drivers/iio/dac/max5821.c2
-rw-r--r--drivers/iio/dac/mcp4725.c2
-rw-r--r--drivers/iio/dac/stm32-dac.c2
-rw-r--r--drivers/iio/dac/ti-dac082s085.c2
-rw-r--r--drivers/iio/dac/ti-dac5571.c2
-rw-r--r--drivers/iio/dac/ti-dac7311.c2
-rw-r--r--drivers/iio/dummy/iio_simple_dummy_buffer.c68
-rw-r--r--drivers/iio/gyro/adxrs290.c1
-rw-r--r--drivers/iio/gyro/bmg160_core.c2
-rw-r--r--drivers/iio/gyro/fxas21002c_core.c1
-rw-r--r--drivers/iio/gyro/hid-sensor-gyro-3d.c19
-rw-r--r--drivers/iio/gyro/itg3200_buffer.c3
-rw-r--r--drivers/iio/gyro/ssp_gyro_sensor.c14
-rw-r--r--drivers/iio/health/afe4403.c1
-rw-r--r--drivers/iio/health/afe4404.c1
-rw-r--r--drivers/iio/health/max30100.c16
-rw-r--r--drivers/iio/health/max30102.c16
-rw-r--r--drivers/iio/humidity/am2315.c2
-rw-r--r--drivers/iio/humidity/hid-sensor-humidity.c16
-rw-r--r--drivers/iio/humidity/hts221_buffer.c1
-rw-r--r--drivers/iio/iio_core.h32
-rw-r--r--drivers/iio/iio_core_trigger.h4
-rw-r--r--drivers/iio/imu/adis16400.c22
-rw-r--r--drivers/iio/imu/adis16460.c4
-rw-r--r--drivers/iio/imu/adis16475.c123
-rw-r--r--drivers/iio/imu/adis16480.c133
-rw-r--r--drivers/iio/imu/adis_trigger.c21
-rw-r--r--drivers/iio/imu/fxos8700_i2c.c3
-rw-r--r--drivers/iio/imu/fxos8700_spi.c3
-rw-r--r--drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c14
-rw-r--r--drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c13
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_core.c72
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c10
-rw-r--r--drivers/iio/imu/kmx61.c1
-rw-r--r--drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c15
-rw-r--r--drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c3
-rw-r--r--drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c3
-rw-r--r--drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c3
-rw-r--r--drivers/iio/industrialio-buffer.c517
-rw-r--r--drivers/iio/industrialio-core.c198
-rw-r--r--drivers/iio/industrialio-event.c9
-rw-r--r--drivers/iio/industrialio-trigger.c72
-rw-r--r--drivers/iio/inkern.c16
-rw-r--r--drivers/iio/light/acpi-als.c117
-rw-r--r--drivers/iio/light/apds9960.c16
-rw-r--r--drivers/iio/light/cros_ec_light_prox.c3
-rw-r--r--drivers/iio/light/gp2ap002.c3
-rw-r--r--drivers/iio/light/gp2ap020a00f.c1
-rw-r--r--drivers/iio/light/hid-sensor-als.c34
-rw-r--r--drivers/iio/light/hid-sensor-prox.c32
-rw-r--r--drivers/iio/light/opt3001.c2
-rw-r--r--drivers/iio/light/rpr0521.c1
-rw-r--r--drivers/iio/light/si1145.c1
-rw-r--r--drivers/iio/light/st_uvis25_core.c1
-rw-r--r--drivers/iio/light/stk3310.c2
-rw-r--r--drivers/iio/light/vcnl4000.c1
-rw-r--r--drivers/iio/light/vcnl4035.c1
-rw-r--r--drivers/iio/magnetometer/bmc150_magn.c1
-rw-r--r--drivers/iio/magnetometer/hid-sensor-magn-3d.c32
-rw-r--r--drivers/iio/magnetometer/rm3100-core.c1
-rw-r--r--drivers/iio/magnetometer/st_magn.h1
-rw-r--r--drivers/iio/magnetometer/st_magn_core.c1
-rw-r--r--drivers/iio/magnetometer/st_magn_i2c.c5
-rw-r--r--drivers/iio/magnetometer/st_magn_spi.c5
-rw-r--r--drivers/iio/magnetometer/yamaha-yas530.c4
-rw-r--r--drivers/iio/orientation/hid-sensor-incl-3d.c20
-rw-r--r--drivers/iio/orientation/hid-sensor-rotation.c37
-rw-r--r--drivers/iio/position/hid-sensor-custom-intel-hinge.c20
-rw-r--r--drivers/iio/potentiometer/max5481.c4
-rw-r--r--drivers/iio/potentiometer/max5487.c4
-rw-r--r--drivers/iio/potentiostat/lmp91000.c3
-rw-r--r--drivers/iio/pressure/cros_ec_baro.c3
-rw-r--r--drivers/iio/pressure/hid-sensor-press.c20
-rw-r--r--drivers/iio/pressure/zpa2326.c5
-rw-r--r--drivers/iio/proximity/Kconfig11
-rw-r--r--drivers/iio/proximity/Makefile1
-rw-r--r--drivers/iio/proximity/as3935.c1
-rw-r--r--drivers/iio/proximity/cros_ec_mkbp_proximity.c271
-rw-r--r--drivers/iio/proximity/sx9310.c53
-rw-r--r--drivers/iio/proximity/sx9500.c3
-rw-r--r--drivers/iio/proximity/vcnl3020.c97
-rw-r--r--drivers/iio/temperature/hid-sensor-temperature.c16
-rw-r--r--drivers/iio/temperature/tmp007.c36
-rw-r--r--drivers/iio/test/Kconfig9
-rw-r--r--drivers/iio/test/Makefile7
-rw-r--r--drivers/iio/test/iio-test-format.c198
-rw-r--r--drivers/iio/trigger/iio-trig-hrtimer.c37
-rw-r--r--drivers/iio/trigger/iio-trig-interrupt.c2
-rw-r--r--drivers/iio/trigger/iio-trig-loop.c2
-rw-r--r--drivers/iio/trigger/iio-trig-sysfs.c3
-rw-r--r--drivers/most/Kconfig10
-rw-r--r--drivers/most/Makefile1
-rw-r--r--drivers/most/most_snd.c (renamed from drivers/staging/most/sound/sound.c)0
-rw-r--r--drivers/regulator/Kconfig9
-rw-r--r--drivers/regulator/Makefile1
-rw-r--r--drivers/regulator/hi6421v600-regulator.c (renamed from drivers/staging/hikey9xx/hi6421v600-regulator.c)0
-rw-r--r--drivers/rtc/rtc-hid-sensor-time.c4
-rw-r--r--drivers/staging/Kconfig6
-rw-r--r--drivers/staging/Makefile3
-rw-r--r--drivers/staging/android/uapi/ashmem.h2
-rw-r--r--drivers/staging/axis-fifo/axis-fifo.c1
-rw-r--r--drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c369
-rw-r--r--drivers/staging/emxx_udc/emxx_udc.c1
-rw-r--r--drivers/staging/fbtft/fbtft-sysfs.c2
-rw-r--r--drivers/staging/fieldbus/anybuss/host.c24
-rw-r--r--drivers/staging/fwserial/fwserial.c6
-rw-r--r--drivers/staging/gasket/Kconfig25
-rw-r--r--drivers/staging/gasket/Makefile10
-rw-r--r--drivers/staging/gasket/TODO22
-rw-r--r--drivers/staging/gasket/apex.h30
-rw-r--r--drivers/staging/gasket/apex_driver.c726
-rw-r--r--drivers/staging/gasket/gasket.h122
-rw-r--r--drivers/staging/gasket/gasket_constants.h44
-rw-r--r--drivers/staging/gasket/gasket_core.c1815
-rw-r--r--drivers/staging/gasket/gasket_core.h638
-rw-r--r--drivers/staging/gasket/gasket_interrupt.c515
-rw-r--r--drivers/staging/gasket/gasket_interrupt.h95
-rw-r--r--drivers/staging/gasket/gasket_ioctl.c388
-rw-r--r--drivers/staging/gasket/gasket_ioctl.h28
-rw-r--r--drivers/staging/gasket/gasket_page_table.c1359
-rw-r--r--drivers/staging/gasket/gasket_page_table.h249
-rw-r--r--drivers/staging/gasket/gasket_sysfs.c398
-rw-r--r--drivers/staging/gasket/gasket_sysfs.h175
-rw-r--r--drivers/staging/greybus/arche-platform.c10
-rw-r--r--drivers/staging/greybus/audio_module.c4
-rw-r--r--drivers/staging/greybus/audio_topology.c12
-rw-r--r--drivers/staging/greybus/camera.c13
-rw-r--r--drivers/staging/greybus/sdio.c1
-rw-r--r--drivers/staging/hikey9xx/Kconfig11
-rw-r--r--drivers/staging/hikey9xx/Makefile1
-rw-r--r--drivers/staging/hikey9xx/hi6421-spmi-pmic.c8
-rw-r--r--drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml18
-rw-r--r--drivers/staging/iio/TODO4
-rw-r--r--drivers/staging/iio/cdc/Kconfig10
-rw-r--r--drivers/staging/iio/cdc/Makefile3
-rw-r--r--drivers/staging/iio/cdc/ad7150.c655
-rw-r--r--drivers/staging/iio/frequency/ad9832.c4
-rw-r--r--drivers/staging/iio/frequency/ad9834.c67
-rw-r--r--drivers/staging/iio/impedance-analyzer/ad5933.c23
-rw-r--r--drivers/staging/kpc2000/kpc2000/pcie.h1
-rw-r--r--drivers/staging/kpc2000/kpc2000_i2c.c6
-rw-r--r--drivers/staging/kpc2000/kpc2000_spi.c2
-rw-r--r--drivers/staging/most/Kconfig2
-rw-r--r--drivers/staging/most/Makefile1
-rw-r--r--drivers/staging/most/sound/Kconfig14
-rw-r--r--drivers/staging/most/sound/Makefile4
-rw-r--r--drivers/staging/mt7621-pci/pci-mt7621.c12
-rw-r--r--drivers/staging/netlogic/Kconfig1
-rw-r--r--drivers/staging/nvec/nvec_ps2.c2
-rw-r--r--drivers/staging/octeon-usb/octeon-hcd.c32
-rw-r--r--drivers/staging/octeon/ethernet-spi.c2
-rw-r--r--drivers/staging/octeon/ethernet.c9
-rw-r--r--drivers/staging/qlge/qlge_devlink.c10
-rw-r--r--drivers/staging/qlge/qlge_devlink.h2
-rw-r--r--drivers/staging/qlge/qlge_main.c17
-rw-r--r--drivers/staging/ralink-gdma/ralink-gdma.c5
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_ap.c6
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_cmd.c83
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_debug.c8
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_ieee80211.c6
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_ioctl_set.c8
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_mlme.c2
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_mlme_ext.c12
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_pwrctrl.c5
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_recv.c27
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_security.c78
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_xmit.c7
-rw-r--r--drivers/staging/rtl8188eu/hal/odm_hwconfig.c11
-rw-r--r--drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c12
-rw-r--r--drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c2
-rw-r--r--drivers/staging/rtl8188eu/hal/usb_halinit.c5
-rw-r--r--drivers/staging/rtl8188eu/include/drv_types.h2
-rw-r--r--drivers/staging/rtl8188eu/include/odm_hwconfig.h8
-rw-r--r--drivers/staging/rtl8188eu/include/osdep_intf.h2
-rw-r--r--drivers/staging/rtl8188eu/include/osdep_service.h13
-rw-r--r--drivers/staging/rtl8188eu/include/recv_osdep.h2
-rw-r--r--drivers/staging/rtl8188eu/include/rtl8188e_hal.h4
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_cmd.h20
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_efuse.h20
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_mlme_ext.h30
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_pwrctrl.h2
-rw-r--r--drivers/staging/rtl8188eu/include/usb_ops_linux.h32
-rw-r--r--drivers/staging/rtl8188eu/include/wifi.h156
-rw-r--r--drivers/staging/rtl8188eu/include/wlan_bssdef.h2
-rw-r--r--drivers/staging/rtl8188eu/os_dep/ioctl_linux.c88
-rw-r--r--drivers/staging/rtl8188eu/os_dep/os_intfs.c22
-rw-r--r--drivers/staging/rtl8188eu/os_dep/osdep_service.c31
-rw-r--r--drivers/staging/rtl8188eu/os_dep/recv_linux.c3
-rw-r--r--drivers/staging/rtl8188eu/os_dep/rtw_android.c23
-rw-r--r--drivers/staging/rtl8188eu/os_dep/usb_intf.c84
-rw-r--r--drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c171
-rw-r--r--drivers/staging/rtl8188eu/os_dep/xmit_linux.c2
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c14
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_core.c5
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_dm.c4
-rw-r--r--drivers/staging/rtl8192e/rtl819x_BA.h40
-rw-r--r--drivers/staging/rtl8192e/rtl819x_BAProc.c127
-rw-r--r--drivers/staging/rtl8192e/rtl819x_HT.h23
-rw-r--r--drivers/staging/rtl8192e/rtl819x_HTProc.c81
-rw-r--r--drivers/staging/rtl8192e/rtl819x_TS.h18
-rw-r--r--drivers/staging/rtl8192e/rtl819x_TSProc.c79
-rw-r--r--drivers/staging/rtl8192e/rtllib_crypt_tkip.c2
-rw-r--r--drivers/staging/rtl8192e/rtllib_rx.c170
-rw-r--r--drivers/staging/rtl8192e/rtllib_softmac.c14
-rw-r--r--drivers/staging/rtl8192e/rtllib_tx.c8
-rw-r--r--drivers/staging/rtl8192e/rtllib_wx.c76
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c42
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c2
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c4
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c6
-rw-r--r--drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c4
-rw-r--r--drivers/staging/rtl8192u/r8190_rtl8256.c7
-rw-r--r--drivers/staging/rtl8192u/r8192U.h6
-rw-r--r--drivers/staging/rtl8192u/r8192U_core.c5
-rw-r--r--drivers/staging/rtl8192u/r8192U_wx.c159
-rw-r--r--drivers/staging/rtl8712/drv_types.h2
-rw-r--r--drivers/staging/rtl8712/ieee80211.c18
-rw-r--r--drivers/staging/rtl8712/mlme_osdep.h4
-rw-r--r--drivers/staging/rtl8712/rtl8712_recv.h2
-rw-r--r--drivers/staging/rtl8712/rtl8712_wmac_regdef.h1
-rw-r--r--drivers/staging/rtl8712/rtl8712_xmit.c13
-rw-r--r--drivers/staging/rtl8712/rtl8712_xmit.h5
-rw-r--r--drivers/staging/rtl8712/rtl871x_cmd.h10
-rw-r--r--drivers/staging/rtl8712/rtl871x_event.h1
-rw-r--r--drivers/staging/rtl8712/rtl871x_ht.h2
-rw-r--r--drivers/staging/rtl8712/rtl871x_io.h1
-rw-r--r--drivers/staging/rtl8712/rtl871x_ioctl_linux.c20
-rw-r--r--drivers/staging/rtl8712/rtl871x_mlme.c28
-rw-r--r--drivers/staging/rtl8712/rtl871x_mlme.h1
-rw-r--r--drivers/staging/rtl8712/rtl871x_mp.c1
-rw-r--r--drivers/staging/rtl8712/rtl871x_mp.h1
-rw-r--r--drivers/staging/rtl8712/rtl871x_mp_ioctl.c3
-rw-r--r--drivers/staging/rtl8712/rtl871x_pwrctrl.h3
-rw-r--r--drivers/staging/rtl8712/rtl871x_recv.c36
-rw-r--r--drivers/staging/rtl8712/rtl871x_recv.h12
-rw-r--r--drivers/staging/rtl8712/rtl871x_security.c24
-rw-r--r--drivers/staging/rtl8712/rtl871x_security.h4
-rw-r--r--drivers/staging/rtl8712/rtl871x_xmit.c8
-rw-r--r--drivers/staging/rtl8712/rtl871x_xmit.h12
-rw-r--r--drivers/staging/rtl8712/sta_info.h1
-rw-r--r--drivers/staging/rtl8712/usb_ops.h6
-rw-r--r--drivers/staging/rtl8712/wifi.h265
-rw-r--r--drivers/staging/rtl8712/wlan_bssdef.h2
-rw-r--r--drivers/staging/rtl8712/xmit_osdep.h8
-rw-r--r--drivers/staging/rtl8723bs/TODO1
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_ap.c336
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_btcoex.c12
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_cmd.c184
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_debug.c61
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_eeprom.c56
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_efuse.c25
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_ieee80211.c156
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_io.c11
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_ioctl_set.c120
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_mlme.c350
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_mlme_ext.c832
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_odm.c60
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_pwrctrl.c316
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_recv.c939
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_security.c283
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_sta_mgt.c35
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_wlan_util.c407
-rw-r--r--drivers/staging/rtl8723bs/core/rtw_xmit.c399
-rw-r--r--drivers/staging/rtl8723bs/hal/Hal8723BReg.h435
-rw-r--r--drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c258
-rw-r--r--drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h54
-rw-r--r--drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c224
-rw-r--r--drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h48
-rw-r--r--drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h188
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c10
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.h6
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c6
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.h2
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c12
-rw-r--r--drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.h6
-rw-r--r--drivers/staging/rtl8723bs/hal/HalPhyRf.c8
-rw-r--r--drivers/staging/rtl8723bs/hal/HalPhyRf.h25
-rw-r--r--drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c70
-rw-r--r--drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.h12
-rw-r--r--drivers/staging/rtl8723bs/hal/HalPwrSeqCmd.c59
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_btcoex.c171
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_com.c233
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_com_phycfg.c250
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_intf.c39
-rw-r--r--drivers/staging/rtl8723bs/hal/hal_pwr_seq.c22
-rw-r--r--drivers/staging/rtl8723bs/hal/odm.c1106
-rw-r--r--drivers/staging/rtl8723bs/hal/odm.h412
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_CfoTracking.c28
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_CfoTracking.h4
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_DIG.c66
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_DIG.h32
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.c8
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.h4
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.c2
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c6
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.h4
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_HWConfig.c35
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_HWConfig.h79
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c2
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h4
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_PathDiv.c4
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c16
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h16
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_debug.c2
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_debug.h4
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_interface.h11
-rw-r--r--drivers/staging/rtl8723bs/hal/odm_types.h47
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c1392
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_dm.c26
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c713
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c74
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c4
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c3
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c35
-rw-r--r--drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c100
-rw-r--r--drivers/staging/rtl8723bs/hal/sdio_halinit.c561
-rw-r--r--drivers/staging/rtl8723bs/hal/sdio_ops.c201
-rw-r--r--drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h8
-rw-r--r--drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h12
-rw-r--r--drivers/staging/rtl8723bs/include/HalVerDef.h62
-rw-r--r--drivers/staging/rtl8723bs/include/autoconf.h10
-rw-r--r--drivers/staging/rtl8723bs/include/basic_types.h6
-rw-r--r--drivers/staging/rtl8723bs/include/drv_conf.h10
-rw-r--r--drivers/staging/rtl8723bs/include/drv_types.h215
-rw-r--r--drivers/staging/rtl8723bs/include/drv_types_sdio.h5
-rw-r--r--drivers/staging/rtl8723bs/include/hal_btcoex.h4
-rw-r--r--drivers/staging/rtl8723bs/include/hal_com.h52
-rw-r--r--drivers/staging/rtl8723bs/include/hal_com_h2c.h185
-rw-r--r--drivers/staging/rtl8723bs/include/hal_com_phycfg.h40
-rw-r--r--drivers/staging/rtl8723bs/include/hal_com_reg.h48
-rw-r--r--drivers/staging/rtl8723bs/include/hal_data.h50
-rw-r--r--drivers/staging/rtl8723bs/include/hal_intf.h72
-rw-r--r--drivers/staging/rtl8723bs/include/hal_phy.h85
-rw-r--r--drivers/staging/rtl8723bs/include/hal_phy_cfg.h6
-rw-r--r--drivers/staging/rtl8723bs/include/hal_pwr_seq.h24
-rw-r--r--drivers/staging/rtl8723bs/include/ieee80211.h202
-rw-r--r--drivers/staging/rtl8723bs/include/ioctl_cfg80211.h6
-rw-r--r--drivers/staging/rtl8723bs/include/osdep_intf.h12
-rw-r--r--drivers/staging/rtl8723bs/include/osdep_service.h39
-rw-r--r--drivers/staging/rtl8723bs/include/osdep_service_linux.h29
-rw-r--r--drivers/staging/rtl8723bs/include/recv_osdep.h8
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_cmd.h8
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_hal.h48
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_recv.h44
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_rf.h2
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_spec.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtl8723b_xmit.h8
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_cmd.h271
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_debug.h92
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_eeprom.h4
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_efuse.h10
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_event.h11
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_ht.h12
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_io.h113
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_ioctl_set.h16
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_mlme.h142
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_mlme_ext.h90
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_mp.h137
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_odm.h2
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_pwrctrl.h95
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_recv.h66
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_rf.h36
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_security.h58
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_wifi_regd.h12
-rw-r--r--drivers/staging/rtl8723bs/include/rtw_xmit.h62
-rw-r--r--drivers/staging/rtl8723bs/include/sdio_ops.h7
-rw-r--r--drivers/staging/rtl8723bs/include/sta_info.h28
-rw-r--r--drivers/staging/rtl8723bs/include/wifi.h101
-rw-r--r--drivers/staging/rtl8723bs/include/wlan_bssdef.h51
-rw-r--r--drivers/staging/rtl8723bs/include/xmit_osdep.h14
-rw-r--r--drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c534
-rw-r--r--drivers/staging/rtl8723bs/os_dep/ioctl_linux.c731
-rw-r--r--drivers/staging/rtl8723bs/os_dep/mlme_linux.c24
-rw-r--r--drivers/staging/rtl8723bs/os_dep/os_intfs.c568
-rw-r--r--drivers/staging/rtl8723bs/os_dep/osdep_service.c8
-rw-r--r--drivers/staging/rtl8723bs/os_dep/recv_linux.c96
-rw-r--r--drivers/staging/rtl8723bs/os_dep/sdio_intf.c217
-rw-r--r--drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c97
-rw-r--r--drivers/staging/rtl8723bs/os_dep/wifi_regd.c4
-rw-r--r--drivers/staging/rtl8723bs/os_dep/xmit_linux.c62
-rw-r--r--drivers/staging/rts5208/xd.c2
-rw-r--r--drivers/staging/sm750fb/sm750.h32
-rw-r--r--drivers/staging/unisys/visornic/visornic_main.c34
-rw-r--r--drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c10
-rw-r--r--drivers/staging/vc04_services/interface/TODO6
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c8
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c360
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h2
-rw-r--r--drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c4
-rw-r--r--drivers/staging/vt6655/baseband.c6
-rw-r--r--drivers/staging/vt6655/channel.c42
-rw-r--r--drivers/staging/vt6656/card.c3
-rw-r--r--drivers/staging/wfx/hif_rx.c6
-rw-r--r--drivers/staging/wfx/sta.c2
-rw-r--r--drivers/staging/wimax/Documentation/i2400m.rst283
-rw-r--r--drivers/staging/wimax/Documentation/index.rst19
-rw-r--r--drivers/staging/wimax/Documentation/wimax.rst89
-rw-r--r--drivers/staging/wimax/Kconfig47
-rw-r--r--drivers/staging/wimax/Makefile15
-rw-r--r--drivers/staging/wimax/TODO18
-rw-r--r--drivers/staging/wimax/debug-levels.h29
-rw-r--r--drivers/staging/wimax/debugfs.c38
-rw-r--r--drivers/staging/wimax/i2400m/Kconfig37
-rw-r--r--drivers/staging/wimax/i2400m/Makefile23
-rw-r--r--drivers/staging/wimax/i2400m/control.c1434
-rw-r--r--drivers/staging/wimax/i2400m/debug-levels.h32
-rw-r--r--drivers/staging/wimax/i2400m/debugfs.c253
-rw-r--r--drivers/staging/wimax/i2400m/driver.c1003
-rw-r--r--drivers/staging/wimax/i2400m/fw.c1666
-rw-r--r--drivers/staging/wimax/i2400m/i2400m-usb.h275
-rw-r--r--drivers/staging/wimax/i2400m/i2400m.h970
-rw-r--r--drivers/staging/wimax/i2400m/linux-wimax-i2400m.h572
-rw-r--r--drivers/staging/wimax/i2400m/netdev.c603
-rw-r--r--drivers/staging/wimax/i2400m/op-rfkill.c196
-rw-r--r--drivers/staging/wimax/i2400m/rx.c1394
-rw-r--r--drivers/staging/wimax/i2400m/sysfs.c65
-rw-r--r--drivers/staging/wimax/i2400m/tx.c1015
-rw-r--r--drivers/staging/wimax/i2400m/usb-debug-levels.h28
-rw-r--r--drivers/staging/wimax/i2400m/usb-fw.c365
-rw-r--r--drivers/staging/wimax/i2400m/usb-notif.c258
-rw-r--r--drivers/staging/wimax/i2400m/usb-rx.c462
-rw-r--r--drivers/staging/wimax/i2400m/usb-tx.c273
-rw-r--r--drivers/staging/wimax/i2400m/usb.c765
-rw-r--r--drivers/staging/wimax/id-table.c130
-rw-r--r--drivers/staging/wimax/linux-wimax-debug.h491
-rw-r--r--drivers/staging/wimax/linux-wimax.h239
-rw-r--r--drivers/staging/wimax/net-wimax.h503
-rw-r--r--drivers/staging/wimax/op-msg.c391
-rw-r--r--drivers/staging/wimax/op-reset.c108
-rw-r--r--drivers/staging/wimax/op-rfkill.c431
-rw-r--r--drivers/staging/wimax/op-state-get.c52
-rw-r--r--drivers/staging/wimax/stack.c616
-rw-r--r--drivers/staging/wimax/wimax-internal.h85
-rw-r--r--drivers/staging/wlan-ng/p80211conv.h3
-rw-r--r--drivers/staging/wlan-ng/p80211netdev.c2
758 files changed, 11272 insertions, 40267 deletions
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 62c753a73651..47980c6b1945 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -149,6 +149,8 @@ source "drivers/xen/Kconfig"
source "drivers/greybus/Kconfig"
+source "drivers/comedi/Kconfig"
+
source "drivers/staging/Kconfig"
source "drivers/platform/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 6fba7daba591..8f3fee8281ad 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -148,6 +148,7 @@ obj-$(CONFIG_VHOST_IOTLB) += vhost/
obj-$(CONFIG_VHOST) += vhost/
obj-$(CONFIG_VLYNQ) += vlynq/
obj-$(CONFIG_GREYBUS) += greybus/
+obj-$(CONFIG_COMEDI) += comedi/
obj-$(CONFIG_STAGING) += staging/
obj-y += platform/
diff --git a/drivers/staging/comedi/Kconfig b/drivers/comedi/Kconfig
index 049b659fa6ad..3cb61fa2c5c3 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/comedi/Kconfig
@@ -1319,4 +1319,37 @@ config COMEDI_NI_TIO
config COMEDI_NI_ROUTING
tristate
+config COMEDI_TESTS
+ tristate "Comedi unit tests"
+ help
+ Enable comedi unit-test modules to be built.
+
+ Note that the answer to this question won't directly affect the
+ kernel: saying N will just cause the configurator to skip all
+ the questions about comedi unit-test modules.
+
+if COMEDI_TESTS
+
+config COMEDI_TESTS_EXAMPLE
+ tristate "Comedi example unit-test module"
+ help
+ Enable support for an example unit-test module. This is just a
+ silly example to be used as a basis for writing other unit-test
+ modules.
+
+ To compile this as a module, choose M here: the module will be called
+ comedi_example_test.
+
+config COMEDI_TESTS_NI_ROUTES
+ tristate "NI routing unit-test module"
+ select COMEDI_NI_ROUTING
+ help
+ Enable support for a unit-test module to test the signal routing
+ code used by comedi drivers for various National Instruments cards.
+
+ To compile this as a module, choose M here: the module will be called
+ ni_routes_test.
+
+endif # COMEDI_TESTS
+
endif # COMEDI
diff --git a/drivers/staging/comedi/Makefile b/drivers/comedi/Makefile
index 072ed83a5a6a..072ed83a5a6a 100644
--- a/drivers/staging/comedi/Makefile
+++ b/drivers/comedi/Makefile
diff --git a/drivers/staging/comedi/TODO b/drivers/comedi/TODO
index f733c017f181..f733c017f181 100644
--- a/drivers/staging/comedi/TODO
+++ b/drivers/comedi/TODO
diff --git a/drivers/staging/comedi/comedi.h b/drivers/comedi/comedi.h
index b5d00a006dbb..b5d00a006dbb 100644
--- a/drivers/staging/comedi/comedi.h
+++ b/drivers/comedi/comedi.h
diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/comedi/comedi_buf.c
index 3ef3ddabf139..06bfc859ab31 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/comedi/comedi_buf.c
@@ -371,35 +371,35 @@ static unsigned int comedi_buf_munge(struct comedi_subdevice *s,
if (!s->munge || (async->cmd.flags & CMDF_RAWDATA)) {
async->munge_count += num_bytes;
- count = num_bytes;
- } else {
- /* don't munge partial samples */
- num_bytes -= num_bytes % num_sample_bytes;
- while (count < num_bytes) {
- int block_size = num_bytes - count;
- unsigned int buf_end;
+ return num_bytes;
+ }
- buf_end = async->prealloc_bufsz - async->munge_ptr;
- if (block_size > buf_end)
- block_size = buf_end;
+ /* don't munge partial samples */
+ num_bytes -= num_bytes % num_sample_bytes;
+ while (count < num_bytes) {
+ int block_size = num_bytes - count;
+ unsigned int buf_end;
- s->munge(s->device, s,
- async->prealloc_buf + async->munge_ptr,
- block_size, async->munge_chan);
+ buf_end = async->prealloc_bufsz - async->munge_ptr;
+ if (block_size > buf_end)
+ block_size = buf_end;
- /*
- * ensure data is munged in buffer before the
- * async buffer munge_count is incremented
- */
- smp_wmb();
-
- async->munge_chan += block_size / num_sample_bytes;
- async->munge_chan %= async->cmd.chanlist_len;
- async->munge_count += block_size;
- async->munge_ptr += block_size;
- async->munge_ptr %= async->prealloc_bufsz;
- count += block_size;
- }
+ s->munge(s->device, s,
+ async->prealloc_buf + async->munge_ptr,
+ block_size, async->munge_chan);
+
+ /*
+ * ensure data is munged in buffer before the
+ * async buffer munge_count is incremented
+ */
+ smp_wmb();
+
+ async->munge_chan += block_size / num_sample_bytes;
+ async->munge_chan %= async->cmd.chanlist_len;
+ async->munge_count += block_size;
+ async->munge_ptr += block_size;
+ async->munge_ptr %= async->prealloc_bufsz;
+ count += block_size;
}
return count;
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/comedi/comedi_fops.c
index df77b6bf5c64..df77b6bf5c64 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/comedi/comedi_fops.c
diff --git a/drivers/staging/comedi/comedi_internal.h b/drivers/comedi/comedi_internal.h
index 9b3631a654c8..9b3631a654c8 100644
--- a/drivers/staging/comedi/comedi_internal.h
+++ b/drivers/comedi/comedi_internal.h
diff --git a/drivers/staging/comedi/comedi_pci.c b/drivers/comedi/comedi_pci.c
index 54739af7eb71..54739af7eb71 100644
--- a/drivers/staging/comedi/comedi_pci.c
+++ b/drivers/comedi/comedi_pci.c
diff --git a/drivers/staging/comedi/comedi_pci.h b/drivers/comedi/comedi_pci.h
index 4e069440cbdc..4e069440cbdc 100644
--- a/drivers/staging/comedi/comedi_pci.h
+++ b/drivers/comedi/comedi_pci.h
diff --git a/drivers/staging/comedi/comedi_pcmcia.c b/drivers/comedi/comedi_pcmcia.c
index bb273bb202e6..bb273bb202e6 100644
--- a/drivers/staging/comedi/comedi_pcmcia.c
+++ b/drivers/comedi/comedi_pcmcia.c
diff --git a/drivers/staging/comedi/comedi_pcmcia.h b/drivers/comedi/comedi_pcmcia.h
index f2f6e779645b..f2f6e779645b 100644
--- a/drivers/staging/comedi/comedi_pcmcia.h
+++ b/drivers/comedi/comedi_pcmcia.h
diff --git a/drivers/staging/comedi/comedi_usb.c b/drivers/comedi/comedi_usb.c
index eea8ebf32ed0..eea8ebf32ed0 100644
--- a/drivers/staging/comedi/comedi_usb.c
+++ b/drivers/comedi/comedi_usb.c
diff --git a/drivers/staging/comedi/comedi_usb.h b/drivers/comedi/comedi_usb.h
index 601e29d3891c..601e29d3891c 100644
--- a/drivers/staging/comedi/comedi_usb.h
+++ b/drivers/comedi/comedi_usb.h
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/comedi/comedidev.h
index 0e1b95ef9a4d..0e1b95ef9a4d 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/comedi/comedidev.h
diff --git a/drivers/staging/comedi/comedilib.h b/drivers/comedi/comedilib.h
index 0223c9cd9215..0223c9cd9215 100644
--- a/drivers/staging/comedi/comedilib.h
+++ b/drivers/comedi/comedilib.h
diff --git a/drivers/staging/comedi/drivers.c b/drivers/comedi/drivers.c
index 750a6ff3c03c..750a6ff3c03c 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/comedi/drivers.c
diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/comedi/drivers/8255.c
index e23335c75867..e23335c75867 100644
--- a/drivers/staging/comedi/drivers/8255.c
+++ b/drivers/comedi/drivers/8255.c
diff --git a/drivers/staging/comedi/drivers/8255.h b/drivers/comedi/drivers/8255.h
index ceae3ca52e60..ceae3ca52e60 100644
--- a/drivers/staging/comedi/drivers/8255.h
+++ b/drivers/comedi/drivers/8255.h
diff --git a/drivers/staging/comedi/drivers/8255_pci.c b/drivers/comedi/drivers/8255_pci.c
index 5a810f0e532a..5a810f0e532a 100644
--- a/drivers/staging/comedi/drivers/8255_pci.c
+++ b/drivers/comedi/drivers/8255_pci.c
diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/comedi/drivers/Makefile
index b24ac00cab73..b24ac00cab73 100644
--- a/drivers/staging/comedi/drivers/Makefile
+++ b/drivers/comedi/drivers/Makefile
diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/comedi/drivers/addi_apci_1032.c
index 81a246fbcc01..81a246fbcc01 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1032.c
+++ b/drivers/comedi/drivers/addi_apci_1032.c
diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/comedi/drivers/addi_apci_1500.c
index b04c15dcfb57..b04c15dcfb57 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1500.c
+++ b/drivers/comedi/drivers/addi_apci_1500.c
diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c b/drivers/comedi/drivers/addi_apci_1516.c
index 274ec9fb030c..274ec9fb030c 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1516.c
+++ b/drivers/comedi/drivers/addi_apci_1516.c
diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/comedi/drivers/addi_apci_1564.c
index 06fc7ed96200..06fc7ed96200 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1564.c
+++ b/drivers/comedi/drivers/addi_apci_1564.c
diff --git a/drivers/staging/comedi/drivers/addi_apci_16xx.c b/drivers/comedi/drivers/addi_apci_16xx.c
index 9bbef3b15f3f..c306aa41df97 100644
--- a/drivers/staging/comedi/drivers/addi_apci_16xx.c
+++ b/drivers/comedi/drivers/addi_apci_16xx.c
@@ -110,7 +110,7 @@ static int apci16xx_auto_attach(struct comedi_device *dev,
dev->iobase = pci_resource_start(pcidev, 0);
/*
- * Work out the nubmer of subdevices needed to support all the
+ * Work out the number of subdevices needed to support all the
* digital i/o channels on the board. Each subdevice supports
* up to 32 channels.
*/
diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/comedi/drivers/addi_apci_2032.c
index e9a2b37a4ae0..e9a2b37a4ae0 100644
--- a/drivers/staging/comedi/drivers/addi_apci_2032.c
+++ b/drivers/comedi/drivers/addi_apci_2032.c
diff --git a/drivers/staging/comedi/drivers/addi_apci_2200.c b/drivers/comedi/drivers/addi_apci_2200.c
index 4c5aee784bd9..4c5aee784bd9 100644
--- a/drivers/staging/comedi/drivers/addi_apci_2200.c
+++ b/drivers/comedi/drivers/addi_apci_2200.c
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/comedi/drivers/addi_apci_3120.c
index 1ed3b33d1a30..1ed3b33d1a30 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/comedi/drivers/addi_apci_3120.c
diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/comedi/drivers/addi_apci_3501.c
index f0c9642f3f1a..f0c9642f3f1a 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3501.c
+++ b/drivers/comedi/drivers/addi_apci_3501.c
diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/comedi/drivers/addi_apci_3xxx.c
index a90d59377e18..a90d59377e18 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c
+++ b/drivers/comedi/drivers/addi_apci_3xxx.c
diff --git a/drivers/staging/comedi/drivers/addi_tcw.h b/drivers/comedi/drivers/addi_tcw.h
index 2b44d3a04484..2b44d3a04484 100644
--- a/drivers/staging/comedi/drivers/addi_tcw.h
+++ b/drivers/comedi/drivers/addi_tcw.h
diff --git a/drivers/staging/comedi/drivers/addi_watchdog.c b/drivers/comedi/drivers/addi_watchdog.c
index 69b323fb869f..69b323fb869f 100644
--- a/drivers/staging/comedi/drivers/addi_watchdog.c
+++ b/drivers/comedi/drivers/addi_watchdog.c
diff --git a/drivers/staging/comedi/drivers/addi_watchdog.h b/drivers/comedi/drivers/addi_watchdog.h
index 7523084a0742..7523084a0742 100644
--- a/drivers/staging/comedi/drivers/addi_watchdog.h
+++ b/drivers/comedi/drivers/addi_watchdog.h
diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/comedi/drivers/adl_pci6208.c
index 9ae4cc523dd4..9ae4cc523dd4 100644
--- a/drivers/staging/comedi/drivers/adl_pci6208.c
+++ b/drivers/comedi/drivers/adl_pci6208.c
diff --git a/drivers/staging/comedi/drivers/adl_pci7x3x.c b/drivers/comedi/drivers/adl_pci7x3x.c
index 8fc45638ff59..8fc45638ff59 100644
--- a/drivers/staging/comedi/drivers/adl_pci7x3x.c
+++ b/drivers/comedi/drivers/adl_pci7x3x.c
diff --git a/drivers/staging/comedi/drivers/adl_pci8164.c b/drivers/comedi/drivers/adl_pci8164.c
index d5e1bda81557..d5e1bda81557 100644
--- a/drivers/staging/comedi/drivers/adl_pci8164.c
+++ b/drivers/comedi/drivers/adl_pci8164.c
diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/comedi/drivers/adl_pci9111.c
index a062c5ab20e9..a062c5ab20e9 100644
--- a/drivers/staging/comedi/drivers/adl_pci9111.c
+++ b/drivers/comedi/drivers/adl_pci9111.c
diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/comedi/drivers/adl_pci9118.c
index cda3a4267dca..cda3a4267dca 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/comedi/drivers/adl_pci9118.c
diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/comedi/drivers/adq12b.c
index d719f76709ef..d719f76709ef 100644
--- a/drivers/staging/comedi/drivers/adq12b.c
+++ b/drivers/comedi/drivers/adq12b.c
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/comedi/drivers/adv_pci1710.c
index 090607760be6..090607760be6 100644
--- a/drivers/staging/comedi/drivers/adv_pci1710.c
+++ b/drivers/comedi/drivers/adv_pci1710.c
diff --git a/drivers/staging/comedi/drivers/adv_pci1720.c b/drivers/comedi/drivers/adv_pci1720.c
index 2fcd7e8e7d85..2fcd7e8e7d85 100644
--- a/drivers/staging/comedi/drivers/adv_pci1720.c
+++ b/drivers/comedi/drivers/adv_pci1720.c
diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/comedi/drivers/adv_pci1723.c
index 23660a9fdb9c..23660a9fdb9c 100644
--- a/drivers/staging/comedi/drivers/adv_pci1723.c
+++ b/drivers/comedi/drivers/adv_pci1723.c
diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/comedi/drivers/adv_pci1724.c
index e8ab573c839f..e8ab573c839f 100644
--- a/drivers/staging/comedi/drivers/adv_pci1724.c
+++ b/drivers/comedi/drivers/adv_pci1724.c
diff --git a/drivers/staging/comedi/drivers/adv_pci1760.c b/drivers/comedi/drivers/adv_pci1760.c
index 6de8ab97d346..6de8ab97d346 100644
--- a/drivers/staging/comedi/drivers/adv_pci1760.c
+++ b/drivers/comedi/drivers/adv_pci1760.c
diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/comedi/drivers/adv_pci_dio.c
index 8e222b6ff2b4..54c7419c8ca6 100644
--- a/drivers/staging/comedi/drivers/adv_pci_dio.c
+++ b/drivers/comedi/drivers/adv_pci_dio.c
@@ -604,7 +604,6 @@ static int pci_dio_auto_attach(struct comedi_device *dev,
? pci_dio_insn_bits_di_w
: pci_dio_insn_bits_di_b;
s->private = (void *)d->addr;
-
}
}
diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/comedi/drivers/aio_aio12_8.c
index 4829115921a3..4829115921a3 100644
--- a/drivers/staging/comedi/drivers/aio_aio12_8.c
+++ b/drivers/comedi/drivers/aio_aio12_8.c
diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/comedi/drivers/aio_iiro_16.c
index fe3876235075..fe3876235075 100644
--- a/drivers/staging/comedi/drivers/aio_iiro_16.c
+++ b/drivers/comedi/drivers/aio_iiro_16.c
diff --git a/drivers/staging/comedi/drivers/amcc_s5933.h b/drivers/comedi/drivers/amcc_s5933.h
index f738b91b2052..f738b91b2052 100644
--- a/drivers/staging/comedi/drivers/amcc_s5933.h
+++ b/drivers/comedi/drivers/amcc_s5933.h
diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/comedi/drivers/amplc_dio200.c
index fa19c9e7c56b..fa19c9e7c56b 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200.c
+++ b/drivers/comedi/drivers/amplc_dio200.c
diff --git a/drivers/staging/comedi/drivers/amplc_dio200.h b/drivers/comedi/drivers/amplc_dio200.h
index 745baaf940ee..745baaf940ee 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200.h
+++ b/drivers/comedi/drivers/amplc_dio200.h
diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/comedi/drivers/amplc_dio200_common.c
index a3454130d5f8..a3454130d5f8 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200_common.c
+++ b/drivers/comedi/drivers/amplc_dio200_common.c
diff --git a/drivers/staging/comedi/drivers/amplc_dio200_pci.c b/drivers/comedi/drivers/amplc_dio200_pci.c
index 1bd7a42c8464..1bd7a42c8464 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200_pci.c
+++ b/drivers/comedi/drivers/amplc_dio200_pci.c
diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/comedi/drivers/amplc_pc236.c
index c377af1d5246..c377af1d5246 100644
--- a/drivers/staging/comedi/drivers/amplc_pc236.c
+++ b/drivers/comedi/drivers/amplc_pc236.c
diff --git a/drivers/staging/comedi/drivers/amplc_pc236.h b/drivers/comedi/drivers/amplc_pc236.h
index 7e72729f7492..7e72729f7492 100644
--- a/drivers/staging/comedi/drivers/amplc_pc236.h
+++ b/drivers/comedi/drivers/amplc_pc236.h
diff --git a/drivers/staging/comedi/drivers/amplc_pc236_common.c b/drivers/comedi/drivers/amplc_pc236_common.c
index 981d281e87a1..981d281e87a1 100644
--- a/drivers/staging/comedi/drivers/amplc_pc236_common.c
+++ b/drivers/comedi/drivers/amplc_pc236_common.c
diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/comedi/drivers/amplc_pc263.c
index 68da6098ee84..68da6098ee84 100644
--- a/drivers/staging/comedi/drivers/amplc_pc263.c
+++ b/drivers/comedi/drivers/amplc_pc263.c
diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/comedi/drivers/amplc_pci224.c
index bcf6d61af863..bcf6d61af863 100644
--- a/drivers/staging/comedi/drivers/amplc_pci224.c
+++ b/drivers/comedi/drivers/amplc_pci224.c
diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/comedi/drivers/amplc_pci230.c
index 8911dc2bd2c6..8911dc2bd2c6 100644
--- a/drivers/staging/comedi/drivers/amplc_pci230.c
+++ b/drivers/comedi/drivers/amplc_pci230.c
diff --git a/drivers/staging/comedi/drivers/amplc_pci236.c b/drivers/comedi/drivers/amplc_pci236.c
index e7f6fa4d101a..e7f6fa4d101a 100644
--- a/drivers/staging/comedi/drivers/amplc_pci236.c
+++ b/drivers/comedi/drivers/amplc_pci236.c
diff --git a/drivers/staging/comedi/drivers/amplc_pci263.c b/drivers/comedi/drivers/amplc_pci263.c
index 9217973f1141..9217973f1141 100644
--- a/drivers/staging/comedi/drivers/amplc_pci263.c
+++ b/drivers/comedi/drivers/amplc_pci263.c
diff --git a/drivers/staging/comedi/drivers/c6xdigio.c b/drivers/comedi/drivers/c6xdigio.c
index 786fd15698df..786fd15698df 100644
--- a/drivers/staging/comedi/drivers/c6xdigio.c
+++ b/drivers/comedi/drivers/c6xdigio.c
diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/comedi/drivers/cb_das16_cs.c
index a5d171e71c33..a5d171e71c33 100644
--- a/drivers/staging/comedi/drivers/cb_das16_cs.c
+++ b/drivers/comedi/drivers/cb_das16_cs.c
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/comedi/drivers/cb_pcidas.c
index 2f20bd56ec6c..2f20bd56ec6c 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/comedi/drivers/cb_pcidas.c
diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/comedi/drivers/cb_pcidas64.c
index 6d3ba399a7f0..41a8fea7f48a 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/comedi/drivers/cb_pcidas64.c
@@ -229,11 +229,6 @@ enum daq_atrig_low_4020_contents {
EXT_START_TRIG_BNC_BIT = 0x2000,
};
-static inline u16 analog_trig_low_threshold_bits(u16 threshold)
-{
- return threshold & 0xfff;
-}
-
enum adc_control0_contents {
ADC_GATE_SRC_MASK = 0x3, /* bits that select gate */
ADC_SOFT_GATE_BITS = 0x1, /* software gate */
diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/comedi/drivers/cb_pcidda.c
index 78cf1603638c..78cf1603638c 100644
--- a/drivers/staging/comedi/drivers/cb_pcidda.c
+++ b/drivers/comedi/drivers/cb_pcidda.c
diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/comedi/drivers/cb_pcimdas.c
index 2292f69da4f4..2292f69da4f4 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/comedi/drivers/cb_pcimdas.c
diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/comedi/drivers/cb_pcimdda.c
index 21fc7b3c5f60..21fc7b3c5f60 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdda.c
+++ b/drivers/comedi/drivers/cb_pcimdda.c
diff --git a/drivers/staging/comedi/drivers/comedi_8254.c b/drivers/comedi/drivers/comedi_8254.c
index d1d509e9add9..d1d509e9add9 100644
--- a/drivers/staging/comedi/drivers/comedi_8254.c
+++ b/drivers/comedi/drivers/comedi_8254.c
diff --git a/drivers/staging/comedi/drivers/comedi_8254.h b/drivers/comedi/drivers/comedi_8254.h
index d8264417e53c..d8264417e53c 100644
--- a/drivers/staging/comedi/drivers/comedi_8254.h
+++ b/drivers/comedi/drivers/comedi_8254.h
diff --git a/drivers/staging/comedi/drivers/comedi_8255.c b/drivers/comedi/drivers/comedi_8255.c
index b7ca465933ee..b7ca465933ee 100644
--- a/drivers/staging/comedi/drivers/comedi_8255.c
+++ b/drivers/comedi/drivers/comedi_8255.c
diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/comedi/drivers/comedi_bond.c
index 4392b5927a99..4392b5927a99 100644
--- a/drivers/staging/comedi/drivers/comedi_bond.c
+++ b/drivers/comedi/drivers/comedi_bond.c
diff --git a/drivers/staging/comedi/drivers/comedi_isadma.c b/drivers/comedi/drivers/comedi_isadma.c
index c729094298c2..c729094298c2 100644
--- a/drivers/staging/comedi/drivers/comedi_isadma.c
+++ b/drivers/comedi/drivers/comedi_isadma.c
diff --git a/drivers/staging/comedi/drivers/comedi_isadma.h b/drivers/comedi/drivers/comedi_isadma.h
index 9d2b12db7e6e..9d2b12db7e6e 100644
--- a/drivers/staging/comedi/drivers/comedi_isadma.h
+++ b/drivers/comedi/drivers/comedi_isadma.h
diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/comedi/drivers/comedi_parport.c
index 5338b5eea440..5338b5eea440 100644
--- a/drivers/staging/comedi/drivers/comedi_parport.c
+++ b/drivers/comedi/drivers/comedi_parport.c
diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/comedi/drivers/comedi_test.c
index cbc225eb1991..cbc225eb1991 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/comedi/drivers/comedi_test.c
diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/comedi/drivers/contec_pci_dio.c
index b8fdd9c1f166..b8fdd9c1f166 100644
--- a/drivers/staging/comedi/drivers/contec_pci_dio.c
+++ b/drivers/comedi/drivers/contec_pci_dio.c
diff --git a/drivers/staging/comedi/drivers/dac02.c b/drivers/comedi/drivers/dac02.c
index 5ef8114c2c85..5ef8114c2c85 100644
--- a/drivers/staging/comedi/drivers/dac02.c
+++ b/drivers/comedi/drivers/dac02.c
diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/comedi/drivers/daqboard2000.c
index f64e747078bd..f64e747078bd 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/comedi/drivers/daqboard2000.c
diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/comedi/drivers/das08.c
index b50743c5b822..b50743c5b822 100644
--- a/drivers/staging/comedi/drivers/das08.c
+++ b/drivers/comedi/drivers/das08.c
diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/comedi/drivers/das08.h
index ef65a7e504ee..ef65a7e504ee 100644
--- a/drivers/staging/comedi/drivers/das08.h
+++ b/drivers/comedi/drivers/das08.h
diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/comedi/drivers/das08_cs.c
index 223479f9ea3c..223479f9ea3c 100644
--- a/drivers/staging/comedi/drivers/das08_cs.c
+++ b/drivers/comedi/drivers/das08_cs.c
diff --git a/drivers/staging/comedi/drivers/das08_isa.c b/drivers/comedi/drivers/das08_isa.c
index 8c4cfa821423..8c4cfa821423 100644
--- a/drivers/staging/comedi/drivers/das08_isa.c
+++ b/drivers/comedi/drivers/das08_isa.c
diff --git a/drivers/staging/comedi/drivers/das08_pci.c b/drivers/comedi/drivers/das08_pci.c
index 1cd903336a4c..1cd903336a4c 100644
--- a/drivers/staging/comedi/drivers/das08_pci.c
+++ b/drivers/comedi/drivers/das08_pci.c
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/comedi/drivers/das16.c
index 4ac2622b0fac..4ac2622b0fac 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/comedi/drivers/das16.c
diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/comedi/drivers/das16m1.c
index 75f3dbbe97ac..75f3dbbe97ac 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/comedi/drivers/das16m1.c
diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/comedi/drivers/das1800.c
index f50891a6ee7d..f50891a6ee7d 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/comedi/drivers/das1800.c
diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/comedi/drivers/das6402.c
index 96f4107b8054..96f4107b8054 100644
--- a/drivers/staging/comedi/drivers/das6402.c
+++ b/drivers/comedi/drivers/das6402.c
diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/comedi/drivers/das800.c
index 2881808d6606..bc08324f422f 100644
--- a/drivers/staging/comedi/drivers/das800.c
+++ b/drivers/comedi/drivers/das800.c
@@ -668,7 +668,7 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->board_name = board->name;
if (irq > 1 && irq <= 7) {
- ret = request_irq(irq, das800_interrupt, 0, dev->board_name,
+ ret = request_irq(irq, das800_interrupt, 0, "das800",
dev);
if (ret == 0)
dev->irq = irq;
diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/comedi/drivers/dmm32at.c
index 56682f01242f..56682f01242f 100644
--- a/drivers/staging/comedi/drivers/dmm32at.c
+++ b/drivers/comedi/drivers/dmm32at.c
diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/comedi/drivers/dt2801.c
index 0d571d817b4e..0d571d817b4e 100644
--- a/drivers/staging/comedi/drivers/dt2801.c
+++ b/drivers/comedi/drivers/dt2801.c
diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/comedi/drivers/dt2811.c
index 0eb5e6ba6916..0eb5e6ba6916 100644
--- a/drivers/staging/comedi/drivers/dt2811.c
+++ b/drivers/comedi/drivers/dt2811.c
diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/comedi/drivers/dt2814.c
index bcf4d5444faf..ed44ce0d151b 100644
--- a/drivers/staging/comedi/drivers/dt2814.c
+++ b/drivers/comedi/drivers/dt2814.c
@@ -44,14 +44,46 @@
#define DT2814_ENB 0x10
#define DT2814_CHANMASK 0x0f
-struct dt2814_private {
- int ntrig;
- int curadchan;
-};
-
#define DT2814_TIMEOUT 10
#define DT2814_MAX_SPEED 100000 /* Arbitrary 10 khz limit */
+static int dt2814_ai_notbusy(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned long context)
+{
+ unsigned int status;
+
+ status = inb(dev->iobase + DT2814_CSR);
+ if (context)
+ *(unsigned int *)context = status;
+ if (status & DT2814_BUSY)
+ return -EBUSY;
+ return 0;
+}
+
+static int dt2814_ai_clear(struct comedi_device *dev)
+{
+ unsigned int status = 0;
+ int ret;
+
+ /* Wait until not busy and get status register value. */
+ ret = comedi_timeout(dev, NULL, NULL, dt2814_ai_notbusy,
+ (unsigned long)&status);
+ if (ret)
+ return ret;
+
+ if (status & (DT2814_FINISH | DT2814_ERR)) {
+ /*
+ * There unread data, or the error flag is set.
+ * Read the data register twice to clear the condition.
+ */
+ inb(dev->iobase + DT2814_DATA);
+ inb(dev->iobase + DT2814_DATA);
+ }
+ return 0;
+}
+
static int dt2814_ai_eoc(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
@@ -73,6 +105,7 @@ static int dt2814_ai_insn_read(struct comedi_device *dev,
int chan;
int ret;
+ dt2814_ai_clear(dev); /* clear stale data or error */
for (n = 0; n < insn->n; n++) {
chan = CR_CHAN(insn->chanspec);
@@ -169,80 +202,119 @@ static int dt2814_ai_cmdtest(struct comedi_device *dev,
static int dt2814_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
- struct dt2814_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
int chan;
int trigvar;
+ dt2814_ai_clear(dev); /* clear stale data or error */
trigvar = dt2814_ns_to_timer(&cmd->scan_begin_arg, cmd->flags);
chan = CR_CHAN(cmd->chanlist[0]);
- devpriv->ntrig = cmd->stop_arg;
outb(chan | DT2814_ENB | (trigvar << 5), dev->iobase + DT2814_CSR);
return 0;
}
+static int dt2814_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ unsigned int status;
+ unsigned long flags;
+
+ spin_lock_irqsave(&dev->spinlock, flags);
+ status = inb(dev->iobase + DT2814_CSR);
+ if (status & DT2814_ENB) {
+ /*
+ * Clear the timed trigger enable bit.
+ *
+ * Note: turning off timed mode triggers another
+ * sample. This will be mopped up by the calls to
+ * dt2814_ai_clear().
+ */
+ outb(status & DT2814_CHANMASK, dev->iobase + DT2814_CSR);
+ }
+ spin_unlock_irqrestore(&dev->spinlock, flags);
+ return 0;
+}
+
static irqreturn_t dt2814_interrupt(int irq, void *d)
{
- int lo, hi;
struct comedi_device *dev = d;
- struct dt2814_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
- int data;
+ struct comedi_async *async;
+ unsigned int lo, hi;
+ unsigned short data;
+ unsigned int status;
if (!dev->attached) {
dev_err(dev->class_dev, "spurious interrupt\n");
return IRQ_HANDLED;
}
+ async = s->async;
+
+ spin_lock(&dev->spinlock);
+
+ status = inb(dev->iobase + DT2814_CSR);
+ if (!(status & DT2814_ENB)) {
+ /* Timed acquisition not enabled. Nothing to do. */
+ spin_unlock(&dev->spinlock);
+ return IRQ_HANDLED;
+ }
+
+ if (!(status & (DT2814_FINISH | DT2814_ERR))) {
+ /* Spurious interrupt? */
+ spin_unlock(&dev->spinlock);
+ return IRQ_HANDLED;
+ }
+
+ /* Read data or clear error. */
hi = inb(dev->iobase + DT2814_DATA);
lo = inb(dev->iobase + DT2814_DATA);
data = (hi << 4) | (lo >> 4);
- if (!(--devpriv->ntrig)) {
- int i;
-
- outb(0, dev->iobase + DT2814_CSR);
+ if (status & DT2814_ERR) {
+ async->events |= COMEDI_CB_ERROR;
+ } else {
+ comedi_buf_write_samples(s, &data, 1);
+ if (async->cmd.stop_src == TRIG_COUNT &&
+ async->scans_done >= async->cmd.stop_arg) {
+ async->events |= COMEDI_CB_EOA;
+ }
+ }
+ if (async->events & COMEDI_CB_CANCEL_MASK) {
/*
- * note: turning off timed mode triggers another
- * sample.
+ * Disable timed mode.
+ *
+ * Note: turning off timed mode triggers another
+ * sample. This will be mopped up by the calls to
+ * dt2814_ai_clear().
*/
+ outb(status & DT2814_CHANMASK, dev->iobase + DT2814_CSR);
+ }
- for (i = 0; i < DT2814_TIMEOUT; i++) {
- if (inb(dev->iobase + DT2814_CSR) & DT2814_FINISH)
- break;
- }
- inb(dev->iobase + DT2814_DATA);
- inb(dev->iobase + DT2814_DATA);
+ spin_unlock(&dev->spinlock);
- s->async->events |= COMEDI_CB_EOA;
- }
comedi_handle_events(dev, s);
return IRQ_HANDLED;
}
static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
- struct dt2814_private *devpriv;
struct comedi_subdevice *s;
int ret;
- int i;
ret = comedi_request_region(dev, it->options[0], 0x2);
if (ret)
return ret;
outb(0, dev->iobase + DT2814_CSR);
- usleep_range(100, 200);
- if (inb(dev->iobase + DT2814_CSR) & DT2814_ERR) {
+ if (dt2814_ai_clear(dev)) {
dev_err(dev->class_dev, "reset error (fatal)\n");
return -EIO;
}
- i = inb(dev->iobase + DT2814_DATA);
- i = inb(dev->iobase + DT2814_DATA);
if (it->options[1]) {
ret = request_irq(it->options[1], dt2814_interrupt, 0,
@@ -255,10 +327,6 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (ret)
return ret;
- devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
- if (!devpriv)
- return -ENOMEM;
-
s = &dev->subdevices[0];
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_GROUND;
@@ -272,16 +340,30 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->len_chanlist = 1;
s->do_cmd = dt2814_ai_cmd;
s->do_cmdtest = dt2814_ai_cmdtest;
+ s->cancel = dt2814_ai_cancel;
}
return 0;
}
+static void dt2814_detach(struct comedi_device *dev)
+{
+ if (dev->irq) {
+ /*
+ * An extra conversion triggered on termination of an
+ * asynchronous command may still be in progress. Wait for
+ * it to finish and clear the data or error status.
+ */
+ dt2814_ai_clear(dev);
+ }
+ comedi_legacy_detach(dev);
+}
+
static struct comedi_driver dt2814_driver = {
.driver_name = "dt2814",
.module = THIS_MODULE,
.attach = dt2814_attach,
- .detach = comedi_legacy_detach,
+ .detach = dt2814_detach,
};
module_comedi_driver(dt2814_driver);
diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/comedi/drivers/dt2815.c
index 5906f32aa01f..5906f32aa01f 100644
--- a/drivers/staging/comedi/drivers/dt2815.c
+++ b/drivers/comedi/drivers/dt2815.c
diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/comedi/drivers/dt2817.c
index 7c1463e835d3..7c1463e835d3 100644
--- a/drivers/staging/comedi/drivers/dt2817.c
+++ b/drivers/comedi/drivers/dt2817.c
diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/comedi/drivers/dt282x.c
index 2656b4b0e3d0..2656b4b0e3d0 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/comedi/drivers/dt282x.c
diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/comedi/drivers/dt3000.c
index ec27aa4730d4..ec27aa4730d4 100644
--- a/drivers/staging/comedi/drivers/dt3000.c
+++ b/drivers/comedi/drivers/dt3000.c
diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/comedi/drivers/dt9812.c
index 634f57730c1e..634f57730c1e 100644
--- a/drivers/staging/comedi/drivers/dt9812.c
+++ b/drivers/comedi/drivers/dt9812.c
diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/comedi/drivers/dyna_pci10xx.c
index c224422bb126..c224422bb126 100644
--- a/drivers/staging/comedi/drivers/dyna_pci10xx.c
+++ b/drivers/comedi/drivers/dyna_pci10xx.c
diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/comedi/drivers/fl512.c
index b715f30659fa..b715f30659fa 100644
--- a/drivers/staging/comedi/drivers/fl512.c
+++ b/drivers/comedi/drivers/fl512.c
diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/comedi/drivers/gsc_hpdi.c
index e35e4a743714..e35e4a743714 100644
--- a/drivers/staging/comedi/drivers/gsc_hpdi.c
+++ b/drivers/comedi/drivers/gsc_hpdi.c
diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/comedi/drivers/icp_multi.c
index 16d2b78de83c..16d2b78de83c 100644
--- a/drivers/staging/comedi/drivers/icp_multi.c
+++ b/drivers/comedi/drivers/icp_multi.c
diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/comedi/drivers/ii_pci20kc.c
index 399255dbe388..399255dbe388 100644
--- a/drivers/staging/comedi/drivers/ii_pci20kc.c
+++ b/drivers/comedi/drivers/ii_pci20kc.c
diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/comedi/drivers/jr3_pci.c
index 7a02c4fa3cda..7a02c4fa3cda 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/comedi/drivers/jr3_pci.c
diff --git a/drivers/staging/comedi/drivers/jr3_pci.h b/drivers/comedi/drivers/jr3_pci.h
index acd4e5456ceb..acd4e5456ceb 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.h
+++ b/drivers/comedi/drivers/jr3_pci.h
diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/comedi/drivers/ke_counter.c
index bef1b20c1c8d..bef1b20c1c8d 100644
--- a/drivers/staging/comedi/drivers/ke_counter.c
+++ b/drivers/comedi/drivers/ke_counter.c
diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/comedi/drivers/me4000.c
index 0d3d4cafce2e..0d3d4cafce2e 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/comedi/drivers/me4000.c
diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/comedi/drivers/me_daq.c
index ef18e387471b..ef18e387471b 100644
--- a/drivers/staging/comedi/drivers/me_daq.c
+++ b/drivers/comedi/drivers/me_daq.c
diff --git a/drivers/staging/comedi/drivers/mf6x4.c b/drivers/comedi/drivers/mf6x4.c
index 9da8dd748078..9da8dd748078 100644
--- a/drivers/staging/comedi/drivers/mf6x4.c
+++ b/drivers/comedi/drivers/mf6x4.c
diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/comedi/drivers/mite.c
index 70960e3ba878..70960e3ba878 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/comedi/drivers/mite.c
diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/comedi/drivers/mite.h
index c6c056069bb7..c6c056069bb7 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/comedi/drivers/mite.h
diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/comedi/drivers/mpc624.c
index 646f4c086204..646f4c086204 100644
--- a/drivers/staging/comedi/drivers/mpc624.c
+++ b/drivers/comedi/drivers/mpc624.c
diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/comedi/drivers/multiq3.c
index c1897aee9a9a..c1897aee9a9a 100644
--- a/drivers/staging/comedi/drivers/multiq3.c
+++ b/drivers/comedi/drivers/multiq3.c
diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/comedi/drivers/ni_6527.c
index f1a45cf7342a..f1a45cf7342a 100644
--- a/drivers/staging/comedi/drivers/ni_6527.c
+++ b/drivers/comedi/drivers/ni_6527.c
diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/comedi/drivers/ni_65xx.c
index 7cd8497420f2..7cd8497420f2 100644
--- a/drivers/staging/comedi/drivers/ni_65xx.c
+++ b/drivers/comedi/drivers/ni_65xx.c
diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/comedi/drivers/ni_660x.c
index e60d0125bcb2..e60d0125bcb2 100644
--- a/drivers/staging/comedi/drivers/ni_660x.c
+++ b/drivers/comedi/drivers/ni_660x.c
diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/comedi/drivers/ni_670x.c
index c197e47486be..c197e47486be 100644
--- a/drivers/staging/comedi/drivers/ni_670x.c
+++ b/drivers/comedi/drivers/ni_670x.c
diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/comedi/drivers/ni_at_a2150.c
index 10ad7b88713e..10ad7b88713e 100644
--- a/drivers/staging/comedi/drivers/ni_at_a2150.c
+++ b/drivers/comedi/drivers/ni_at_a2150.c
diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/comedi/drivers/ni_at_ao.c
index 2a0fb4d460db..2a0fb4d460db 100644
--- a/drivers/staging/comedi/drivers/ni_at_ao.c
+++ b/drivers/comedi/drivers/ni_at_ao.c
diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/comedi/drivers/ni_atmio.c
index 56c78da475e7..56c78da475e7 100644
--- a/drivers/staging/comedi/drivers/ni_atmio.c
+++ b/drivers/comedi/drivers/ni_atmio.c
diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/comedi/drivers/ni_atmio16d.c
index dffce1aa3e69..dffce1aa3e69 100644
--- a/drivers/staging/comedi/drivers/ni_atmio16d.c
+++ b/drivers/comedi/drivers/ni_atmio16d.c
diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/comedi/drivers/ni_daq_700.c
index d40fc89f9cef..d40fc89f9cef 100644
--- a/drivers/staging/comedi/drivers/ni_daq_700.c
+++ b/drivers/comedi/drivers/ni_daq_700.c
diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/comedi/drivers/ni_daq_dio24.c
index 44fb65afc218..44fb65afc218 100644
--- a/drivers/staging/comedi/drivers/ni_daq_dio24.c
+++ b/drivers/comedi/drivers/ni_daq_dio24.c
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/comedi/drivers/ni_labpc.c
index 1f4a07bd1d26..1f4a07bd1d26 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/comedi/drivers/ni_labpc.c
diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/comedi/drivers/ni_labpc.h
index 728e901f53cd..728e901f53cd 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.h
+++ b/drivers/comedi/drivers/ni_labpc.h
diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/comedi/drivers/ni_labpc_common.c
index dd97946eacaf..dd97946eacaf 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_common.c
+++ b/drivers/comedi/drivers/ni_labpc_common.c
diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/comedi/drivers/ni_labpc_cs.c
index 4f7e2fe21254..4f7e2fe21254 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_cs.c
+++ b/drivers/comedi/drivers/ni_labpc_cs.c
diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.c b/drivers/comedi/drivers/ni_labpc_isadma.c
index a551aca6e615..a551aca6e615 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_isadma.c
+++ b/drivers/comedi/drivers/ni_labpc_isadma.c
diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.h b/drivers/comedi/drivers/ni_labpc_isadma.h
index f06f9353cb6c..f06f9353cb6c 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_isadma.h
+++ b/drivers/comedi/drivers/ni_labpc_isadma.h
diff --git a/drivers/staging/comedi/drivers/ni_labpc_pci.c b/drivers/comedi/drivers/ni_labpc_pci.c
index ec180b0fedf7..ec180b0fedf7 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_pci.c
+++ b/drivers/comedi/drivers/ni_labpc_pci.c
diff --git a/drivers/staging/comedi/drivers/ni_labpc_regs.h b/drivers/comedi/drivers/ni_labpc_regs.h
index ace40065a25b..ace40065a25b 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_regs.h
+++ b/drivers/comedi/drivers/ni_labpc_regs.h
diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/comedi/drivers/ni_mio_common.c
index 4f80a4991f95..4f80a4991f95 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/comedi/drivers/ni_mio_common.c
diff --git a/drivers/staging/comedi/drivers/ni_mio_cs.c b/drivers/comedi/drivers/ni_mio_cs.c
index 4f37b4e58f09..4f37b4e58f09 100644
--- a/drivers/staging/comedi/drivers/ni_mio_cs.c
+++ b/drivers/comedi/drivers/ni_mio_cs.c
diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/comedi/drivers/ni_pcidio.c
index 623f8d08d13a..623f8d08d13a 100644
--- a/drivers/staging/comedi/drivers/ni_pcidio.c
+++ b/drivers/comedi/drivers/ni_pcidio.c
diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/comedi/drivers/ni_pcimio.c
index 6c813a490ba5..6c813a490ba5 100644
--- a/drivers/staging/comedi/drivers/ni_pcimio.c
+++ b/drivers/comedi/drivers/ni_pcimio.c
diff --git a/drivers/staging/comedi/drivers/ni_routes.c b/drivers/comedi/drivers/ni_routes.c
index c426a9286f15..c426a9286f15 100644
--- a/drivers/staging/comedi/drivers/ni_routes.c
+++ b/drivers/comedi/drivers/ni_routes.c
diff --git a/drivers/staging/comedi/drivers/ni_routes.h b/drivers/comedi/drivers/ni_routes.h
index b7680fd2afe1..b7680fd2afe1 100644
--- a/drivers/staging/comedi/drivers/ni_routes.h
+++ b/drivers/comedi/drivers/ni_routes.h
diff --git a/drivers/staging/comedi/drivers/ni_routing/README b/drivers/comedi/drivers/ni_routing/README
index b65c4ebedbc4..b65c4ebedbc4 100644
--- a/drivers/staging/comedi/drivers/ni_routing/README
+++ b/drivers/comedi/drivers/ni_routing/README
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes.c b/drivers/comedi/drivers/ni_routing/ni_device_routes.c
index 7b6a74dfe48b..7b6a74dfe48b 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes.h b/drivers/comedi/drivers/ni_routing/ni_device_routes.h
index b9f1c47d19e1..b9f1c47d19e1 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes.h
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes.h
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/all.h b/drivers/comedi/drivers/ni_routing/ni_device_routes/all.h
index 78b24138acb7..78b24138acb7 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/all.h
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/all.h
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6070e.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6070e.c
index f1126a0cb285..f1126a0cb285 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6070e.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6070e.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6220.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6220.c
index 74a59222963f..74a59222963f 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6220.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6220.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6221.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6221.c
index 44dcbabf2a99..44dcbabf2a99 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6221.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6221.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6229.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6229.c
index fa5794e4e2b3..fa5794e4e2b3 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6229.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6229.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6251.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6251.c
index 645fd1cd2de4..645fd1cd2de4 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6251.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6251.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6254.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6254.c
index 056a240cd3a2..056a240cd3a2 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6254.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6254.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6259.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6259.c
index e0b5fa78c3bc..e0b5fa78c3bc 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6259.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6259.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6534.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6534.c
index a2472ed288cf..a2472ed288cf 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6534.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6534.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6602.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6602.c
index 91de9dac2d6a..91de9dac2d6a 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6602.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6602.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6713.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6713.c
index d378b36d2084..d378b36d2084 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6713.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6713.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6723.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6723.c
index e0cc57ab06e7..e0cc57ab06e7 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6723.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6723.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6733.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6733.c
index f6e1e17ab854..f6e1e17ab854 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pci-6733.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pci-6733.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6030e.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6030e.c
index 9978d632117f..9978d632117f 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6030e.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6030e.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6224.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6224.c
index 1b89e27d7aa5..1b89e27d7aa5 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6224.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6224.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6225.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6225.c
index 10dfc34bc87c..10dfc34bc87c 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6225.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6225.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6251.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6251.c
index 25db4b7363de..25db4b7363de 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6251.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6251.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6733.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6733.c
index 27da4433fc4a..27da4433fc4a 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxi-6733.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxi-6733.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxie-6251.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxie-6251.c
index 8354fe971d59..8354fe971d59 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxie-6251.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxie-6251.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxie-6535.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxie-6535.c
index 2ebb679e0129..2ebb679e0129 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxie-6535.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxie-6535.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxie-6738.c b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxie-6738.c
index d88504314d7f..d88504314d7f 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_device_routes/pxie-6738.c
+++ b/drivers/comedi/drivers/ni_routing/ni_device_routes/pxie-6738.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_route_values.c b/drivers/comedi/drivers/ni_routing/ni_route_values.c
index 5901762734ed..5901762734ed 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_route_values.c
+++ b/drivers/comedi/drivers/ni_routing/ni_route_values.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_route_values.h b/drivers/comedi/drivers/ni_routing/ni_route_values.h
index 80e0145fb82b..80e0145fb82b 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_route_values.h
+++ b/drivers/comedi/drivers/ni_routing/ni_route_values.h
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_route_values/all.h b/drivers/comedi/drivers/ni_routing/ni_route_values/all.h
index 7227461500b5..7227461500b5 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_route_values/all.h
+++ b/drivers/comedi/drivers/ni_routing/ni_route_values/all.h
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_route_values/ni_660x.c b/drivers/comedi/drivers/ni_routing/ni_route_values/ni_660x.c
index f1c7e6646261..f1c7e6646261 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_route_values/ni_660x.c
+++ b/drivers/comedi/drivers/ni_routing/ni_route_values/ni_660x.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_route_values/ni_eseries.c b/drivers/comedi/drivers/ni_routing/ni_route_values/ni_eseries.c
index d1ab3c9ce585..d1ab3c9ce585 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_route_values/ni_eseries.c
+++ b/drivers/comedi/drivers/ni_routing/ni_route_values/ni_eseries.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/ni_route_values/ni_mseries.c b/drivers/comedi/drivers/ni_routing/ni_route_values/ni_mseries.c
index c59d8afe0ae9..c59d8afe0ae9 100644
--- a/drivers/staging/comedi/drivers/ni_routing/ni_route_values/ni_mseries.c
+++ b/drivers/comedi/drivers/ni_routing/ni_route_values/ni_mseries.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/tools/.gitignore b/drivers/comedi/drivers/ni_routing/tools/.gitignore
index e3ebffcd900e..e3ebffcd900e 100644
--- a/drivers/staging/comedi/drivers/ni_routing/tools/.gitignore
+++ b/drivers/comedi/drivers/ni_routing/tools/.gitignore
diff --git a/drivers/staging/comedi/drivers/ni_routing/tools/Makefile b/drivers/comedi/drivers/ni_routing/tools/Makefile
index 6e92a06a44cb..6e92a06a44cb 100644
--- a/drivers/staging/comedi/drivers/ni_routing/tools/Makefile
+++ b/drivers/comedi/drivers/ni_routing/tools/Makefile
diff --git a/drivers/staging/comedi/drivers/ni_routing/tools/convert_c_to_py.c b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
index dedb6f2fc678..dedb6f2fc678 100644
--- a/drivers/staging/comedi/drivers/ni_routing/tools/convert_c_to_py.c
+++ b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
diff --git a/drivers/staging/comedi/drivers/ni_routing/tools/convert_csv_to_c.py b/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py
index 532eb6372a5a..532eb6372a5a 100755
--- a/drivers/staging/comedi/drivers/ni_routing/tools/convert_csv_to_c.py
+++ b/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py
diff --git a/drivers/staging/comedi/drivers/ni_routing/tools/convert_py_to_csv.py b/drivers/comedi/drivers/ni_routing/tools/convert_py_to_csv.py
index b3e6472bac22..b3e6472bac22 100755
--- a/drivers/staging/comedi/drivers/ni_routing/tools/convert_py_to_csv.py
+++ b/drivers/comedi/drivers/ni_routing/tools/convert_py_to_csv.py
diff --git a/drivers/staging/comedi/drivers/ni_routing/tools/csv_collection.py b/drivers/comedi/drivers/ni_routing/tools/csv_collection.py
index 12617329a928..12617329a928 100644
--- a/drivers/staging/comedi/drivers/ni_routing/tools/csv_collection.py
+++ b/drivers/comedi/drivers/ni_routing/tools/csv_collection.py
diff --git a/drivers/staging/comedi/drivers/ni_routing/tools/make_blank_csv.py b/drivers/comedi/drivers/ni_routing/tools/make_blank_csv.py
index 89c90a0ba24d..89c90a0ba24d 100755
--- a/drivers/staging/comedi/drivers/ni_routing/tools/make_blank_csv.py
+++ b/drivers/comedi/drivers/ni_routing/tools/make_blank_csv.py
diff --git a/drivers/staging/comedi/drivers/ni_routing/tools/ni_names.py b/drivers/comedi/drivers/ni_routing/tools/ni_names.py
index 5f9b825968b1..5f9b825968b1 100644
--- a/drivers/staging/comedi/drivers/ni_routing/tools/ni_names.py
+++ b/drivers/comedi/drivers/ni_routing/tools/ni_names.py
diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/comedi/drivers/ni_stc.h
index fbc0b753a0f5..fbc0b753a0f5 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/comedi/drivers/ni_stc.h
diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/comedi/drivers/ni_tio.c
index f6154addaa95..f6154addaa95 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/comedi/drivers/ni_tio.c
diff --git a/drivers/staging/comedi/drivers/ni_tio.h b/drivers/comedi/drivers/ni_tio.h
index e7b05718df9b..e7b05718df9b 100644
--- a/drivers/staging/comedi/drivers/ni_tio.h
+++ b/drivers/comedi/drivers/ni_tio.h
diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/comedi/drivers/ni_tio_internal.h
index 20fcd60038cd..20fcd60038cd 100644
--- a/drivers/staging/comedi/drivers/ni_tio_internal.h
+++ b/drivers/comedi/drivers/ni_tio_internal.h
diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/comedi/drivers/ni_tiocmd.c
index ab6d9e8269f3..ab6d9e8269f3 100644
--- a/drivers/staging/comedi/drivers/ni_tiocmd.c
+++ b/drivers/comedi/drivers/ni_tiocmd.c
diff --git a/drivers/staging/comedi/drivers/ni_usb6501.c b/drivers/comedi/drivers/ni_usb6501.c
index 5b6d9d783b2f..5b6d9d783b2f 100644
--- a/drivers/staging/comedi/drivers/ni_usb6501.c
+++ b/drivers/comedi/drivers/ni_usb6501.c
diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/comedi/drivers/pcl711.c
index bd6f42fe9e3c..bd6f42fe9e3c 100644
--- a/drivers/staging/comedi/drivers/pcl711.c
+++ b/drivers/comedi/drivers/pcl711.c
diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/comedi/drivers/pcl724.c
index 1a5799278a7a..1a5799278a7a 100644
--- a/drivers/staging/comedi/drivers/pcl724.c
+++ b/drivers/comedi/drivers/pcl724.c
diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/comedi/drivers/pcl726.c
index 88f25d7e76f7..88f25d7e76f7 100644
--- a/drivers/staging/comedi/drivers/pcl726.c
+++ b/drivers/comedi/drivers/pcl726.c
diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/comedi/drivers/pcl730.c
index 32a29129e6e8..32a29129e6e8 100644
--- a/drivers/staging/comedi/drivers/pcl730.c
+++ b/drivers/comedi/drivers/pcl730.c
diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/comedi/drivers/pcl812.c
index b87ab3840eee..b87ab3840eee 100644
--- a/drivers/staging/comedi/drivers/pcl812.c
+++ b/drivers/comedi/drivers/pcl812.c
diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/comedi/drivers/pcl816.c
index c368a337a0ae..c368a337a0ae 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/comedi/drivers/pcl816.c
diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/comedi/drivers/pcl818.c
index f4b4a686c710..f4b4a686c710 100644
--- a/drivers/staging/comedi/drivers/pcl818.c
+++ b/drivers/comedi/drivers/pcl818.c
diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/comedi/drivers/pcm3724.c
index 0cb1ad060402..0cb1ad060402 100644
--- a/drivers/staging/comedi/drivers/pcm3724.c
+++ b/drivers/comedi/drivers/pcm3724.c
diff --git a/drivers/staging/comedi/drivers/pcmad.c b/drivers/comedi/drivers/pcmad.c
index eec89a0afb2f..eec89a0afb2f 100644
--- a/drivers/staging/comedi/drivers/pcmad.c
+++ b/drivers/comedi/drivers/pcmad.c
diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/comedi/drivers/pcmda12.c
index 14ab1f0d1e9f..14ab1f0d1e9f 100644
--- a/drivers/staging/comedi/drivers/pcmda12.c
+++ b/drivers/comedi/drivers/pcmda12.c
diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/comedi/drivers/pcmmio.c
index 24a9568d3378..24a9568d3378 100644
--- a/drivers/staging/comedi/drivers/pcmmio.c
+++ b/drivers/comedi/drivers/pcmmio.c
diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/comedi/drivers/pcmuio.c
index b299d648a0eb..b299d648a0eb 100644
--- a/drivers/staging/comedi/drivers/pcmuio.c
+++ b/drivers/comedi/drivers/pcmuio.c
diff --git a/drivers/staging/comedi/drivers/plx9052.h b/drivers/comedi/drivers/plx9052.h
index e68a7afef025..e68a7afef025 100644
--- a/drivers/staging/comedi/drivers/plx9052.h
+++ b/drivers/comedi/drivers/plx9052.h
diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/comedi/drivers/plx9080.h
index aa0eda5a8093..aa0eda5a8093 100644
--- a/drivers/staging/comedi/drivers/plx9080.h
+++ b/drivers/comedi/drivers/plx9080.h
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/comedi/drivers/quatech_daqp_cs.c
index fe4408ebf6b3..fe4408ebf6b3 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/comedi/drivers/quatech_daqp_cs.c
diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/comedi/drivers/rtd520.c
index 2d99a648b054..2d99a648b054 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/comedi/drivers/rtd520.c
diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/comedi/drivers/rti800.c
index 327fd93b8b12..327fd93b8b12 100644
--- a/drivers/staging/comedi/drivers/rti800.c
+++ b/drivers/comedi/drivers/rti800.c
diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/comedi/drivers/rti802.c
index 195e2b1ac4c1..195e2b1ac4c1 100644
--- a/drivers/staging/comedi/drivers/rti802.c
+++ b/drivers/comedi/drivers/rti802.c
diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/comedi/drivers/s526.c
index 085cf5b449e5..085cf5b449e5 100644
--- a/drivers/staging/comedi/drivers/s526.c
+++ b/drivers/comedi/drivers/s526.c
diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/comedi/drivers/s626.c
index e7aba937d896..e7aba937d896 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/comedi/drivers/s626.c
diff --git a/drivers/staging/comedi/drivers/s626.h b/drivers/comedi/drivers/s626.h
index 749252b1d26b..749252b1d26b 100644
--- a/drivers/staging/comedi/drivers/s626.h
+++ b/drivers/comedi/drivers/s626.h
diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/comedi/drivers/ssv_dnp.c
index 016d315aa584..016d315aa584 100644
--- a/drivers/staging/comedi/drivers/ssv_dnp.c
+++ b/drivers/comedi/drivers/ssv_dnp.c
diff --git a/drivers/staging/comedi/drivers/tests/Makefile b/drivers/comedi/drivers/tests/Makefile
index b5d8e13d4162..5ff7cdc32a32 100644
--- a/drivers/staging/comedi/drivers/tests/Makefile
+++ b/drivers/comedi/drivers/tests/Makefile
@@ -3,5 +3,6 @@
#
ccflags-$(CONFIG_COMEDI_DEBUG) := -DDEBUG
-obj-$(CONFIG_COMEDI_TESTS) += example_test.o ni_routes_test.o
+obj-$(CONFIG_COMEDI_TESTS_EXAMPLE) += comedi_example_test.o
+obj-$(CONFIG_COMEDI_TESTS_NI_ROUTES) += ni_routes_test.o
CFLAGS_ni_routes_test.o := -DDEBUG
diff --git a/drivers/staging/comedi/drivers/tests/example_test.c b/drivers/comedi/drivers/tests/comedi_example_test.c
index fc65158b8e8e..e5aaaeab7bdd 100644
--- a/drivers/staging/comedi/drivers/tests/example_test.c
+++ b/drivers/comedi/drivers/tests/comedi_example_test.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/* vim: set ts=8 sw=8 noet tw=80 nowrap: */
/*
- * comedi/drivers/tests/example_test.c
+ * comedi/drivers/tests/comedi_example_test.c
* Example set of unit tests.
*
* COMEDI - Linux Control and Measurement Device Interface
@@ -35,14 +35,14 @@ static struct comedi_device dev = {
/* *** END fake board data *** */
/* *** BEGIN fake data init *** */
-void init_fake(void)
+static void init_fake(void)
{
dev.item = 10;
}
/* *** END fake data init *** */
-void test0(void)
+static void test0(void)
{
init_fake();
unittest(dev.item != 11, "negative result\n");
@@ -52,8 +52,8 @@ void test0(void)
/* **** BEGIN simple module entry/exit functions **** */
static int __init unittest_enter(void)
{
- const unittest_fptr unit_tests[] = {
- (unittest_fptr)test0,
+ static const unittest_fptr unit_tests[] = {
+ test0,
NULL,
};
diff --git a/drivers/staging/comedi/drivers/tests/ni_routes_test.c b/drivers/comedi/drivers/tests/ni_routes_test.c
index 4061b3b5f8e9..32073850d545 100644
--- a/drivers/staging/comedi/drivers/tests/ni_routes_test.c
+++ b/drivers/comedi/drivers/tests/ni_routes_test.c
@@ -24,7 +24,7 @@
#include "../ni_routes.h"
#include "unittest.h"
-#define RVi(table, src, dest) ((table)[(dest) * NI_NUM_NAMES + (src)])
+#define RVI(table, src, dest) ((table)[(dest) * NI_NUM_NAMES + (src)])
#define O(x) ((x) + NI_NAMES_BASE)
#define B(x) ((x) - NI_NAMES_BASE)
#define V(x) ((x) | 0x80)
@@ -63,24 +63,24 @@ static const int no_val_dest = O(7), no_val_index = 4;
/* I1 and I2 should not call O(...). Mostly here to shut checkpatch.pl up */
#define I1(x1) \
- (int[]){ \
- x1, 0 \
- }
+ ((int[]){ \
+ (x1), 0 \
+ })
#define I2(x1, x2) \
- (int[]){ \
+ ((int[]){ \
(x1), (x2), 0 \
- }
+ })
#define I3(x1, x2, x3) \
- (int[]){ \
+ ((int[]){ \
(x1), (x2), (x3), 0 \
- }
+ })
/* O9 is build to call O(...) for each arg */
#define O9(x1, x2, x3, x4, x5, x6, x7, x8, x9) \
- (int[]){ \
+ ((int[]){ \
O(x1), O(x2), O(x3), O(x4), O(x5), O(x6), O(x7), O(x8), O(x9), \
0 \
- }
+ })
static struct ni_device_routes DR = {
.device = "testdev",
@@ -194,7 +194,7 @@ static bool route_set_dests_in_order(const struct ni_device_routes *devroutes)
}
/* Tests that all route_set->src are in order of the signal source. */
-bool route_set_sources_in_order(const struct ni_device_routes *devroutes)
+static bool route_set_sources_in_order(const struct ni_device_routes *devroutes)
{
int i;
@@ -211,13 +211,14 @@ bool route_set_sources_in_order(const struct ni_device_routes *devroutes)
return true;
}
-void test_ni_assign_device_routes(void)
+static void test_ni_assign_device_routes(void)
{
- const struct ni_device_routes *devroutes, *olddevroutes;
+ const struct ni_device_routes *devroutes;
const u8 *table, *oldtable;
init_pci_6070e();
- ni_assign_device_routes(ni_eseries, pci_6070e, &private.routing_tables);
+ ni_assign_device_routes(ni_eseries, pci_6070e, NULL,
+ &private.routing_tables);
devroutes = private.routing_tables.valid_routes;
table = private.routing_tables.route_values;
@@ -242,18 +243,16 @@ void test_ni_assign_device_routes(void)
unittest(route_set_sources_in_order(devroutes),
"all pci-6070e route_set->src's in order of signal source\n");
- unittest(
- RVi(table, B(PXI_Star), B(NI_AI_SampleClock)) == V(17) &&
- RVi(table, B(NI_10MHzRefClock), B(TRIGGER_LINE(0))) == 0 &&
- RVi(table, B(NI_AI_ConvertClock), B(NI_PFI(0))) == 0 &&
- RVi(table, B(NI_AI_ConvertClock), B(NI_PFI(2))) ==
- V(NI_PFI_OUTPUT_AI_CONVERT),
- "pci-6070e finds e-series route_values table\n");
+ unittest(RVI(table, B(PXI_Star), B(NI_AI_SampleClock)) == V(17) &&
+ RVI(table, B(NI_10MHzRefClock), B(TRIGGER_LINE(0))) == 0 &&
+ RVI(table, B(NI_AI_ConvertClock), B(NI_PFI(0))) == 0 &&
+ RVI(table, B(NI_AI_ConvertClock), B(NI_PFI(2))) == V(NI_PFI_OUTPUT_AI_CONVERT),
+ "pci-6070e finds e-series route_values table\n");
- olddevroutes = devroutes;
oldtable = table;
init_pci_6220();
- ni_assign_device_routes(ni_mseries, pci_6220, &private.routing_tables);
+ ni_assign_device_routes(ni_mseries, pci_6220, NULL,
+ &private.routing_tables);
devroutes = private.routing_tables.valid_routes;
table = private.routing_tables.route_values;
@@ -261,15 +260,14 @@ void test_ni_assign_device_routes(void)
"find device pci-6220\n");
unittest(oldtable != table, "pci-6220 find other route_values table\n");
- unittest(
- RVi(table, B(PXI_Star), B(NI_AI_SampleClock)) == V(20) &&
- RVi(table, B(NI_10MHzRefClock), B(TRIGGER_LINE(0))) == V(12) &&
- RVi(table, B(NI_AI_ConvertClock), B(NI_PFI(0))) == V(3) &&
- RVi(table, B(NI_AI_ConvertClock), B(NI_PFI(2))) == V(3),
- "pci-6220 finds m-series route_values table\n");
+ unittest(RVI(table, B(PXI_Star), B(NI_AI_SampleClock)) == V(20) &&
+ RVI(table, B(NI_10MHzRefClock), B(TRIGGER_LINE(0))) == V(12) &&
+ RVI(table, B(NI_AI_ConvertClock), B(NI_PFI(0))) == V(3) &&
+ RVI(table, B(NI_AI_ConvertClock), B(NI_PFI(2))) == V(3),
+ "pci-6220 finds m-series route_values table\n");
}
-void test_ni_sort_device_routes(void)
+static void test_ni_sort_device_routes(void)
{
/* We begin by sorting the device routes for use in later tests */
ni_sort_device_routes(&DR);
@@ -280,7 +278,7 @@ void test_ni_sort_device_routes(void)
"all route_set->src's of fake data in order of sig. source\n");
}
-void test_ni_find_route_set(void)
+static void test_ni_find_route_set(void)
{
unittest(!ni_find_route_set(bad_dest, &DR),
"check for nonexistent route_set\n");
@@ -296,7 +294,7 @@ void test_ni_find_route_set(void)
"find last route_set\n");
}
-void test_ni_route_set_has_source(void)
+static void test_ni_route_set_has_source(void)
{
unittest(!ni_route_set_has_source(&DR.routes[0], O(0)),
"check for bad source\n");
@@ -308,7 +306,7 @@ void test_ni_route_set_has_source(void)
"find last source\n");
}
-void test_ni_route_to_register(void)
+static void test_ni_route_to_register(void)
{
const struct ni_route_tables *T = &private.routing_tables;
@@ -358,7 +356,7 @@ void test_ni_route_to_register(void)
"validate indirect route through brd3 to TRIGGER_LINE(1)\n");
}
-void test_ni_lookup_route_register(void)
+static void test_ni_lookup_route_register(void)
{
const struct ni_route_tables *T = &private.routing_tables;
@@ -397,7 +395,7 @@ void test_ni_lookup_route_register(void)
"brd0_src1: lookup indirect route register\n");
}
-void test_route_is_valid(void)
+static void test_route_is_valid(void)
{
const struct ni_route_tables *T = &private.routing_tables;
@@ -412,7 +410,7 @@ void test_route_is_valid(void)
"validate last destination\n");
}
-void test_ni_is_cmd_dest(void)
+static void test_ni_is_cmd_dest(void)
{
init_pci_fake();
unittest(ni_is_cmd_dest(NI_AI_SampleClock),
@@ -429,7 +427,7 @@ void test_ni_is_cmd_dest(void)
"check that AO/SampleClockTimebase _not_ cmd destination\n");
}
-void test_channel_is_pfi(void)
+static void test_channel_is_pfi(void)
{
init_pci_fake();
unittest(channel_is_pfi(NI_PFI(0)), "check First pfi channel\n");
@@ -439,7 +437,7 @@ void test_channel_is_pfi(void)
"check first non pfi channel\n");
}
-void test_channel_is_rtsi(void)
+static void test_channel_is_rtsi(void)
{
init_pci_fake();
unittest(channel_is_rtsi(TRIGGER_LINE(0)),
@@ -452,7 +450,7 @@ void test_channel_is_rtsi(void)
"check first non rtsi channel\n");
}
-void test_ni_count_valid_routes(void)
+static void test_ni_count_valid_routes(void)
{
const struct ni_route_tables *T = &private.routing_tables;
@@ -460,7 +458,7 @@ void test_ni_count_valid_routes(void)
unittest(ni_count_valid_routes(T) == 57, "count all valid routes\n");
}
-void test_ni_get_valid_routes(void)
+static void test_ni_get_valid_routes(void)
{
const struct ni_route_tables *T = &private.routing_tables;
unsigned int pair_data[2];
@@ -477,7 +475,7 @@ void test_ni_get_valid_routes(void)
"destination of first valid pair from ni_get_valid_routes\n");
}
-void test_ni_find_route_source(void)
+static void test_ni_find_route_source(void)
{
const struct ni_route_tables *T = &private.routing_tables;
@@ -494,7 +492,7 @@ void test_ni_find_route_source(void)
"find invalid source (without checking device routes)\n");
}
-void test_route_register_is_valid(void)
+static void test_route_register_is_valid(void)
{
const struct ni_route_tables *T = &private.routing_tables;
@@ -509,7 +507,7 @@ void test_route_register_is_valid(void)
"find last source");
}
-void test_ni_check_trigger_arg(void)
+static void test_ni_check_trigger_arg(void)
{
const struct ni_route_tables *T = &private.routing_tables;
@@ -542,7 +540,7 @@ void test_ni_check_trigger_arg(void)
"check trigger arg for last src->dest\n");
}
-void test_ni_get_reg_value(void)
+static void test_ni_get_reg_value(void)
{
const struct ni_route_tables *T = &private.routing_tables;
@@ -578,23 +576,23 @@ void test_ni_get_reg_value(void)
/* **** BEGIN simple module entry/exit functions **** */
static int __init ni_routes_unittest(void)
{
- const unittest_fptr unit_tests[] = {
- (unittest_fptr)test_ni_assign_device_routes,
- (unittest_fptr)test_ni_sort_device_routes,
- (unittest_fptr)test_ni_find_route_set,
- (unittest_fptr)test_ni_route_set_has_source,
- (unittest_fptr)test_ni_route_to_register,
- (unittest_fptr)test_ni_lookup_route_register,
- (unittest_fptr)test_route_is_valid,
- (unittest_fptr)test_ni_is_cmd_dest,
- (unittest_fptr)test_channel_is_pfi,
- (unittest_fptr)test_channel_is_rtsi,
- (unittest_fptr)test_ni_count_valid_routes,
- (unittest_fptr)test_ni_get_valid_routes,
- (unittest_fptr)test_ni_find_route_source,
- (unittest_fptr)test_route_register_is_valid,
- (unittest_fptr)test_ni_check_trigger_arg,
- (unittest_fptr)test_ni_get_reg_value,
+ static const unittest_fptr unit_tests[] = {
+ test_ni_assign_device_routes,
+ test_ni_sort_device_routes,
+ test_ni_find_route_set,
+ test_ni_route_set_has_source,
+ test_ni_route_to_register,
+ test_ni_lookup_route_register,
+ test_route_is_valid,
+ test_ni_is_cmd_dest,
+ test_channel_is_pfi,
+ test_channel_is_rtsi,
+ test_ni_count_valid_routes,
+ test_ni_get_valid_routes,
+ test_ni_find_route_source,
+ test_route_register_is_valid,
+ test_ni_check_trigger_arg,
+ test_ni_get_reg_value,
NULL,
};
diff --git a/drivers/staging/comedi/drivers/tests/unittest.h b/drivers/comedi/drivers/tests/unittest.h
index b8e622ea1de1..2da3beea2479 100644
--- a/drivers/staging/comedi/drivers/tests/unittest.h
+++ b/drivers/comedi/drivers/tests/unittest.h
@@ -27,7 +27,7 @@ static struct unittest_results {
int failed;
} unittest_results;
-typedef void *(*unittest_fptr)(void);
+typedef void (*unittest_fptr)(void);
#define unittest(result, fmt, ...) ({ \
bool failed = !(result); \
diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/comedi/drivers/usbdux.c
index 0350f303d557..0350f303d557 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/comedi/drivers/usbdux.c
diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/comedi/drivers/usbduxfast.c
index 4af012968cb6..4af012968cb6 100644
--- a/drivers/staging/comedi/drivers/usbduxfast.c
+++ b/drivers/comedi/drivers/usbduxfast.c
diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/comedi/drivers/usbduxsigma.c
index 54d7605e909f..54d7605e909f 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/comedi/drivers/usbduxsigma.c
diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/comedi/drivers/vmk80xx.c
index 9f920819cd74..9f920819cd74 100644
--- a/drivers/staging/comedi/drivers/vmk80xx.c
+++ b/drivers/comedi/drivers/vmk80xx.c
diff --git a/drivers/staging/comedi/drivers/z8536.h b/drivers/comedi/drivers/z8536.h
index 3ef5f9e79b89..3ef5f9e79b89 100644
--- a/drivers/staging/comedi/drivers/z8536.h
+++ b/drivers/comedi/drivers/z8536.h
diff --git a/drivers/staging/comedi/kcomedilib/Makefile b/drivers/comedi/kcomedilib/Makefile
index 8031142a105f..8031142a105f 100644
--- a/drivers/staging/comedi/kcomedilib/Makefile
+++ b/drivers/comedi/kcomedilib/Makefile
diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/comedi/kcomedilib/kcomedilib_main.c
index df9bba1b69ed..df9bba1b69ed 100644
--- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c
+++ b/drivers/comedi/kcomedilib/kcomedilib_main.c
diff --git a/drivers/staging/comedi/proc.c b/drivers/comedi/proc.c
index 8bc8e42beb90..8bc8e42beb90 100644
--- a/drivers/staging/comedi/proc.c
+++ b/drivers/comedi/proc.c
diff --git a/drivers/staging/comedi/range.c b/drivers/comedi/range.c
index a4e6fe0fb729..a4e6fe0fb729 100644
--- a/drivers/staging/comedi/range.c
+++ b/drivers/comedi/range.c
diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c
index 78766b6ec271..9691f8612be8 100644
--- a/drivers/counter/104-quad-8.c
+++ b/drivers/counter/104-quad-8.c
@@ -9,8 +9,6 @@
#include <linux/counter.h>
#include <linux/device.h>
#include <linux/errno.h>
-#include <linux/iio/iio.h>
-#include <linux/iio/types.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/isa.h>
@@ -29,7 +27,7 @@ MODULE_PARM_DESC(base, "ACCES 104-QUAD-8 base addresses");
#define QUAD8_NUM_COUNTERS 8
/**
- * struct quad8_iio - IIO device private data structure
+ * struct quad8 - device private data structure
* @counter: instance of the counter_device
* @fck_prescaler: array of filter clock prescaler configurations
* @preset: array of preset values
@@ -41,9 +39,9 @@ MODULE_PARM_DESC(base, "ACCES 104-QUAD-8 base addresses");
* @synchronous_mode: array of index function synchronous mode configurations
* @index_polarity: array of index function polarity configurations
* @cable_fault_enable: differential encoder cable status enable configurations
- * @base: base port address of the IIO device
+ * @base: base port address of the device
*/
-struct quad8_iio {
+struct quad8 {
struct mutex lock;
struct counter_device counter;
unsigned int fck_prescaler[QUAD8_NUM_COUNTERS];
@@ -98,532 +96,10 @@ struct quad8_iio {
#define QUAD8_CMR_QUADRATURE_X2 0x10
#define QUAD8_CMR_QUADRATURE_X4 0x18
-
-static int quad8_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan, int *val, int *val2, long mask)
-{
- struct quad8_iio *const priv = iio_priv(indio_dev);
- const int base_offset = priv->base + 2 * chan->channel;
- unsigned int flags;
- unsigned int borrow;
- unsigned int carry;
- int i;
-
- switch (mask) {
- case IIO_CHAN_INFO_RAW:
- if (chan->type == IIO_INDEX) {
- *val = !!(inb(priv->base + QUAD8_REG_INDEX_INPUT_LEVELS)
- & BIT(chan->channel));
- return IIO_VAL_INT;
- }
-
- flags = inb(base_offset + 1);
- borrow = flags & QUAD8_FLAG_BT;
- carry = !!(flags & QUAD8_FLAG_CT);
-
- /* Borrow XOR Carry effectively doubles count range */
- *val = (borrow ^ carry) << 24;
-
- mutex_lock(&priv->lock);
-
- /* Reset Byte Pointer; transfer Counter to Output Latch */
- outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP | QUAD8_RLD_CNTR_OUT,
- base_offset + 1);
-
- for (i = 0; i < 3; i++)
- *val |= (unsigned int)inb(base_offset) << (8 * i);
-
- mutex_unlock(&priv->lock);
-
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_ENABLE:
- *val = priv->ab_enable[chan->channel];
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_SCALE:
- *val = 1;
- *val2 = priv->quadrature_scale[chan->channel];
- return IIO_VAL_FRACTIONAL_LOG2;
- }
-
- return -EINVAL;
-}
-
-static int quad8_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan, int val, int val2, long mask)
-{
- struct quad8_iio *const priv = iio_priv(indio_dev);
- const int base_offset = priv->base + 2 * chan->channel;
- int i;
- unsigned int ior_cfg;
-
- switch (mask) {
- case IIO_CHAN_INFO_RAW:
- if (chan->type == IIO_INDEX)
- return -EINVAL;
-
- /* Only 24-bit values are supported */
- if ((unsigned int)val > 0xFFFFFF)
- return -EINVAL;
-
- mutex_lock(&priv->lock);
-
- /* Reset Byte Pointer */
- outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1);
-
- /* Counter can only be set via Preset Register */
- for (i = 0; i < 3; i++)
- outb(val >> (8 * i), base_offset);
-
- /* Transfer Preset Register to Counter */
- outb(QUAD8_CTR_RLD | QUAD8_RLD_PRESET_CNTR, base_offset + 1);
-
- /* Reset Byte Pointer */
- outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1);
-
- /* Set Preset Register back to original value */
- val = priv->preset[chan->channel];
- for (i = 0; i < 3; i++)
- outb(val >> (8 * i), base_offset);
-
- /* Reset Borrow, Carry, Compare, and Sign flags */
- outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_FLAGS, base_offset + 1);
- /* Reset Error flag */
- outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_E, base_offset + 1);
-
- mutex_unlock(&priv->lock);
-
- return 0;
- case IIO_CHAN_INFO_ENABLE:
- /* only boolean values accepted */
- if (val < 0 || val > 1)
- return -EINVAL;
-
- mutex_lock(&priv->lock);
-
- priv->ab_enable[chan->channel] = val;
-
- ior_cfg = val | priv->preset_enable[chan->channel] << 1;
-
- /* Load I/O control configuration */
- outb(QUAD8_CTR_IOR | ior_cfg, base_offset + 1);
-
- mutex_unlock(&priv->lock);
-
- return 0;
- case IIO_CHAN_INFO_SCALE:
- mutex_lock(&priv->lock);
-
- /* Quadrature scaling only available in quadrature mode */
- if (!priv->quadrature_mode[chan->channel] &&
- (val2 || val != 1)) {
- mutex_unlock(&priv->lock);
- return -EINVAL;
- }
-
- /* Only three gain states (1, 0.5, 0.25) */
- if (val == 1 && !val2)
- priv->quadrature_scale[chan->channel] = 0;
- else if (!val)
- switch (val2) {
- case 500000:
- priv->quadrature_scale[chan->channel] = 1;
- break;
- case 250000:
- priv->quadrature_scale[chan->channel] = 2;
- break;
- default:
- mutex_unlock(&priv->lock);
- return -EINVAL;
- }
- else {
- mutex_unlock(&priv->lock);
- return -EINVAL;
- }
-
- mutex_unlock(&priv->lock);
- return 0;
- }
-
- return -EINVAL;
-}
-
-static const struct iio_info quad8_info = {
- .read_raw = quad8_read_raw,
- .write_raw = quad8_write_raw
-};
-
-static ssize_t quad8_read_preset(struct iio_dev *indio_dev, uintptr_t private,
- const struct iio_chan_spec *chan, char *buf)
-{
- const struct quad8_iio *const priv = iio_priv(indio_dev);
-
- return snprintf(buf, PAGE_SIZE, "%u\n", priv->preset[chan->channel]);
-}
-
-static ssize_t quad8_write_preset(struct iio_dev *indio_dev, uintptr_t private,
- const struct iio_chan_spec *chan, const char *buf, size_t len)
-{
- struct quad8_iio *const priv = iio_priv(indio_dev);
- const int base_offset = priv->base + 2 * chan->channel;
- unsigned int preset;
- int ret;
- int i;
-
- ret = kstrtouint(buf, 0, &preset);
- if (ret)
- return ret;
-
- /* Only 24-bit values are supported */
- if (preset > 0xFFFFFF)
- return -EINVAL;
-
- mutex_lock(&priv->lock);
-
- priv->preset[chan->channel] = preset;
-
- /* Reset Byte Pointer */
- outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1);
-
- /* Set Preset Register */
- for (i = 0; i < 3; i++)
- outb(preset >> (8 * i), base_offset);
-
- mutex_unlock(&priv->lock);
-
- return len;
-}
-
-static ssize_t quad8_read_set_to_preset_on_index(struct iio_dev *indio_dev,
- uintptr_t private, const struct iio_chan_spec *chan, char *buf)
-{
- const struct quad8_iio *const priv = iio_priv(indio_dev);
-
- return snprintf(buf, PAGE_SIZE, "%u\n",
- !priv->preset_enable[chan->channel]);
-}
-
-static ssize_t quad8_write_set_to_preset_on_index(struct iio_dev *indio_dev,
- uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
- size_t len)
-{
- struct quad8_iio *const priv = iio_priv(indio_dev);
- const int base_offset = priv->base + 2 * chan->channel + 1;
- bool preset_enable;
- int ret;
- unsigned int ior_cfg;
-
- ret = kstrtobool(buf, &preset_enable);
- if (ret)
- return ret;
-
- /* Preset enable is active low in Input/Output Control register */
- preset_enable = !preset_enable;
-
- mutex_lock(&priv->lock);
-
- priv->preset_enable[chan->channel] = preset_enable;
-
- ior_cfg = priv->ab_enable[chan->channel] |
- (unsigned int)preset_enable << 1;
-
- /* Load I/O control configuration to Input / Output Control Register */
- outb(QUAD8_CTR_IOR | ior_cfg, base_offset);
-
- mutex_unlock(&priv->lock);
-
- return len;
-}
-
-static const char *const quad8_noise_error_states[] = {
- "No excessive noise is present at the count inputs",
- "Excessive noise is present at the count inputs"
-};
-
-static int quad8_get_noise_error(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan)
-{
- struct quad8_iio *const priv = iio_priv(indio_dev);
- const int base_offset = priv->base + 2 * chan->channel + 1;
-
- return !!(inb(base_offset) & QUAD8_FLAG_E);
-}
-
-static const struct iio_enum quad8_noise_error_enum = {
- .items = quad8_noise_error_states,
- .num_items = ARRAY_SIZE(quad8_noise_error_states),
- .get = quad8_get_noise_error
-};
-
-static const char *const quad8_count_direction_states[] = {
- "down",
- "up"
-};
-
-static int quad8_get_count_direction(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan)
-{
- struct quad8_iio *const priv = iio_priv(indio_dev);
- const int base_offset = priv->base + 2 * chan->channel + 1;
-
- return !!(inb(base_offset) & QUAD8_FLAG_UD);
-}
-
-static const struct iio_enum quad8_count_direction_enum = {
- .items = quad8_count_direction_states,
- .num_items = ARRAY_SIZE(quad8_count_direction_states),
- .get = quad8_get_count_direction
-};
-
-static const char *const quad8_count_modes[] = {
- "normal",
- "range limit",
- "non-recycle",
- "modulo-n"
-};
-
-static int quad8_set_count_mode(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan, unsigned int cnt_mode)
-{
- struct quad8_iio *const priv = iio_priv(indio_dev);
- unsigned int mode_cfg = cnt_mode << 1;
- const int base_offset = priv->base + 2 * chan->channel + 1;
-
- mutex_lock(&priv->lock);
-
- priv->count_mode[chan->channel] = cnt_mode;
-
- /* Add quadrature mode configuration */
- if (priv->quadrature_mode[chan->channel])
- mode_cfg |= (priv->quadrature_scale[chan->channel] + 1) << 3;
-
- /* Load mode configuration to Counter Mode Register */
- outb(QUAD8_CTR_CMR | mode_cfg, base_offset);
-
- mutex_unlock(&priv->lock);
-
- return 0;
-}
-
-static int quad8_get_count_mode(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan)
-{
- const struct quad8_iio *const priv = iio_priv(indio_dev);
-
- return priv->count_mode[chan->channel];
-}
-
-static const struct iio_enum quad8_count_mode_enum = {
- .items = quad8_count_modes,
- .num_items = ARRAY_SIZE(quad8_count_modes),
- .set = quad8_set_count_mode,
- .get = quad8_get_count_mode
-};
-
-static const char *const quad8_synchronous_modes[] = {
- "non-synchronous",
- "synchronous"
-};
-
-static int quad8_set_synchronous_mode(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan, unsigned int synchronous_mode)
-{
- struct quad8_iio *const priv = iio_priv(indio_dev);
- const int base_offset = priv->base + 2 * chan->channel + 1;
- unsigned int idr_cfg = synchronous_mode;
-
- mutex_lock(&priv->lock);
-
- idr_cfg |= priv->index_polarity[chan->channel] << 1;
-
- /* Index function must be non-synchronous in non-quadrature mode */
- if (synchronous_mode && !priv->quadrature_mode[chan->channel]) {
- mutex_unlock(&priv->lock);
- return -EINVAL;
- }
-
- priv->synchronous_mode[chan->channel] = synchronous_mode;
-
- /* Load Index Control configuration to Index Control Register */
- outb(QUAD8_CTR_IDR | idr_cfg, base_offset);
-
- mutex_unlock(&priv->lock);
-
- return 0;
-}
-
-static int quad8_get_synchronous_mode(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan)
-{
- const struct quad8_iio *const priv = iio_priv(indio_dev);
-
- return priv->synchronous_mode[chan->channel];
-}
-
-static const struct iio_enum quad8_synchronous_mode_enum = {
- .items = quad8_synchronous_modes,
- .num_items = ARRAY_SIZE(quad8_synchronous_modes),
- .set = quad8_set_synchronous_mode,
- .get = quad8_get_synchronous_mode
-};
-
-static const char *const quad8_quadrature_modes[] = {
- "non-quadrature",
- "quadrature"
-};
-
-static int quad8_set_quadrature_mode(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan, unsigned int quadrature_mode)
-{
- struct quad8_iio *const priv = iio_priv(indio_dev);
- const int base_offset = priv->base + 2 * chan->channel + 1;
- unsigned int mode_cfg;
-
- mutex_lock(&priv->lock);
-
- mode_cfg = priv->count_mode[chan->channel] << 1;
-
- if (quadrature_mode)
- mode_cfg |= (priv->quadrature_scale[chan->channel] + 1) << 3;
- else {
- /* Quadrature scaling only available in quadrature mode */
- priv->quadrature_scale[chan->channel] = 0;
-
- /* Synchronous function not supported in non-quadrature mode */
- if (priv->synchronous_mode[chan->channel])
- quad8_set_synchronous_mode(indio_dev, chan, 0);
- }
-
- priv->quadrature_mode[chan->channel] = quadrature_mode;
-
- /* Load mode configuration to Counter Mode Register */
- outb(QUAD8_CTR_CMR | mode_cfg, base_offset);
-
- mutex_unlock(&priv->lock);
-
- return 0;
-}
-
-static int quad8_get_quadrature_mode(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan)
-{
- const struct quad8_iio *const priv = iio_priv(indio_dev);
-
- return priv->quadrature_mode[chan->channel];
-}
-
-static const struct iio_enum quad8_quadrature_mode_enum = {
- .items = quad8_quadrature_modes,
- .num_items = ARRAY_SIZE(quad8_quadrature_modes),
- .set = quad8_set_quadrature_mode,
- .get = quad8_get_quadrature_mode
-};
-
-static const char *const quad8_index_polarity_modes[] = {
- "negative",
- "positive"
-};
-
-static int quad8_set_index_polarity(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan, unsigned int index_polarity)
-{
- struct quad8_iio *const priv = iio_priv(indio_dev);
- const int base_offset = priv->base + 2 * chan->channel + 1;
- unsigned int idr_cfg = index_polarity << 1;
-
- mutex_lock(&priv->lock);
-
- idr_cfg |= priv->synchronous_mode[chan->channel];
-
- priv->index_polarity[chan->channel] = index_polarity;
-
- /* Load Index Control configuration to Index Control Register */
- outb(QUAD8_CTR_IDR | idr_cfg, base_offset);
-
- mutex_unlock(&priv->lock);
-
- return 0;
-}
-
-static int quad8_get_index_polarity(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan)
-{
- const struct quad8_iio *const priv = iio_priv(indio_dev);
-
- return priv->index_polarity[chan->channel];
-}
-
-static const struct iio_enum quad8_index_polarity_enum = {
- .items = quad8_index_polarity_modes,
- .num_items = ARRAY_SIZE(quad8_index_polarity_modes),
- .set = quad8_set_index_polarity,
- .get = quad8_get_index_polarity
-};
-
-static const struct iio_chan_spec_ext_info quad8_count_ext_info[] = {
- {
- .name = "preset",
- .shared = IIO_SEPARATE,
- .read = quad8_read_preset,
- .write = quad8_write_preset
- },
- {
- .name = "set_to_preset_on_index",
- .shared = IIO_SEPARATE,
- .read = quad8_read_set_to_preset_on_index,
- .write = quad8_write_set_to_preset_on_index
- },
- IIO_ENUM("noise_error", IIO_SEPARATE, &quad8_noise_error_enum),
- IIO_ENUM_AVAILABLE("noise_error", &quad8_noise_error_enum),
- IIO_ENUM("count_direction", IIO_SEPARATE, &quad8_count_direction_enum),
- IIO_ENUM_AVAILABLE("count_direction", &quad8_count_direction_enum),
- IIO_ENUM("count_mode", IIO_SEPARATE, &quad8_count_mode_enum),
- IIO_ENUM_AVAILABLE("count_mode", &quad8_count_mode_enum),
- IIO_ENUM("quadrature_mode", IIO_SEPARATE, &quad8_quadrature_mode_enum),
- IIO_ENUM_AVAILABLE("quadrature_mode", &quad8_quadrature_mode_enum),
- {}
-};
-
-static const struct iio_chan_spec_ext_info quad8_index_ext_info[] = {
- IIO_ENUM("synchronous_mode", IIO_SEPARATE,
- &quad8_synchronous_mode_enum),
- IIO_ENUM_AVAILABLE("synchronous_mode", &quad8_synchronous_mode_enum),
- IIO_ENUM("index_polarity", IIO_SEPARATE, &quad8_index_polarity_enum),
- IIO_ENUM_AVAILABLE("index_polarity", &quad8_index_polarity_enum),
- {}
-};
-
-#define QUAD8_COUNT_CHAN(_chan) { \
- .type = IIO_COUNT, \
- .channel = (_chan), \
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
- BIT(IIO_CHAN_INFO_ENABLE) | BIT(IIO_CHAN_INFO_SCALE), \
- .ext_info = quad8_count_ext_info, \
- .indexed = 1 \
-}
-
-#define QUAD8_INDEX_CHAN(_chan) { \
- .type = IIO_INDEX, \
- .channel = (_chan), \
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
- .ext_info = quad8_index_ext_info, \
- .indexed = 1 \
-}
-
-static const struct iio_chan_spec quad8_channels[] = {
- QUAD8_COUNT_CHAN(0), QUAD8_INDEX_CHAN(0),
- QUAD8_COUNT_CHAN(1), QUAD8_INDEX_CHAN(1),
- QUAD8_COUNT_CHAN(2), QUAD8_INDEX_CHAN(2),
- QUAD8_COUNT_CHAN(3), QUAD8_INDEX_CHAN(3),
- QUAD8_COUNT_CHAN(4), QUAD8_INDEX_CHAN(4),
- QUAD8_COUNT_CHAN(5), QUAD8_INDEX_CHAN(5),
- QUAD8_COUNT_CHAN(6), QUAD8_INDEX_CHAN(6),
- QUAD8_COUNT_CHAN(7), QUAD8_INDEX_CHAN(7)
-};
-
static int quad8_signal_read(struct counter_device *counter,
struct counter_signal *signal, enum counter_signal_value *val)
{
- const struct quad8_iio *const priv = counter->priv;
+ const struct quad8 *const priv = counter->priv;
unsigned int state;
/* Only Index signal levels can be read */
@@ -641,7 +117,7 @@ static int quad8_signal_read(struct counter_device *counter,
static int quad8_count_read(struct counter_device *counter,
struct counter_count *count, unsigned long *val)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
const int base_offset = priv->base + 2 * count->id;
unsigned int flags;
unsigned int borrow;
@@ -672,7 +148,7 @@ static int quad8_count_read(struct counter_device *counter,
static int quad8_count_write(struct counter_device *counter,
struct counter_count *count, unsigned long val)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
const int base_offset = priv->base + 2 * count->id;
int i;
@@ -727,7 +203,7 @@ static enum counter_count_function quad8_count_functions_list[] = {
static int quad8_function_get(struct counter_device *counter,
struct counter_count *count, size_t *function)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
const int id = count->id;
mutex_lock(&priv->lock);
@@ -755,7 +231,7 @@ static int quad8_function_get(struct counter_device *counter,
static int quad8_function_set(struct counter_device *counter,
struct counter_count *count, size_t function)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
const int id = count->id;
unsigned int *const quadrature_mode = priv->quadrature_mode + id;
unsigned int *const scale = priv->quadrature_scale + id;
@@ -811,7 +287,7 @@ static int quad8_function_set(struct counter_device *counter,
static void quad8_direction_get(struct counter_device *counter,
struct counter_count *count, enum counter_count_direction *direction)
{
- const struct quad8_iio *const priv = counter->priv;
+ const struct quad8 *const priv = counter->priv;
unsigned int ud_flag;
const unsigned int flag_addr = priv->base + 2 * count->id + 1;
@@ -845,7 +321,7 @@ static int quad8_action_get(struct counter_device *counter,
struct counter_count *count, struct counter_synapse *synapse,
size_t *action)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
int err;
size_t function = 0;
const size_t signal_a_id = count->synapses[0].signal->id;
@@ -905,10 +381,15 @@ static const struct counter_ops quad8_ops = {
.action_get = quad8_action_get
};
+static const char *const quad8_index_polarity_modes[] = {
+ "negative",
+ "positive"
+};
+
static int quad8_index_polarity_get(struct counter_device *counter,
struct counter_signal *signal, size_t *index_polarity)
{
- const struct quad8_iio *const priv = counter->priv;
+ const struct quad8 *const priv = counter->priv;
const size_t channel_id = signal->id - 16;
*index_polarity = priv->index_polarity[channel_id];
@@ -919,7 +400,7 @@ static int quad8_index_polarity_get(struct counter_device *counter,
static int quad8_index_polarity_set(struct counter_device *counter,
struct counter_signal *signal, size_t index_polarity)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
const size_t channel_id = signal->id - 16;
const int base_offset = priv->base + 2 * channel_id + 1;
unsigned int idr_cfg = index_polarity << 1;
@@ -945,10 +426,15 @@ static struct counter_signal_enum_ext quad8_index_pol_enum = {
.set = quad8_index_polarity_set
};
+static const char *const quad8_synchronous_modes[] = {
+ "non-synchronous",
+ "synchronous"
+};
+
static int quad8_synchronous_mode_get(struct counter_device *counter,
struct counter_signal *signal, size_t *synchronous_mode)
{
- const struct quad8_iio *const priv = counter->priv;
+ const struct quad8 *const priv = counter->priv;
const size_t channel_id = signal->id - 16;
*synchronous_mode = priv->synchronous_mode[channel_id];
@@ -959,7 +445,7 @@ static int quad8_synchronous_mode_get(struct counter_device *counter,
static int quad8_synchronous_mode_set(struct counter_device *counter,
struct counter_signal *signal, size_t synchronous_mode)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
const size_t channel_id = signal->id - 16;
const int base_offset = priv->base + 2 * channel_id + 1;
unsigned int idr_cfg = synchronous_mode;
@@ -1001,7 +487,7 @@ static ssize_t quad8_count_floor_read(struct counter_device *counter,
static int quad8_count_mode_get(struct counter_device *counter,
struct counter_count *count, size_t *cnt_mode)
{
- const struct quad8_iio *const priv = counter->priv;
+ const struct quad8 *const priv = counter->priv;
/* Map 104-QUAD-8 count mode to Generic Counter count mode */
switch (priv->count_mode[count->id]) {
@@ -1025,7 +511,7 @@ static int quad8_count_mode_get(struct counter_device *counter,
static int quad8_count_mode_set(struct counter_device *counter,
struct counter_count *count, size_t cnt_mode)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
unsigned int mode_cfg;
const int base_offset = priv->base + 2 * count->id + 1;
@@ -1084,7 +570,7 @@ static ssize_t quad8_count_direction_read(struct counter_device *counter,
static ssize_t quad8_count_enable_read(struct counter_device *counter,
struct counter_count *count, void *private, char *buf)
{
- const struct quad8_iio *const priv = counter->priv;
+ const struct quad8 *const priv = counter->priv;
return sprintf(buf, "%u\n", priv->ab_enable[count->id]);
}
@@ -1092,7 +578,7 @@ static ssize_t quad8_count_enable_read(struct counter_device *counter,
static ssize_t quad8_count_enable_write(struct counter_device *counter,
struct counter_count *count, void *private, const char *buf, size_t len)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
const int base_offset = priv->base + 2 * count->id;
int err;
bool ab_enable;
@@ -1116,10 +602,15 @@ static ssize_t quad8_count_enable_write(struct counter_device *counter,
return len;
}
+static const char *const quad8_noise_error_states[] = {
+ "No excessive noise is present at the count inputs",
+ "Excessive noise is present at the count inputs"
+};
+
static int quad8_error_noise_get(struct counter_device *counter,
struct counter_count *count, size_t *noise_error)
{
- const struct quad8_iio *const priv = counter->priv;
+ const struct quad8 *const priv = counter->priv;
const int base_offset = priv->base + 2 * count->id + 1;
*noise_error = !!(inb(base_offset) & QUAD8_FLAG_E);
@@ -1136,18 +627,18 @@ static struct counter_count_enum_ext quad8_error_noise_enum = {
static ssize_t quad8_count_preset_read(struct counter_device *counter,
struct counter_count *count, void *private, char *buf)
{
- const struct quad8_iio *const priv = counter->priv;
+ const struct quad8 *const priv = counter->priv;
return sprintf(buf, "%u\n", priv->preset[count->id]);
}
-static void quad8_preset_register_set(struct quad8_iio *quad8iio, int id,
- unsigned int preset)
+static void quad8_preset_register_set(struct quad8 *priv, int id,
+ unsigned int preset)
{
- const unsigned int base_offset = quad8iio->base + 2 * id;
+ const unsigned int base_offset = priv->base + 2 * id;
int i;
- quad8iio->preset[id] = preset;
+ priv->preset[id] = preset;
/* Reset Byte Pointer */
outb(QUAD8_CTR_RLD | QUAD8_RLD_RESET_BP, base_offset + 1);
@@ -1160,7 +651,7 @@ static void quad8_preset_register_set(struct quad8_iio *quad8iio, int id,
static ssize_t quad8_count_preset_write(struct counter_device *counter,
struct counter_count *count, void *private, const char *buf, size_t len)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
unsigned int preset;
int ret;
@@ -1184,7 +675,7 @@ static ssize_t quad8_count_preset_write(struct counter_device *counter,
static ssize_t quad8_count_ceiling_read(struct counter_device *counter,
struct counter_count *count, void *private, char *buf)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
mutex_lock(&priv->lock);
@@ -1205,7 +696,7 @@ static ssize_t quad8_count_ceiling_read(struct counter_device *counter,
static ssize_t quad8_count_ceiling_write(struct counter_device *counter,
struct counter_count *count, void *private, const char *buf, size_t len)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
unsigned int ceiling;
int ret;
@@ -1235,7 +726,7 @@ static ssize_t quad8_count_ceiling_write(struct counter_device *counter,
static ssize_t quad8_count_preset_enable_read(struct counter_device *counter,
struct counter_count *count, void *private, char *buf)
{
- const struct quad8_iio *const priv = counter->priv;
+ const struct quad8 *const priv = counter->priv;
return sprintf(buf, "%u\n", !priv->preset_enable[count->id]);
}
@@ -1243,7 +734,7 @@ static ssize_t quad8_count_preset_enable_read(struct counter_device *counter,
static ssize_t quad8_count_preset_enable_write(struct counter_device *counter,
struct counter_count *count, void *private, const char *buf, size_t len)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
const int base_offset = priv->base + 2 * count->id + 1;
bool preset_enable;
int ret;
@@ -1274,7 +765,7 @@ static ssize_t quad8_signal_cable_fault_read(struct counter_device *counter,
struct counter_signal *signal,
void *private, char *buf)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
const size_t channel_id = signal->id / 2;
bool disabled;
unsigned int status;
@@ -1304,7 +795,7 @@ static ssize_t quad8_signal_cable_fault_enable_read(
struct counter_device *counter, struct counter_signal *signal,
void *private, char *buf)
{
- const struct quad8_iio *const priv = counter->priv;
+ const struct quad8 *const priv = counter->priv;
const size_t channel_id = signal->id / 2;
const unsigned int enb = !!(priv->cable_fault_enable & BIT(channel_id));
@@ -1315,7 +806,7 @@ static ssize_t quad8_signal_cable_fault_enable_write(
struct counter_device *counter, struct counter_signal *signal,
void *private, const char *buf, size_t len)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
const size_t channel_id = signal->id / 2;
bool enable;
int ret;
@@ -1345,7 +836,7 @@ static ssize_t quad8_signal_cable_fault_enable_write(
static ssize_t quad8_signal_fck_prescaler_read(struct counter_device *counter,
struct counter_signal *signal, void *private, char *buf)
{
- const struct quad8_iio *const priv = counter->priv;
+ const struct quad8 *const priv = counter->priv;
const size_t channel_id = signal->id / 2;
return sprintf(buf, "%u\n", priv->fck_prescaler[channel_id]);
@@ -1355,7 +846,7 @@ static ssize_t quad8_signal_fck_prescaler_write(struct counter_device *counter,
struct counter_signal *signal, void *private, const char *buf,
size_t len)
{
- struct quad8_iio *const priv = counter->priv;
+ struct quad8 *const priv = counter->priv;
const size_t channel_id = signal->id / 2;
const int base_offset = priv->base + 2 * channel_id;
u8 prescaler;
@@ -1531,11 +1022,9 @@ static struct counter_count quad8_counts[] = {
static int quad8_probe(struct device *dev, unsigned int id)
{
- struct iio_dev *indio_dev;
- struct quad8_iio *quad8iio;
+ struct quad8 *priv;
int i, j;
unsigned int base_offset;
- int err;
if (!devm_request_region(dev, base[id], QUAD8_EXTENT, dev_name(dev))) {
dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
@@ -1543,32 +1032,23 @@ static int quad8_probe(struct device *dev, unsigned int id)
return -EBUSY;
}
- /* Allocate IIO device; this also allocates driver data structure */
- indio_dev = devm_iio_device_alloc(dev, sizeof(*quad8iio));
- if (!indio_dev)
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
return -ENOMEM;
- /* Initialize IIO device */
- indio_dev->info = &quad8_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->num_channels = ARRAY_SIZE(quad8_channels);
- indio_dev->channels = quad8_channels;
- indio_dev->name = dev_name(dev);
-
/* Initialize Counter device and driver data */
- quad8iio = iio_priv(indio_dev);
- quad8iio->counter.name = dev_name(dev);
- quad8iio->counter.parent = dev;
- quad8iio->counter.ops = &quad8_ops;
- quad8iio->counter.counts = quad8_counts;
- quad8iio->counter.num_counts = ARRAY_SIZE(quad8_counts);
- quad8iio->counter.signals = quad8_signals;
- quad8iio->counter.num_signals = ARRAY_SIZE(quad8_signals);
- quad8iio->counter.priv = quad8iio;
- quad8iio->base = base[id];
+ priv->counter.name = dev_name(dev);
+ priv->counter.parent = dev;
+ priv->counter.ops = &quad8_ops;
+ priv->counter.counts = quad8_counts;
+ priv->counter.num_counts = ARRAY_SIZE(quad8_counts);
+ priv->counter.signals = quad8_signals;
+ priv->counter.num_signals = ARRAY_SIZE(quad8_signals);
+ priv->counter.priv = priv;
+ priv->base = base[id];
/* Initialize mutex */
- mutex_init(&quad8iio->lock);
+ mutex_init(&priv->lock);
/* Reset all counters and disable interrupt function */
outb(QUAD8_CHAN_OP_RESET_COUNTERS, base[id] + QUAD8_REG_CHAN_OP);
@@ -1602,13 +1082,8 @@ static int quad8_probe(struct device *dev, unsigned int id)
/* Enable all counters */
outb(QUAD8_CHAN_OP_ENABLE_COUNTERS, base[id] + QUAD8_REG_CHAN_OP);
- /* Register IIO device */
- err = devm_iio_device_register(dev, indio_dev);
- if (err)
- return err;
-
/* Register Counter device */
- return devm_counter_register(dev, &quad8iio->counter);
+ return devm_counter_register(dev, &priv->counter);
}
static struct isa_driver quad8_driver = {
@@ -1621,5 +1096,5 @@ static struct isa_driver quad8_driver = {
module_isa_driver(quad8_driver, num_quad8);
MODULE_AUTHOR("William Breathitt Gray <vilhelm.gray@gmail.com>");
-MODULE_DESCRIPTION("ACCES 104-QUAD-8 IIO driver");
+MODULE_DESCRIPTION("ACCES 104-QUAD-8 driver");
MODULE_LICENSE("GPL v2");
diff --git a/drivers/counter/Kconfig b/drivers/counter/Kconfig
index 2de53ab0dd25..5328705aa09c 100644
--- a/drivers/counter/Kconfig
+++ b/drivers/counter/Kconfig
@@ -14,7 +14,7 @@ if COUNTER
config 104_QUAD_8
tristate "ACCES 104-QUAD-8 driver"
- depends on PC104 && X86 && IIO
+ depends on PC104 && X86
select ISA_BUS_API
help
Say yes here to build support for the ACCES 104-QUAD-8 quadrature
@@ -29,6 +29,16 @@ config 104_QUAD_8
The base port addresses for the devices may be configured via the base
array module parameter.
+config INTERRUPT_CNT
+ tristate "Interrupt counter driver"
+ depends on GPIOLIB
+ help
+ Select this option to enable interrupt counter driver. Any interrupt
+ source can be used by this driver as the event source.
+
+ To compile this driver as a module, choose M here: the
+ module will be called interrupt-cnt.
+
config STM32_TIMER_CNT
tristate "STM32 Timer encoder counter driver"
depends on MFD_STM32_TIMERS || COMPILE_TEST
@@ -41,7 +51,7 @@ config STM32_TIMER_CNT
config STM32_LPTIMER_CNT
tristate "STM32 LP Timer encoder counter driver"
- depends on (MFD_STM32_LPTIMER || COMPILE_TEST) && IIO
+ depends on MFD_STM32_LPTIMER || COMPILE_TEST
help
Select this option to enable STM32 Low-Power Timer quadrature encoder
and counter driver.
diff --git a/drivers/counter/Makefile b/drivers/counter/Makefile
index 0a393f71e481..cb646ed2f039 100644
--- a/drivers/counter/Makefile
+++ b/drivers/counter/Makefile
@@ -6,6 +6,7 @@
obj-$(CONFIG_COUNTER) += counter.o
obj-$(CONFIG_104_QUAD_8) += 104-quad-8.o
+obj-$(CONFIG_INTERRUPT_CNT) += interrupt-cnt.o
obj-$(CONFIG_STM32_TIMER_CNT) += stm32-timer-cnt.o
obj-$(CONFIG_STM32_LPTIMER_CNT) += stm32-lptimer-cnt.o
obj-$(CONFIG_TI_EQEP) += ti-eqep.o
diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c
new file mode 100644
index 000000000000..a99ee7996977
--- /dev/null
+++ b/drivers/counter/interrupt-cnt.c
@@ -0,0 +1,244 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 Pengutronix, Oleksij Rempel <kernel@pengutronix.de>
+ */
+
+#include <linux/counter.h>
+#include <linux/gpio/consumer.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+#define INTERRUPT_CNT_NAME "interrupt-cnt"
+
+struct interrupt_cnt_priv {
+ atomic_t count;
+ struct counter_device counter;
+ struct gpio_desc *gpio;
+ int irq;
+ bool enabled;
+ struct counter_signal signals;
+ struct counter_synapse synapses;
+ struct counter_count cnts;
+};
+
+static irqreturn_t interrupt_cnt_isr(int irq, void *dev_id)
+{
+ struct interrupt_cnt_priv *priv = dev_id;
+
+ atomic_inc(&priv->count);
+
+ return IRQ_HANDLED;
+}
+
+static ssize_t interrupt_cnt_enable_read(struct counter_device *counter,
+ struct counter_count *count,
+ void *private, char *buf)
+{
+ struct interrupt_cnt_priv *priv = counter->priv;
+
+ return sysfs_emit(buf, "%d\n", priv->enabled);
+}
+
+static ssize_t interrupt_cnt_enable_write(struct counter_device *counter,
+ struct counter_count *count,
+ void *private, const char *buf,
+ size_t len)
+{
+ struct interrupt_cnt_priv *priv = counter->priv;
+ bool enable;
+ ssize_t ret;
+
+ ret = kstrtobool(buf, &enable);
+ if (ret)
+ return ret;
+
+ if (priv->enabled == enable)
+ return len;
+
+ if (enable) {
+ priv->enabled = true;
+ enable_irq(priv->irq);
+ } else {
+ disable_irq(priv->irq);
+ priv->enabled = false;
+ }
+
+ return len;
+}
+
+static const struct counter_count_ext interrupt_cnt_ext[] = {
+ {
+ .name = "enable",
+ .read = interrupt_cnt_enable_read,
+ .write = interrupt_cnt_enable_write,
+ },
+};
+
+static enum counter_synapse_action interrupt_cnt_synapse_actionss[] = {
+ COUNTER_SYNAPSE_ACTION_RISING_EDGE,
+};
+
+static int interrupt_cnt_action_get(struct counter_device *counter,
+ struct counter_count *count,
+ struct counter_synapse *synapse,
+ size_t *action)
+{
+ *action = 0;
+
+ return 0;
+}
+
+static int interrupt_cnt_read(struct counter_device *counter,
+ struct counter_count *count, unsigned long *val)
+{
+ struct interrupt_cnt_priv *priv = counter->priv;
+
+ *val = atomic_read(&priv->count);
+
+ return 0;
+}
+
+static int interrupt_cnt_write(struct counter_device *counter,
+ struct counter_count *count,
+ const unsigned long val)
+{
+ struct interrupt_cnt_priv *priv = counter->priv;
+
+ atomic_set(&priv->count, val);
+
+ return 0;
+}
+
+static enum counter_count_function interrupt_cnt_functions[] = {
+ COUNTER_COUNT_FUNCTION_INCREASE,
+};
+
+static int interrupt_cnt_function_get(struct counter_device *counter,
+ struct counter_count *count,
+ size_t *function)
+{
+ *function = 0;
+
+ return 0;
+}
+
+static int interrupt_cnt_signal_read(struct counter_device *counter,
+ struct counter_signal *signal,
+ enum counter_signal_value *val)
+{
+ struct interrupt_cnt_priv *priv = counter->priv;
+ int ret;
+
+ if (!priv->gpio)
+ return -EINVAL;
+
+ ret = gpiod_get_value(priv->gpio);
+ if (ret < 0)
+ return ret;
+
+ *val = ret ? COUNTER_SIGNAL_HIGH : COUNTER_SIGNAL_LOW;
+
+ return 0;
+}
+
+static const struct counter_ops interrupt_cnt_ops = {
+ .action_get = interrupt_cnt_action_get,
+ .count_read = interrupt_cnt_read,
+ .count_write = interrupt_cnt_write,
+ .function_get = interrupt_cnt_function_get,
+ .signal_read = interrupt_cnt_signal_read,
+};
+
+static int interrupt_cnt_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct interrupt_cnt_priv *priv;
+ int ret;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->irq = platform_get_irq_optional(pdev, 0);
+ if (priv->irq == -ENXIO)
+ priv->irq = 0;
+ else if (priv->irq < 0)
+ return dev_err_probe(dev, priv->irq, "failed to get IRQ\n");
+
+ priv->gpio = devm_gpiod_get_optional(dev, NULL, GPIOD_IN);
+ if (IS_ERR(priv->gpio))
+ return dev_err_probe(dev, PTR_ERR(priv->gpio), "failed to get GPIO\n");
+
+ if (!priv->irq && !priv->gpio) {
+ dev_err(dev, "IRQ and GPIO are not found. At least one source should be provided\n");
+ return -ENODEV;
+ }
+
+ if (!priv->irq) {
+ int irq = gpiod_to_irq(priv->gpio);
+
+ if (irq < 0)
+ return dev_err_probe(dev, irq, "failed to get IRQ from GPIO\n");
+
+ priv->irq = irq;
+ }
+
+ priv->signals.name = devm_kasprintf(dev, GFP_KERNEL, "IRQ %d",
+ priv->irq);
+ if (!priv->signals.name)
+ return -ENOMEM;
+
+ priv->counter.signals = &priv->signals;
+ priv->counter.num_signals = 1;
+
+ priv->synapses.actions_list = interrupt_cnt_synapse_actionss;
+ priv->synapses.num_actions = ARRAY_SIZE(interrupt_cnt_synapse_actionss);
+ priv->synapses.signal = &priv->signals;
+
+ priv->cnts.name = "Channel 0 Count";
+ priv->cnts.functions_list = interrupt_cnt_functions;
+ priv->cnts.num_functions = ARRAY_SIZE(interrupt_cnt_functions);
+ priv->cnts.synapses = &priv->synapses;
+ priv->cnts.num_synapses = 1;
+ priv->cnts.ext = interrupt_cnt_ext;
+ priv->cnts.num_ext = ARRAY_SIZE(interrupt_cnt_ext);
+
+ priv->counter.priv = priv;
+ priv->counter.name = dev_name(dev);
+ priv->counter.parent = dev;
+ priv->counter.ops = &interrupt_cnt_ops;
+ priv->counter.counts = &priv->cnts;
+ priv->counter.num_counts = 1;
+
+ irq_set_status_flags(priv->irq, IRQ_NOAUTOEN);
+ ret = devm_request_irq(dev, priv->irq, interrupt_cnt_isr,
+ IRQF_TRIGGER_RISING | IRQF_NO_THREAD,
+ dev_name(dev), priv);
+ if (ret)
+ return ret;
+
+ return devm_counter_register(dev, &priv->counter);
+}
+
+static const struct of_device_id interrupt_cnt_of_match[] = {
+ { .compatible = "interrupt-counter", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, interrupt_cnt_of_match);
+
+static struct platform_driver interrupt_cnt_driver = {
+ .probe = interrupt_cnt_probe,
+ .driver = {
+ .name = INTERRUPT_CNT_NAME,
+ .of_match_table = interrupt_cnt_of_match,
+ },
+};
+module_platform_driver(interrupt_cnt_driver);
+
+MODULE_ALIAS("platform:interrupt-counter");
+MODULE_AUTHOR("Oleksij Rempel <o.rempel@pengutronix.de>");
+MODULE_DESCRIPTION("Interrupt counter driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c
index fd6828e2d34f..937439635d53 100644
--- a/drivers/counter/stm32-lptimer-cnt.c
+++ b/drivers/counter/stm32-lptimer-cnt.c
@@ -12,8 +12,8 @@
#include <linux/bitfield.h>
#include <linux/counter.h>
-#include <linux/iio/iio.h>
#include <linux/mfd/stm32-lptimer.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
@@ -107,249 +107,27 @@ static int stm32_lptim_setup(struct stm32_lptim_cnt *priv, int enable)
return regmap_update_bits(priv->regmap, STM32_LPTIM_CFGR, mask, val);
}
-static int stm32_lptim_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val, int val2, long mask)
-{
- struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
- int ret;
-
- switch (mask) {
- case IIO_CHAN_INFO_ENABLE:
- if (val < 0 || val > 1)
- return -EINVAL;
-
- /* Check nobody uses the timer, or already disabled/enabled */
- ret = stm32_lptim_is_enabled(priv);
- if ((ret < 0) || (!ret && !val))
- return ret;
- if (val && ret)
- return -EBUSY;
-
- ret = stm32_lptim_setup(priv, val);
- if (ret)
- return ret;
- return stm32_lptim_set_enable_state(priv, val);
-
- default:
- return -EINVAL;
- }
-}
-
-static int stm32_lptim_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val, int *val2, long mask)
-{
- struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
- u32 dat;
- int ret;
-
- switch (mask) {
- case IIO_CHAN_INFO_RAW:
- ret = regmap_read(priv->regmap, STM32_LPTIM_CNT, &dat);
- if (ret)
- return ret;
- *val = dat;
- return IIO_VAL_INT;
-
- case IIO_CHAN_INFO_ENABLE:
- ret = stm32_lptim_is_enabled(priv);
- if (ret < 0)
- return ret;
- *val = ret;
- return IIO_VAL_INT;
-
- case IIO_CHAN_INFO_SCALE:
- /* Non-quadrature mode: scale = 1 */
- *val = 1;
- *val2 = 0;
- if (priv->quadrature_mode) {
- /*
- * Quadrature encoder mode:
- * - both edges, quarter cycle, scale is 0.25
- * - either rising/falling edge scale is 0.5
- */
- if (priv->polarity > 1)
- *val2 = 2;
- else
- *val2 = 1;
- }
- return IIO_VAL_FRACTIONAL_LOG2;
-
- default:
- return -EINVAL;
- }
-}
-
-static const struct iio_info stm32_lptim_cnt_iio_info = {
- .read_raw = stm32_lptim_read_raw,
- .write_raw = stm32_lptim_write_raw,
-};
-
-static const char *const stm32_lptim_quadrature_modes[] = {
- "non-quadrature",
- "quadrature",
-};
-
-static int stm32_lptim_get_quadrature_mode(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan)
-{
- struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
-
- return priv->quadrature_mode;
-}
-
-static int stm32_lptim_set_quadrature_mode(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan,
- unsigned int type)
-{
- struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
-
- if (stm32_lptim_is_enabled(priv))
- return -EBUSY;
-
- priv->quadrature_mode = type;
-
- return 0;
-}
-
-static const struct iio_enum stm32_lptim_quadrature_mode_en = {
- .items = stm32_lptim_quadrature_modes,
- .num_items = ARRAY_SIZE(stm32_lptim_quadrature_modes),
- .get = stm32_lptim_get_quadrature_mode,
- .set = stm32_lptim_set_quadrature_mode,
-};
-
-static const char * const stm32_lptim_cnt_polarity[] = {
- "rising-edge", "falling-edge", "both-edges",
-};
-
-static int stm32_lptim_cnt_get_polarity(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan)
-{
- struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
-
- return priv->polarity;
-}
-
-static int stm32_lptim_cnt_set_polarity(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan,
- unsigned int type)
-{
- struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
-
- if (stm32_lptim_is_enabled(priv))
- return -EBUSY;
-
- priv->polarity = type;
-
- return 0;
-}
-
-static const struct iio_enum stm32_lptim_cnt_polarity_en = {
- .items = stm32_lptim_cnt_polarity,
- .num_items = ARRAY_SIZE(stm32_lptim_cnt_polarity),
- .get = stm32_lptim_cnt_get_polarity,
- .set = stm32_lptim_cnt_set_polarity,
-};
-
-static ssize_t stm32_lptim_cnt_get_ceiling(struct stm32_lptim_cnt *priv,
- char *buf)
-{
- return snprintf(buf, PAGE_SIZE, "%u\n", priv->ceiling);
-}
-
-static ssize_t stm32_lptim_cnt_set_ceiling(struct stm32_lptim_cnt *priv,
- const char *buf, size_t len)
-{
- int ret;
-
- if (stm32_lptim_is_enabled(priv))
- return -EBUSY;
-
- ret = kstrtouint(buf, 0, &priv->ceiling);
- if (ret)
- return ret;
-
- if (priv->ceiling > STM32_LPTIM_MAX_ARR)
- return -EINVAL;
-
- return len;
-}
-
-static ssize_t stm32_lptim_cnt_get_preset_iio(struct iio_dev *indio_dev,
- uintptr_t private,
- const struct iio_chan_spec *chan,
- char *buf)
-{
- struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
-
- return stm32_lptim_cnt_get_ceiling(priv, buf);
-}
-
-static ssize_t stm32_lptim_cnt_set_preset_iio(struct iio_dev *indio_dev,
- uintptr_t private,
- const struct iio_chan_spec *chan,
- const char *buf, size_t len)
-{
- struct stm32_lptim_cnt *priv = iio_priv(indio_dev);
-
- return stm32_lptim_cnt_set_ceiling(priv, buf, len);
-}
-
-/* LP timer with encoder */
-static const struct iio_chan_spec_ext_info stm32_lptim_enc_ext_info[] = {
- {
- .name = "preset",
- .shared = IIO_SEPARATE,
- .read = stm32_lptim_cnt_get_preset_iio,
- .write = stm32_lptim_cnt_set_preset_iio,
- },
- IIO_ENUM("polarity", IIO_SEPARATE, &stm32_lptim_cnt_polarity_en),
- IIO_ENUM_AVAILABLE("polarity", &stm32_lptim_cnt_polarity_en),
- IIO_ENUM("quadrature_mode", IIO_SEPARATE,
- &stm32_lptim_quadrature_mode_en),
- IIO_ENUM_AVAILABLE("quadrature_mode", &stm32_lptim_quadrature_mode_en),
- {}
-};
-
-static const struct iio_chan_spec stm32_lptim_enc_channels = {
- .type = IIO_COUNT,
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
- BIT(IIO_CHAN_INFO_ENABLE) |
- BIT(IIO_CHAN_INFO_SCALE),
- .ext_info = stm32_lptim_enc_ext_info,
- .indexed = 1,
-};
-
-/* LP timer without encoder (counter only) */
-static const struct iio_chan_spec_ext_info stm32_lptim_cnt_ext_info[] = {
- {
- .name = "preset",
- .shared = IIO_SEPARATE,
- .read = stm32_lptim_cnt_get_preset_iio,
- .write = stm32_lptim_cnt_set_preset_iio,
- },
- IIO_ENUM("polarity", IIO_SEPARATE, &stm32_lptim_cnt_polarity_en),
- IIO_ENUM_AVAILABLE("polarity", &stm32_lptim_cnt_polarity_en),
- {}
-};
-
-static const struct iio_chan_spec stm32_lptim_cnt_channels = {
- .type = IIO_COUNT,
- .channel = 0,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
- BIT(IIO_CHAN_INFO_ENABLE) |
- BIT(IIO_CHAN_INFO_SCALE),
- .ext_info = stm32_lptim_cnt_ext_info,
- .indexed = 1,
-};
-
/**
* enum stm32_lptim_cnt_function - enumerates LPTimer counter & encoder modes
* @STM32_LPTIM_COUNTER_INCREASE: up count on IN1 rising, falling or both edges
* @STM32_LPTIM_ENCODER_BOTH_EDGE: count on both edges (IN1 & IN2 quadrature)
+ *
+ * In non-quadrature mode, device counts up on active edge.
+ * In quadrature mode, encoder counting scenarios are as follows:
+ * +---------+----------+--------------------+--------------------+
+ * | Active | Level on | IN1 signal | IN2 signal |
+ * | edge | opposite +----------+---------+----------+---------+
+ * | | signal | Rising | Falling | Rising | Falling |
+ * +---------+----------+----------+---------+----------+---------+
+ * | Rising | High -> | Down | - | Up | - |
+ * | edge | Low -> | Up | - | Down | - |
+ * +---------+----------+----------+---------+----------+---------+
+ * | Falling | High -> | - | Up | - | Down |
+ * | edge | Low -> | - | Down | - | Up |
+ * +---------+----------+----------+---------+----------+---------+
+ * | Both | High -> | Down | Up | Up | Down |
+ * | edges | Low -> | Up | Down | Down | Up |
+ * +---------+----------+----------+---------+----------+---------+
*/
enum stm32_lptim_cnt_function {
STM32_LPTIM_COUNTER_INCREASE,
@@ -484,7 +262,7 @@ static ssize_t stm32_lptim_cnt_ceiling_read(struct counter_device *counter,
{
struct stm32_lptim_cnt *const priv = counter->priv;
- return stm32_lptim_cnt_get_ceiling(priv, buf);
+ return snprintf(buf, PAGE_SIZE, "%u\n", priv->ceiling);
}
static ssize_t stm32_lptim_cnt_ceiling_write(struct counter_device *counter,
@@ -493,8 +271,22 @@ static ssize_t stm32_lptim_cnt_ceiling_write(struct counter_device *counter,
const char *buf, size_t len)
{
struct stm32_lptim_cnt *const priv = counter->priv;
+ unsigned int ceiling;
+ int ret;
+
+ if (stm32_lptim_is_enabled(priv))
+ return -EBUSY;
+
+ ret = kstrtouint(buf, 0, &ceiling);
+ if (ret)
+ return ret;
+
+ if (ceiling > STM32_LPTIM_MAX_ARR)
+ return -EINVAL;
+
+ priv->ceiling = ceiling;
- return stm32_lptim_cnt_set_ceiling(priv, buf, len);
+ return len;
}
static const struct counter_count_ext stm32_lptim_cnt_ext[] = {
@@ -630,32 +422,19 @@ static int stm32_lptim_cnt_probe(struct platform_device *pdev)
{
struct stm32_lptimer *ddata = dev_get_drvdata(pdev->dev.parent);
struct stm32_lptim_cnt *priv;
- struct iio_dev *indio_dev;
- int ret;
if (IS_ERR_OR_NULL(ddata))
return -EINVAL;
- indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*priv));
- if (!indio_dev)
+ priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
return -ENOMEM;
- priv = iio_priv(indio_dev);
priv->dev = &pdev->dev;
priv->regmap = ddata->regmap;
priv->clk = ddata->clk;
priv->ceiling = STM32_LPTIM_MAX_ARR;
- /* Initialize IIO device */
- indio_dev->name = dev_name(&pdev->dev);
- indio_dev->dev.of_node = pdev->dev.of_node;
- indio_dev->info = &stm32_lptim_cnt_iio_info;
- if (ddata->has_encoder)
- indio_dev->channels = &stm32_lptim_enc_channels;
- else
- indio_dev->channels = &stm32_lptim_cnt_channels;
- indio_dev->num_channels = 1;
-
/* Initialize Counter device */
priv->counter.name = dev_name(&pdev->dev);
priv->counter.parent = &pdev->dev;
@@ -673,10 +452,6 @@ static int stm32_lptim_cnt_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv);
- ret = devm_iio_device_register(&pdev->dev, indio_dev);
- if (ret)
- return ret;
-
return devm_counter_register(&pdev->dev, &priv->counter);
}
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index cacdf1589b10..3e748e57deab 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -741,7 +741,7 @@ static struct scmi_prot_devnames devnames[] = {
{ SCMI_PROTOCOL_SYSTEM, { "syspower" },},
{ SCMI_PROTOCOL_PERF, { "cpufreq" },},
{ SCMI_PROTOCOL_CLOCK, { "clocks" },},
- { SCMI_PROTOCOL_SENSOR, { "hwmon" },},
+ { SCMI_PROTOCOL_SENSOR, { "hwmon", "iiodev" },},
{ SCMI_PROTOCOL_RESET, { "reset" },},
{ SCMI_PROTOCOL_VOLTAGE, { "regulator" },},
};
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
index 3aad62a0e661..8587189c7f15 100644
--- a/drivers/hwmon/ntc_thermistor.c
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -326,18 +326,27 @@ struct ntc_data {
static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata)
{
struct iio_channel *channel = pdata->chan;
- int raw, uv, ret;
+ int uv, ret;
- ret = iio_read_channel_raw(channel, &raw);
+ ret = iio_read_channel_processed_scale(channel, &uv, 1000);
if (ret < 0) {
- pr_err("read channel() error: %d\n", ret);
- return ret;
- }
+ int raw;
- ret = iio_convert_raw_to_processed(channel, raw, &uv, 1000);
- if (ret < 0) {
- /* Assume 12 bit ADC with vref at pullup_uv */
- uv = (pdata->pullup_uv * (s64)raw) >> 12;
+ /*
+ * This fallback uses a raw read and then
+ * assumes the ADC is 12 bits, scaling with
+ * a factor 1000 to get to microvolts.
+ */
+ ret = iio_read_channel_raw(channel, &raw);
+ if (ret < 0) {
+ pr_err("read channel() error: %d\n", ret);
+ return ret;
+ }
+ ret = iio_convert_raw_to_processed(channel, raw, &uv, 1000);
+ if (ret < 0) {
+ /* Assume 12 bit ADC with vref at pullup_uv */
+ uv = (pdata->pullup_uv * (s64)raw) >> 12;
+ }
}
return uv;
diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig
index 267553386c71..2334ad249b46 100644
--- a/drivers/iio/Kconfig
+++ b/drivers/iio/Kconfig
@@ -72,6 +72,7 @@ source "drivers/iio/accel/Kconfig"
source "drivers/iio/adc/Kconfig"
source "drivers/iio/afe/Kconfig"
source "drivers/iio/amplifiers/Kconfig"
+source "drivers/iio/cdc/Kconfig"
source "drivers/iio/chemical/Kconfig"
source "drivers/iio/common/Kconfig"
source "drivers/iio/dac/Kconfig"
@@ -85,6 +86,7 @@ source "drivers/iio/light/Kconfig"
source "drivers/iio/magnetometer/Kconfig"
source "drivers/iio/multiplexer/Kconfig"
source "drivers/iio/orientation/Kconfig"
+source "drivers/iio/test/Kconfig"
if IIO_TRIGGER
source "drivers/iio/trigger/Kconfig"
endif #IIO_TRIGGER
diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile
index 1712011c0f4a..65e39bd4f934 100644
--- a/drivers/iio/Makefile
+++ b/drivers/iio/Makefile
@@ -18,6 +18,7 @@ obj-y += adc/
obj-y += afe/
obj-y += amplifiers/
obj-y += buffer/
+obj-y += cdc/
obj-y += chemical/
obj-y += common/
obj-y += dac/
@@ -38,4 +39,5 @@ obj-y += pressure/
obj-y += proximity/
obj-y += resolver/
obj-y += temperature/
+obj-y += test/
obj-y += trigger/
diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
index 2e0c62c39155..cceda3cecbcf 100644
--- a/drivers/iio/accel/Kconfig
+++ b/drivers/iio/accel/Kconfig
@@ -157,6 +157,24 @@ config BMC150_ACCEL_SPI
tristate
select REGMAP_SPI
+config BMI088_ACCEL
+ tristate "Bosch BMI088 Accelerometer Driver"
+ depends on SPI
+ select IIO_BUFFER
+ select IIO_TRIGGERED_BUFFER
+ select REGMAP
+ select BMI088_ACCEL_SPI
+ help
+ Say yes here to build support for the Bosch BMI088 accelerometer.
+
+ This is a combo module with both accelerometer and gyroscope. This
+ driver only implements the accelerometer part, which has its own
+ address and register map. BMG160 provides the gyroscope driver.
+
+config BMI088_ACCEL_SPI
+ tristate
+ select REGMAP_SPI
+
config DA280
tristate "MiraMEMS DA280 3-axis 14-bit digital accelerometer driver"
depends on I2C
diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile
index 4f6c1ebe13b0..32cd1342a31a 100644
--- a/drivers/iio/accel/Makefile
+++ b/drivers/iio/accel/Makefile
@@ -20,6 +20,8 @@ obj-$(CONFIG_BMA400_SPI) += bma400_spi.o
obj-$(CONFIG_BMC150_ACCEL) += bmc150-accel-core.o
obj-$(CONFIG_BMC150_ACCEL_I2C) += bmc150-accel-i2c.o
obj-$(CONFIG_BMC150_ACCEL_SPI) += bmc150-accel-spi.o
+obj-$(CONFIG_BMI088_ACCEL) += bmi088-accel-core.o
+obj-$(CONFIG_BMI088_ACCEL_SPI) += bmi088-accel-spi.o
obj-$(CONFIG_DA280) += da280.o
obj-$(CONFIG_DA311) += da311.o
obj-$(CONFIG_DMARD06) += dmard06.o
diff --git a/drivers/iio/accel/adis16201.c b/drivers/iio/accel/adis16201.c
index 3633a4e302c6..fe225990de24 100644
--- a/drivers/iio/accel/adis16201.c
+++ b/drivers/iio/accel/adis16201.c
@@ -215,7 +215,7 @@ static const struct iio_chan_spec adis16201_channels[] = {
ADIS_AUX_ADC_CHAN(ADIS16201_AUX_ADC_REG, ADIS16201_SCAN_AUX_ADC, 0, 12),
ADIS_INCLI_CHAN(X, ADIS16201_XINCL_OUT_REG, ADIS16201_SCAN_INCLI_X,
BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
- ADIS_INCLI_CHAN(X, ADIS16201_YINCL_OUT_REG, ADIS16201_SCAN_INCLI_Y,
+ ADIS_INCLI_CHAN(Y, ADIS16201_YINCL_OUT_REG, ADIS16201_SCAN_INCLI_Y,
BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
IIO_CHAN_SOFT_TIMESTAMP(7)
};
diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
index 8ba1453b8dbf..9c9a896a872a 100644
--- a/drivers/iio/accel/adxl372.c
+++ b/drivers/iio/accel/adxl372.c
@@ -1236,8 +1236,6 @@ int adxl372_probe(struct device *dev, struct regmap *regmap,
st->dready_trig->ops = &adxl372_trigger_ops;
st->peak_datardy_trig->ops = &adxl372_peak_data_trigger_ops;
- st->dready_trig->dev.parent = dev;
- st->peak_datardy_trig->dev.parent = dev;
iio_trigger_set_drvdata(st->dready_trig, indio_dev);
iio_trigger_set_drvdata(st->peak_datardy_trig, indio_dev);
ret = devm_iio_trigger_register(dev, st->dready_trig);
diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 71f85a3e525b..b8a7469cdae4 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -1044,7 +1044,7 @@ static int bma180_probe(struct i2c_client *client,
indio_dev->info = &bma180_info;
if (client->irq > 0) {
- data->trig = iio_trigger_alloc("%s-dev%d", indio_dev->name,
+ data->trig = iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name,
indio_dev->id);
if (!data->trig) {
ret = -ENOMEM;
@@ -1059,7 +1059,6 @@ static int bma180_probe(struct i2c_client *client,
goto err_trigger_free;
}
- data->trig->dev.parent = dev;
data->trig->ops = &bma180_trigger_ops;
iio_trigger_set_drvdata(data->trig, indio_dev);
indio_dev->trig = iio_trigger_get(data->trig);
diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
index 3c9b0c6954e6..36fc9876dbca 100644
--- a/drivers/iio/accel/bma220_spi.c
+++ b/drivers/iio/accel/bma220_spi.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
* BMA220 Digital triaxial acceleration sensor driver
*
* Copyright (c) 2016,2020 Intel Corporation.
diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index 7e425ebcd7ea..04d85ce34e9f 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -443,26 +443,32 @@ static bool bmc150_apply_acpi_orientation(struct device *dev,
struct iio_mount_matrix *orientation)
{
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct acpi_device *adev = ACPI_COMPANION(dev);
+ char *name, *alt_name, *label, *str;
union acpi_object *obj, *elements;
- char *name, *alt_name, *str;
acpi_status status;
int i, j, val[3];
if (!adev || !acpi_dev_hid_uid_match(adev, "BOSC0200", NULL))
return false;
- if (strcmp(dev_name(dev), "i2c-BOSC0200:base") == 0)
+ if (strcmp(dev_name(dev), "i2c-BOSC0200:base") == 0) {
alt_name = "ROMK";
- else
+ label = "accel-base";
+ } else {
alt_name = "ROMS";
+ label = "accel-display";
+ }
- if (acpi_has_method(adev->handle, "ROTM"))
+ if (acpi_has_method(adev->handle, "ROTM")) {
name = "ROTM";
- else if (acpi_has_method(adev->handle, alt_name))
+ } else if (acpi_has_method(adev->handle, alt_name)) {
name = alt_name;
- else
+ indio_dev->label = label;
+ } else {
return false;
+ }
status = acpi_evaluate_object(adev->handle, name, NULL, &buffer);
if (ACPI_FAILURE(status)) {
@@ -1472,7 +1478,6 @@ static int bmc150_accel_triggers_setup(struct iio_dev *indio_dev,
break;
}
- t->indio_trig->dev.parent = dev;
t->indio_trig->ops = &bmc150_accel_trigger_ops;
t->intr = bmc150_accel_triggers[i].intr;
t->data = data;
diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c
new file mode 100644
index 000000000000..12d00658e46f
--- /dev/null
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -0,0 +1,567 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * 3-axis accelerometer driver supporting following Bosch-Sensortec chips:
+ * - BMI088
+ *
+ * Copyright (c) 2018-2021, Topic Embedded Products
+ */
+
+#include <linux/delay.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <asm/unaligned.h>
+
+#include "bmi088-accel.h"
+
+#define BMI088_ACCEL_REG_CHIP_ID 0x00
+#define BMI088_ACCEL_REG_ERROR 0x02
+
+#define BMI088_ACCEL_REG_INT_STATUS 0x1D
+#define BMI088_ACCEL_INT_STATUS_BIT_DRDY BIT(7)
+
+#define BMI088_ACCEL_REG_RESET 0x7E
+#define BMI088_ACCEL_RESET_VAL 0xB6
+
+#define BMI088_ACCEL_REG_PWR_CTRL 0x7D
+#define BMI088_ACCEL_REG_PWR_CONF 0x7C
+
+#define BMI088_ACCEL_REG_INT_MAP_DATA 0x58
+#define BMI088_ACCEL_INT_MAP_DATA_BIT_INT1_DRDY BIT(2)
+#define BMI088_ACCEL_INT_MAP_DATA_BIT_INT2_FWM BIT(5)
+
+#define BMI088_ACCEL_REG_INT1_IO_CONF 0x53
+#define BMI088_ACCEL_INT1_IO_CONF_BIT_ENABLE_OUT BIT(3)
+#define BMI088_ACCEL_INT1_IO_CONF_BIT_LVL BIT(1)
+
+#define BMI088_ACCEL_REG_INT2_IO_CONF 0x54
+#define BMI088_ACCEL_INT2_IO_CONF_BIT_ENABLE_OUT BIT(3)
+#define BMI088_ACCEL_INT2_IO_CONF_BIT_LVL BIT(1)
+
+#define BMI088_ACCEL_REG_ACC_CONF 0x40
+#define BMI088_ACCEL_MODE_ODR_MASK 0x0f
+
+#define BMI088_ACCEL_REG_ACC_RANGE 0x41
+#define BMI088_ACCEL_RANGE_3G 0x00
+#define BMI088_ACCEL_RANGE_6G 0x01
+#define BMI088_ACCEL_RANGE_12G 0x02
+#define BMI088_ACCEL_RANGE_24G 0x03
+
+#define BMI088_ACCEL_REG_TEMP 0x22
+#define BMI088_ACCEL_REG_TEMP_SHIFT 5
+#define BMI088_ACCEL_TEMP_UNIT 125
+#define BMI088_ACCEL_TEMP_OFFSET 23000
+
+#define BMI088_ACCEL_REG_XOUT_L 0x12
+#define BMI088_ACCEL_AXIS_TO_REG(axis) \
+ (BMI088_ACCEL_REG_XOUT_L + (axis * 2))
+
+#define BMI088_ACCEL_MAX_STARTUP_TIME_US 1000
+#define BMI088_AUTO_SUSPEND_DELAY_MS 2000
+
+#define BMI088_ACCEL_REG_FIFO_STATUS 0x0E
+#define BMI088_ACCEL_REG_FIFO_CONFIG0 0x48
+#define BMI088_ACCEL_REG_FIFO_CONFIG1 0x49
+#define BMI088_ACCEL_REG_FIFO_DATA 0x3F
+#define BMI088_ACCEL_FIFO_LENGTH 100
+
+#define BMI088_ACCEL_FIFO_MODE_FIFO 0x40
+#define BMI088_ACCEL_FIFO_MODE_STREAM 0x80
+
+enum bmi088_accel_axis {
+ AXIS_X,
+ AXIS_Y,
+ AXIS_Z,
+};
+
+static const int bmi088_sample_freqs[] = {
+ 12, 500000,
+ 25, 0,
+ 50, 0,
+ 100, 0,
+ 200, 0,
+ 400, 0,
+ 800, 0,
+ 1600, 0,
+};
+
+/* Available OSR (over sampling rate) sets the 3dB cut-off frequency */
+enum bmi088_osr_modes {
+ BMI088_ACCEL_MODE_OSR_NORMAL = 0xA,
+ BMI088_ACCEL_MODE_OSR_2 = 0x9,
+ BMI088_ACCEL_MODE_OSR_4 = 0x8,
+};
+
+/* Available ODR (output data rates) in Hz */
+enum bmi088_odr_modes {
+ BMI088_ACCEL_MODE_ODR_12_5 = 0x5,
+ BMI088_ACCEL_MODE_ODR_25 = 0x6,
+ BMI088_ACCEL_MODE_ODR_50 = 0x7,
+ BMI088_ACCEL_MODE_ODR_100 = 0x8,
+ BMI088_ACCEL_MODE_ODR_200 = 0x9,
+ BMI088_ACCEL_MODE_ODR_400 = 0xa,
+ BMI088_ACCEL_MODE_ODR_800 = 0xb,
+ BMI088_ACCEL_MODE_ODR_1600 = 0xc,
+};
+
+struct bmi088_scale_info {
+ int scale;
+ u8 reg_range;
+};
+
+struct bmi088_accel_chip_info {
+ const char *name;
+ u8 chip_id;
+ const struct iio_chan_spec *channels;
+ int num_channels;
+};
+
+struct bmi088_accel_data {
+ struct regmap *regmap;
+ const struct bmi088_accel_chip_info *chip_info;
+ u8 buffer[2] ____cacheline_aligned; /* shared DMA safe buffer */
+};
+
+static const struct regmap_range bmi088_volatile_ranges[] = {
+ /* All registers below 0x40 are volatile, except the CHIP ID. */
+ regmap_reg_range(BMI088_ACCEL_REG_ERROR, 0x3f),
+ /* Mark the RESET as volatile too, it is self-clearing */
+ regmap_reg_range(BMI088_ACCEL_REG_RESET, BMI088_ACCEL_REG_RESET),
+};
+
+static const struct regmap_access_table bmi088_volatile_table = {
+ .yes_ranges = bmi088_volatile_ranges,
+ .n_yes_ranges = ARRAY_SIZE(bmi088_volatile_ranges),
+};
+
+const struct regmap_config bmi088_regmap_conf = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = 0x7E,
+ .volatile_table = &bmi088_volatile_table,
+ .cache_type = REGCACHE_RBTREE,
+};
+EXPORT_SYMBOL_GPL(bmi088_regmap_conf);
+
+static int bmi088_accel_power_up(struct bmi088_accel_data *data)
+{
+ int ret;
+
+ /* Enable accelerometer and temperature sensor */
+ ret = regmap_write(data->regmap, BMI088_ACCEL_REG_PWR_CTRL, 0x4);
+ if (ret)
+ return ret;
+
+ /* Datasheet recommends to wait at least 5ms before communication */
+ usleep_range(5000, 6000);
+
+ /* Disable suspend mode */
+ ret = regmap_write(data->regmap, BMI088_ACCEL_REG_PWR_CONF, 0x0);
+ if (ret)
+ return ret;
+
+ /* Recommended at least 1ms before further communication */
+ usleep_range(1000, 1200);
+
+ return 0;
+}
+
+static int bmi088_accel_power_down(struct bmi088_accel_data *data)
+{
+ int ret;
+
+ /* Enable suspend mode */
+ ret = regmap_write(data->regmap, BMI088_ACCEL_REG_PWR_CONF, 0x3);
+ if (ret)
+ return ret;
+
+ /* Recommended at least 1ms before further communication */
+ usleep_range(1000, 1200);
+
+ /* Disable accelerometer and temperature sensor */
+ ret = regmap_write(data->regmap, BMI088_ACCEL_REG_PWR_CTRL, 0x0);
+ if (ret)
+ return ret;
+
+ /* Datasheet recommends to wait at least 5ms before communication */
+ usleep_range(5000, 6000);
+
+ return 0;
+}
+
+static int bmi088_accel_get_sample_freq(struct bmi088_accel_data *data,
+ int *val, int *val2)
+{
+ unsigned int value;
+ int ret;
+
+ ret = regmap_read(data->regmap, BMI088_ACCEL_REG_ACC_CONF,
+ &value);
+ if (ret)
+ return ret;
+
+ value &= BMI088_ACCEL_MODE_ODR_MASK;
+ value -= BMI088_ACCEL_MODE_ODR_12_5;
+ value <<= 1;
+
+ if (value >= ARRAY_SIZE(bmi088_sample_freqs) - 1)
+ return -EINVAL;
+
+ *val = bmi088_sample_freqs[value];
+ *val2 = bmi088_sample_freqs[value + 1];
+
+ return IIO_VAL_INT_PLUS_MICRO;
+}
+
+static int bmi088_accel_set_sample_freq(struct bmi088_accel_data *data, int val)
+{
+ unsigned int regval;
+ int index = 0;
+
+ while (index < ARRAY_SIZE(bmi088_sample_freqs) &&
+ bmi088_sample_freqs[index] != val)
+ index += 2;
+
+ if (index >= ARRAY_SIZE(bmi088_sample_freqs))
+ return -EINVAL;
+
+ regval = (index >> 1) + BMI088_ACCEL_MODE_ODR_12_5;
+
+ return regmap_update_bits(data->regmap, BMI088_ACCEL_REG_ACC_CONF,
+ BMI088_ACCEL_MODE_ODR_MASK, regval);
+}
+
+static int bmi088_accel_get_temp(struct bmi088_accel_data *data, int *val)
+{
+ int ret;
+ s16 temp;
+
+ ret = regmap_bulk_read(data->regmap, BMI088_ACCEL_REG_TEMP,
+ &data->buffer, sizeof(__be16));
+ if (ret)
+ return ret;
+
+ /* data->buffer is cacheline aligned */
+ temp = be16_to_cpu(*(__be16 *)data->buffer);
+
+ *val = temp >> BMI088_ACCEL_REG_TEMP_SHIFT;
+
+ return IIO_VAL_INT;
+}
+
+static int bmi088_accel_get_axis(struct bmi088_accel_data *data,
+ struct iio_chan_spec const *chan,
+ int *val)
+{
+ int ret;
+ s16 raw_val;
+
+ ret = regmap_bulk_read(data->regmap,
+ BMI088_ACCEL_AXIS_TO_REG(chan->scan_index),
+ data->buffer, sizeof(__le16));
+ if (ret)
+ return ret;
+
+ raw_val = le16_to_cpu(*(__le16 *)data->buffer);
+ *val = raw_val;
+
+ return IIO_VAL_INT;
+}
+
+static int bmi088_accel_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2, long mask)
+{
+ struct bmi088_accel_data *data = iio_priv(indio_dev);
+ struct device *dev = regmap_get_device(data->regmap);
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ switch (chan->type) {
+ case IIO_TEMP:
+ pm_runtime_get_sync(dev);
+ ret = bmi088_accel_get_temp(data, val);
+ goto out_read_raw_pm_put;
+ case IIO_ACCEL:
+ pm_runtime_get_sync(dev);
+ ret = iio_device_claim_direct_mode(indio_dev);
+ if (ret)
+ goto out_read_raw_pm_put;
+
+ ret = bmi088_accel_get_axis(data, chan, val);
+ iio_device_release_direct_mode(indio_dev);
+ if (!ret)
+ ret = IIO_VAL_INT;
+
+ goto out_read_raw_pm_put;
+ default:
+ return -EINVAL;
+ }
+ case IIO_CHAN_INFO_OFFSET:
+ switch (chan->type) {
+ case IIO_TEMP:
+ /* Offset applies before scale */
+ *val = BMI088_ACCEL_TEMP_OFFSET/BMI088_ACCEL_TEMP_UNIT;
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+ case IIO_CHAN_INFO_SCALE:
+ switch (chan->type) {
+ case IIO_TEMP:
+ /* 0.125 degrees per LSB */
+ *val = BMI088_ACCEL_TEMP_UNIT;
+ return IIO_VAL_INT;
+ case IIO_ACCEL:
+ pm_runtime_get_sync(dev);
+ ret = regmap_read(data->regmap,
+ BMI088_ACCEL_REG_ACC_RANGE, val);
+ if (ret)
+ goto out_read_raw_pm_put;
+
+ *val2 = 15 - (*val & 0x3);
+ *val = 3 * 980;
+ ret = IIO_VAL_FRACTIONAL_LOG2;
+
+ goto out_read_raw_pm_put;
+ default:
+ return -EINVAL;
+ }
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ pm_runtime_get_sync(dev);
+ ret = bmi088_accel_get_sample_freq(data, val, val2);
+ goto out_read_raw_pm_put;
+ default:
+ break;
+ }
+
+ return -EINVAL;
+
+out_read_raw_pm_put:
+ pm_runtime_mark_last_busy(dev);
+ pm_runtime_put_autosuspend(dev);
+
+ return ret;
+}
+
+static int bmi088_accel_read_avail(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ const int **vals, int *type, int *length,
+ long mask)
+{
+ switch (mask) {
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ *type = IIO_VAL_INT_PLUS_MICRO;
+ *vals = bmi088_sample_freqs;
+ *length = ARRAY_SIZE(bmi088_sample_freqs);
+ return IIO_AVAIL_LIST;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int bmi088_accel_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val, int val2, long mask)
+{
+ struct bmi088_accel_data *data = iio_priv(indio_dev);
+ struct device *dev = regmap_get_device(data->regmap);
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ pm_runtime_get_sync(dev);
+ ret = bmi088_accel_set_sample_freq(data, val);
+ pm_runtime_mark_last_busy(dev);
+ pm_runtime_put_autosuspend(dev);
+ return ret;
+ default:
+ return -EINVAL;
+ }
+}
+
+#define BMI088_ACCEL_CHANNEL(_axis) { \
+ .type = IIO_ACCEL, \
+ .modified = 1, \
+ .channel2 = IIO_MOD_##_axis, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
+ BIT(IIO_CHAN_INFO_SAMP_FREQ), \
+ .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
+ .scan_index = AXIS_##_axis, \
+}
+
+static const struct iio_chan_spec bmi088_accel_channels[] = {
+ {
+ .type = IIO_TEMP,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_SCALE) |
+ BIT(IIO_CHAN_INFO_OFFSET),
+ .scan_index = -1,
+ },
+ BMI088_ACCEL_CHANNEL(X),
+ BMI088_ACCEL_CHANNEL(Y),
+ BMI088_ACCEL_CHANNEL(Z),
+ IIO_CHAN_SOFT_TIMESTAMP(3),
+};
+
+static const struct bmi088_accel_chip_info bmi088_accel_chip_info_tbl[] = {
+ [0] = {
+ .name = "bmi088a",
+ .chip_id = 0x1E,
+ .channels = bmi088_accel_channels,
+ .num_channels = ARRAY_SIZE(bmi088_accel_channels),
+ },
+};
+
+static const struct iio_info bmi088_accel_info = {
+ .read_raw = bmi088_accel_read_raw,
+ .write_raw = bmi088_accel_write_raw,
+ .read_avail = bmi088_accel_read_avail,
+};
+
+static const unsigned long bmi088_accel_scan_masks[] = {
+ BIT(AXIS_X) | BIT(AXIS_Y) | BIT(AXIS_Z),
+ 0
+};
+
+static int bmi088_accel_chip_init(struct bmi088_accel_data *data)
+{
+ struct device *dev = regmap_get_device(data->regmap);
+ int ret, i;
+ unsigned int val;
+
+ /* Do a dummy read to enable SPI interface, won't harm I2C */
+ regmap_read(data->regmap, BMI088_ACCEL_REG_INT_STATUS, &val);
+
+ /*
+ * Reset chip to get it in a known good state. A delay of 1ms after
+ * reset is required according to the data sheet
+ */
+ ret = regmap_write(data->regmap, BMI088_ACCEL_REG_RESET,
+ BMI088_ACCEL_RESET_VAL);
+ if (ret)
+ return ret;
+
+ usleep_range(1000, 2000);
+
+ /* Do a dummy read again after a reset to enable the SPI interface */
+ regmap_read(data->regmap, BMI088_ACCEL_REG_INT_STATUS, &val);
+
+ /* Read chip ID */
+ ret = regmap_read(data->regmap, BMI088_ACCEL_REG_CHIP_ID, &val);
+ if (ret) {
+ dev_err(dev, "Error: Reading chip id\n");
+ return ret;
+ }
+
+ /* Validate chip ID */
+ for (i = 0; i < ARRAY_SIZE(bmi088_accel_chip_info_tbl); i++) {
+ if (bmi088_accel_chip_info_tbl[i].chip_id == val) {
+ data->chip_info = &bmi088_accel_chip_info_tbl[i];
+ break;
+ }
+ }
+ if (i == ARRAY_SIZE(bmi088_accel_chip_info_tbl)) {
+ dev_err(dev, "Invalid chip %x\n", val);
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap,
+ int irq, const char *name, bool block_supported)
+{
+ struct bmi088_accel_data *data;
+ struct iio_dev *indio_dev;
+ int ret;
+
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ data = iio_priv(indio_dev);
+ dev_set_drvdata(dev, indio_dev);
+
+ data->regmap = regmap;
+
+ ret = bmi088_accel_chip_init(data);
+ if (ret)
+ return ret;
+
+ indio_dev->dev.parent = dev;
+ indio_dev->channels = data->chip_info->channels;
+ indio_dev->num_channels = data->chip_info->num_channels;
+ indio_dev->name = name ? name : data->chip_info->name;
+ indio_dev->available_scan_masks = bmi088_accel_scan_masks;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->info = &bmi088_accel_info;
+
+ /* Enable runtime PM */
+ pm_runtime_get_noresume(dev);
+ pm_runtime_set_suspended(dev);
+ pm_runtime_enable(dev);
+ /* We need ~6ms to startup, so set the delay to 6 seconds */
+ pm_runtime_set_autosuspend_delay(dev, 6000);
+ pm_runtime_use_autosuspend(dev);
+ pm_runtime_put(dev);
+
+ ret = iio_device_register(indio_dev);
+ if (ret)
+ dev_err(dev, "Unable to register iio device\n");
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(bmi088_accel_core_probe);
+
+
+int bmi088_accel_core_remove(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct bmi088_accel_data *data = iio_priv(indio_dev);
+
+ iio_device_unregister(indio_dev);
+
+ pm_runtime_disable(dev);
+ pm_runtime_set_suspended(dev);
+ pm_runtime_put_noidle(dev);
+ bmi088_accel_power_down(data);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(bmi088_accel_core_remove);
+
+static int __maybe_unused bmi088_accel_runtime_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct bmi088_accel_data *data = iio_priv(indio_dev);
+
+ return bmi088_accel_power_down(data);
+}
+
+static int __maybe_unused bmi088_accel_runtime_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct bmi088_accel_data *data = iio_priv(indio_dev);
+
+ return bmi088_accel_power_up(data);
+}
+
+const struct dev_pm_ops bmi088_accel_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+ pm_runtime_force_resume)
+ SET_RUNTIME_PM_OPS(bmi088_accel_runtime_suspend,
+ bmi088_accel_runtime_resume, NULL)
+};
+EXPORT_SYMBOL_GPL(bmi088_accel_pm_ops);
+
+MODULE_AUTHOR("Niek van Agt <niek.van.agt@topicproducts.com>");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("BMI088 accelerometer driver (core)");
diff --git a/drivers/iio/accel/bmi088-accel-spi.c b/drivers/iio/accel/bmi088-accel-spi.c
new file mode 100644
index 000000000000..dd1e3f6cf211
--- /dev/null
+++ b/drivers/iio/accel/bmi088-accel-spi.c
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * 3-axis accelerometer driver supporting following Bosch-Sensortec chips:
+ * - BMI088
+ *
+ * Copyright (c) 2018-2020, Topic Embedded Products
+ */
+
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/spi/spi.h>
+
+#include "bmi088-accel.h"
+
+static int bmi088_regmap_spi_write(void *context, const void *data, size_t count)
+{
+ struct spi_device *spi = context;
+
+ /* Write register is same as generic SPI */
+ return spi_write(spi, data, count);
+}
+
+static int bmi088_regmap_spi_read(void *context, const void *reg,
+ size_t reg_size, void *val, size_t val_size)
+{
+ struct spi_device *spi = context;
+ u8 addr[2];
+
+ addr[0] = *(u8 *)reg;
+ addr[0] |= BIT(7); /* Set RW = '1' */
+ addr[1] = 0; /* Read requires a dummy byte transfer */
+
+ return spi_write_then_read(spi, addr, sizeof(addr), val, val_size);
+}
+
+static struct regmap_bus bmi088_regmap_bus = {
+ .write = bmi088_regmap_spi_write,
+ .read = bmi088_regmap_spi_read,
+};
+
+static int bmi088_accel_probe(struct spi_device *spi)
+{
+ struct regmap *regmap;
+ const struct spi_device_id *id = spi_get_device_id(spi);
+
+ regmap = devm_regmap_init(&spi->dev, &bmi088_regmap_bus,
+ spi, &bmi088_regmap_conf);
+
+ if (IS_ERR(regmap)) {
+ dev_err(&spi->dev, "Failed to initialize spi regmap\n");
+ return PTR_ERR(regmap);
+ }
+
+ return bmi088_accel_core_probe(&spi->dev, regmap, spi->irq, id->name,
+ true);
+}
+
+static int bmi088_accel_remove(struct spi_device *spi)
+{
+ return bmi088_accel_core_remove(&spi->dev);
+}
+
+static const struct spi_device_id bmi088_accel_id[] = {
+ {"bmi088-accel", },
+ {}
+};
+MODULE_DEVICE_TABLE(spi, bmi088_accel_id);
+
+static struct spi_driver bmi088_accel_driver = {
+ .driver = {
+ .name = "bmi088_accel_spi",
+ .pm = &bmi088_accel_pm_ops,
+ },
+ .probe = bmi088_accel_probe,
+ .remove = bmi088_accel_remove,
+ .id_table = bmi088_accel_id,
+};
+module_spi_driver(bmi088_accel_driver);
+
+MODULE_AUTHOR("Niek van Agt <niek.van.agt@topicproducts.com>");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("BMI088 accelerometer driver (SPI)");
diff --git a/drivers/iio/accel/bmi088-accel.h b/drivers/iio/accel/bmi088-accel.h
new file mode 100644
index 000000000000..5c25f16b672c
--- /dev/null
+++ b/drivers/iio/accel/bmi088-accel.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef BMI088_ACCEL_H
+#define BMI088_ACCEL_H
+
+#include <linux/pm.h>
+#include <linux/regmap.h>
+#include <linux/types.h>
+
+struct device;
+
+extern const struct regmap_config bmi088_regmap_conf;
+extern const struct dev_pm_ops bmi088_accel_pm_ops;
+
+int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
+ const char *name, bool block_supported);
+int bmi088_accel_core_remove(struct device *dev);
+
+#endif /* BMI088_ACCEL_H */
diff --git a/drivers/iio/accel/cros_ec_accel_legacy.c b/drivers/iio/accel/cros_ec_accel_legacy.c
index 8f1232c38e0d..b6f3471b62dc 100644
--- a/drivers/iio/accel/cros_ec_accel_legacy.c
+++ b/drivers/iio/accel/cros_ec_accel_legacy.c
@@ -215,7 +215,7 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev)
return -ENOMEM;
ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
- cros_ec_sensors_capture, NULL, false);
+ cros_ec_sensors_capture, NULL);
if (ret)
return ret;
diff --git a/drivers/iio/accel/da280.c b/drivers/iio/accel/da280.c
index 4472dde6899e..5edff9ba72da 100644
--- a/drivers/iio/accel/da280.c
+++ b/drivers/iio/accel/da280.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
* IIO driver for the MiraMEMS DA280 3-axis accelerometer and
* IIO driver for the MiraMEMS DA226 2-axis accelerometer
*
diff --git a/drivers/iio/accel/da311.c b/drivers/iio/accel/da311.c
index 3b3df620ba27..92593a1cd1aa 100644
--- a/drivers/iio/accel/da311.c
+++ b/drivers/iio/accel/da311.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
* IIO driver for the MiraMEMS DA311 3-axis accelerometer
*
* Copyright (c) 2016 Hans de Goede <hdegoede@redhat.com>
diff --git a/drivers/iio/accel/dmard10.c b/drivers/iio/accel/dmard10.c
index 90206f015857..e84bf8db1e89 100644
--- a/drivers/iio/accel/dmard10.c
+++ b/drivers/iio/accel/dmard10.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
* IIO driver for the 3-axis accelerometer Domintech ARD10.
*
* Copyright (c) 2016 Hans de Goede <hdegoede@redhat.com>
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 5d63ed19e6e2..2f9465cb382f 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -43,6 +43,10 @@ static const u32 accel_3d_addresses[ACCEL_3D_CHANNEL_MAX] = {
HID_USAGE_SENSOR_ACCEL_Z_AXIS
};
+static const u32 accel_3d_sensitivity_addresses[] = {
+ HID_USAGE_SENSOR_DATA_ACCELERATION,
+};
+
/* Channel definitions */
static const struct iio_chan_spec accel_3d_channels[] = {
{
@@ -317,18 +321,6 @@ static int accel_3d_parse_report(struct platform_device *pdev,
&st->accel[CHANNEL_SCAN_INDEX_X],
&st->scale_pre_decml, &st->scale_post_decml);
- /* Set Sensitivity field ids, when there is no individual modifier */
- if (st->common_attributes.sensitivity.index < 0) {
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_DATA_ACCELERATION,
- &st->common_attributes.sensitivity);
- dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
- st->common_attributes.sensitivity.index,
- st->common_attributes.sensitivity.report_id);
- }
-
return ret;
}
@@ -366,8 +358,11 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
channel_size = sizeof(gravity_channels);
indio_dev->num_channels = ARRAY_SIZE(gravity_channels);
}
- ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage,
- &accel_state->common_attributes);
+ ret = hid_sensor_parse_common_attributes(hsdev,
+ hsdev->usage,
+ &accel_state->common_attributes,
+ accel_3d_sensitivity_addresses,
+ ARRAY_SIZE(accel_3d_sensitivity_addresses));
if (ret) {
dev_err(&pdev->dev, "failed to setup common attributes\n");
return ret;
diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index 2fadafc860fd..ff724bc17a45 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -1284,7 +1284,8 @@ static irqreturn_t kxcjk1013_data_rdy_trig_poll(int irq, void *private)
static const char *kxcjk1013_match_acpi_device(struct device *dev,
enum kx_chipset *chipset,
- enum kx_acpi_type *acpi_type)
+ enum kx_acpi_type *acpi_type,
+ const char **label)
{
const struct acpi_device_id *id;
@@ -1292,10 +1293,14 @@ static const char *kxcjk1013_match_acpi_device(struct device *dev,
if (!id)
return NULL;
- if (strcmp(id->id, "SMO8500") == 0)
+ if (strcmp(id->id, "SMO8500") == 0) {
*acpi_type = ACPI_SMO8500;
- else if (strcmp(id->id, "KIOX010A") == 0)
+ } else if (strcmp(id->id, "KIOX010A") == 0) {
*acpi_type = ACPI_KIOX010A;
+ *label = "accel-display";
+ } else if (strcmp(id->id, "KIOX020A") == 0) {
+ *label = "accel-base";
+ }
*chipset = (enum kx_chipset)id->driver_data;
@@ -1368,7 +1373,8 @@ static int kxcjk1013_probe(struct i2c_client *client,
} else if (ACPI_HANDLE(&client->dev)) {
name = kxcjk1013_match_acpi_device(&client->dev,
&data->chipset,
- &data->acpi_type);
+ &data->acpi_type,
+ &indio_dev->label);
} else
return -ENODEV;
@@ -1413,7 +1419,6 @@ static int kxcjk1013_probe(struct i2c_client *client,
goto err_poweroff;
}
- data->dready_trig->dev.parent = &client->dev;
data->dready_trig->ops = &kxcjk1013_trigger_ops;
iio_trigger_set_drvdata(data->dready_trig, indio_dev);
indio_dev->trig = data->dready_trig;
@@ -1422,7 +1427,6 @@ static int kxcjk1013_probe(struct i2c_client *client,
if (ret)
goto err_poweroff;
- data->motion_trig->dev.parent = &client->dev;
data->motion_trig->ops = &kxcjk1013_trigger_ops;
iio_trigger_set_drvdata(data->motion_trig, indio_dev);
ret = iio_trigger_register(data->motion_trig);
diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c
index 46e4283fc037..735002b716f3 100644
--- a/drivers/iio/accel/mc3230.c
+++ b/drivers/iio/accel/mc3230.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-or-later
-/**
+/*
* mCube MC3230 3-Axis Accelerometer
*
* Copyright (c) 2016 Hans de Goede <hdegoede@redhat.com>
diff --git a/drivers/iio/accel/mma7660.c b/drivers/iio/accel/mma7660.c
index b3c9136d51ec..47f5cd66e996 100644
--- a/drivers/iio/accel/mma7660.c
+++ b/drivers/iio/accel/mma7660.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
* Freescale MMA7660FC 3-Axis Accelerometer
*
* Copyright (c) 2016, Intel Corporation.
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index b0176d936423..4d307dfb9169 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -58,7 +58,7 @@
#define MMA8452_FF_MT_THS 0x17
#define MMA8452_FF_MT_THS_MASK 0x7f
#define MMA8452_FF_MT_COUNT 0x18
-#define MMA8452_FF_MT_CHAN_SHIFT 3
+#define MMA8452_FF_MT_CHAN_SHIFT 3
#define MMA8452_TRANSIENT_CFG 0x1d
#define MMA8452_TRANSIENT_CFG_CHAN(chan) BIT(chan + 1)
#define MMA8452_TRANSIENT_CFG_HPF_BYP BIT(0)
@@ -70,7 +70,7 @@
#define MMA8452_TRANSIENT_THS 0x1f
#define MMA8452_TRANSIENT_THS_MASK GENMASK(6, 0)
#define MMA8452_TRANSIENT_COUNT 0x20
-#define MMA8452_TRANSIENT_CHAN_SHIFT 1
+#define MMA8452_TRANSIENT_CHAN_SHIFT 1
#define MMA8452_CTRL_REG1 0x2a
#define MMA8452_CTRL_ACTIVE BIT(0)
#define MMA8452_CTRL_DR_MASK GENMASK(5, 3)
@@ -134,33 +134,33 @@ struct mma8452_data {
* used for different chips and the relevant registers are included here.
*/
struct mma8452_event_regs {
- u8 ev_cfg;
- u8 ev_cfg_ele;
- u8 ev_cfg_chan_shift;
- u8 ev_src;
- u8 ev_ths;
- u8 ev_ths_mask;
- u8 ev_count;
+ u8 ev_cfg;
+ u8 ev_cfg_ele;
+ u8 ev_cfg_chan_shift;
+ u8 ev_src;
+ u8 ev_ths;
+ u8 ev_ths_mask;
+ u8 ev_count;
};
static const struct mma8452_event_regs ff_mt_ev_regs = {
- .ev_cfg = MMA8452_FF_MT_CFG,
- .ev_cfg_ele = MMA8452_FF_MT_CFG_ELE,
- .ev_cfg_chan_shift = MMA8452_FF_MT_CHAN_SHIFT,
- .ev_src = MMA8452_FF_MT_SRC,
- .ev_ths = MMA8452_FF_MT_THS,
- .ev_ths_mask = MMA8452_FF_MT_THS_MASK,
- .ev_count = MMA8452_FF_MT_COUNT
+ .ev_cfg = MMA8452_FF_MT_CFG,
+ .ev_cfg_ele = MMA8452_FF_MT_CFG_ELE,
+ .ev_cfg_chan_shift = MMA8452_FF_MT_CHAN_SHIFT,
+ .ev_src = MMA8452_FF_MT_SRC,
+ .ev_ths = MMA8452_FF_MT_THS,
+ .ev_ths_mask = MMA8452_FF_MT_THS_MASK,
+ .ev_count = MMA8452_FF_MT_COUNT
};
static const struct mma8452_event_regs trans_ev_regs = {
- .ev_cfg = MMA8452_TRANSIENT_CFG,
- .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE,
- .ev_cfg_chan_shift = MMA8452_TRANSIENT_CHAN_SHIFT,
- .ev_src = MMA8452_TRANSIENT_SRC,
- .ev_ths = MMA8452_TRANSIENT_THS,
- .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK,
- .ev_count = MMA8452_TRANSIENT_COUNT,
+ .ev_cfg = MMA8452_TRANSIENT_CFG,
+ .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE,
+ .ev_cfg_chan_shift = MMA8452_TRANSIENT_CHAN_SHIFT,
+ .ev_src = MMA8452_TRANSIENT_SRC,
+ .ev_ths = MMA8452_TRANSIENT_THS,
+ .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK,
+ .ev_count = MMA8452_TRANSIENT_COUNT,
};
/**
@@ -1465,7 +1465,6 @@ static int mma8452_trigger_setup(struct iio_dev *indio_dev)
if (!trig)
return -ENOMEM;
- trig->dev.parent = &data->client->dev;
trig->ops = &mma8452_trigger_ops;
iio_trigger_set_drvdata(trig, indio_dev);
diff --git a/drivers/iio/accel/mxc4005.c b/drivers/iio/accel/mxc4005.c
index 0f8fd687866d..fb3cbaa62bd8 100644
--- a/drivers/iio/accel/mxc4005.c
+++ b/drivers/iio/accel/mxc4005.c
@@ -450,7 +450,6 @@ static int mxc4005_probe(struct i2c_client *client,
return ret;
}
- data->dready_trig->dev.parent = &client->dev;
data->dready_trig->ops = &mxc4005_trigger_ops;
iio_trigger_set_drvdata(data->dready_trig, indio_dev);
indio_dev->trig = data->dready_trig;
diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index 194738660523..cb753a43533c 100644
--- a/drivers/iio/accel/sca3000.c
+++ b/drivers/iio/accel/sca3000.c
@@ -351,7 +351,7 @@ static int __sca3000_unlock_reg_lock(struct sca3000_state *st)
}
/**
- * sca3000_write_ctrl_reg() write to a lock protect ctrl register
+ * sca3000_write_ctrl_reg() - write to a lock protect ctrl register
* @st: Driver specific device instance data.
* @sel: selects which registers we wish to write to
* @val: the value to be written
@@ -389,7 +389,7 @@ error_ret:
}
/**
- * sca3000_read_ctrl_reg() read from lock protected control register.
+ * sca3000_read_ctrl_reg() - read from lock protected control register.
* @st: Driver specific device instance data.
* @ctrl_reg: Which ctrl register do we want to read.
*
@@ -421,7 +421,7 @@ error_ret:
}
/**
- * sca3000_show_rev() - sysfs interface to read the chip revision number
+ * sca3000_print_rev() - sysfs interface to read the chip revision number
* @indio_dev: Device instance specific generic IIO data.
* Driver specific device instance data can be obtained via
* via iio_priv(indio_dev)
@@ -902,7 +902,7 @@ static int sca3000_read_event_value(struct iio_dev *indio_dev,
}
/**
- * sca3000_write_value() - control of threshold and period
+ * sca3000_write_event_value() - control of threshold and period
* @indio_dev: Device instance specific IIO information.
* @chan: Description of the channel for which the event is being
* configured.
@@ -1272,20 +1272,6 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev,
return ret;
}
-static int sca3000_configure_ring(struct iio_dev *indio_dev)
-{
- struct iio_buffer *buffer;
-
- buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
- indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
-
- return 0;
-}
-
static inline
int __sca3000_hw_ring_state_set(struct iio_dev *indio_dev, bool state)
{
@@ -1479,7 +1465,9 @@ static int sca3000_probe(struct spi_device *spi)
}
indio_dev->modes = INDIO_DIRECT_MODE;
- ret = sca3000_configure_ring(indio_dev);
+ ret = devm_iio_kfifo_buffer_setup(&spi->dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ &sca3000_ring_setup_ops);
if (ret)
return ret;
@@ -1493,7 +1481,6 @@ static int sca3000_probe(struct spi_device *spi)
if (ret)
return ret;
}
- indio_dev->setup_ops = &sca3000_ring_setup_ops;
ret = sca3000_clean_setup(st);
if (ret)
goto error_free_irq;
diff --git a/drivers/iio/accel/ssp_accel_sensor.c b/drivers/iio/accel/ssp_accel_sensor.c
index 474477e91b5e..04dcb2b657ee 100644
--- a/drivers/iio/accel/ssp_accel_sensor.c
+++ b/drivers/iio/accel/ssp_accel_sensor.c
@@ -96,7 +96,6 @@ static int ssp_accel_probe(struct platform_device *pdev)
int ret;
struct iio_dev *indio_dev;
struct ssp_sensor_data *spd;
- struct iio_buffer *buffer;
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*spd));
if (!indio_dev)
@@ -109,18 +108,15 @@ static int ssp_accel_probe(struct platform_device *pdev)
indio_dev->name = ssp_accel_device_name;
indio_dev->info = &ssp_accel_iio_info;
- indio_dev->modes = INDIO_BUFFER_SOFTWARE;
indio_dev->channels = ssp_acc_channels;
indio_dev->num_channels = ARRAY_SIZE(ssp_acc_channels);
indio_dev->available_scan_masks = ssp_accel_scan_mask;
- buffer = devm_iio_kfifo_allocate(&pdev->dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
-
- indio_dev->setup_ops = &ssp_accel_buffer_ops;
+ ret = devm_iio_kfifo_buffer_setup(&pdev->dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ &ssp_accel_buffer_ops);
+ if (ret)
+ return ret;
platform_set_drvdata(pdev, indio_dev);
diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
index 3b59887a8581..157d8faefb9e 100644
--- a/drivers/iio/accel/stk8312.c
+++ b/drivers/iio/accel/stk8312.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
* Sensortek STK8312 3-Axis Accelerometer
*
* Copyright (c) 2015, Intel Corporation.
@@ -558,7 +558,6 @@ static int stk8312_probe(struct i2c_client *client,
goto err_power_off;
}
- data->dready_trig->dev.parent = &client->dev;
data->dready_trig->ops = &stk8312_trigger_ops;
iio_trigger_set_drvdata(data->dready_trig, indio_dev);
ret = iio_trigger_register(data->dready_trig);
diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c
index 3ead378b02c9..7cf9cb7e8666 100644
--- a/drivers/iio/accel/stk8ba50.c
+++ b/drivers/iio/accel/stk8ba50.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
* Sensortek STK8BA50 3-Axis Accelerometer
*
* Copyright (c) 2015, Intel Corporation.
@@ -454,7 +454,6 @@ static int stk8ba50_probe(struct i2c_client *client,
goto err_power_off;
}
- data->dready_trig->dev.parent = &client->dev;
data->dready_trig->ops = &stk8ba50_trigger_ops;
iio_trigger_set_drvdata(data->dready_trig, indio_dev);
ret = iio_trigger_register(data->dready_trig);
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index e0667c4b3c08..c7946c439612 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -97,7 +97,7 @@ config AD7298
module will be called ad7298.
config AD7476
- tristate "Analog Devices AD7476 1-channel ADCs driver and other similar devices from AD an TI"
+ tristate "Analog Devices AD7476 1-channel ADCs driver and other similar devices from AD and TI"
depends on SPI
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
@@ -249,7 +249,7 @@ config AD799X
config AD9467
tristate "Analog Devices AD9467 High Speed ADC driver"
depends on SPI
- select ADI_AXI_ADC
+ depends on ADI_AXI_ADC
help
Say yes here to build support for Analog Devices:
* AD9467 16-Bit, 200 MSPS/250 MSPS Analog-to-Digital Converter
@@ -1154,6 +1154,18 @@ config TI_ADS124S08
This driver can also be built as a module. If so, the module will be
called ti-ads124s08.
+config TI_ADS131E08
+ tristate "Texas Instruments ADS131E08"
+ depends on SPI
+ select IIO_BUFFER
+ select IIO_TRIGGERED_BUFFER
+ help
+ Say yes here to get support for Texas Instruments ADS131E04, ADS131E06
+ and ADS131E08 chips.
+
+ This driver can also be built as a module. If so, the module will be
+ called ti-ads131e08.
+
config TI_AM335X_ADC
tristate "TI's AM335X ADC driver"
depends on MFD_TI_AM335X_TSCADC && HAS_DMA
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index 5fca90ada0ec..a226657d19c0 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -103,6 +103,7 @@ obj-$(CONFIG_TI_ADS7950) += ti-ads7950.o
obj-$(CONFIG_TI_ADS8344) += ti-ads8344.o
obj-$(CONFIG_TI_ADS8688) += ti-ads8688.o
obj-$(CONFIG_TI_ADS124S08) += ti-ads124s08.o
+obj-$(CONFIG_TI_ADS131E08) += ti-ads131e08.o
obj-$(CONFIG_TI_AM335X_ADC) += ti_am335x_adc.o
obj-$(CONFIG_TI_TLC4541) += ti-tlc4541.o
obj-$(CONFIG_TWL4030_MADC) += twl4030-madc.o
diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
index 766c73333604..9d3952b4674f 100644
--- a/drivers/iio/adc/ad7124.c
+++ b/drivers/iio/adc/ad7124.c
@@ -5,12 +5,14 @@
* Copyright 2018 Analog Devices Inc.
*/
#include <linux/bitfield.h>
+#include <linux/bitops.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
+#include <linux/kfifo.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/regulator/consumer.h>
@@ -86,6 +88,10 @@
#define AD7124_SINC3_FILTER 2
#define AD7124_SINC4_FILTER 0
+#define AD7124_CONF_ADDR_OFFSET 20
+#define AD7124_MAX_CONFIGS 8
+#define AD7124_MAX_CHANNELS 16
+
enum ad7124_ids {
ID_AD7124_4,
ID_AD7124_8,
@@ -136,25 +142,37 @@ struct ad7124_chip_info {
};
struct ad7124_channel_config {
+ bool live;
+ unsigned int cfg_slot;
enum ad7124_ref_sel refsel;
bool bipolar;
bool buf_positive;
bool buf_negative;
- unsigned int ain;
unsigned int vref_mv;
unsigned int pga_bits;
unsigned int odr;
+ unsigned int odr_sel_bits;
unsigned int filter_type;
};
+struct ad7124_channel {
+ unsigned int nr;
+ struct ad7124_channel_config cfg;
+ unsigned int ain;
+ unsigned int slot;
+};
+
struct ad7124_state {
const struct ad7124_chip_info *chip_info;
struct ad_sigma_delta sd;
- struct ad7124_channel_config *channel_config;
+ struct ad7124_channel *channels;
struct regulator *vref[4];
struct clk *mclk;
unsigned int adc_control;
unsigned int num_channels;
+ struct mutex cfgs_lock; /* lock for configs access */
+ unsigned long cfg_slots_status; /* bitmap with slot status (1 means it is used) */
+ DECLARE_KFIFO(live_cfgs_fifo, struct ad7124_channel_config *, AD7124_MAX_CONFIGS);
};
static const struct iio_chan_spec ad7124_channel_template = {
@@ -238,33 +256,9 @@ static int ad7124_set_mode(struct ad_sigma_delta *sd,
return ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL, 2, st->adc_control);
}
-static int ad7124_set_channel(struct ad_sigma_delta *sd, unsigned int channel)
-{
- struct ad7124_state *st = container_of(sd, struct ad7124_state, sd);
- unsigned int val;
-
- val = st->channel_config[channel].ain | AD7124_CHANNEL_EN(1) |
- AD7124_CHANNEL_SETUP(channel);
-
- return ad_sd_write_reg(&st->sd, AD7124_CHANNEL(channel), 2, val);
-}
-
-static const struct ad_sigma_delta_info ad7124_sigma_delta_info = {
- .set_channel = ad7124_set_channel,
- .set_mode = ad7124_set_mode,
- .has_registers = true,
- .addr_shift = 0,
- .read_mask = BIT(6),
- .data_reg = AD7124_DATA,
- .irq_flags = IRQF_TRIGGER_FALLING,
-};
-
-static int ad7124_set_channel_odr(struct ad7124_state *st,
- unsigned int channel,
- unsigned int odr)
+static void ad7124_set_channel_odr(struct ad7124_state *st, unsigned int channel, unsigned int odr)
{
unsigned int fclk, odr_sel_bits;
- int ret;
fclk = clk_get_rate(st->mclk);
/*
@@ -280,36 +274,12 @@ static int ad7124_set_channel_odr(struct ad7124_state *st,
else if (odr_sel_bits > 2047)
odr_sel_bits = 2047;
- ret = ad7124_spi_write_mask(st, AD7124_FILTER(channel),
- AD7124_FILTER_FS_MSK,
- AD7124_FILTER_FS(odr_sel_bits), 3);
- if (ret < 0)
- return ret;
- /* fADC = fCLK / (FS[10:0] x 32) */
- st->channel_config[channel].odr =
- DIV_ROUND_CLOSEST(fclk, odr_sel_bits * 32);
-
- return 0;
-}
-
-static int ad7124_set_channel_gain(struct ad7124_state *st,
- unsigned int channel,
- unsigned int gain)
-{
- unsigned int res;
- int ret;
+ if (odr_sel_bits != st->channels[channel].cfg.odr_sel_bits)
+ st->channels[channel].cfg.live = false;
- res = ad7124_find_closest_match(ad7124_gain,
- ARRAY_SIZE(ad7124_gain), gain);
- ret = ad7124_spi_write_mask(st, AD7124_CONFIG(channel),
- AD7124_CONFIG_PGA_MSK,
- AD7124_CONFIG_PGA(res), 2);
- if (ret < 0)
- return ret;
-
- st->channel_config[channel].pga_bits = res;
-
- return 0;
+ /* fADC = fCLK / (FS[10:0] x 32) */
+ st->channels[channel].cfg.odr = DIV_ROUND_CLOSEST(fclk, odr_sel_bits * 32);
+ st->channels[channel].cfg.odr_sel_bits = odr_sel_bits;
}
static int ad7124_get_3db_filter_freq(struct ad7124_state *st,
@@ -317,9 +287,9 @@ static int ad7124_get_3db_filter_freq(struct ad7124_state *st,
{
unsigned int fadc;
- fadc = st->channel_config[channel].odr;
+ fadc = st->channels[channel].cfg.odr;
- switch (st->channel_config[channel].filter_type) {
+ switch (st->channels[channel].cfg.filter_type) {
case AD7124_SINC3_FILTER:
return DIV_ROUND_CLOSEST(fadc * 230, 1000);
case AD7124_SINC4_FILTER:
@@ -329,9 +299,8 @@ static int ad7124_get_3db_filter_freq(struct ad7124_state *st,
}
}
-static int ad7124_set_3db_filter_freq(struct ad7124_state *st,
- unsigned int channel,
- unsigned int freq)
+static void ad7124_set_3db_filter_freq(struct ad7124_state *st, unsigned int channel,
+ unsigned int freq)
{
unsigned int sinc4_3db_odr;
unsigned int sinc3_3db_odr;
@@ -349,21 +318,211 @@ static int ad7124_set_3db_filter_freq(struct ad7124_state *st,
new_odr = sinc3_3db_odr;
}
- if (st->channel_config[channel].filter_type != new_filter) {
- int ret;
+ if (new_odr != st->channels[channel].cfg.odr)
+ st->channels[channel].cfg.live = false;
- st->channel_config[channel].filter_type = new_filter;
- ret = ad7124_spi_write_mask(st, AD7124_FILTER(channel),
- AD7124_FILTER_TYPE_MSK,
- AD7124_FILTER_TYPE_SEL(new_filter),
- 3);
- if (ret < 0)
- return ret;
+ st->channels[channel].cfg.filter_type = new_filter;
+ st->channels[channel].cfg.odr = new_odr;
+}
+
+static struct ad7124_channel_config *ad7124_find_similar_live_cfg(struct ad7124_state *st,
+ struct ad7124_channel_config *cfg)
+{
+ struct ad7124_channel_config *cfg_aux;
+ ptrdiff_t cmp_size;
+ int i;
+
+ cmp_size = (u8 *)&cfg->live - (u8 *)cfg;
+ for (i = 0; i < st->num_channels; i++) {
+ cfg_aux = &st->channels[i].cfg;
+
+ if (cfg_aux->live && !memcmp(cfg, cfg_aux, cmp_size))
+ return cfg_aux;
+ }
+
+ return NULL;
+}
+
+static int ad7124_find_free_config_slot(struct ad7124_state *st)
+{
+ unsigned int free_cfg_slot;
+
+ free_cfg_slot = find_next_zero_bit(&st->cfg_slots_status, AD7124_MAX_CONFIGS, 0);
+ if (free_cfg_slot == AD7124_MAX_CONFIGS)
+ return -1;
+
+ return free_cfg_slot;
+}
+
+static int ad7124_init_config_vref(struct ad7124_state *st, struct ad7124_channel_config *cfg)
+{
+ unsigned int refsel = cfg->refsel;
+
+ switch (refsel) {
+ case AD7124_REFIN1:
+ case AD7124_REFIN2:
+ case AD7124_AVDD_REF:
+ if (IS_ERR(st->vref[refsel])) {
+ dev_err(&st->sd.spi->dev,
+ "Error, trying to use external voltage reference without a %s regulator.\n",
+ ad7124_ref_names[refsel]);
+ return PTR_ERR(st->vref[refsel]);
+ }
+ cfg->vref_mv = regulator_get_voltage(st->vref[refsel]);
+ /* Conversion from uV to mV */
+ cfg->vref_mv /= 1000;
+ return 0;
+ case AD7124_INT_REF:
+ cfg->vref_mv = 2500;
+ st->adc_control &= ~AD7124_ADC_CTRL_REF_EN_MSK;
+ st->adc_control |= AD7124_ADC_CTRL_REF_EN(1);
+ return ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL,
+ 2, st->adc_control);
+ default:
+ dev_err(&st->sd.spi->dev, "Invalid reference %d\n", refsel);
+ return -EINVAL;
+ }
+}
+
+static int ad7124_write_config(struct ad7124_state *st, struct ad7124_channel_config *cfg,
+ unsigned int cfg_slot)
+{
+ unsigned int tmp;
+ unsigned int val;
+ int ret;
+
+ cfg->cfg_slot = cfg_slot;
+
+ tmp = (cfg->buf_positive << 1) + cfg->buf_negative;
+ val = AD7124_CONFIG_BIPOLAR(cfg->bipolar) | AD7124_CONFIG_REF_SEL(cfg->refsel) |
+ AD7124_CONFIG_IN_BUFF(tmp);
+ ret = ad_sd_write_reg(&st->sd, AD7124_CONFIG(cfg->cfg_slot), 2, val);
+ if (ret < 0)
+ return ret;
+
+ tmp = AD7124_FILTER_TYPE_SEL(cfg->filter_type);
+ ret = ad7124_spi_write_mask(st, AD7124_FILTER(cfg->cfg_slot), AD7124_FILTER_TYPE_MSK,
+ tmp, 3);
+ if (ret < 0)
+ return ret;
+
+ ret = ad7124_spi_write_mask(st, AD7124_FILTER(cfg->cfg_slot), AD7124_FILTER_FS_MSK,
+ AD7124_FILTER_FS(cfg->odr_sel_bits), 3);
+ if (ret < 0)
+ return ret;
+
+ return ad7124_spi_write_mask(st, AD7124_CONFIG(cfg->cfg_slot), AD7124_CONFIG_PGA_MSK,
+ AD7124_CONFIG_PGA(cfg->pga_bits), 2);
+}
+
+static struct ad7124_channel_config *ad7124_pop_config(struct ad7124_state *st)
+{
+ struct ad7124_channel_config *lru_cfg;
+ struct ad7124_channel_config *cfg;
+ int ret;
+ int i;
+
+ /*
+ * Pop least recently used config from the fifo
+ * in order to make room for the new one
+ */
+ ret = kfifo_get(&st->live_cfgs_fifo, &lru_cfg);
+ if (ret <= 0)
+ return NULL;
+
+ lru_cfg->live = false;
+
+ /* mark slot as free */
+ assign_bit(lru_cfg->cfg_slot, &st->cfg_slots_status, 0);
+
+ /* invalidate all other configs that pointed to this one */
+ for (i = 0; i < st->num_channels; i++) {
+ cfg = &st->channels[i].cfg;
+
+ if (cfg->cfg_slot == lru_cfg->cfg_slot)
+ cfg->live = false;
+ }
+
+ return lru_cfg;
+}
+
+static int ad7124_push_config(struct ad7124_state *st, struct ad7124_channel_config *cfg)
+{
+ struct ad7124_channel_config *lru_cfg;
+ int free_cfg_slot;
+
+ free_cfg_slot = ad7124_find_free_config_slot(st);
+ if (free_cfg_slot >= 0) {
+ /* push the new config in configs queue */
+ kfifo_put(&st->live_cfgs_fifo, cfg);
+ } else {
+ /* pop one config to make room for the new one */
+ lru_cfg = ad7124_pop_config(st);
+ if (!lru_cfg)
+ return -EINVAL;
+
+ /* push the new config in configs queue */
+ free_cfg_slot = lru_cfg->cfg_slot;
+ kfifo_put(&st->live_cfgs_fifo, cfg);
+ }
+
+ /* mark slot as used */
+ assign_bit(free_cfg_slot, &st->cfg_slots_status, 1);
+
+ return ad7124_write_config(st, cfg, free_cfg_slot);
+}
+
+static int ad7124_enable_channel(struct ad7124_state *st, struct ad7124_channel *ch)
+{
+ ch->cfg.live = true;
+ return ad_sd_write_reg(&st->sd, AD7124_CHANNEL(ch->nr), 2, ch->ain |
+ AD7124_CHANNEL_SETUP(ch->cfg.cfg_slot) | AD7124_CHANNEL_EN(1));
+}
+
+static int ad7124_prepare_read(struct ad7124_state *st, int address)
+{
+ struct ad7124_channel_config *cfg = &st->channels[address].cfg;
+ struct ad7124_channel_config *live_cfg;
+
+ /*
+ * Before doing any reads assign the channel a configuration.
+ * Check if channel's config is on the device
+ */
+ if (!cfg->live) {
+ /* check if config matches another one */
+ live_cfg = ad7124_find_similar_live_cfg(st, cfg);
+ if (!live_cfg)
+ ad7124_push_config(st, cfg);
+ else
+ cfg->cfg_slot = live_cfg->cfg_slot;
}
- return ad7124_set_channel_odr(st, channel, new_odr);
+ /* point channel to the config slot and enable */
+ return ad7124_enable_channel(st, &st->channels[address]);
}
+static int ad7124_set_channel(struct ad_sigma_delta *sd, unsigned int channel)
+{
+ struct ad7124_state *st = container_of(sd, struct ad7124_state, sd);
+ int ret;
+
+ mutex_lock(&st->cfgs_lock);
+ ret = ad7124_prepare_read(st, channel);
+ mutex_unlock(&st->cfgs_lock);
+
+ return ret;
+}
+
+static const struct ad_sigma_delta_info ad7124_sigma_delta_info = {
+ .set_channel = ad7124_set_channel,
+ .set_mode = ad7124_set_mode,
+ .has_registers = true,
+ .addr_shift = 0,
+ .read_mask = BIT(6),
+ .data_reg = AD7124_DATA,
+ .irq_flags = IRQF_TRIGGER_FALLING
+};
+
static int ad7124_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long info)
@@ -378,36 +537,44 @@ static int ad7124_read_raw(struct iio_dev *indio_dev,
return ret;
/* After the conversion is performed, disable the channel */
- ret = ad_sd_write_reg(&st->sd,
- AD7124_CHANNEL(chan->address), 2,
- st->channel_config[chan->address].ain |
- AD7124_CHANNEL_EN(0));
+ ret = ad_sd_write_reg(&st->sd, AD7124_CHANNEL(chan->address), 2,
+ st->channels[chan->address].ain | AD7124_CHANNEL_EN(0));
if (ret < 0)
return ret;
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
- idx = st->channel_config[chan->address].pga_bits;
- *val = st->channel_config[chan->address].vref_mv;
- if (st->channel_config[chan->address].bipolar)
+ mutex_lock(&st->cfgs_lock);
+
+ idx = st->channels[chan->address].cfg.pga_bits;
+ *val = st->channels[chan->address].cfg.vref_mv;
+ if (st->channels[chan->address].cfg.bipolar)
*val2 = chan->scan_type.realbits - 1 + idx;
else
*val2 = chan->scan_type.realbits + idx;
+ mutex_unlock(&st->cfgs_lock);
return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_OFFSET:
- if (st->channel_config[chan->address].bipolar)
+ mutex_lock(&st->cfgs_lock);
+ if (st->channels[chan->address].cfg.bipolar)
*val = -(1 << (chan->scan_type.realbits - 1));
else
*val = 0;
+ mutex_unlock(&st->cfgs_lock);
return IIO_VAL_INT;
case IIO_CHAN_INFO_SAMP_FREQ:
- *val = st->channel_config[chan->address].odr;
+ mutex_lock(&st->cfgs_lock);
+ *val = st->channels[chan->address].cfg.odr;
+ mutex_unlock(&st->cfgs_lock);
return IIO_VAL_INT;
case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
+ mutex_lock(&st->cfgs_lock);
*val = ad7124_get_3db_filter_freq(st, chan->scan_index);
+ mutex_unlock(&st->cfgs_lock);
+
return IIO_VAL_INT;
default:
return -EINVAL;
@@ -420,35 +587,54 @@ static int ad7124_write_raw(struct iio_dev *indio_dev,
{
struct ad7124_state *st = iio_priv(indio_dev);
unsigned int res, gain, full_scale, vref;
+ int ret = 0;
+
+ mutex_lock(&st->cfgs_lock);
switch (info) {
case IIO_CHAN_INFO_SAMP_FREQ:
- if (val2 != 0)
- return -EINVAL;
+ if (val2 != 0) {
+ ret = -EINVAL;
+ break;
+ }
- return ad7124_set_channel_odr(st, chan->address, val);
+ ad7124_set_channel_odr(st, chan->address, val);
+ break;
case IIO_CHAN_INFO_SCALE:
- if (val != 0)
- return -EINVAL;
+ if (val != 0) {
+ ret = -EINVAL;
+ break;
+ }
- if (st->channel_config[chan->address].bipolar)
+ if (st->channels[chan->address].cfg.bipolar)
full_scale = 1 << (chan->scan_type.realbits - 1);
else
full_scale = 1 << chan->scan_type.realbits;
- vref = st->channel_config[chan->address].vref_mv * 1000000LL;
+ vref = st->channels[chan->address].cfg.vref_mv * 1000000LL;
res = DIV_ROUND_CLOSEST(vref, full_scale);
gain = DIV_ROUND_CLOSEST(res, val2);
+ res = ad7124_find_closest_match(ad7124_gain, ARRAY_SIZE(ad7124_gain), gain);
+
+ if (st->channels[chan->address].cfg.pga_bits != res)
+ st->channels[chan->address].cfg.live = false;
- return ad7124_set_channel_gain(st, chan->address, gain);
+ st->channels[chan->address].cfg.pga_bits = res;
+ break;
case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
- if (val2 != 0)
- return -EINVAL;
+ if (val2 != 0) {
+ ret = -EINVAL;
+ break;
+ }
- return ad7124_set_3db_filter_freq(st, chan->address, val);
+ ad7124_set_3db_filter_freq(st, chan->address, val);
+ break;
default:
- return -EINVAL;
+ ret = -EINVAL;
}
+
+ mutex_unlock(&st->cfgs_lock);
+ return ret;
}
static int ad7124_reg_access(struct iio_dev *indio_dev,
@@ -547,47 +733,14 @@ static int ad7124_check_chip_id(struct ad7124_state *st)
return 0;
}
-static int ad7124_init_channel_vref(struct ad7124_state *st,
- unsigned int channel_number)
-{
- unsigned int refsel = st->channel_config[channel_number].refsel;
-
- switch (refsel) {
- case AD7124_REFIN1:
- case AD7124_REFIN2:
- case AD7124_AVDD_REF:
- if (IS_ERR(st->vref[refsel])) {
- dev_err(&st->sd.spi->dev,
- "Error, trying to use external voltage reference without a %s regulator.\n",
- ad7124_ref_names[refsel]);
- return PTR_ERR(st->vref[refsel]);
- }
- st->channel_config[channel_number].vref_mv =
- regulator_get_voltage(st->vref[refsel]);
- /* Conversion from uV to mV */
- st->channel_config[channel_number].vref_mv /= 1000;
- break;
- case AD7124_INT_REF:
- st->channel_config[channel_number].vref_mv = 2500;
- st->adc_control &= ~AD7124_ADC_CTRL_REF_EN_MSK;
- st->adc_control |= AD7124_ADC_CTRL_REF_EN(1);
- return ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL,
- 2, st->adc_control);
- default:
- dev_err(&st->sd.spi->dev, "Invalid reference %d\n", refsel);
- return -EINVAL;
- }
-
- return 0;
-}
-
static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
struct device_node *np)
{
struct ad7124_state *st = iio_priv(indio_dev);
+ struct ad7124_channel_config *cfg;
+ struct ad7124_channel *channels;
struct device_node *child;
struct iio_chan_spec *chan;
- struct ad7124_channel_config *chan_config;
unsigned int ain[2], channel = 0, tmp;
int ret;
@@ -602,16 +755,18 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
if (!chan)
return -ENOMEM;
- chan_config = devm_kcalloc(indio_dev->dev.parent, st->num_channels,
- sizeof(*chan_config), GFP_KERNEL);
- if (!chan_config)
+ channels = devm_kcalloc(indio_dev->dev.parent, st->num_channels, sizeof(*channels),
+ GFP_KERNEL);
+ if (!channels)
return -ENOMEM;
indio_dev->channels = chan;
indio_dev->num_channels = st->num_channels;
- st->channel_config = chan_config;
+ st->channels = channels;
for_each_available_child_of_node(np, child) {
+ cfg = &st->channels[channel].cfg;
+
ret = of_property_read_u32(child, "reg", &channel);
if (ret)
goto err;
@@ -621,21 +776,20 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
if (ret)
goto err;
- st->channel_config[channel].ain = AD7124_CHANNEL_AINP(ain[0]) |
+ st->channels[channel].nr = channel;
+ st->channels[channel].ain = AD7124_CHANNEL_AINP(ain[0]) |
AD7124_CHANNEL_AINM(ain[1]);
- st->channel_config[channel].bipolar =
- of_property_read_bool(child, "bipolar");
+
+ cfg->bipolar = of_property_read_bool(child, "bipolar");
ret = of_property_read_u32(child, "adi,reference-select", &tmp);
if (ret)
- st->channel_config[channel].refsel = AD7124_INT_REF;
+ cfg->refsel = AD7124_INT_REF;
else
- st->channel_config[channel].refsel = tmp;
+ cfg->refsel = tmp;
- st->channel_config[channel].buf_positive =
- of_property_read_bool(child, "adi,buffered-positive");
- st->channel_config[channel].buf_negative =
- of_property_read_bool(child, "adi,buffered-negative");
+ cfg->buf_positive = of_property_read_bool(child, "adi,buffered-positive");
+ cfg->buf_negative = of_property_read_bool(child, "adi,buffered-negative");
chan[channel] = ad7124_channel_template;
chan[channel].address = channel;
@@ -653,8 +807,8 @@ err:
static int ad7124_setup(struct ad7124_state *st)
{
- unsigned int val, fclk, power_mode;
- int i, ret, tmp;
+ unsigned int fclk, power_mode;
+ int i, ret;
fclk = clk_get_rate(st->mclk);
if (!fclk)
@@ -677,31 +831,20 @@ static int ad7124_setup(struct ad7124_state *st)
if (ret < 0)
return ret;
+ mutex_init(&st->cfgs_lock);
+ INIT_KFIFO(st->live_cfgs_fifo);
for (i = 0; i < st->num_channels; i++) {
- val = st->channel_config[i].ain | AD7124_CHANNEL_SETUP(i);
- ret = ad_sd_write_reg(&st->sd, AD7124_CHANNEL(i), 2, val);
- if (ret < 0)
- return ret;
- ret = ad7124_init_channel_vref(st, i);
+ ret = ad7124_init_config_vref(st, &st->channels[i].cfg);
if (ret < 0)
return ret;
- tmp = (st->channel_config[i].buf_positive << 1) +
- st->channel_config[i].buf_negative;
-
- val = AD7124_CONFIG_BIPOLAR(st->channel_config[i].bipolar) |
- AD7124_CONFIG_REF_SEL(st->channel_config[i].refsel) |
- AD7124_CONFIG_IN_BUFF(tmp);
- ret = ad_sd_write_reg(&st->sd, AD7124_CONFIG(i), 2, val);
- if (ret < 0)
- return ret;
/*
* 9.38 SPS is the minimum output data rate supported
* regardless of the selected power mode. Round it up to 10 and
- * set all the enabled channels to this default value.
+ * set all channels to this default value.
*/
- ret = ad7124_set_channel_odr(st, i, 10);
+ ad7124_set_channel_odr(st, i, 10);
}
return ret;
diff --git a/drivers/iio/adc/ad7292.c b/drivers/iio/adc/ad7292.c
index 70e33dd1c9f7..3271a31afde1 100644
--- a/drivers/iio/adc/ad7292.c
+++ b/drivers/iio/adc/ad7292.c
@@ -260,7 +260,7 @@ static int ad7292_probe(struct spi_device *spi)
struct ad7292_state *st;
struct iio_dev *indio_dev;
struct device_node *child;
- bool diff_channels = 0;
+ bool diff_channels = false;
int ret;
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c
index 689ecd5dd563..d2163cb62f4f 100644
--- a/drivers/iio/adc/ad7298.c
+++ b/drivers/iio/adc/ad7298.c
@@ -142,12 +142,6 @@ static int ad7298_update_scan_mode(struct iio_dev *indio_dev,
return 0;
}
-/*
- * ad7298_trigger_handler() bh of trigger launched polling to ring buffer
- *
- * Currently there is no option in this driver to disable the saving of
- * timestamps within the ring.
- */
static irqreturn_t ad7298_trigger_handler(int irq, void *p)
{
struct iio_poll_func *pf = p;
diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
index 17402714b387..9e9ff07cf972 100644
--- a/drivers/iio/adc/ad7476.c
+++ b/drivers/iio/adc/ad7476.c
@@ -321,25 +321,15 @@ static int ad7476_probe(struct spi_device *spi)
spi_message_init(&st->msg);
spi_message_add_tail(&st->xfer, &st->msg);
- ret = iio_triggered_buffer_setup(indio_dev, NULL,
- &ad7476_trigger_handler, NULL);
+ ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL,
+ &ad7476_trigger_handler, NULL);
if (ret)
- goto error_disable_reg;
+ return ret;
if (st->chip_info->reset)
st->chip_info->reset(st);
- ret = iio_device_register(indio_dev);
- if (ret)
- goto error_ring_unregister;
- return 0;
-
-error_ring_unregister:
- iio_triggered_buffer_cleanup(indio_dev);
-error_disable_reg:
- regulator_disable(st->reg);
-
- return ret;
+ return devm_iio_device_register(&spi->dev, indio_dev);
}
static const struct spi_device_id ad7476_id[] = {
diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index ee7b108688b3..0af0bb4d5a7f 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -668,7 +668,6 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
return -ENOMEM;
st->trig->ops = &ad7606_trigger_ops;
- st->trig->dev.parent = dev;
iio_trigger_set_drvdata(st->trig, indio_dev);
ret = devm_iio_trigger_register(dev, st->trig);
if (ret)
diff --git a/drivers/iio/adc/ad7766.c b/drivers/iio/adc/ad7766.c
index b6b6765be7b4..1e41759f3ee5 100644
--- a/drivers/iio/adc/ad7766.c
+++ b/drivers/iio/adc/ad7766.c
@@ -253,21 +253,19 @@ static int ad7766_probe(struct spi_device *spi)
return -ENOMEM;
ad7766->trig->ops = &ad7766_trigger_ops;
- ad7766->trig->dev.parent = &spi->dev;
iio_trigger_set_drvdata(ad7766->trig, ad7766);
- ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq,
- IRQF_TRIGGER_FALLING, dev_name(&spi->dev),
- ad7766->trig);
- if (ret < 0)
- return ret;
-
/*
* The device generates interrupts as long as it is powered up.
* Some platforms might not allow the option to power it down so
- * disable the interrupt to avoid extra load on the system
+ * don't enable the interrupt to avoid extra load on the system
*/
- disable_irq(spi->irq);
+ ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq,
+ IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN,
+ dev_name(&spi->dev),
+ ad7766->trig);
+ if (ret < 0)
+ return ret;
ret = devm_iio_trigger_register(&spi->dev, ad7766->trig);
if (ret)
diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
index 5c0cbee03230..c945f1349623 100644
--- a/drivers/iio/adc/ad7768-1.c
+++ b/drivers/iio/adc/ad7768-1.c
@@ -631,7 +631,6 @@ static int ad7768_probe(struct spi_device *spi)
return -ENOMEM;
st->trig->ops = &ad7768_trigger_ops;
- st->trig->dev.parent = &spi->dev;
iio_trigger_set_drvdata(st->trig, indio_dev);
ret = devm_iio_trigger_register(&spi->dev, st->trig);
if (ret)
diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
index 4f6f0e0e03ee..9b3cbe1ddc6f 100644
--- a/drivers/iio/adc/ad7887.c
+++ b/drivers/iio/adc/ad7887.c
@@ -109,12 +109,6 @@ static int ad7887_ring_postdisable(struct iio_dev *indio_dev)
return spi_sync(st->spi, &st->msg[AD7887_CH0]);
}
-/*
- * ad7887_trigger_handler() bh of trigger launched polling to ring buffer
- *
- * Currently there is no option in this driver to disable the saving of
- * timestamps within the ring.
- **/
static irqreturn_t ad7887_trigger_handler(int irq, void *p)
{
struct iio_poll_func *pf = p;
diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index a2cc96658054..9a649745cd0a 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -192,12 +192,6 @@ static int ad7923_update_scan_mode(struct iio_dev *indio_dev,
return 0;
}
-/*
- * ad7923_trigger_handler() bh of trigger launched polling to ring buffer
- *
- * Currently there is no option in this driver to disable the saving of
- * timestamps within the ring.
- */
static irqreturn_t ad7923_trigger_handler(int irq, void *p)
{
struct iio_poll_func *pf = p;
@@ -293,6 +287,13 @@ static const struct iio_info ad7923_info = {
.update_scan_mode = ad7923_update_scan_mode,
};
+static void ad7923_regulator_disable(void *data)
+{
+ struct ad7923_state *st = data;
+
+ regulator_disable(st->reg);
+}
+
static int ad7923_probe(struct spi_device *spi)
{
struct ad7923_state *st;
@@ -306,8 +307,6 @@ static int ad7923_probe(struct spi_device *spi)
st = iio_priv(indio_dev);
- spi_set_drvdata(spi, indio_dev);
-
st->spi = spi;
st->settings = AD7923_CODING | AD7923_RANGE |
AD7923_PM_MODE_WRITE(AD7923_PM_MODE_OPS);
@@ -340,35 +339,16 @@ static int ad7923_probe(struct spi_device *spi)
if (ret)
return ret;
- ret = iio_triggered_buffer_setup(indio_dev, NULL,
- &ad7923_trigger_handler, NULL);
+ ret = devm_add_action_or_reset(&spi->dev, ad7923_regulator_disable, st);
if (ret)
- goto error_disable_reg;
+ return ret;
- ret = iio_device_register(indio_dev);
+ ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL,
+ &ad7923_trigger_handler, NULL);
if (ret)
- goto error_cleanup_ring;
-
- return 0;
-
-error_cleanup_ring:
- iio_triggered_buffer_cleanup(indio_dev);
-error_disable_reg:
- regulator_disable(st->reg);
-
- return ret;
-}
-
-static int ad7923_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ad7923_state *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
- iio_triggered_buffer_cleanup(indio_dev);
- regulator_disable(st->reg);
+ return ret;
- return 0;
+ return devm_iio_device_register(&spi->dev, indio_dev);
}
static const struct spi_device_id ad7923_id[] = {
@@ -401,7 +381,6 @@ static struct spi_driver ad7923_driver = {
.of_match_table = ad7923_of_match,
},
.probe = ad7923_probe,
- .remove = ad7923_remove,
.id_table = ad7923_id,
};
module_spi_driver(ad7923_driver);
diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
index 1575b7670207..18bf8386d50a 100644
--- a/drivers/iio/adc/ad799x.c
+++ b/drivers/iio/adc/ad799x.c
@@ -182,12 +182,6 @@ static int ad799x_update_config(struct ad799x_state *st, u16 config)
return 0;
}
-/*
- * ad799x_trigger_handler() bh of trigger launched polling to ring buffer
- *
- * Currently there is no option in this driver to disable the saving of
- * timestamps within the ring.
- **/
static irqreturn_t ad799x_trigger_handler(int irq, void *p)
{
struct iio_poll_func *pf = p;
diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
index 3a6f239d4acc..e777ec718973 100644
--- a/drivers/iio/adc/ad_sigma_delta.c
+++ b/drivers/iio/adc/ad_sigma_delta.c
@@ -475,8 +475,9 @@ static int ad_sd_probe_trigger(struct iio_dev *indio_dev)
struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev);
int ret;
- sigma_delta->trig = iio_trigger_alloc("%s-dev%d", indio_dev->name,
- indio_dev->id);
+ sigma_delta->trig = iio_trigger_alloc(&sigma_delta->spi->dev,
+ "%s-dev%d", indio_dev->name,
+ indio_dev->id);
if (sigma_delta->trig == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -484,19 +485,15 @@ static int ad_sd_probe_trigger(struct iio_dev *indio_dev)
sigma_delta->trig->ops = &ad_sd_trigger_ops;
init_completion(&sigma_delta->completion);
+ sigma_delta->irq_dis = true;
ret = request_irq(sigma_delta->spi->irq,
ad_sd_data_rdy_trig_poll,
- sigma_delta->info->irq_flags,
+ sigma_delta->info->irq_flags | IRQF_NO_AUTOEN,
indio_dev->name,
sigma_delta);
if (ret)
goto error_free_trig;
- if (!sigma_delta->irq_dis) {
- sigma_delta->irq_dis = true;
- disable_irq_nosync(sigma_delta->spi->irq);
- }
- sigma_delta->trig->dev.parent = &sigma_delta->spi->dev;
iio_trigger_set_drvdata(sigma_delta->trig, sigma_delta);
ret = iio_trigger_register(sigma_delta->trig);
diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
index 9109da2d2e15..d5f6ffc5b5bc 100644
--- a/drivers/iio/adc/adi-axi-adc.c
+++ b/drivers/iio/adc/adi-axi-adc.c
@@ -23,7 +23,7 @@
#include <linux/fpga/adi-axi-common.h>
#include <linux/iio/adc/adi-axi-adc.h>
-/**
+/*
* Register definitions:
* https://wiki.analog.com/resources/fpga/docs/axi_adc_ip#register_map
*/
@@ -104,7 +104,6 @@ static unsigned int adi_axi_adc_read(struct adi_axi_adc_state *st,
static int adi_axi_adc_config_dma_buffer(struct device *dev,
struct iio_dev *indio_dev)
{
- struct iio_buffer *buffer;
const char *dma_name;
if (!device_property_present(dev, "dmas"))
@@ -113,15 +112,8 @@ static int adi_axi_adc_config_dma_buffer(struct device *dev,
if (device_property_read_string(dev, "dma-names", &dma_name))
dma_name = "rx";
- buffer = devm_iio_dmaengine_buffer_alloc(indio_dev->dev.parent,
- dma_name);
- if (IS_ERR(buffer))
- return PTR_ERR(buffer);
-
- indio_dev->modes |= INDIO_BUFFER_HARDWARE;
- iio_device_attach_buffer(indio_dev, buffer);
-
- return 0;
+ return devm_iio_dmaengine_buffer_setup(indio_dev->dev.parent,
+ indio_dev, dma_name);
}
static int adi_axi_adc_read_raw(struct iio_dev *indio_dev,
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 70750abb5dea..0b5f0c91d0d7 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -625,12 +625,11 @@ static struct iio_trigger *at91_adc_allocate_trigger(struct iio_dev *idev,
struct iio_trigger *trig;
int ret;
- trig = iio_trigger_alloc("%s-dev%d-%s", idev->name,
+ trig = iio_trigger_alloc(idev->dev.parent, "%s-dev%d-%s", idev->name,
idev->id, trigger->name);
if (trig == NULL)
return NULL;
- trig->dev.parent = idev->dev.parent;
iio_trigger_set_drvdata(trig, idev);
trig->ops = &at91_adc_trigger_ops;
diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c
index f19c9aa93f17..40e59f4c95bc 100644
--- a/drivers/iio/adc/cpcap-adc.c
+++ b/drivers/iio/adc/cpcap-adc.c
@@ -100,7 +100,7 @@ struct cpcap_adc_ato {
};
/**
- * struct cpcap-adc - cpcap adc device driver data
+ * struct cpcap_adc - cpcap adc device driver data
* @reg: cpcap regmap
* @dev: struct device
* @vendor: cpcap vendor
diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index 784c10deeb1a..8c98d8c9ab1f 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -778,9 +778,9 @@ static int exynos_adc_ts_init(struct exynos_adc *info)
return ret;
}
- disable_irq(info->tsirq);
ret = request_threaded_irq(info->tsirq, NULL, exynos_ts_isr,
- IRQF_ONESHOT, "touchscreen", info);
+ IRQF_ONESHOT | IRQF_NO_AUTOEN,
+ "touchscreen", info);
if (ret)
input_unregister_device(info->input);
diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
index b573ec60a8b8..2ae54258b221 100644
--- a/drivers/iio/adc/ina2xx-adc.c
+++ b/drivers/iio/adc/ina2xx-adc.c
@@ -953,7 +953,6 @@ static int ina2xx_probe(struct i2c_client *client,
{
struct ina2xx_chip_info *chip;
struct iio_dev *indio_dev;
- struct iio_buffer *buffer;
unsigned int val;
enum ina2xx_ids type;
int ret;
@@ -1017,7 +1016,7 @@ static int ina2xx_probe(struct i2c_client *client,
return ret;
}
- indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
+ indio_dev->modes = INDIO_DIRECT_MODE;
if (id->driver_data == ina226) {
indio_dev->channels = ina226_channels;
indio_dev->num_channels = ARRAY_SIZE(ina226_channels);
@@ -1028,13 +1027,12 @@ static int ina2xx_probe(struct i2c_client *client,
indio_dev->info = &ina219_info;
}
indio_dev->name = id->name;
- indio_dev->setup_ops = &ina2xx_setup_ops;
- buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
+ ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ &ina2xx_setup_ops);
+ if (ret)
+ return ret;
return iio_device_register(indio_dev);
}
diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c
index ca1dff3924ff..e3c8ec107722 100644
--- a/drivers/iio/adc/max1027.c
+++ b/drivers/iio/adc/max1027.c
@@ -473,7 +473,6 @@ static int max1027_probe(struct spi_device *spi)
}
st->trig->ops = &max1027_trigger_ops;
- st->trig->dev.parent = &spi->dev;
iio_trigger_set_drvdata(st->trig, indio_dev);
ret = devm_iio_trigger_register(&indio_dev->dev,
st->trig);
diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c
index f57db3056fbe..6b39a139ce28 100644
--- a/drivers/iio/adc/mt6360-adc.c
+++ b/drivers/iio/adc/mt6360-adc.c
@@ -9,13 +9,14 @@
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
-#include <linux/unaligned/be_byteshift.h>
#include <linux/iio/buffer.h>
#include <linux/iio/iio.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
+#include <asm/unaligned.h>
+
#define MT6360_REG_PMUCHGCTRL3 0x313
#define MT6360_REG_PMUADCCFG 0x356
#define MT6360_REG_PMUADCIDLET 0x358
diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c
index 07c85434b568..bb70b51d25b1 100644
--- a/drivers/iio/adc/nau7802.c
+++ b/drivers/iio/adc/nau7802.c
@@ -498,7 +498,8 @@ static int nau7802_probe(struct i2c_client *client,
ret = request_threaded_irq(client->irq,
NULL,
nau7802_eoc_trigger,
- IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+ IRQF_TRIGGER_HIGH | IRQF_ONESHOT |
+ IRQF_NO_AUTOEN,
client->dev.driver->name,
indio_dev);
if (ret) {
@@ -513,8 +514,7 @@ static int nau7802_probe(struct i2c_client *client,
dev_info(&client->dev,
"Failed to allocate IRQ, using polling mode\n");
client->irq = 0;
- } else
- disable_irq(client->irq);
+ }
}
if (!client->irq) {
diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c
index d9d105920001..f7bc0bb7f112 100644
--- a/drivers/iio/adc/npcm_adc.c
+++ b/drivers/iio/adc/npcm_adc.c
@@ -25,6 +25,15 @@ struct npcm_adc {
wait_queue_head_t wq;
struct regulator *vref;
struct reset_control *reset;
+ /*
+ * Lock to protect the device state during a potential concurrent
+ * read access from userspace. Reading a raw value requires a sequence
+ * of register writes, then a wait for a event and finally a register
+ * read, during which userspace could issue another read request.
+ * This lock protects a read access from ocurring before another one
+ * has finished.
+ */
+ struct mutex lock;
};
/* ADC registers */
@@ -135,9 +144,9 @@ static int npcm_adc_read_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_RAW:
- mutex_lock(&indio_dev->mlock);
+ mutex_lock(&info->lock);
ret = npcm_adc_read(info, val, chan->channel);
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&info->lock);
if (ret) {
dev_err(info->dev, "NPCM ADC read failed\n");
return ret;
@@ -187,6 +196,8 @@ static int npcm_adc_probe(struct platform_device *pdev)
return -ENOMEM;
info = iio_priv(indio_dev);
+ mutex_init(&info->lock);
+
info->dev = &pdev->dev;
info->regs = devm_platform_ioremap_resource(pdev, 0);
diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
index 889b88768b63..6ef09609be9f 100644
--- a/drivers/iio/adc/palmas_gpadc.c
+++ b/drivers/iio/adc/palmas_gpadc.c
@@ -90,6 +90,12 @@ static struct palmas_gpadc_info palmas_gpadc_info[] = {
* 3: 800 uA
* @extended_delay: enable the gpadc extended delay mode
* @auto_conversion_period: define the auto_conversion_period
+ * @lock: Lock to protect the device state during a potential concurrent
+ * read access from userspace. Reading a raw value requires a sequence
+ * of register writes, then a wait for a completion callback,
+ * and finally a register read, during which userspace could issue
+ * another read request. This lock protects a read access from
+ * ocurring before another one has finished.
*
* This is the palmas_gpadc structure to store run-time information
* and pointers for this driver instance.
@@ -110,6 +116,7 @@ struct palmas_gpadc {
bool wakeup1_enable;
bool wakeup2_enable;
int auto_conversion_period;
+ struct mutex lock;
};
/*
@@ -388,7 +395,7 @@ static int palmas_gpadc_read_raw(struct iio_dev *indio_dev,
if (adc_chan > PALMAS_ADC_CH_MAX)
return -EINVAL;
- mutex_lock(&indio_dev->mlock);
+ mutex_lock(&adc->lock);
switch (mask) {
case IIO_CHAN_INFO_RAW:
@@ -414,12 +421,12 @@ static int palmas_gpadc_read_raw(struct iio_dev *indio_dev,
goto out;
}
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&adc->lock);
return ret;
out:
palmas_gpadc_read_done(adc, adc_chan);
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&adc->lock);
return ret;
}
@@ -516,8 +523,11 @@ static int palmas_gpadc_probe(struct platform_device *pdev)
adc->dev = &pdev->dev;
adc->palmas = dev_get_drvdata(pdev->dev.parent);
adc->adc_info = palmas_gpadc_info;
+
+ mutex_init(&adc->lock);
+
init_completion(&adc->conv_completion);
- dev_set_drvdata(&pdev->dev, indio_dev);
+ platform_set_drvdata(pdev, indio_dev);
adc->auto_conversion_period = gpadc_pdata->auto_conversion_period_ms;
adc->irq = palmas_irq_get_virq(adc->palmas, PALMAS_GPADC_EOC_SW_IRQ);
diff --git a/drivers/iio/adc/spear_adc.c b/drivers/iio/adc/spear_adc.c
index 1bc986a7009d..d93e580b3dc5 100644
--- a/drivers/iio/adc/spear_adc.c
+++ b/drivers/iio/adc/spear_adc.c
@@ -75,6 +75,15 @@ struct spear_adc_state {
struct adc_regs_spear6xx __iomem *adc_base_spear6xx;
struct clk *clk;
struct completion completion;
+ /*
+ * Lock to protect the device state during a potential concurrent
+ * read access from userspace. Reading a raw value requires a sequence
+ * of register writes, then a wait for a completion callback,
+ * and finally a register read, during which userspace could issue
+ * another read request. This lock protects a read access from
+ * ocurring before another one has finished.
+ */
+ struct mutex lock;
u32 current_clk;
u32 sampling_freq;
u32 avg_samples;
@@ -146,7 +155,7 @@ static int spear_adc_read_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_RAW:
- mutex_lock(&indio_dev->mlock);
+ mutex_lock(&st->lock);
status = SPEAR_ADC_STATUS_CHANNEL_NUM(chan->channel) |
SPEAR_ADC_STATUS_AVG_SAMPLE(st->avg_samples) |
@@ -159,7 +168,7 @@ static int spear_adc_read_raw(struct iio_dev *indio_dev,
wait_for_completion(&st->completion); /* set by ISR */
*val = st->value;
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&st->lock);
return IIO_VAL_INT;
@@ -187,7 +196,7 @@ static int spear_adc_write_raw(struct iio_dev *indio_dev,
if (mask != IIO_CHAN_INFO_SAMP_FREQ)
return -EINVAL;
- mutex_lock(&indio_dev->mlock);
+ mutex_lock(&st->lock);
if ((val < SPEAR_ADC_CLK_MIN) ||
(val > SPEAR_ADC_CLK_MAX) ||
@@ -199,7 +208,7 @@ static int spear_adc_write_raw(struct iio_dev *indio_dev,
spear_adc_set_clk(st, val);
out:
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&st->lock);
return ret;
}
@@ -271,6 +280,9 @@ static int spear_adc_probe(struct platform_device *pdev)
}
st = iio_priv(indio_dev);
+
+ mutex_init(&st->lock);
+
st->np = np;
/*
diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index f7c53cea509a..b25386b19373 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -177,7 +177,7 @@ struct stm32_adc_cfg {
* @offset: ADC instance register offset in ADC block
* @cfg: compatible configuration data
* @completion: end of single conversion completion
- * @buffer: data buffer
+ * @buffer: data buffer + 8 bytes for timestamp if enabled
* @clk: clock for this adc instance
* @irq: interrupt for this adc instance
* @lock: spinlock
@@ -200,7 +200,7 @@ struct stm32_adc {
u32 offset;
const struct stm32_adc_cfg *cfg;
struct completion completion;
- u16 buffer[STM32_ADC_MAX_SQ];
+ u16 buffer[STM32_ADC_MAX_SQ + 4] __aligned(8);
struct clk *clk;
int irq;
spinlock_t lock; /* interrupt lock */
@@ -1714,7 +1714,7 @@ static void stm32_adc_chan_init_one(struct iio_dev *indio_dev,
}
}
-static int stm32_adc_chan_of_init(struct iio_dev *indio_dev)
+static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
{
struct device_node *node = indio_dev->dev.of_node;
struct stm32_adc *adc = iio_priv(indio_dev);
@@ -1762,6 +1762,9 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev)
return -EINVAL;
}
+ if (timestamping)
+ num_channels++;
+
channels = devm_kcalloc(&indio_dev->dev, num_channels,
sizeof(struct iio_chan_spec), GFP_KERNEL);
if (!channels)
@@ -1812,6 +1815,19 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev)
stm32_adc_smpr_init(adc, channels[i].channel, smp);
}
+ if (timestamping) {
+ struct iio_chan_spec *timestamp = &channels[scan_index];
+
+ timestamp->type = IIO_TIMESTAMP;
+ timestamp->channel = -1;
+ timestamp->scan_index = scan_index;
+ timestamp->scan_type.sign = 's';
+ timestamp->scan_type.realbits = 64;
+ timestamp->scan_type.storagebits = 64;
+
+ scan_index++;
+ }
+
indio_dev->num_channels = scan_index;
indio_dev->channels = channels;
@@ -1871,6 +1887,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
irqreturn_t (*handler)(int irq, void *p) = NULL;
struct stm32_adc *adc;
+ bool timestamping = false;
int ret;
if (!pdev->dev.of_node)
@@ -1927,16 +1944,22 @@ static int stm32_adc_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
- ret = stm32_adc_chan_of_init(indio_dev);
- if (ret < 0)
- return ret;
-
ret = stm32_adc_dma_request(dev, indio_dev);
if (ret < 0)
return ret;
- if (!adc->dma_chan)
+ if (!adc->dma_chan) {
+ /* For PIO mode only, iio_pollfunc_store_time stores a timestamp
+ * in the primary trigger IRQ handler and stm32_adc_trigger_handler
+ * runs in the IRQ thread to push out buffer along with timestamp.
+ */
handler = &stm32_adc_trigger_handler;
+ timestamping = true;
+ }
+
+ ret = stm32_adc_chan_of_init(indio_dev, timestamping);
+ if (ret < 0)
+ goto err_dma_disable;
ret = iio_triggered_buffer_setup(indio_dev,
&iio_pollfunc_store_time, handler,
diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
index 9234f14167b7..1cfefb3b5e56 100644
--- a/drivers/iio/adc/stm32-dfsdm-adc.c
+++ b/drivers/iio/adc/stm32-dfsdm-adc.c
@@ -198,7 +198,7 @@ static int stm32_dfsdm_compute_osrs(struct stm32_dfsdm_filter *fl,
unsigned int p = fl->ford; /* filter order (ford) */
struct stm32_dfsdm_filter_osr *flo = &fl->flo[fast];
- pr_debug("%s: Requested oversampling: %d\n", __func__, oversamp);
+ pr_debug("Requested oversampling: %d\n", oversamp);
/*
* This function tries to compute filter oversampling and integrator
* oversampling, base on oversampling ratio requested by user.
@@ -295,8 +295,8 @@ static int stm32_dfsdm_compute_osrs(struct stm32_dfsdm_filter *fl,
flo->max = (s32)max;
flo->bits = bits;
- pr_debug("%s: fast %d, fosr %d, iosr %d, res 0x%llx/%d bits, rshift %d, lshift %d\n",
- __func__, fast, flo->fosr, flo->iosr,
+ pr_debug("fast %d, fosr %d, iosr %d, res 0x%llx/%d bits, rshift %d, lshift %d\n",
+ fast, flo->fosr, flo->iosr,
flo->res, bits, flo->rshift,
flo->lshift);
}
@@ -864,7 +864,7 @@ static void stm32_dfsdm_dma_buffer_done(void *data)
* support in IIO.
*/
- dev_dbg(&indio_dev->dev, "%s: pos = %d, available = %d\n", __func__,
+ dev_dbg(&indio_dev->dev, "pos = %d, available = %d\n",
adc->bufi, available);
old_pos = adc->bufi;
@@ -918,7 +918,7 @@ static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev)
if (!adc->dma_chan)
return -EINVAL;
- dev_dbg(&indio_dev->dev, "%s size=%d watermark=%d\n", __func__,
+ dev_dbg(&indio_dev->dev, "size=%d watermark=%d\n",
adc->buf_sz, adc->buf_sz / 2);
if (adc->nconv == 1 && !indio_dev->trig)
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index 99b43f28e879..2d393a4dfff6 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -470,7 +470,8 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
}
*irq = ret;
- ret = devm_request_any_context_irq(&pdev->dev, *irq, handler, 0,
+ ret = devm_request_any_context_irq(&pdev->dev, *irq, handler,
+ IRQF_NO_AUTOEN,
devname, info);
if (ret < 0) {
dev_err(&pdev->dev, "could not request %s interrupt: %d\n",
@@ -478,7 +479,6 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
return ret;
}
- disable_irq(*irq);
atomic_set(atomic, 0);
return 0;
diff --git a/drivers/iio/adc/ti-adc084s021.c b/drivers/iio/adc/ti-adc084s021.c
index fb14b92fa6e7..33aea961d850 100644
--- a/drivers/iio/adc/ti-adc084s021.c
+++ b/drivers/iio/adc/ti-adc084s021.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
* Copyright (C) 2017 Axis Communications AB
*
* Driver for Texas Instruments' ADC084S021 ADC chip.
@@ -65,7 +65,7 @@ static const struct iio_chan_spec adc084s021_channels[] = {
};
/**
- * Read an ADC channel and return its value.
+ * adc084s021_adc_conversion() - Read an ADC channel and return its value.
*
* @adc: The ADC SPI data.
* @data: Buffer for converted data.
@@ -136,7 +136,7 @@ static int adc084s021_read_raw(struct iio_dev *indio_dev,
}
/**
- * Read enabled ADC channels and push data to the buffer.
+ * adc084s021_buffer_trigger_handler() - Read ADC channels and push to buffer.
*
* @irq: The interrupt number (not used).
* @pollfunc: Pointer to the poll func.
diff --git a/drivers/iio/adc/ti-ads131e08.c b/drivers/iio/adc/ti-ads131e08.c
new file mode 100644
index 000000000000..0060d5f0abb0
--- /dev/null
+++ b/drivers/iio/adc/ti-ads131e08.c
@@ -0,0 +1,948 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Texas Instruments ADS131E0x 4-, 6- and 8-Channel ADCs
+ *
+ * Copyright (c) 2020 AVL DiTEST GmbH
+ * Tomislav Denis <tomislav.denis@avl.com>
+ *
+ * Datasheet: https://www.ti.com/lit/ds/symlink/ads131e08.pdf
+ */
+
+#include <linux/bitfield.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+
+#include <linux/iio/buffer.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/trigger.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
+
+#include <linux/regulator/consumer.h>
+#include <linux/spi/spi.h>
+
+#include <asm/unaligned.h>
+
+/* Commands */
+#define ADS131E08_CMD_RESET 0x06
+#define ADS131E08_CMD_START 0x08
+#define ADS131E08_CMD_STOP 0x0A
+#define ADS131E08_CMD_OFFSETCAL 0x1A
+#define ADS131E08_CMD_SDATAC 0x11
+#define ADS131E08_CMD_RDATA 0x12
+#define ADS131E08_CMD_RREG(r) (BIT(5) | (r & GENMASK(4, 0)))
+#define ADS131E08_CMD_WREG(r) (BIT(6) | (r & GENMASK(4, 0)))
+
+/* Registers */
+#define ADS131E08_ADR_CFG1R 0x01
+#define ADS131E08_ADR_CFG3R 0x03
+#define ADS131E08_ADR_CH0R 0x05
+
+/* Configuration register 1 */
+#define ADS131E08_CFG1R_DR_MASK GENMASK(2, 0)
+
+/* Configuration register 3 */
+#define ADS131E08_CFG3R_PDB_REFBUF_MASK BIT(7)
+#define ADS131E08_CFG3R_VREF_4V_MASK BIT(5)
+
+/* Channel settings register */
+#define ADS131E08_CHR_GAIN_MASK GENMASK(6, 4)
+#define ADS131E08_CHR_MUX_MASK GENMASK(2, 0)
+#define ADS131E08_CHR_PWD_MASK BIT(7)
+
+/* ADC misc */
+#define ADS131E08_DEFAULT_DATA_RATE 1
+#define ADS131E08_DEFAULT_PGA_GAIN 1
+#define ADS131E08_DEFAULT_MUX 0
+
+#define ADS131E08_VREF_2V4_mV 2400
+#define ADS131E08_VREF_4V_mV 4000
+
+#define ADS131E08_WAIT_RESET_CYCLES 18
+#define ADS131E08_WAIT_SDECODE_CYCLES 4
+#define ADS131E08_WAIT_OFFSETCAL_MS 153
+#define ADS131E08_MAX_SETTLING_TIME_MS 6
+
+#define ADS131E08_NUM_STATUS_BYTES 3
+#define ADS131E08_NUM_DATA_BYTES_MAX 24
+#define ADS131E08_NUM_DATA_BYTES(dr) (((dr) >= 32) ? 2 : 3)
+#define ADS131E08_NUM_DATA_BITS(dr) (ADS131E08_NUM_DATA_BYTES(dr) * 8)
+#define ADS131E08_NUM_STORAGE_BYTES 4
+
+enum ads131e08_ids {
+ ads131e04,
+ ads131e06,
+ ads131e08,
+};
+
+struct ads131e08_info {
+ unsigned int max_channels;
+ const char *name;
+};
+
+struct ads131e08_channel_config {
+ unsigned int pga_gain;
+ unsigned int mux;
+};
+
+struct ads131e08_state {
+ const struct ads131e08_info *info;
+ struct spi_device *spi;
+ struct iio_trigger *trig;
+ struct clk *adc_clk;
+ struct regulator *vref_reg;
+ struct ads131e08_channel_config *channel_config;
+ unsigned int data_rate;
+ unsigned int vref_mv;
+ unsigned int sdecode_delay_us;
+ unsigned int reset_delay_us;
+ unsigned int readback_len;
+ struct completion completion;
+ struct {
+ u8 data[ADS131E08_NUM_DATA_BYTES_MAX];
+ s64 ts __aligned(8);
+ } tmp_buf;
+
+ u8 tx_buf[3] ____cacheline_aligned;
+ /*
+ * Add extra one padding byte to be able to access the last channel
+ * value using u32 pointer
+ */
+ u8 rx_buf[ADS131E08_NUM_STATUS_BYTES +
+ ADS131E08_NUM_DATA_BYTES_MAX + 1];
+};
+
+static const struct ads131e08_info ads131e08_info_tbl[] = {
+ [ads131e04] = {
+ .max_channels = 4,
+ .name = "ads131e04",
+ },
+ [ads131e06] = {
+ .max_channels = 6,
+ .name = "ads131e06",
+ },
+ [ads131e08] = {
+ .max_channels = 8,
+ .name = "ads131e08",
+ },
+};
+
+struct ads131e08_data_rate_desc {
+ unsigned int rate; /* data rate in kSPS */
+ u8 reg; /* reg value */
+};
+
+static const struct ads131e08_data_rate_desc ads131e08_data_rate_tbl[] = {
+ { .rate = 64, .reg = 0x00 },
+ { .rate = 32, .reg = 0x01 },
+ { .rate = 16, .reg = 0x02 },
+ { .rate = 8, .reg = 0x03 },
+ { .rate = 4, .reg = 0x04 },
+ { .rate = 2, .reg = 0x05 },
+ { .rate = 1, .reg = 0x06 },
+};
+
+struct ads131e08_pga_gain_desc {
+ unsigned int gain; /* PGA gain value */
+ u8 reg; /* field value */
+};
+
+static const struct ads131e08_pga_gain_desc ads131e08_pga_gain_tbl[] = {
+ { .gain = 1, .reg = 0x01 },
+ { .gain = 2, .reg = 0x02 },
+ { .gain = 4, .reg = 0x04 },
+ { .gain = 8, .reg = 0x05 },
+ { .gain = 12, .reg = 0x06 },
+};
+
+static const u8 ads131e08_valid_channel_mux_values[] = { 0, 1, 3, 4 };
+
+static int ads131e08_exec_cmd(struct ads131e08_state *st, u8 cmd)
+{
+ int ret;
+
+ ret = spi_write_then_read(st->spi, &cmd, 1, NULL, 0);
+ if (ret)
+ dev_err(&st->spi->dev, "Exec cmd(%02x) failed\n", cmd);
+
+ return ret;
+}
+
+static int ads131e08_read_reg(struct ads131e08_state *st, u8 reg)
+{
+ int ret;
+ struct spi_transfer transfer[] = {
+ {
+ .tx_buf = &st->tx_buf,
+ .len = 2,
+ .delay_usecs = st->sdecode_delay_us,
+ }, {
+ .rx_buf = &st->rx_buf,
+ .len = 1,
+ },
+ };
+
+ st->tx_buf[0] = ADS131E08_CMD_RREG(reg);
+ st->tx_buf[1] = 0;
+
+ ret = spi_sync_transfer(st->spi, transfer, ARRAY_SIZE(transfer));
+ if (ret) {
+ dev_err(&st->spi->dev, "Read register failed\n");
+ return ret;
+ }
+
+ return st->rx_buf[0];
+}
+
+static int ads131e08_write_reg(struct ads131e08_state *st, u8 reg, u8 value)
+{
+ int ret;
+ struct spi_transfer transfer[] = {
+ {
+ .tx_buf = &st->tx_buf,
+ .len = 3,
+ .delay_usecs = st->sdecode_delay_us,
+ }
+ };
+
+ st->tx_buf[0] = ADS131E08_CMD_WREG(reg);
+ st->tx_buf[1] = 0;
+ st->tx_buf[2] = value;
+
+ ret = spi_sync_transfer(st->spi, transfer, ARRAY_SIZE(transfer));
+ if (ret)
+ dev_err(&st->spi->dev, "Write register failed\n");
+
+ return ret;
+}
+
+static int ads131e08_read_data(struct ads131e08_state *st, int rx_len)
+{
+ int ret;
+ struct spi_transfer transfer[] = {
+ {
+ .tx_buf = &st->tx_buf,
+ .len = 1,
+ }, {
+ .rx_buf = &st->rx_buf,
+ .len = rx_len,
+ },
+ };
+
+ st->tx_buf[0] = ADS131E08_CMD_RDATA;
+
+ ret = spi_sync_transfer(st->spi, transfer, ARRAY_SIZE(transfer));
+ if (ret)
+ dev_err(&st->spi->dev, "Read data failed\n");
+
+ return ret;
+}
+
+static int ads131e08_set_data_rate(struct ads131e08_state *st, int data_rate)
+{
+ int i, reg, ret;
+
+ for (i = 0; i < ARRAY_SIZE(ads131e08_data_rate_tbl); i++) {
+ if (ads131e08_data_rate_tbl[i].rate == data_rate)
+ break;
+ }
+
+ if (i == ARRAY_SIZE(ads131e08_data_rate_tbl)) {
+ dev_err(&st->spi->dev, "invalid data rate value\n");
+ return -EINVAL;
+ }
+
+ reg = ads131e08_read_reg(st, ADS131E08_ADR_CFG1R);
+ if (reg < 0)
+ return reg;
+
+ reg &= ~ADS131E08_CFG1R_DR_MASK;
+ reg |= FIELD_PREP(ADS131E08_CFG1R_DR_MASK,
+ ads131e08_data_rate_tbl[i].reg);
+
+ ret = ads131e08_write_reg(st, ADS131E08_ADR_CFG1R, reg);
+ if (ret)
+ return ret;
+
+ st->data_rate = data_rate;
+ st->readback_len = ADS131E08_NUM_STATUS_BYTES +
+ ADS131E08_NUM_DATA_BYTES(st->data_rate) *
+ st->info->max_channels;
+
+ return 0;
+}
+
+static int ads131e08_pga_gain_to_field_value(struct ads131e08_state *st,
+ unsigned int pga_gain)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(ads131e08_pga_gain_tbl); i++) {
+ if (ads131e08_pga_gain_tbl[i].gain == pga_gain)
+ break;
+ }
+
+ if (i == ARRAY_SIZE(ads131e08_pga_gain_tbl)) {
+ dev_err(&st->spi->dev, "invalid PGA gain value\n");
+ return -EINVAL;
+ }
+
+ return ads131e08_pga_gain_tbl[i].reg;
+}
+
+static int ads131e08_set_pga_gain(struct ads131e08_state *st,
+ unsigned int channel, unsigned int pga_gain)
+{
+ int field_value, reg;
+
+ field_value = ads131e08_pga_gain_to_field_value(st, pga_gain);
+ if (field_value < 0)
+ return field_value;
+
+ reg = ads131e08_read_reg(st, ADS131E08_ADR_CH0R + channel);
+ if (reg < 0)
+ return reg;
+
+ reg &= ~ADS131E08_CHR_GAIN_MASK;
+ reg |= FIELD_PREP(ADS131E08_CHR_GAIN_MASK, field_value);
+
+ return ads131e08_write_reg(st, ADS131E08_ADR_CH0R + channel, reg);
+}
+
+static int ads131e08_validate_channel_mux(struct ads131e08_state *st,
+ unsigned int mux)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(ads131e08_valid_channel_mux_values); i++) {
+ if (ads131e08_valid_channel_mux_values[i] == mux)
+ break;
+ }
+
+ if (i == ARRAY_SIZE(ads131e08_valid_channel_mux_values)) {
+ dev_err(&st->spi->dev, "invalid channel mux value\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int ads131e08_set_channel_mux(struct ads131e08_state *st,
+ unsigned int channel, unsigned int mux)
+{
+ int reg;
+
+ reg = ads131e08_read_reg(st, ADS131E08_ADR_CH0R + channel);
+ if (reg < 0)
+ return reg;
+
+ reg &= ~ADS131E08_CHR_MUX_MASK;
+ reg |= FIELD_PREP(ADS131E08_CHR_MUX_MASK, mux);
+
+ return ads131e08_write_reg(st, ADS131E08_ADR_CH0R + channel, reg);
+}
+
+static int ads131e08_power_down_channel(struct ads131e08_state *st,
+ unsigned int channel, bool value)
+{
+ int reg;
+
+ reg = ads131e08_read_reg(st, ADS131E08_ADR_CH0R + channel);
+ if (reg < 0)
+ return reg;
+
+ reg &= ~ADS131E08_CHR_PWD_MASK;
+ reg |= FIELD_PREP(ADS131E08_CHR_PWD_MASK, value);
+
+ return ads131e08_write_reg(st, ADS131E08_ADR_CH0R + channel, reg);
+}
+
+static int ads131e08_config_reference_voltage(struct ads131e08_state *st)
+{
+ int reg;
+
+ reg = ads131e08_read_reg(st, ADS131E08_ADR_CFG3R);
+ if (reg < 0)
+ return reg;
+
+ reg &= ~ADS131E08_CFG3R_PDB_REFBUF_MASK;
+ if (!st->vref_reg) {
+ reg |= FIELD_PREP(ADS131E08_CFG3R_PDB_REFBUF_MASK, 1);
+ reg &= ~ADS131E08_CFG3R_VREF_4V_MASK;
+ reg |= FIELD_PREP(ADS131E08_CFG3R_VREF_4V_MASK,
+ st->vref_mv == ADS131E08_VREF_4V_mV);
+ }
+
+ return ads131e08_write_reg(st, ADS131E08_ADR_CFG3R, reg);
+}
+
+static int ads131e08_initial_config(struct iio_dev *indio_dev)
+{
+ const struct iio_chan_spec *channel = indio_dev->channels;
+ struct ads131e08_state *st = iio_priv(indio_dev);
+ unsigned long active_channels = 0;
+ int ret, i;
+
+ ret = ads131e08_exec_cmd(st, ADS131E08_CMD_RESET);
+ if (ret)
+ return ret;
+
+ udelay(st->reset_delay_us);
+
+ /* Disable read data in continuous mode (enabled by default) */
+ ret = ads131e08_exec_cmd(st, ADS131E08_CMD_SDATAC);
+ if (ret)
+ return ret;
+
+ ret = ads131e08_set_data_rate(st, ADS131E08_DEFAULT_DATA_RATE);
+ if (ret)
+ return ret;
+
+ ret = ads131e08_config_reference_voltage(st);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < indio_dev->num_channels; i++) {
+ ret = ads131e08_set_pga_gain(st, channel->channel,
+ st->channel_config[i].pga_gain);
+ if (ret)
+ return ret;
+
+ ret = ads131e08_set_channel_mux(st, channel->channel,
+ st->channel_config[i].mux);
+ if (ret)
+ return ret;
+
+ active_channels |= BIT(channel->channel);
+ channel++;
+ }
+
+ /* Power down unused channels */
+ for_each_clear_bit(i, &active_channels, st->info->max_channels) {
+ ret = ads131e08_power_down_channel(st, i, true);
+ if (ret)
+ return ret;
+ }
+
+ /* Request channel offset calibration */
+ ret = ads131e08_exec_cmd(st, ADS131E08_CMD_OFFSETCAL);
+ if (ret)
+ return ret;
+
+ /*
+ * Channel offset calibration is triggered with the first START
+ * command. Since calibration takes more time than settling operation,
+ * this causes timeout error when command START is sent first
+ * time (e.g. first call of the ads131e08_read_direct method).
+ * To avoid this problem offset calibration is triggered here.
+ */
+ ret = ads131e08_exec_cmd(st, ADS131E08_CMD_START);
+ if (ret)
+ return ret;
+
+ msleep(ADS131E08_WAIT_OFFSETCAL_MS);
+
+ return ads131e08_exec_cmd(st, ADS131E08_CMD_STOP);
+}
+
+static int ads131e08_pool_data(struct ads131e08_state *st)
+{
+ unsigned long timeout;
+ int ret;
+
+ reinit_completion(&st->completion);
+
+ ret = ads131e08_exec_cmd(st, ADS131E08_CMD_START);
+ if (ret)
+ return ret;
+
+ timeout = msecs_to_jiffies(ADS131E08_MAX_SETTLING_TIME_MS);
+ ret = wait_for_completion_timeout(&st->completion, timeout);
+ if (!ret)
+ return -ETIMEDOUT;
+
+ ret = ads131e08_read_data(st, st->readback_len);
+ if (ret)
+ return ret;
+
+ return ads131e08_exec_cmd(st, ADS131E08_CMD_STOP);
+}
+
+static int ads131e08_read_direct(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *channel, int *value)
+{
+ struct ads131e08_state *st = iio_priv(indio_dev);
+ u8 num_bits, *src;
+ int ret;
+
+ ret = ads131e08_pool_data(st);
+ if (ret)
+ return ret;
+
+ src = st->rx_buf + ADS131E08_NUM_STATUS_BYTES +
+ channel->channel * ADS131E08_NUM_DATA_BYTES(st->data_rate);
+
+ num_bits = ADS131E08_NUM_DATA_BITS(st->data_rate);
+ *value = sign_extend32(get_unaligned_be32(src) >> (32 - num_bits), num_bits - 1);
+
+ return 0;
+}
+
+static int ads131e08_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *channel, int *value,
+ int *value2, long mask)
+{
+ struct ads131e08_state *st = iio_priv(indio_dev);
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ ret = iio_device_claim_direct_mode(indio_dev);
+ if (ret)
+ return ret;
+
+ ret = ads131e08_read_direct(indio_dev, channel, value);
+ iio_device_release_direct_mode(indio_dev);
+ if (ret)
+ return ret;
+
+ return IIO_VAL_INT;
+
+ case IIO_CHAN_INFO_SCALE:
+ if (st->vref_reg) {
+ ret = regulator_get_voltage(st->vref_reg);
+ if (ret < 0)
+ return ret;
+
+ *value = ret / 1000;
+ } else {
+ *value = st->vref_mv;
+ }
+
+ *value /= st->channel_config[channel->address].pga_gain;
+ *value2 = ADS131E08_NUM_DATA_BITS(st->data_rate) - 1;
+
+ return IIO_VAL_FRACTIONAL_LOG2;
+
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ *value = st->data_rate;
+
+ return IIO_VAL_INT;
+
+ default:
+ return -EINVAL;
+ }
+}
+
+static int ads131e08_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *channel, int value,
+ int value2, long mask)
+{
+ struct ads131e08_state *st = iio_priv(indio_dev);
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ ret = iio_device_claim_direct_mode(indio_dev);
+ if (ret)
+ return ret;
+
+ ret = ads131e08_set_data_rate(st, value);
+ iio_device_release_direct_mode(indio_dev);
+ return ret;
+
+ default:
+ return -EINVAL;
+ }
+}
+
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("1 2 4 8 16 32 64");
+
+static struct attribute *ads131e08_attributes[] = {
+ &iio_const_attr_sampling_frequency_available.dev_attr.attr,
+ NULL
+};
+
+static const struct attribute_group ads131e08_attribute_group = {
+ .attrs = ads131e08_attributes,
+};
+
+static int ads131e08_debugfs_reg_access(struct iio_dev *indio_dev,
+ unsigned int reg, unsigned int writeval, unsigned int *readval)
+{
+ struct ads131e08_state *st = iio_priv(indio_dev);
+
+ if (readval) {
+ int ret = ads131e08_read_reg(st, reg);
+ *readval = ret;
+ return ret;
+ }
+
+ return ads131e08_write_reg(st, reg, writeval);
+}
+
+static const struct iio_info ads131e08_iio_info = {
+ .read_raw = ads131e08_read_raw,
+ .write_raw = ads131e08_write_raw,
+ .attrs = &ads131e08_attribute_group,
+ .debugfs_reg_access = &ads131e08_debugfs_reg_access,
+};
+
+static int ads131e08_set_trigger_state(struct iio_trigger *trig, bool state)
+{
+ struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
+ struct ads131e08_state *st = iio_priv(indio_dev);
+ u8 cmd = state ? ADS131E08_CMD_START : ADS131E08_CMD_STOP;
+
+ return ads131e08_exec_cmd(st, cmd);
+}
+
+static const struct iio_trigger_ops ads131e08_trigger_ops = {
+ .set_trigger_state = &ads131e08_set_trigger_state,
+ .validate_device = &iio_trigger_validate_own_device,
+};
+
+static irqreturn_t ads131e08_trigger_handler(int irq, void *private)
+{
+ struct iio_poll_func *pf = private;
+ struct iio_dev *indio_dev = pf->indio_dev;
+ struct ads131e08_state *st = iio_priv(indio_dev);
+ unsigned int chn, i = 0;
+ u8 *src, *dest;
+ int ret;
+
+ /*
+ * The number of data bits per channel depends on the data rate.
+ * For 32 and 64 ksps data rates, number of data bits per channel
+ * is 16. This case is not compliant with used (fixed) scan element
+ * type (be:s24/32>>8). So we use a little tweak to pack properly
+ * 16 bits of data into the buffer.
+ */
+ unsigned int num_bytes = ADS131E08_NUM_DATA_BYTES(st->data_rate);
+ u8 tweek_offset = num_bytes == 2 ? 1 : 0;
+
+ if (iio_trigger_using_own(indio_dev))
+ ret = ads131e08_read_data(st, st->readback_len);
+ else
+ ret = ads131e08_pool_data(st);
+
+ if (ret)
+ goto out;
+
+ for_each_set_bit(chn, indio_dev->active_scan_mask, indio_dev->masklength) {
+ src = st->rx_buf + ADS131E08_NUM_STATUS_BYTES + chn * num_bytes;
+ dest = st->tmp_buf.data + i * ADS131E08_NUM_STORAGE_BYTES;
+
+ /*
+ * Tweek offset is 0:
+ * +---+---+---+---+
+ * |D0 |D1 |D2 | X | (3 data bytes)
+ * +---+---+---+---+
+ * a+0 a+1 a+2 a+3
+ *
+ * Tweek offset is 1:
+ * +---+---+---+---+
+ * |P0 |D0 |D1 | X | (one padding byte and 2 data bytes)
+ * +---+---+---+---+
+ * a+0 a+1 a+2 a+3
+ */
+ memcpy(dest + tweek_offset, src, num_bytes);
+
+ /*
+ * Data conversion from 16 bits of data to 24 bits of data
+ * is done by sign extension (properly filling padding byte).
+ */
+ if (tweek_offset)
+ *dest = *src & BIT(7) ? 0xff : 0x00;
+
+ i++;
+ }
+
+ iio_push_to_buffers_with_timestamp(indio_dev, st->tmp_buf.data,
+ iio_get_time_ns(indio_dev));
+
+out:
+ iio_trigger_notify_done(indio_dev->trig);
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t ads131e08_interrupt(int irq, void *private)
+{
+ struct iio_dev *indio_dev = private;
+ struct ads131e08_state *st = iio_priv(indio_dev);
+
+ if (iio_buffer_enabled(indio_dev) && iio_trigger_using_own(indio_dev))
+ iio_trigger_poll(st->trig);
+ else
+ complete(&st->completion);
+
+ return IRQ_HANDLED;
+}
+
+static int ads131e08_alloc_channels(struct iio_dev *indio_dev)
+{
+ struct ads131e08_state *st = iio_priv(indio_dev);
+ struct ads131e08_channel_config *channel_config;
+ struct device *dev = &st->spi->dev;
+ struct iio_chan_spec *channels;
+ struct fwnode_handle *node;
+ unsigned int channel, tmp;
+ int num_channels, i, ret;
+
+ ret = device_property_read_u32(dev, "ti,vref-internal", &tmp);
+ if (ret)
+ tmp = 0;
+
+ switch (tmp) {
+ case 0:
+ st->vref_mv = ADS131E08_VREF_2V4_mV;
+ break;
+ case 1:
+ st->vref_mv = ADS131E08_VREF_4V_mV;
+ break;
+ default:
+ dev_err(&st->spi->dev, "invalid internal voltage reference\n");
+ return -EINVAL;
+ }
+
+ num_channels = device_get_child_node_count(dev);
+ if (num_channels == 0) {
+ dev_err(&st->spi->dev, "no channel children\n");
+ return -ENODEV;
+ }
+
+ if (num_channels > st->info->max_channels) {
+ dev_err(&st->spi->dev, "num of channel children out of range\n");
+ return -EINVAL;
+ }
+
+ channels = devm_kcalloc(&st->spi->dev, num_channels,
+ sizeof(*channels), GFP_KERNEL);
+ if (!channels)
+ return -ENOMEM;
+
+ channel_config = devm_kcalloc(&st->spi->dev, num_channels,
+ sizeof(*channel_config), GFP_KERNEL);
+ if (!channel_config)
+ return -ENOMEM;
+
+ i = 0;
+ device_for_each_child_node(dev, node) {
+ ret = fwnode_property_read_u32(node, "reg", &channel);
+ if (ret)
+ return ret;
+
+ ret = fwnode_property_read_u32(node, "ti,gain", &tmp);
+ if (ret) {
+ channel_config[i].pga_gain = ADS131E08_DEFAULT_PGA_GAIN;
+ } else {
+ ret = ads131e08_pga_gain_to_field_value(st, tmp);
+ if (ret < 0)
+ return ret;
+
+ channel_config[i].pga_gain = tmp;
+ }
+
+ ret = fwnode_property_read_u32(node, "ti,mux", &tmp);
+ if (ret) {
+ channel_config[i].mux = ADS131E08_DEFAULT_MUX;
+ } else {
+ ret = ads131e08_validate_channel_mux(st, tmp);
+ if (ret)
+ return ret;
+
+ channel_config[i].mux = tmp;
+ }
+
+ channels[i].type = IIO_VOLTAGE;
+ channels[i].indexed = 1;
+ channels[i].channel = channel;
+ channels[i].address = i;
+ channels[i].info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_SCALE);
+ channels[i].info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ);
+ channels[i].scan_index = channel;
+ channels[i].scan_type.sign = 's';
+ channels[i].scan_type.realbits = 24;
+ channels[i].scan_type.storagebits = 32;
+ channels[i].scan_type.shift = 8;
+ channels[i].scan_type.endianness = IIO_BE;
+ i++;
+ }
+
+ indio_dev->channels = channels;
+ indio_dev->num_channels = num_channels;
+ st->channel_config = channel_config;
+
+ return 0;
+}
+
+static void ads131e08_regulator_disable(void *data)
+{
+ struct ads131e08_state *st = data;
+
+ regulator_disable(st->vref_reg);
+}
+
+static void ads131e08_clk_disable(void *data)
+{
+ struct ads131e08_state *st = data;
+
+ clk_disable_unprepare(st->adc_clk);
+}
+
+static int ads131e08_probe(struct spi_device *spi)
+{
+ const struct ads131e08_info *info;
+ struct ads131e08_state *st;
+ struct iio_dev *indio_dev;
+ unsigned long adc_clk_hz;
+ unsigned long adc_clk_ns;
+ int ret;
+
+ info = device_get_match_data(&spi->dev);
+ if (!info) {
+ dev_err(&spi->dev, "failed to get match data\n");
+ return -ENODEV;
+ }
+
+ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+ if (!indio_dev) {
+ dev_err(&spi->dev, "failed to allocate IIO device\n");
+ return -ENOMEM;
+ }
+
+ st = iio_priv(indio_dev);
+ st->info = info;
+ st->spi = spi;
+
+ ret = ads131e08_alloc_channels(indio_dev);
+ if (ret)
+ return ret;
+
+ indio_dev->name = st->info->name;
+ indio_dev->dev.parent = &spi->dev;
+ indio_dev->info = &ads131e08_iio_info;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+
+ init_completion(&st->completion);
+
+ if (spi->irq) {
+ ret = devm_request_irq(&spi->dev, spi->irq,
+ ads131e08_interrupt,
+ IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ spi->dev.driver->name, indio_dev);
+ if (ret)
+ return dev_err_probe(&spi->dev, ret,
+ "request irq failed\n");
+ } else {
+ dev_err(&spi->dev, "data ready IRQ missing\n");
+ return -ENODEV;
+ }
+
+ st->trig = devm_iio_trigger_alloc(&spi->dev, "%s-dev%d",
+ indio_dev->name, indio_dev->id);
+ if (!st->trig) {
+ dev_err(&spi->dev, "failed to allocate IIO trigger\n");
+ return -ENOMEM;
+ }
+
+ st->trig->ops = &ads131e08_trigger_ops;
+ st->trig->dev.parent = &spi->dev;
+ iio_trigger_set_drvdata(st->trig, indio_dev);
+ ret = devm_iio_trigger_register(&spi->dev, st->trig);
+ if (ret) {
+ dev_err(&spi->dev, "failed to register IIO trigger\n");
+ return -ENOMEM;
+ }
+
+ indio_dev->trig = iio_trigger_get(st->trig);
+
+ ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev,
+ NULL, &ads131e08_trigger_handler, NULL);
+ if (ret) {
+ dev_err(&spi->dev, "failed to setup IIO buffer\n");
+ return ret;
+ }
+
+ st->vref_reg = devm_regulator_get_optional(&spi->dev, "vref");
+ if (!IS_ERR(st->vref_reg)) {
+ ret = regulator_enable(st->vref_reg);
+ if (ret) {
+ dev_err(&spi->dev,
+ "failed to enable external vref supply\n");
+ return ret;
+ }
+
+ ret = devm_add_action_or_reset(&spi->dev, ads131e08_regulator_disable, st);
+ if (ret)
+ return ret;
+ } else {
+ if (PTR_ERR(st->vref_reg) != -ENODEV)
+ return PTR_ERR(st->vref_reg);
+
+ st->vref_reg = NULL;
+ }
+
+ st->adc_clk = devm_clk_get(&spi->dev, "adc-clk");
+ if (IS_ERR(st->adc_clk))
+ return dev_err_probe(&spi->dev, PTR_ERR(st->adc_clk),
+ "failed to get the ADC clock\n");
+
+ ret = clk_prepare_enable(st->adc_clk);
+ if (ret) {
+ dev_err(&spi->dev, "failed to prepare/enable the ADC clock\n");
+ return ret;
+ }
+
+ ret = devm_add_action_or_reset(&spi->dev, ads131e08_clk_disable, st);
+ if (ret)
+ return ret;
+
+ adc_clk_hz = clk_get_rate(st->adc_clk);
+ if (!adc_clk_hz) {
+ dev_err(&spi->dev, "failed to get the ADC clock rate\n");
+ return -EINVAL;
+ }
+
+ adc_clk_ns = NSEC_PER_SEC / adc_clk_hz;
+ st->sdecode_delay_us = DIV_ROUND_UP(
+ ADS131E08_WAIT_SDECODE_CYCLES * adc_clk_ns, NSEC_PER_USEC);
+ st->reset_delay_us = DIV_ROUND_UP(
+ ADS131E08_WAIT_RESET_CYCLES * adc_clk_ns, NSEC_PER_USEC);
+
+ ret = ads131e08_initial_config(indio_dev);
+ if (ret) {
+ dev_err(&spi->dev, "initial configuration failed\n");
+ return ret;
+ }
+
+ return devm_iio_device_register(&spi->dev, indio_dev);
+}
+
+static const struct of_device_id ads131e08_of_match[] = {
+ { .compatible = "ti,ads131e04",
+ .data = &ads131e08_info_tbl[ads131e04], },
+ { .compatible = "ti,ads131e06",
+ .data = &ads131e08_info_tbl[ads131e06], },
+ { .compatible = "ti,ads131e08",
+ .data = &ads131e08_info_tbl[ads131e08], },
+ {}
+};
+MODULE_DEVICE_TABLE(of, ads131e08_of_match);
+
+static struct spi_driver ads131e08_driver = {
+ .driver = {
+ .name = "ads131e08",
+ .of_match_table = ads131e08_of_match,
+ },
+ .probe = ads131e08_probe,
+};
+module_spi_driver(ads131e08_driver);
+
+MODULE_AUTHOR("Tomislav Denis <tomislav.denis@avl.com>");
+MODULE_DESCRIPTION("Driver for ADS131E0x ADC family");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index e946903b0993..855cc2d64ac8 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -385,24 +385,16 @@ static int tiadc_iio_buffered_hardware_setup(struct device *dev,
unsigned long flags,
const struct iio_buffer_setup_ops *setup_ops)
{
- struct iio_buffer *buffer;
int ret;
- buffer = devm_iio_kfifo_allocate(dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
-
- ret = devm_request_threaded_irq(dev, irq, pollfunc_th, pollfunc_bh,
- flags, indio_dev->name, indio_dev);
+ ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ setup_ops);
if (ret)
return ret;
- indio_dev->setup_ops = setup_ops;
- indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
-
- return 0;
+ return devm_request_threaded_irq(dev, irq, pollfunc_th, pollfunc_bh,
+ flags, indio_dev->name, indio_dev);
}
static const char * const chan_name_ain[] = {
diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
index 34800dccbf69..6914c1900ed0 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -747,7 +747,6 @@ static struct iio_trigger *xadc_alloc_trigger(struct iio_dev *indio_dev,
if (trig == NULL)
return ERR_PTR(-ENOMEM);
- trig->dev.parent = indio_dev->dev.parent;
trig->ops = &xadc_trigger_ops;
iio_trigger_set_drvdata(trig, iio_priv(indio_dev));
diff --git a/drivers/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
index b0cb9a35f5cd..d76179878ff9 100644
--- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c
+++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
@@ -132,9 +132,9 @@ static const struct iio_dma_buffer_ops iio_dmaengine_default_ops = {
static ssize_t iio_dmaengine_buffer_get_length_align(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
struct dmaengine_buffer *dmaengine_buffer =
- iio_buffer_to_dmaengine_buffer(indio_dev->buffer);
+ iio_buffer_to_dmaengine_buffer(buffer);
return sprintf(buf, "%zu\n", dmaengine_buffer->align);
}
@@ -244,7 +244,7 @@ static void __devm_iio_dmaengine_buffer_free(struct device *dev, void *res)
*
* The buffer will be automatically de-allocated once the device gets destroyed.
*/
-struct iio_buffer *devm_iio_dmaengine_buffer_alloc(struct device *dev,
+static struct iio_buffer *devm_iio_dmaengine_buffer_alloc(struct device *dev,
const char *channel)
{
struct iio_buffer **bufferp, *buffer;
@@ -265,7 +265,34 @@ struct iio_buffer *devm_iio_dmaengine_buffer_alloc(struct device *dev,
return buffer;
}
-EXPORT_SYMBOL_GPL(devm_iio_dmaengine_buffer_alloc);
+
+/**
+ * devm_iio_dmaengine_buffer_setup() - Setup a DMA buffer for an IIO device
+ * @dev: Parent device for the buffer
+ * @indio_dev: IIO device to which to attach this buffer.
+ * @channel: DMA channel name, typically "rx".
+ *
+ * This allocates a new IIO buffer with devm_iio_dmaengine_buffer_alloc()
+ * and attaches it to an IIO device with iio_device_attach_buffer().
+ * It also appends the INDIO_BUFFER_HARDWARE mode to the supported modes of the
+ * IIO device.
+ */
+int devm_iio_dmaengine_buffer_setup(struct device *dev,
+ struct iio_dev *indio_dev,
+ const char *channel)
+{
+ struct iio_buffer *buffer;
+
+ buffer = devm_iio_dmaengine_buffer_alloc(indio_dev->dev.parent,
+ channel);
+ if (IS_ERR(buffer))
+ return PTR_ERR(buffer);
+
+ indio_dev->modes |= INDIO_BUFFER_HARDWARE;
+
+ return iio_device_attach_buffer(indio_dev, buffer);
+}
+EXPORT_SYMBOL_GPL(devm_iio_dmaengine_buffer_setup);
MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
MODULE_DESCRIPTION("DMA buffer for the IIO framework");
diff --git a/drivers/iio/buffer/industrialio-triggered-buffer.c b/drivers/iio/buffer/industrialio-triggered-buffer.c
index 92b8aea3e063..b2b1b7d27af4 100644
--- a/drivers/iio/buffer/industrialio-triggered-buffer.c
+++ b/drivers/iio/buffer/industrialio-triggered-buffer.c
@@ -50,8 +50,6 @@ int iio_triggered_buffer_setup_ext(struct iio_dev *indio_dev,
goto error_ret;
}
- iio_device_attach_buffer(indio_dev, buffer);
-
indio_dev->pollfunc = iio_alloc_pollfunc(h,
thread,
IRQF_ONESHOT,
@@ -72,10 +70,16 @@ int iio_triggered_buffer_setup_ext(struct iio_dev *indio_dev,
buffer->attrs = buffer_attrs;
+ ret = iio_device_attach_buffer(indio_dev, buffer);
+ if (ret < 0)
+ goto error_dealloc_pollfunc;
+
return 0;
+error_dealloc_pollfunc:
+ iio_dealloc_pollfunc(indio_dev->pollfunc);
error_kfifo_free:
- iio_kfifo_free(indio_dev->buffer);
+ iio_kfifo_free(buffer);
error_ret:
return ret;
}
diff --git a/drivers/iio/buffer/kfifo_buf.c b/drivers/iio/buffer/kfifo_buf.c
index 1359abed3b31..516eb3465de1 100644
--- a/drivers/iio/buffer/kfifo_buf.c
+++ b/drivers/iio/buffer/kfifo_buf.c
@@ -180,13 +180,13 @@ static void devm_iio_kfifo_release(struct device *dev, void *res)
}
/**
- * devm_iio_fifo_allocate - Resource-managed iio_kfifo_allocate()
+ * devm_iio_kfifo_allocate - Resource-managed iio_kfifo_allocate()
* @dev: Device to allocate kfifo buffer for
*
* RETURNS:
* Pointer to allocated iio_buffer on success, NULL on failure.
*/
-struct iio_buffer *devm_iio_kfifo_allocate(struct device *dev)
+static struct iio_buffer *devm_iio_kfifo_allocate(struct device *dev)
{
struct iio_buffer **ptr, *r;
@@ -204,6 +204,45 @@ struct iio_buffer *devm_iio_kfifo_allocate(struct device *dev)
return r;
}
-EXPORT_SYMBOL(devm_iio_kfifo_allocate);
+
+/**
+ * devm_iio_kfifo_buffer_setup_ext - Allocate a kfifo buffer & attach it to an IIO device
+ * @dev: Device object to which to attach the life-time of this kfifo buffer
+ * @indio_dev: The device the buffer should be attached to
+ * @mode_flags: The mode flags for this buffer (INDIO_BUFFER_SOFTWARE and/or
+ * INDIO_BUFFER_TRIGGERED).
+ * @setup_ops: The setup_ops required to configure the HW part of the buffer (optional)
+ * @buffer_attrs: Extra sysfs buffer attributes for this IIO buffer
+ *
+ * This function allocates a kfifo buffer via devm_iio_kfifo_allocate() and
+ * attaches it to the IIO device via iio_device_attach_buffer().
+ * This is meant to be a bit of a short-hand/helper function as there are a few
+ * drivers that seem to do this.
+ */
+int devm_iio_kfifo_buffer_setup_ext(struct device *dev,
+ struct iio_dev *indio_dev,
+ int mode_flags,
+ const struct iio_buffer_setup_ops *setup_ops,
+ const struct attribute **buffer_attrs)
+{
+ struct iio_buffer *buffer;
+
+ if (!mode_flags)
+ return -EINVAL;
+
+ buffer = devm_iio_kfifo_allocate(dev);
+ if (!buffer)
+ return -ENOMEM;
+
+ mode_flags &= kfifo_access_funcs.modes;
+
+ indio_dev->modes |= mode_flags;
+ indio_dev->setup_ops = setup_ops;
+
+ buffer->attrs = buffer_attrs;
+
+ return iio_device_attach_buffer(indio_dev, buffer);
+}
+EXPORT_SYMBOL_GPL(devm_iio_kfifo_buffer_setup_ext);
MODULE_LICENSE("GPL");
diff --git a/drivers/iio/cdc/Kconfig b/drivers/iio/cdc/Kconfig
new file mode 100644
index 000000000000..5e3319a3ff48
--- /dev/null
+++ b/drivers/iio/cdc/Kconfig
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# CDC drivers
+#
+menu "Capacitance to digital converters"
+
+config AD7150
+ tristate "Analog Devices ad7150/1/6 capacitive sensor driver"
+ depends on I2C
+ help
+ Say yes here to build support for Analog Devices capacitive sensors.
+ (ad7150, ad7151, ad7156) Provides direct access via sysfs.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ad7150.
+
+endmenu
diff --git a/drivers/iio/cdc/Makefile b/drivers/iio/cdc/Makefile
new file mode 100644
index 000000000000..ee490637b032
--- /dev/null
+++ b/drivers/iio/cdc/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for industrial I/O capacitance to digital converter (CDC) drivers
+#
+
+obj-$(CONFIG_AD7150) += ad7150.o
diff --git a/drivers/iio/cdc/ad7150.c b/drivers/iio/cdc/ad7150.c
new file mode 100644
index 000000000000..ebe112b4618b
--- /dev/null
+++ b/drivers/iio/cdc/ad7150.c
@@ -0,0 +1,673 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * AD7150 capacitive sensor driver supporting AD7150/1/6
+ *
+ * Copyright 2010-2011 Analog Devices Inc.
+ * Copyright 2021 Jonathan Cameron <Jonathan.Cameron@huawei.com>
+ */
+
+#include <linux/bitfield.h>
+#include <linux/device.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/i2c.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/regulator/consumer.h>
+#include <linux/slab.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
+
+#define AD7150_STATUS_REG 0
+#define AD7150_STATUS_OUT1 BIT(3)
+#define AD7150_STATUS_OUT2 BIT(5)
+#define AD7150_CH1_DATA_HIGH_REG 1
+#define AD7150_CH2_DATA_HIGH_REG 3
+#define AD7150_CH1_AVG_HIGH_REG 5
+#define AD7150_CH2_AVG_HIGH_REG 7
+#define AD7150_CH1_SENSITIVITY_REG 9
+#define AD7150_CH1_THR_HOLD_H_REG 9
+#define AD7150_CH1_TIMEOUT_REG 10
+#define AD7150_CH_TIMEOUT_RECEDING GENMASK(3, 0)
+#define AD7150_CH_TIMEOUT_APPROACHING GENMASK(7, 4)
+#define AD7150_CH1_SETUP_REG 11
+#define AD7150_CH2_SENSITIVITY_REG 12
+#define AD7150_CH2_THR_HOLD_H_REG 12
+#define AD7150_CH2_TIMEOUT_REG 13
+#define AD7150_CH2_SETUP_REG 14
+#define AD7150_CFG_REG 15
+#define AD7150_CFG_FIX BIT(7)
+#define AD7150_CFG_THRESHTYPE_MSK GENMASK(6, 5)
+#define AD7150_CFG_TT_NEG 0x0
+#define AD7150_CFG_TT_POS 0x1
+#define AD7150_CFG_TT_IN_WINDOW 0x2
+#define AD7150_CFG_TT_OUT_WINDOW 0x3
+#define AD7150_PD_TIMER_REG 16
+#define AD7150_CH1_CAPDAC_REG 17
+#define AD7150_CH2_CAPDAC_REG 18
+#define AD7150_SN3_REG 19
+#define AD7150_SN2_REG 20
+#define AD7150_SN1_REG 21
+#define AD7150_SN0_REG 22
+#define AD7150_ID_REG 23
+
+enum {
+ AD7150,
+ AD7151,
+};
+
+/**
+ * struct ad7150_chip_info - instance specific chip data
+ * @client: i2c client for this device
+ * @threshold: thresholds for simple capacitance value events
+ * @thresh_sensitivity: threshold for simple capacitance offset
+ * from 'average' value.
+ * @thresh_timeout: a timeout, in samples from the moment an
+ * adaptive threshold event occurs to when the average
+ * value jumps to current value. Note made up of two fields,
+ * 3:0 are for timeout receding - applies if below lower threshold
+ * 7:4 are for timeout approaching - applies if above upper threshold
+ * @state_lock: ensure consistent state of this structure wrt the
+ * hardware.
+ * @interrupts: one or two interrupt numbers depending on device type.
+ * @int_enabled: is a given interrupt currently enabled.
+ * @type: threshold type
+ * @dir: threshold direction
+ */
+struct ad7150_chip_info {
+ struct i2c_client *client;
+ u16 threshold[2][2];
+ u8 thresh_sensitivity[2][2];
+ u8 thresh_timeout[2][2];
+ struct mutex state_lock;
+ int interrupts[2];
+ bool int_enabled[2];
+ enum iio_event_type type;
+ enum iio_event_direction dir;
+};
+
+static const u8 ad7150_addresses[][6] = {
+ { AD7150_CH1_DATA_HIGH_REG, AD7150_CH1_AVG_HIGH_REG,
+ AD7150_CH1_SETUP_REG, AD7150_CH1_THR_HOLD_H_REG,
+ AD7150_CH1_SENSITIVITY_REG, AD7150_CH1_TIMEOUT_REG },
+ { AD7150_CH2_DATA_HIGH_REG, AD7150_CH2_AVG_HIGH_REG,
+ AD7150_CH2_SETUP_REG, AD7150_CH2_THR_HOLD_H_REG,
+ AD7150_CH2_SENSITIVITY_REG, AD7150_CH2_TIMEOUT_REG },
+};
+
+static int ad7150_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val,
+ int *val2,
+ long mask)
+{
+ struct ad7150_chip_info *chip = iio_priv(indio_dev);
+ int channel = chan->channel;
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ ret = i2c_smbus_read_word_swapped(chip->client,
+ ad7150_addresses[channel][0]);
+ if (ret < 0)
+ return ret;
+ *val = ret >> 4;
+
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_AVERAGE_RAW:
+ ret = i2c_smbus_read_word_swapped(chip->client,
+ ad7150_addresses[channel][1]);
+ if (ret < 0)
+ return ret;
+ *val = ret;
+
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_SCALE:
+ /*
+ * Base units for capacitance are nano farads and the value
+ * calculated from the datasheet formula is in picofarad
+ * so multiply by 1000
+ */
+ *val = 1000;
+ *val2 = 40944 >> 4; /* To match shift in _RAW */
+ return IIO_VAL_FRACTIONAL;
+ case IIO_CHAN_INFO_OFFSET:
+ *val = -(12288 >> 4); /* To match shift in _RAW */
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ /* Strangely same for both 1 and 2 chan parts */
+ *val = 100;
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int ad7150_read_event_config(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir)
+{
+ struct ad7150_chip_info *chip = iio_priv(indio_dev);
+ u8 threshtype;
+ bool thrfixed;
+ int ret;
+
+ ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG_REG);
+ if (ret < 0)
+ return ret;
+
+ threshtype = FIELD_GET(AD7150_CFG_THRESHTYPE_MSK, ret);
+
+ /*check if threshold mode is fixed or adaptive*/
+ thrfixed = FIELD_GET(AD7150_CFG_FIX, ret);
+
+ switch (type) {
+ case IIO_EV_TYPE_THRESH_ADAPTIVE:
+ if (dir == IIO_EV_DIR_RISING)
+ return !thrfixed && (threshtype == AD7150_CFG_TT_POS);
+ return !thrfixed && (threshtype == AD7150_CFG_TT_NEG);
+ case IIO_EV_TYPE_THRESH:
+ if (dir == IIO_EV_DIR_RISING)
+ return thrfixed && (threshtype == AD7150_CFG_TT_POS);
+ return thrfixed && (threshtype == AD7150_CFG_TT_NEG);
+ default:
+ break;
+ }
+ return -EINVAL;
+}
+
+/* state_lock should be held to ensure consistent state */
+static int ad7150_write_event_params(struct iio_dev *indio_dev,
+ unsigned int chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir)
+{
+ struct ad7150_chip_info *chip = iio_priv(indio_dev);
+ int rising = (dir == IIO_EV_DIR_RISING);
+
+ /* Only update value live, if parameter is in use */
+ if ((type != chip->type) || (dir != chip->dir))
+ return 0;
+
+ switch (type) {
+ /* Note completely different from the adaptive versions */
+ case IIO_EV_TYPE_THRESH: {
+ u16 value = chip->threshold[rising][chan];
+ return i2c_smbus_write_word_swapped(chip->client,
+ ad7150_addresses[chan][3],
+ value);
+ }
+ case IIO_EV_TYPE_THRESH_ADAPTIVE: {
+ int ret;
+ u8 sens, timeout;
+
+ sens = chip->thresh_sensitivity[rising][chan];
+ ret = i2c_smbus_write_byte_data(chip->client,
+ ad7150_addresses[chan][4],
+ sens);
+ if (ret)
+ return ret;
+
+ /*
+ * Single timeout register contains timeouts for both
+ * directions.
+ */
+ timeout = FIELD_PREP(AD7150_CH_TIMEOUT_APPROACHING,
+ chip->thresh_timeout[1][chan]);
+ timeout |= FIELD_PREP(AD7150_CH_TIMEOUT_RECEDING,
+ chip->thresh_timeout[0][chan]);
+ return i2c_smbus_write_byte_data(chip->client,
+ ad7150_addresses[chan][5],
+ timeout);
+ }
+ default:
+ return -EINVAL;
+ }
+}
+
+static int ad7150_write_event_config(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir, int state)
+{
+ struct ad7150_chip_info *chip = iio_priv(indio_dev);
+ int ret = 0;
+
+ /*
+ * There is only a single shared control and no on chip
+ * interrupt disables for the two interrupt lines.
+ * So, enabling will switch the events configured to enable
+ * whatever was most recently requested and if necessary enable_irq()
+ * the interrupt and any disable will disable_irq() for that
+ * channels interrupt.
+ */
+ if (!state) {
+ if ((chip->int_enabled[chan->channel]) &&
+ (type == chip->type) && (dir == chip->dir)) {
+ disable_irq(chip->interrupts[chan->channel]);
+ chip->int_enabled[chan->channel] = false;
+ }
+ return 0;
+ }
+
+ mutex_lock(&chip->state_lock);
+ if ((type != chip->type) || (dir != chip->dir)) {
+ int rising = (dir == IIO_EV_DIR_RISING);
+ u8 thresh_type, cfg, fixed;
+
+ /*
+ * Need to temporarily disable both interrupts if
+ * enabled - this is to avoid races around changing
+ * config and thresholds.
+ * Note enable/disable_irq() are reference counted so
+ * no need to check if already enabled.
+ */
+ disable_irq(chip->interrupts[0]);
+ disable_irq(chip->interrupts[1]);
+
+ ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG_REG);
+ if (ret < 0)
+ goto error_ret;
+
+ cfg = ret & ~(AD7150_CFG_THRESHTYPE_MSK | AD7150_CFG_FIX);
+
+ if (type == IIO_EV_TYPE_THRESH_ADAPTIVE)
+ fixed = 0;
+ else
+ fixed = 1;
+
+ if (rising)
+ thresh_type = AD7150_CFG_TT_POS;
+ else
+ thresh_type = AD7150_CFG_TT_NEG;
+
+ cfg |= FIELD_PREP(AD7150_CFG_FIX, fixed) |
+ FIELD_PREP(AD7150_CFG_THRESHTYPE_MSK, thresh_type);
+
+ ret = i2c_smbus_write_byte_data(chip->client, AD7150_CFG_REG,
+ cfg);
+ if (ret < 0)
+ goto error_ret;
+
+ /*
+ * There is a potential race condition here, but not easy
+ * to close given we can't disable the interrupt at the
+ * chip side of things. Rely on the status bit.
+ */
+ chip->type = type;
+ chip->dir = dir;
+
+ /* update control attributes */
+ ret = ad7150_write_event_params(indio_dev, chan->channel, type,
+ dir);
+ if (ret)
+ goto error_ret;
+ /* reenable any irq's we disabled whilst changing mode */
+ enable_irq(chip->interrupts[0]);
+ enable_irq(chip->interrupts[1]);
+ }
+ if (!chip->int_enabled[chan->channel]) {
+ enable_irq(chip->interrupts[chan->channel]);
+ chip->int_enabled[chan->channel] = true;
+ }
+
+error_ret:
+ mutex_unlock(&chip->state_lock);
+
+ return ret;
+}
+
+static int ad7150_read_event_value(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info,
+ int *val, int *val2)
+{
+ struct ad7150_chip_info *chip = iio_priv(indio_dev);
+ int rising = (dir == IIO_EV_DIR_RISING);
+
+ /* Complex register sharing going on here */
+ switch (info) {
+ case IIO_EV_INFO_VALUE:
+ switch (type) {
+ case IIO_EV_TYPE_THRESH_ADAPTIVE:
+ *val = chip->thresh_sensitivity[rising][chan->channel];
+ return IIO_VAL_INT;
+ case IIO_EV_TYPE_THRESH:
+ *val = chip->threshold[rising][chan->channel];
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+ case IIO_EV_INFO_TIMEOUT:
+ *val = 0;
+ *val2 = chip->thresh_timeout[rising][chan->channel] * 10000;
+ return IIO_VAL_INT_PLUS_MICRO;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int ad7150_write_event_value(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info,
+ int val, int val2)
+{
+ int ret;
+ struct ad7150_chip_info *chip = iio_priv(indio_dev);
+ int rising = (dir == IIO_EV_DIR_RISING);
+
+ mutex_lock(&chip->state_lock);
+ switch (info) {
+ case IIO_EV_INFO_VALUE:
+ switch (type) {
+ case IIO_EV_TYPE_THRESH_ADAPTIVE:
+ chip->thresh_sensitivity[rising][chan->channel] = val;
+ break;
+ case IIO_EV_TYPE_THRESH:
+ chip->threshold[rising][chan->channel] = val;
+ break;
+ default:
+ ret = -EINVAL;
+ goto error_ret;
+ }
+ break;
+ case IIO_EV_INFO_TIMEOUT: {
+ /*
+ * Raw timeout is in cycles of 10 msecs as long as both
+ * channels are enabled.
+ * In terms of INT_PLUS_MICRO, that is in units of 10,000
+ */
+ int timeout = val2 / 10000;
+
+ if (val != 0 || timeout < 0 || timeout > 15 || val2 % 10000) {
+ ret = -EINVAL;
+ goto error_ret;
+ }
+
+ chip->thresh_timeout[rising][chan->channel] = timeout;
+ break;
+ }
+ default:
+ ret = -EINVAL;
+ goto error_ret;
+ }
+
+ /* write back if active */
+ ret = ad7150_write_event_params(indio_dev, chan->channel, type, dir);
+
+error_ret:
+ mutex_unlock(&chip->state_lock);
+ return ret;
+}
+
+static const struct iio_event_spec ad7150_events[] = {
+ {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_RISING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE) |
+ BIT(IIO_EV_INFO_ENABLE),
+ }, {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_FALLING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE) |
+ BIT(IIO_EV_INFO_ENABLE),
+ }, {
+ .type = IIO_EV_TYPE_THRESH_ADAPTIVE,
+ .dir = IIO_EV_DIR_RISING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE) |
+ BIT(IIO_EV_INFO_ENABLE) |
+ BIT(IIO_EV_INFO_TIMEOUT),
+ }, {
+ .type = IIO_EV_TYPE_THRESH_ADAPTIVE,
+ .dir = IIO_EV_DIR_FALLING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE) |
+ BIT(IIO_EV_INFO_ENABLE) |
+ BIT(IIO_EV_INFO_TIMEOUT),
+ },
+};
+
+#define AD7150_CAPACITANCE_CHAN(_chan) { \
+ .type = IIO_CAPACITANCE, \
+ .indexed = 1, \
+ .channel = _chan, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
+ BIT(IIO_CHAN_INFO_AVERAGE_RAW), \
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
+ BIT(IIO_CHAN_INFO_OFFSET), \
+ .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\
+ .event_spec = ad7150_events, \
+ .num_event_specs = ARRAY_SIZE(ad7150_events), \
+ }
+
+#define AD7150_CAPACITANCE_CHAN_NO_IRQ(_chan) { \
+ .type = IIO_CAPACITANCE, \
+ .indexed = 1, \
+ .channel = _chan, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
+ BIT(IIO_CHAN_INFO_AVERAGE_RAW), \
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
+ BIT(IIO_CHAN_INFO_OFFSET), \
+ .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\
+ }
+
+static const struct iio_chan_spec ad7150_channels[] = {
+ AD7150_CAPACITANCE_CHAN(0),
+ AD7150_CAPACITANCE_CHAN(1),
+};
+
+static const struct iio_chan_spec ad7150_channels_no_irq[] = {
+ AD7150_CAPACITANCE_CHAN_NO_IRQ(0),
+ AD7150_CAPACITANCE_CHAN_NO_IRQ(1),
+};
+
+static const struct iio_chan_spec ad7151_channels[] = {
+ AD7150_CAPACITANCE_CHAN(0),
+};
+
+static const struct iio_chan_spec ad7151_channels_no_irq[] = {
+ AD7150_CAPACITANCE_CHAN_NO_IRQ(0),
+};
+
+static irqreturn_t __ad7150_event_handler(void *private, u8 status_mask,
+ int channel)
+{
+ struct iio_dev *indio_dev = private;
+ struct ad7150_chip_info *chip = iio_priv(indio_dev);
+ s64 timestamp = iio_get_time_ns(indio_dev);
+ int int_status;
+
+ int_status = i2c_smbus_read_byte_data(chip->client, AD7150_STATUS_REG);
+ if (int_status < 0)
+ return IRQ_HANDLED;
+
+ if (!(int_status & status_mask))
+ return IRQ_HANDLED;
+
+ iio_push_event(indio_dev,
+ IIO_UNMOD_EVENT_CODE(IIO_CAPACITANCE, channel,
+ chip->type, chip->dir),
+ timestamp);
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t ad7150_event_handler_ch1(int irq, void *private)
+{
+ return __ad7150_event_handler(private, AD7150_STATUS_OUT1, 0);
+}
+
+static irqreturn_t ad7150_event_handler_ch2(int irq, void *private)
+{
+ return __ad7150_event_handler(private, AD7150_STATUS_OUT2, 1);
+}
+
+static IIO_CONST_ATTR(in_capacitance_thresh_adaptive_timeout_available,
+ "[0 0.01 0.15]");
+
+static struct attribute *ad7150_event_attributes[] = {
+ &iio_const_attr_in_capacitance_thresh_adaptive_timeout_available
+ .dev_attr.attr,
+ NULL,
+};
+
+static const struct attribute_group ad7150_event_attribute_group = {
+ .attrs = ad7150_event_attributes,
+ .name = "events",
+};
+
+static const struct iio_info ad7150_info = {
+ .event_attrs = &ad7150_event_attribute_group,
+ .read_raw = &ad7150_read_raw,
+ .read_event_config = &ad7150_read_event_config,
+ .write_event_config = &ad7150_write_event_config,
+ .read_event_value = &ad7150_read_event_value,
+ .write_event_value = &ad7150_write_event_value,
+};
+
+static const struct iio_info ad7150_info_no_irq = {
+ .read_raw = &ad7150_read_raw,
+};
+
+static void ad7150_reg_disable(void *data)
+{
+ struct regulator *reg = data;
+
+ regulator_disable(reg);
+}
+
+static int ad7150_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct ad7150_chip_info *chip;
+ struct iio_dev *indio_dev;
+ struct regulator *reg;
+ int ret;
+
+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ chip = iio_priv(indio_dev);
+ mutex_init(&chip->state_lock);
+ chip->client = client;
+
+ indio_dev->name = id->name;
+
+ indio_dev->modes = INDIO_DIRECT_MODE;
+
+ reg = devm_regulator_get(&client->dev, "vdd");
+ if (IS_ERR(reg))
+ return PTR_ERR(reg);
+
+ ret = regulator_enable(reg);
+ if (ret)
+ return ret;
+
+ ret = devm_add_action_or_reset(&client->dev, ad7150_reg_disable, reg);
+ if (ret)
+ return ret;
+
+ chip->interrupts[0] = fwnode_irq_get(dev_fwnode(&client->dev), 0);
+ if (chip->interrupts[0] < 0)
+ return chip->interrupts[0];
+ if (id->driver_data == AD7150) {
+ chip->interrupts[1] = fwnode_irq_get(dev_fwnode(&client->dev), 1);
+ if (chip->interrupts[1] < 0)
+ return chip->interrupts[1];
+ }
+ if (chip->interrupts[0] &&
+ (id->driver_data == AD7151 || chip->interrupts[1])) {
+ irq_set_status_flags(chip->interrupts[0], IRQ_NOAUTOEN);
+ ret = devm_request_threaded_irq(&client->dev,
+ chip->interrupts[0],
+ NULL,
+ &ad7150_event_handler_ch1,
+ IRQF_TRIGGER_RISING |
+ IRQF_ONESHOT,
+ "ad7150_irq1",
+ indio_dev);
+ if (ret)
+ return ret;
+
+ indio_dev->info = &ad7150_info;
+ switch (id->driver_data) {
+ case AD7150:
+ indio_dev->channels = ad7150_channels;
+ indio_dev->num_channels = ARRAY_SIZE(ad7150_channels);
+ irq_set_status_flags(chip->interrupts[1], IRQ_NOAUTOEN);
+ ret = devm_request_threaded_irq(&client->dev,
+ chip->interrupts[1],
+ NULL,
+ &ad7150_event_handler_ch2,
+ IRQF_TRIGGER_RISING |
+ IRQF_ONESHOT,
+ "ad7150_irq2",
+ indio_dev);
+ if (ret)
+ return ret;
+ break;
+ case AD7151:
+ indio_dev->channels = ad7151_channels;
+ indio_dev->num_channels = ARRAY_SIZE(ad7151_channels);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ } else {
+ indio_dev->info = &ad7150_info_no_irq;
+ switch (id->driver_data) {
+ case AD7150:
+ indio_dev->channels = ad7150_channels_no_irq;
+ indio_dev->num_channels =
+ ARRAY_SIZE(ad7150_channels_no_irq);
+ break;
+ case AD7151:
+ indio_dev->channels = ad7151_channels_no_irq;
+ indio_dev->num_channels =
+ ARRAY_SIZE(ad7151_channels_no_irq);
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ return devm_iio_device_register(indio_dev->dev.parent, indio_dev);
+}
+
+static const struct i2c_device_id ad7150_id[] = {
+ { "ad7150", AD7150 },
+ { "ad7151", AD7151 },
+ { "ad7156", AD7150 },
+ {}
+};
+
+MODULE_DEVICE_TABLE(i2c, ad7150_id);
+
+static const struct of_device_id ad7150_of_match[] = {
+ { "adi,ad7150" },
+ { "adi,ad7151" },
+ { "adi,ad7156" },
+ {}
+};
+static struct i2c_driver ad7150_driver = {
+ .driver = {
+ .name = "ad7150",
+ .of_match_table = ad7150_of_match,
+ },
+ .probe = ad7150_probe,
+ .id_table = ad7150_id,
+};
+module_i2c_driver(ad7150_driver);
+
+MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
+MODULE_DESCRIPTION("Analog Devices AD7150/1/6 capacitive sensor driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
index cdab9d04dedd..56ba6c82b501 100644
--- a/drivers/iio/chemical/atlas-sensor.c
+++ b/drivers/iio/chemical/atlas-sensor.c
@@ -649,7 +649,6 @@ static int atlas_probe(struct i2c_client *client,
data->client = client;
data->trig = trig;
data->chip = chip;
- trig->dev.parent = indio_dev->dev.parent;
trig->ops = &atlas_interrupt_trigger_ops;
iio_trigger_set_drvdata(trig, indio_dev);
diff --git a/drivers/iio/chemical/bme680_i2c.c b/drivers/iio/chemical/bme680_i2c.c
index de9c9e3d23ea..29c0dfa4702b 100644
--- a/drivers/iio/chemical/bme680_i2c.c
+++ b/drivers/iio/chemical/bme680_i2c.c
@@ -26,8 +26,7 @@ static int bme680_i2c_probe(struct i2c_client *client,
regmap = devm_regmap_init_i2c(client, &bme680_regmap_config);
if (IS_ERR(regmap)) {
- dev_err(&client->dev, "Failed to register i2c regmap %d\n",
- (int)PTR_ERR(regmap));
+ dev_err(&client->dev, "Failed to register i2c regmap %ld\n", PTR_ERR(regmap));
return PTR_ERR(regmap);
}
diff --git a/drivers/iio/chemical/bme680_spi.c b/drivers/iio/chemical/bme680_spi.c
index 3b838068a7e4..6f56ad48cc40 100644
--- a/drivers/iio/chemical/bme680_spi.c
+++ b/drivers/iio/chemical/bme680_spi.c
@@ -132,8 +132,7 @@ static int bme680_spi_probe(struct spi_device *spi)
regmap = devm_regmap_init(&spi->dev, &bme680_regmap_bus,
bus_context, &bme680_regmap_config);
if (IS_ERR(regmap)) {
- dev_err(&spi->dev, "Failed to register spi regmap %d\n",
- (int)PTR_ERR(regmap));
+ dev_err(&spi->dev, "Failed to register spi regmap %ld\n", PTR_ERR(regmap));
return PTR_ERR(regmap);
}
diff --git a/drivers/iio/chemical/ccs811.c b/drivers/iio/chemical/ccs811.c
index 60dd87e96f5f..886e96496dbf 100644
--- a/drivers/iio/chemical/ccs811.c
+++ b/drivers/iio/chemical/ccs811.c
@@ -497,7 +497,6 @@ static int ccs811_probe(struct i2c_client *client,
goto err_poweroff;
}
- data->drdy_trig->dev.parent = &client->dev;
data->drdy_trig->ops = &ccs811_trigger_ops;
iio_trigger_set_drvdata(data->drdy_trig, indio_dev);
indio_dev->trig = data->drdy_trig;
diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c
index 4d0d798c7cd3..d89f117dd0ef 100644
--- a/drivers/iio/chemical/scd30_core.c
+++ b/drivers/iio/chemical/scd30_core.c
@@ -646,7 +646,6 @@ static int scd30_setup_trigger(struct iio_dev *indio_dev)
return -ENOMEM;
}
- trig->dev.parent = dev;
trig->ops = &scd30_trigger_ops;
iio_trigger_set_drvdata(trig, indio_dev);
@@ -656,19 +655,19 @@ static int scd30_setup_trigger(struct iio_dev *indio_dev)
indio_dev->trig = iio_trigger_get(trig);
+ /*
+ * Interrupt is enabled just before taking a fresh measurement
+ * and disabled afterwards. This means we need to ensure it is not
+ * enabled here to keep calls to enable/disable balanced.
+ */
ret = devm_request_threaded_irq(dev, state->irq, scd30_irq_handler,
- scd30_irq_thread_handler, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+ scd30_irq_thread_handler,
+ IRQF_TRIGGER_HIGH | IRQF_ONESHOT |
+ IRQF_NO_AUTOEN,
indio_dev->name, indio_dev);
if (ret)
dev_err(dev, "failed to request irq\n");
- /*
- * Interrupt is enabled just before taking a fresh measurement
- * and disabled afterwards. This means we need to disable it here
- * to keep calls to enable/disable balanced.
- */
- disable_irq(state->irq);
-
return ret;
}
diff --git a/drivers/iio/chemical/scd30_serial.c b/drivers/iio/chemical/scd30_serial.c
index 06f85eb1a4dd..568b34486c44 100644
--- a/drivers/iio/chemical/scd30_serial.c
+++ b/drivers/iio/chemical/scd30_serial.c
@@ -177,7 +177,7 @@ static int scd30_serdev_command(struct scd30_state *state, enum scd30_cmd cmd, u
static int scd30_serdev_receive_buf(struct serdev_device *serdev,
const unsigned char *buf, size_t size)
{
- struct iio_dev *indio_dev = dev_get_drvdata(&serdev->dev);
+ struct iio_dev *indio_dev = serdev_device_get_drvdata(serdev);
struct scd30_serdev_priv *priv;
struct scd30_state *state;
int num;
diff --git a/drivers/iio/common/Kconfig b/drivers/iio/common/Kconfig
index 2b9ee9161abd..0334b4954773 100644
--- a/drivers/iio/common/Kconfig
+++ b/drivers/iio/common/Kconfig
@@ -6,5 +6,6 @@
source "drivers/iio/common/cros_ec_sensors/Kconfig"
source "drivers/iio/common/hid-sensors/Kconfig"
source "drivers/iio/common/ms_sensors/Kconfig"
+source "drivers/iio/common/scmi_sensors/Kconfig"
source "drivers/iio/common/ssp_sensors/Kconfig"
source "drivers/iio/common/st_sensors/Kconfig"
diff --git a/drivers/iio/common/Makefile b/drivers/iio/common/Makefile
index 4bc30bb548e2..fad40e1e1718 100644
--- a/drivers/iio/common/Makefile
+++ b/drivers/iio/common/Makefile
@@ -11,5 +11,6 @@
obj-y += cros_ec_sensors/
obj-y += hid-sensors/
obj-y += ms_sensors/
+obj-y += scmi_sensors/
obj-y += ssp_sensors/
obj-y += st_sensors/
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
index 752f59037715..af801e203623 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
@@ -97,8 +97,7 @@ static int cros_ec_lid_angle_probe(struct platform_device *pdev)
if (!indio_dev)
return -ENOMEM;
- ret = cros_ec_sensors_core_init(pdev, indio_dev, false, NULL,
- NULL, false);
+ ret = cros_ec_sensors_core_init(pdev, indio_dev, false, NULL, NULL);
if (ret)
return ret;
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
index dee1191de752..376a5b30010a 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -236,8 +236,7 @@ static int cros_ec_sensors_probe(struct platform_device *pdev)
ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
cros_ec_sensors_capture,
- cros_ec_sensors_push_data,
- true);
+ cros_ec_sensors_push_data);
if (ret)
return ret;
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
index c833ec0ef214..28bde13003b7 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
@@ -12,6 +12,7 @@
#include <linux/iio/iio.h>
#include <linux/iio/kfifo_buf.h>
#include <linux/iio/sysfs.h>
+#include <linux/iio/trigger.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/kernel.h>
@@ -240,7 +241,6 @@ static void cros_ec_sensors_core_clean(void *arg)
* for backward compatibility.
* @push_data: function to call when cros_ec_sensorhub receives
* a sample for that sensor.
- * @has_hw_fifo: Set true if this device has/uses a HW FIFO
*
* Return: 0 on success, -errno on failure.
*/
@@ -248,8 +248,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
struct iio_dev *indio_dev,
bool physical_device,
cros_ec_sensors_capture_t trigger_capture,
- cros_ec_sensorhub_push_data_cb_t push_data,
- bool has_hw_fifo)
+ cros_ec_sensorhub_push_data_cb_t push_data)
{
struct device *dev = &pdev->dev;
struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
@@ -334,14 +333,11 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
* We can not use trigger here, as events are generated
* as soon as sample_frequency is set.
*/
- struct iio_buffer *buffer;
-
- buffer = devm_iio_kfifo_allocate(dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
- indio_dev->modes = INDIO_BUFFER_SOFTWARE;
+ ret = devm_iio_kfifo_buffer_setup_ext(dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE, NULL,
+ cros_ec_sensor_fifo_attributes);
+ if (ret)
+ return ret;
ret = cros_ec_sensorhub_register_push_data(
sensor_hub, sensor_platform->sensor_num,
@@ -358,21 +354,14 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
ret = iio_device_set_clock(indio_dev, CLOCK_BOOTTIME);
if (ret)
return ret;
- } else {
- const struct attribute **fifo_attrs;
-
- if (has_hw_fifo)
- fifo_attrs = cros_ec_sensor_fifo_attributes;
- else
- fifo_attrs = NULL;
+ } else {
/*
* The only way to get samples in buffer is to set a
* software trigger (systrig, hrtimer).
*/
- ret = devm_iio_triggered_buffer_setup_ext(
- dev, indio_dev, NULL, trigger_capture,
- NULL, fifo_attrs);
+ ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
+ NULL, trigger_capture, NULL);
if (ret)
return ret;
}
@@ -562,7 +551,7 @@ static int cros_ec_sensors_read_until_not_busy(
}
/**
- * read_ec_sensors_data_unsafe() - read acceleration data from EC shared memory
+ * cros_ec_sensors_read_data_unsafe() - read acceleration data from EC shared memory
* @indio_dev: pointer to IIO device
* @scan_mask: bitmap of the sensor indices to scan
* @data: location to store data
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index 5b822a4298a0..cb52b4fd6bf7 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -263,6 +263,29 @@ int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st,
}
EXPORT_SYMBOL(hid_sensor_read_raw_hyst_value);
+int hid_sensor_read_raw_hyst_rel_value(struct hid_sensor_common *st, int *val1,
+ int *val2)
+{
+ s32 value;
+ int ret;
+
+ ret = sensor_hub_get_feature(st->hsdev,
+ st->sensitivity_rel.report_id,
+ st->sensitivity_rel.index, sizeof(value),
+ &value);
+ if (ret < 0 || value < 0) {
+ *val1 = *val2 = 0;
+ return -EINVAL;
+ }
+
+ convert_from_vtf_format(value, st->sensitivity_rel.size,
+ st->sensitivity_rel.unit_expo, val1, val2);
+
+ return IIO_VAL_INT_PLUS_MICRO;
+}
+EXPORT_SYMBOL(hid_sensor_read_raw_hyst_rel_value);
+
+
int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
int val1, int val2)
{
@@ -294,6 +317,37 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
}
EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value);
+int hid_sensor_write_raw_hyst_rel_value(struct hid_sensor_common *st,
+ int val1, int val2)
+{
+ s32 value;
+ int ret;
+
+ if (val1 < 0 || val2 < 0)
+ return -EINVAL;
+
+ value = convert_to_vtf_format(st->sensitivity_rel.size,
+ st->sensitivity_rel.unit_expo,
+ val1, val2);
+ ret = sensor_hub_set_feature(st->hsdev, st->sensitivity_rel.report_id,
+ st->sensitivity_rel.index, sizeof(value),
+ &value);
+ if (ret < 0 || value < 0)
+ return -EINVAL;
+
+ ret = sensor_hub_get_feature(st->hsdev,
+ st->sensitivity_rel.report_id,
+ st->sensitivity_rel.index, sizeof(value),
+ &value);
+ if (ret < 0 || value < 0)
+ return -EINVAL;
+
+ st->raw_hystersis = value;
+
+ return 0;
+}
+EXPORT_SYMBOL(hid_sensor_write_raw_hyst_rel_value);
+
/*
* This fuction applies the unit exponent to the scale.
* For example:
@@ -448,12 +502,15 @@ EXPORT_SYMBOL(hid_sensor_batch_mode_supported);
int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
u32 usage_id,
- struct hid_sensor_common *st)
+ struct hid_sensor_common *st,
+ const u32 *sensitivity_addresses,
+ u32 sensitivity_addresses_len)
{
struct hid_sensor_hub_attribute_info timestamp;
s32 value;
int ret;
+ int i;
hid_sensor_get_reporting_interval(hsdev, usage_id, st);
@@ -475,6 +532,30 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS,
&st->sensitivity);
+ sensor_hub_input_get_attribute_info(hsdev,
+ HID_FEATURE_REPORT, usage_id,
+ HID_USAGE_SENSOR_PROP_SENSITIVITY_REL_PCT,
+ &st->sensitivity_rel);
+ /*
+ * Set Sensitivity field ids, when there is no individual modifier, will
+ * check absolute sensitivity and relative sensitivity of data field
+ */
+ for (i = 0; i < sensitivity_addresses_len; i++) {
+ if (st->sensitivity.index < 0)
+ sensor_hub_input_get_attribute_info(
+ hsdev, HID_FEATURE_REPORT, usage_id,
+ HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
+ sensitivity_addresses[i],
+ &st->sensitivity);
+
+ if (st->sensitivity_rel.index < 0)
+ sensor_hub_input_get_attribute_info(
+ hsdev, HID_FEATURE_REPORT, usage_id,
+ HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_REL_PCT |
+ sensitivity_addresses[i],
+ &st->sensitivity_rel);
+ }
+
st->raw_hystersis = -1;
sensor_hub_input_get_attribute_info(hsdev,
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 064c32bec9c7..95ddccb44f1c 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -255,14 +255,14 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
return ret;
}
- trig = iio_trigger_alloc("%s-dev%d", name, indio_dev->id);
+ trig = iio_trigger_alloc(indio_dev->dev.parent,
+ "%s-dev%d", name, indio_dev->id);
if (trig == NULL) {
dev_err(&indio_dev->dev, "Trigger Allocate Failed\n");
ret = -ENOMEM;
goto error_triggered_buffer_cleanup;
}
- trig->dev.parent = indio_dev->dev.parent;
iio_trigger_set_drvdata(trig, attrb);
trig->ops = &hid_sensor_trigger_ops;
ret = iio_trigger_register(trig);
diff --git a/drivers/iio/common/scmi_sensors/Kconfig b/drivers/iio/common/scmi_sensors/Kconfig
new file mode 100644
index 000000000000..67e084cbb1ab
--- /dev/null
+++ b/drivers/iio/common/scmi_sensors/Kconfig
@@ -0,0 +1,18 @@
+#
+# IIO over SCMI
+#
+# When adding new entries keep the list in alphabetical order
+
+menu "IIO SCMI Sensors"
+
+config IIO_SCMI
+ tristate "IIO SCMI"
+ depends on ARM_SCMI_PROTOCOL
+ select IIO_BUFFER
+ select IIO_KFIFO_BUF
+ help
+ Say yes here to build support for IIO SCMI Driver.
+ This provides ARM SCMI Protocol based IIO device.
+ This driver provides support for accelerometer and gyroscope
+ sensors available on SCMI based platforms.
+endmenu
diff --git a/drivers/iio/common/scmi_sensors/Makefile b/drivers/iio/common/scmi_sensors/Makefile
new file mode 100644
index 000000000000..f13140a2575a
--- /dev/null
+++ b/drivers/iio/common/scmi_sensors/Makefile
@@ -0,0 +1,5 @@
+# SPDX - License - Identifier : GPL - 2.0 - only
+#
+# Makefile for the IIO over SCMI
+#
+obj-$(CONFIG_IIO_SCMI) += scmi_iio.o
diff --git a/drivers/iio/common/scmi_sensors/scmi_iio.c b/drivers/iio/common/scmi_sensors/scmi_iio.c
new file mode 100644
index 000000000000..63e4cec9de5e
--- /dev/null
+++ b/drivers/iio/common/scmi_sensors/scmi_iio.c
@@ -0,0 +1,672 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * System Control and Management Interface(SCMI) based IIO sensor driver
+ *
+ * Copyright (C) 2021 Google LLC
+ */
+
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/kfifo_buf.h>
+#include <linux/iio/sysfs.h>
+#include <linux/kernel.h>
+#include <linux/kthread.h>
+#include <linux/module.h>
+#include <linux/scmi_protocol.h>
+#include <linux/time.h>
+#include <linux/types.h>
+
+#define SCMI_IIO_NUM_OF_AXIS 3
+
+struct scmi_iio_priv {
+ struct scmi_handle *handle;
+ const struct scmi_sensor_info *sensor_info;
+ struct iio_dev *indio_dev;
+ /* adding one additional channel for timestamp */
+ s64 iio_buf[SCMI_IIO_NUM_OF_AXIS + 1];
+ struct notifier_block sensor_update_nb;
+ u32 *freq_avail;
+};
+
+static int scmi_iio_sensor_update_cb(struct notifier_block *nb,
+ unsigned long event, void *data)
+{
+ struct scmi_sensor_update_report *sensor_update = data;
+ struct iio_dev *scmi_iio_dev;
+ struct scmi_iio_priv *sensor;
+ s8 tstamp_scale;
+ u64 time, time_ns;
+ int i;
+
+ if (sensor_update->readings_count == 0)
+ return NOTIFY_DONE;
+
+ sensor = container_of(nb, struct scmi_iio_priv, sensor_update_nb);
+
+ for (i = 0; i < sensor_update->readings_count; i++)
+ sensor->iio_buf[i] = sensor_update->readings[i].value;
+
+ if (!sensor->sensor_info->timestamped) {
+ time_ns = ktime_to_ns(sensor_update->timestamp);
+ } else {
+ /*
+ * All the axes are supposed to have the same value for timestamp.
+ * We are just using the values from the Axis 0 here.
+ */
+ time = sensor_update->readings[0].timestamp;
+
+ /*
+ * Timestamp returned by SCMI is in seconds and is equal to
+ * time * power-of-10 multiplier(tstamp_scale) seconds.
+ * Converting the timestamp to nanoseconds below.
+ */
+ tstamp_scale = sensor->sensor_info->tstamp_scale +
+ const_ilog2(NSEC_PER_SEC) / const_ilog2(10);
+ if (tstamp_scale < 0) {
+ do_div(time, int_pow(10, abs(tstamp_scale)));
+ time_ns = time;
+ } else {
+ time_ns = time * int_pow(10, tstamp_scale);
+ }
+ }
+
+ scmi_iio_dev = sensor->indio_dev;
+ iio_push_to_buffers_with_timestamp(scmi_iio_dev, sensor->iio_buf,
+ time_ns);
+ return NOTIFY_OK;
+}
+
+static int scmi_iio_buffer_preenable(struct iio_dev *iio_dev)
+{
+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
+ u32 sensor_id = sensor->sensor_info->id;
+ u32 sensor_config = 0;
+ int err;
+
+ if (sensor->sensor_info->timestamped)
+ sensor_config |= FIELD_PREP(SCMI_SENS_CFG_TSTAMP_ENABLED_MASK,
+ SCMI_SENS_CFG_TSTAMP_ENABLE);
+
+ sensor_config |= FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
+ SCMI_SENS_CFG_SENSOR_ENABLE);
+
+ err = sensor->handle->notify_ops->register_event_notifier(sensor->handle,
+ SCMI_PROTOCOL_SENSOR, SCMI_EVENT_SENSOR_UPDATE,
+ &sensor_id, &sensor->sensor_update_nb);
+ if (err) {
+ dev_err(&iio_dev->dev,
+ "Error in registering sensor update notifier for sensor %s err %d",
+ sensor->sensor_info->name, err);
+ return err;
+ }
+
+ err = sensor->handle->sensor_ops->config_set(sensor->handle,
+ sensor->sensor_info->id, sensor_config);
+ if (err) {
+ sensor->handle->notify_ops->unregister_event_notifier(sensor->handle,
+ SCMI_PROTOCOL_SENSOR,
+ SCMI_EVENT_SENSOR_UPDATE, &sensor_id,
+ &sensor->sensor_update_nb);
+ dev_err(&iio_dev->dev, "Error in enabling sensor %s err %d",
+ sensor->sensor_info->name, err);
+ }
+
+ return err;
+}
+
+static int scmi_iio_buffer_postdisable(struct iio_dev *iio_dev)
+{
+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
+ u32 sensor_id = sensor->sensor_info->id;
+ u32 sensor_config = 0;
+ int err;
+
+ sensor_config |= FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
+ SCMI_SENS_CFG_SENSOR_DISABLE);
+
+ err = sensor->handle->notify_ops->unregister_event_notifier(sensor->handle,
+ SCMI_PROTOCOL_SENSOR, SCMI_EVENT_SENSOR_UPDATE,
+ &sensor_id, &sensor->sensor_update_nb);
+ if (err) {
+ dev_err(&iio_dev->dev,
+ "Error in unregistering sensor update notifier for sensor %s err %d",
+ sensor->sensor_info->name, err);
+ return err;
+ }
+
+ err = sensor->handle->sensor_ops->config_set(sensor->handle, sensor_id,
+ sensor_config);
+ if (err) {
+ dev_err(&iio_dev->dev,
+ "Error in disabling sensor %s with err %d",
+ sensor->sensor_info->name, err);
+ }
+
+ return err;
+}
+
+static const struct iio_buffer_setup_ops scmi_iio_buffer_ops = {
+ .preenable = scmi_iio_buffer_preenable,
+ .postdisable = scmi_iio_buffer_postdisable,
+};
+
+static int scmi_iio_set_odr_val(struct iio_dev *iio_dev, int val, int val2)
+{
+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
+ const unsigned long UHZ_PER_HZ = 1000000UL;
+ u64 sec, mult, uHz, sf;
+ u32 sensor_config;
+ char buf[32];
+
+ int err = sensor->handle->sensor_ops->config_get(sensor->handle,
+ sensor->sensor_info->id, &sensor_config);
+ if (err) {
+ dev_err(&iio_dev->dev,
+ "Error in getting sensor config for sensor %s err %d",
+ sensor->sensor_info->name, err);
+ return err;
+ }
+
+ uHz = val * UHZ_PER_HZ + val2;
+
+ /*
+ * The seconds field in the sensor interval in SCMI is 16 bits long
+ * Therefore seconds = 1/Hz <= 0xFFFF. As floating point calculations are
+ * discouraged in the kernel driver code, to calculate the scale factor (sf)
+ * (1* 1000000 * sf)/uHz <= 0xFFFF. Therefore, sf <= (uHz * 0xFFFF)/1000000
+ * To calculate the multiplier,we convert the sf into char string and
+ * count the number of characters
+ */
+ sf = (u64)uHz * 0xFFFF;
+ do_div(sf, UHZ_PER_HZ);
+ mult = scnprintf(buf, sizeof(buf), "%llu", sf) - 1;
+
+ sec = int_pow(10, mult) * UHZ_PER_HZ;
+ do_div(sec, uHz);
+ if (sec == 0) {
+ dev_err(&iio_dev->dev,
+ "Trying to set invalid sensor update value for sensor %s",
+ sensor->sensor_info->name);
+ return -EINVAL;
+ }
+
+ sensor_config &= ~SCMI_SENS_CFG_UPDATE_SECS_MASK;
+ sensor_config |= FIELD_PREP(SCMI_SENS_CFG_UPDATE_SECS_MASK, sec);
+ sensor_config &= ~SCMI_SENS_CFG_UPDATE_EXP_MASK;
+ sensor_config |= FIELD_PREP(SCMI_SENS_CFG_UPDATE_EXP_MASK, -mult);
+
+ if (sensor->sensor_info->timestamped) {
+ sensor_config &= ~SCMI_SENS_CFG_TSTAMP_ENABLED_MASK;
+ sensor_config |= FIELD_PREP(SCMI_SENS_CFG_TSTAMP_ENABLED_MASK,
+ SCMI_SENS_CFG_TSTAMP_ENABLE);
+ }
+
+ sensor_config &= ~SCMI_SENS_CFG_ROUND_MASK;
+ sensor_config |=
+ FIELD_PREP(SCMI_SENS_CFG_ROUND_MASK, SCMI_SENS_CFG_ROUND_AUTO);
+
+ err = sensor->handle->sensor_ops->config_set(sensor->handle,
+ sensor->sensor_info->id, sensor_config);
+ if (err)
+ dev_err(&iio_dev->dev,
+ "Error in setting sensor update interval for sensor %s value %u err %d",
+ sensor->sensor_info->name, sensor_config, err);
+
+ return err;
+}
+
+static int scmi_iio_write_raw(struct iio_dev *iio_dev,
+ struct iio_chan_spec const *chan, int val,
+ int val2, long mask)
+{
+ int err;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ mutex_lock(&iio_dev->mlock);
+ err = scmi_iio_set_odr_val(iio_dev, val, val2);
+ mutex_unlock(&iio_dev->mlock);
+ return err;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int scmi_iio_read_avail(struct iio_dev *iio_dev,
+ struct iio_chan_spec const *chan,
+ const int **vals, int *type, int *length,
+ long mask)
+{
+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ *vals = sensor->freq_avail;
+ *type = IIO_VAL_INT_PLUS_MICRO;
+ *length = sensor->sensor_info->intervals.count * 2;
+ if (sensor->sensor_info->intervals.segmented)
+ return IIO_AVAIL_RANGE;
+ else
+ return IIO_AVAIL_LIST;
+ default:
+ return -EINVAL;
+ }
+}
+
+static void convert_ns_to_freq(u64 interval_ns, u64 *hz, u64 *uhz)
+{
+ u64 rem, freq;
+
+ freq = NSEC_PER_SEC;
+ rem = do_div(freq, interval_ns);
+ *hz = freq;
+ *uhz = rem * 1000000UL;
+ do_div(*uhz, interval_ns);
+}
+
+static int scmi_iio_get_odr_val(struct iio_dev *iio_dev, int *val, int *val2)
+{
+ u64 sensor_update_interval, sensor_interval_mult, hz, uhz;
+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
+ u32 sensor_config;
+ int mult;
+
+ int err = sensor->handle->sensor_ops->config_get(sensor->handle,
+ sensor->sensor_info->id, &sensor_config);
+ if (err) {
+ dev_err(&iio_dev->dev,
+ "Error in getting sensor config for sensor %s err %d",
+ sensor->sensor_info->name, err);
+ return err;
+ }
+
+ sensor_update_interval =
+ SCMI_SENS_CFG_GET_UPDATE_SECS(sensor_config) * NSEC_PER_SEC;
+
+ mult = SCMI_SENS_CFG_GET_UPDATE_EXP(sensor_config);
+ if (mult < 0) {
+ sensor_interval_mult = int_pow(10, abs(mult));
+ do_div(sensor_update_interval, sensor_interval_mult);
+ } else {
+ sensor_interval_mult = int_pow(10, mult);
+ sensor_update_interval =
+ sensor_update_interval * sensor_interval_mult;
+ }
+
+ convert_ns_to_freq(sensor_update_interval, &hz, &uhz);
+ *val = hz;
+ *val2 = uhz;
+ return 0;
+}
+
+static int scmi_iio_read_raw(struct iio_dev *iio_dev,
+ struct iio_chan_spec const *ch, int *val,
+ int *val2, long mask)
+{
+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
+ s8 scale;
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SCALE:
+ scale = sensor->sensor_info->axis[ch->scan_index].scale;
+ if (scale < 0) {
+ *val = 1;
+ *val2 = int_pow(10, abs(scale));
+ return IIO_VAL_FRACTIONAL;
+ }
+ *val = int_pow(10, scale);
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ ret = scmi_iio_get_odr_val(iio_dev, val, val2);
+ return ret ? ret : IIO_VAL_INT_PLUS_MICRO;
+ default:
+ return -EINVAL;
+ }
+}
+
+static const struct iio_info scmi_iio_info = {
+ .read_raw = scmi_iio_read_raw,
+ .read_avail = scmi_iio_read_avail,
+ .write_raw = scmi_iio_write_raw,
+};
+
+static ssize_t scmi_iio_get_raw_available(struct iio_dev *iio_dev,
+ uintptr_t private,
+ const struct iio_chan_spec *chan,
+ char *buf)
+{
+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
+ u64 resolution, rem;
+ s64 min_range, max_range;
+ s8 exponent, scale;
+ int len = 0;
+
+ /*
+ * All the axes are supposed to have the same value for range and resolution.
+ * We are just using the values from the Axis 0 here.
+ */
+ if (sensor->sensor_info->axis[0].extended_attrs) {
+ min_range = sensor->sensor_info->axis[0].attrs.min_range;
+ max_range = sensor->sensor_info->axis[0].attrs.max_range;
+ resolution = sensor->sensor_info->axis[0].resolution;
+ exponent = sensor->sensor_info->axis[0].exponent;
+ scale = sensor->sensor_info->axis[0].scale;
+
+ /*
+ * To provide the raw value for the resolution to the userspace,
+ * need to divide the resolution exponent by the sensor scale
+ */
+ exponent = exponent - scale;
+ if (exponent < 0) {
+ rem = do_div(resolution,
+ int_pow(10, abs(exponent))
+ );
+ len = scnprintf(buf, PAGE_SIZE,
+ "[%lld %llu.%llu %lld]\n", min_range,
+ resolution, rem, max_range);
+ } else {
+ resolution = resolution * int_pow(10, exponent);
+ len = scnprintf(buf, PAGE_SIZE, "[%lld %llu %lld]\n",
+ min_range, resolution, max_range);
+ }
+ }
+ return len;
+}
+
+static const struct iio_chan_spec_ext_info scmi_iio_ext_info[] = {
+ {
+ .name = "raw_available",
+ .read = scmi_iio_get_raw_available,
+ .shared = IIO_SHARED_BY_TYPE,
+ },
+ {},
+};
+
+static void scmi_iio_set_timestamp_channel(struct iio_chan_spec *iio_chan,
+ int scan_index)
+{
+ iio_chan->type = IIO_TIMESTAMP;
+ iio_chan->channel = -1;
+ iio_chan->scan_index = scan_index;
+ iio_chan->scan_type.sign = 'u';
+ iio_chan->scan_type.realbits = 64;
+ iio_chan->scan_type.storagebits = 64;
+}
+
+static void scmi_iio_set_data_channel(struct iio_chan_spec *iio_chan,
+ enum iio_chan_type type,
+ enum iio_modifier mod, int scan_index)
+{
+ iio_chan->type = type;
+ iio_chan->modified = 1;
+ iio_chan->channel2 = mod;
+ iio_chan->info_mask_separate = BIT(IIO_CHAN_INFO_SCALE);
+ iio_chan->info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ);
+ iio_chan->info_mask_shared_by_type_available =
+ BIT(IIO_CHAN_INFO_SAMP_FREQ);
+ iio_chan->scan_index = scan_index;
+ iio_chan->scan_type.sign = 's';
+ iio_chan->scan_type.realbits = 64;
+ iio_chan->scan_type.storagebits = 64;
+ iio_chan->scan_type.endianness = IIO_LE;
+ iio_chan->ext_info = scmi_iio_ext_info;
+}
+
+static int scmi_iio_get_chan_modifier(const char *name,
+ enum iio_modifier *modifier)
+{
+ char *pch, mod;
+
+ if (!name)
+ return -EINVAL;
+
+ pch = strrchr(name, '_');
+ if (!pch)
+ return -EINVAL;
+
+ mod = *(pch + 1);
+ switch (mod) {
+ case 'X':
+ *modifier = IIO_MOD_X;
+ return 0;
+ case 'Y':
+ *modifier = IIO_MOD_Y;
+ return 0;
+ case 'Z':
+ *modifier = IIO_MOD_Z;
+ return 0;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int scmi_iio_get_chan_type(u8 scmi_type, enum iio_chan_type *iio_type)
+{
+ switch (scmi_type) {
+ case METERS_SEC_SQUARED:
+ *iio_type = IIO_ACCEL;
+ return 0;
+ case RADIANS_SEC:
+ *iio_type = IIO_ANGL_VEL;
+ return 0;
+ default:
+ return -EINVAL;
+ }
+}
+
+static u64 scmi_iio_convert_interval_to_ns(u32 val)
+{
+ u64 sensor_update_interval =
+ SCMI_SENS_INTVL_GET_SECS(val) * NSEC_PER_SEC;
+ u64 sensor_interval_mult;
+ int mult;
+
+ mult = SCMI_SENS_INTVL_GET_EXP(val);
+ if (mult < 0) {
+ sensor_interval_mult = int_pow(10, abs(mult));
+ do_div(sensor_update_interval, sensor_interval_mult);
+ } else {
+ sensor_interval_mult = int_pow(10, mult);
+ sensor_update_interval =
+ sensor_update_interval * sensor_interval_mult;
+ }
+ return sensor_update_interval;
+}
+
+static int scmi_iio_set_sampling_freq_avail(struct iio_dev *iio_dev)
+{
+ u64 cur_interval_ns, low_interval_ns, high_interval_ns, step_size_ns,
+ hz, uhz;
+ unsigned int cur_interval, low_interval, high_interval, step_size;
+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
+ int i;
+
+ sensor->freq_avail =
+ devm_kzalloc(&iio_dev->dev,
+ sizeof(*sensor->freq_avail) *
+ (sensor->sensor_info->intervals.count * 2),
+ GFP_KERNEL);
+ if (!sensor->freq_avail)
+ return -ENOMEM;
+
+ if (sensor->sensor_info->intervals.segmented) {
+ low_interval = sensor->sensor_info->intervals
+ .desc[SCMI_SENS_INTVL_SEGMENT_LOW];
+ low_interval_ns = scmi_iio_convert_interval_to_ns(low_interval);
+ convert_ns_to_freq(low_interval_ns, &hz, &uhz);
+ sensor->freq_avail[0] = hz;
+ sensor->freq_avail[1] = uhz;
+
+ step_size = sensor->sensor_info->intervals
+ .desc[SCMI_SENS_INTVL_SEGMENT_STEP];
+ step_size_ns = scmi_iio_convert_interval_to_ns(step_size);
+ convert_ns_to_freq(step_size_ns, &hz, &uhz);
+ sensor->freq_avail[2] = hz;
+ sensor->freq_avail[3] = uhz;
+
+ high_interval = sensor->sensor_info->intervals
+ .desc[SCMI_SENS_INTVL_SEGMENT_HIGH];
+ high_interval_ns =
+ scmi_iio_convert_interval_to_ns(high_interval);
+ convert_ns_to_freq(high_interval_ns, &hz, &uhz);
+ sensor->freq_avail[4] = hz;
+ sensor->freq_avail[5] = uhz;
+ } else {
+ for (i = 0; i < sensor->sensor_info->intervals.count; i++) {
+ cur_interval = sensor->sensor_info->intervals.desc[i];
+ cur_interval_ns =
+ scmi_iio_convert_interval_to_ns(cur_interval);
+ convert_ns_to_freq(cur_interval_ns, &hz, &uhz);
+ sensor->freq_avail[i * 2] = hz;
+ sensor->freq_avail[i * 2 + 1] = uhz;
+ }
+ }
+ return 0;
+}
+
+static struct iio_dev *scmi_alloc_iiodev(struct device *dev,
+ struct scmi_handle *handle,
+ const struct scmi_sensor_info *sensor_info)
+{
+ struct iio_chan_spec *iio_channels;
+ struct scmi_iio_priv *sensor;
+ enum iio_modifier modifier;
+ enum iio_chan_type type;
+ struct iio_dev *iiodev;
+ int i, ret;
+
+ iiodev = devm_iio_device_alloc(dev, sizeof(*sensor));
+ if (!iiodev)
+ return ERR_PTR(-ENOMEM);
+
+ iiodev->modes = INDIO_DIRECT_MODE;
+ iiodev->dev.parent = dev;
+ sensor = iio_priv(iiodev);
+ sensor->handle = handle;
+ sensor->sensor_info = sensor_info;
+ sensor->sensor_update_nb.notifier_call = scmi_iio_sensor_update_cb;
+ sensor->indio_dev = iiodev;
+
+ /* adding one additional channel for timestamp */
+ iiodev->num_channels = sensor_info->num_axis + 1;
+ iiodev->name = sensor_info->name;
+ iiodev->info = &scmi_iio_info;
+
+ iio_channels =
+ devm_kzalloc(dev,
+ sizeof(*iio_channels) * (iiodev->num_channels),
+ GFP_KERNEL);
+ if (!iio_channels)
+ return ERR_PTR(-ENOMEM);
+
+ ret = scmi_iio_set_sampling_freq_avail(iiodev);
+ if (ret < 0)
+ return ERR_PTR(ret);
+
+ for (i = 0; i < sensor_info->num_axis; i++) {
+ ret = scmi_iio_get_chan_type(sensor_info->axis[i].type, &type);
+ if (ret < 0)
+ return ERR_PTR(ret);
+
+ ret = scmi_iio_get_chan_modifier(sensor_info->axis[i].name,
+ &modifier);
+ if (ret < 0)
+ return ERR_PTR(ret);
+
+ scmi_iio_set_data_channel(&iio_channels[i], type, modifier,
+ sensor_info->axis[i].id);
+ }
+
+ scmi_iio_set_timestamp_channel(&iio_channels[i], i);
+ iiodev->channels = iio_channels;
+ return iiodev;
+}
+
+static int scmi_iio_dev_probe(struct scmi_device *sdev)
+{
+ const struct scmi_sensor_info *sensor_info;
+ struct scmi_handle *handle = sdev->handle;
+ struct device *dev = &sdev->dev;
+ struct iio_dev *scmi_iio_dev;
+ u16 nr_sensors;
+ int err = -ENODEV, i;
+
+ if (!handle || !handle->sensor_ops) {
+ dev_err(dev, "SCMI device has no sensor interface\n");
+ return -EINVAL;
+ }
+
+ nr_sensors = handle->sensor_ops->count_get(handle);
+ if (!nr_sensors) {
+ dev_dbg(dev, "0 sensors found via SCMI bus\n");
+ return -ENODEV;
+ }
+
+ for (i = 0; i < nr_sensors; i++) {
+ sensor_info = handle->sensor_ops->info_get(handle, i);
+ if (!sensor_info) {
+ dev_err(dev, "SCMI sensor %d has missing info\n", i);
+ return -EINVAL;
+ }
+
+ /* This driver only supports 3-axis accel and gyro, skipping other sensors */
+ if (sensor_info->num_axis != SCMI_IIO_NUM_OF_AXIS)
+ continue;
+
+ /* This driver only supports 3-axis accel and gyro, skipping other sensors */
+ if (sensor_info->axis[0].type != METERS_SEC_SQUARED &&
+ sensor_info->axis[0].type != RADIANS_SEC)
+ continue;
+
+ scmi_iio_dev = scmi_alloc_iiodev(dev, handle, sensor_info);
+ if (IS_ERR(scmi_iio_dev)) {
+ dev_err(dev,
+ "failed to allocate IIO device for sensor %s: %ld\n",
+ sensor_info->name, PTR_ERR(scmi_iio_dev));
+ return PTR_ERR(scmi_iio_dev);
+ }
+
+ err = devm_iio_kfifo_buffer_setup(&scmi_iio_dev->dev,
+ scmi_iio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ &scmi_iio_buffer_ops);
+ if (err < 0) {
+ dev_err(dev,
+ "IIO buffer setup error at sensor %s: %d\n",
+ sensor_info->name, err);
+ return err;
+ }
+
+ err = devm_iio_device_register(dev, scmi_iio_dev);
+ if (err) {
+ dev_err(dev,
+ "IIO device registration failed at sensor %s: %d\n",
+ sensor_info->name, err);
+ return err;
+ }
+ }
+ return err;
+}
+
+static const struct scmi_device_id scmi_id_table[] = {
+ { SCMI_PROTOCOL_SENSOR, "iiodev" },
+ {},
+};
+
+MODULE_DEVICE_TABLE(scmi, scmi_id_table);
+
+static struct scmi_driver scmi_iiodev_driver = {
+ .name = "scmi-sensor-iiodev",
+ .probe = scmi_iio_dev_probe,
+ .id_table = scmi_id_table,
+};
+
+module_scmi_driver(scmi_iiodev_driver);
+
+MODULE_AUTHOR("Jyoti Bhayana <jbhayana@google.com>");
+MODULE_DESCRIPTION("SCMI IIO Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c
index eee30130ae23..802f9ae04cf4 100644
--- a/drivers/iio/common/st_sensors/st_sensors_buffer.c
+++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c
@@ -57,7 +57,7 @@ irqreturn_t st_sensors_trigger_handler(int irq, void *p)
s64 timestamp;
/*
- * If we do timetamping here, do it before reading the values, because
+ * If we do timestamping here, do it before reading the values, because
* once we've read the values, new interrupts can occur (when using
* the hardware trigger) and the hw_timestamp may get updated.
* By storing it in a local variable first, we are safe.
diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c
index 2dbd2646e44e..0b511665dee5 100644
--- a/drivers/iio/common/st_sensors/st_sensors_trigger.c
+++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c
@@ -123,7 +123,8 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
unsigned long irq_trig;
int err;
- sdata->trig = iio_trigger_alloc("%s-trigger", indio_dev->name);
+ sdata->trig = iio_trigger_alloc(sdata->dev, "%s-trigger",
+ indio_dev->name);
if (sdata->trig == NULL) {
dev_err(&indio_dev->dev, "failed to allocate iio trigger.\n");
return -ENOMEM;
@@ -131,7 +132,6 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
iio_trigger_set_drvdata(sdata->trig, indio_dev);
sdata->trig->ops = trigger_ops;
- sdata->trig->dev.parent = sdata->dev;
irq_trig = irqd_get_trigger_type(irq_get_irq_data(sdata->irq));
/*
diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
index cea07b4cced1..75e1f2b48638 100644
--- a/drivers/iio/dac/Kconfig
+++ b/drivers/iio/dac/Kconfig
@@ -142,8 +142,9 @@ config AD5696_I2C
select AD5686
help
Say yes here to build support for Analog Devices AD5311R, AD5338R,
- AD5671R, AD5675R, AD5691R, AD5692R, AD5693, AD5693R, AD5694, AD5694R,
- AD5695R, AD5696, and AD5696R Digital to Analog converters.
+ AD5671R, AD5673R, AD5675R, AD5677R, AD5691R, AD5692R, AD5693, AD5693R,
+ AD5694, AD5694R, AD5695R, AD5696, and AD5696R Digital to Analog
+ converters.
To compile this driver as a module, choose M here: the module will be
called ad5696.
diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c
index 82abd4d6886c..dff623b65e4f 100644
--- a/drivers/iio/dac/ad5064.c
+++ b/drivers/iio/dac/ad5064.c
@@ -277,7 +277,7 @@ static ssize_t ad5064_read_dac_powerdown(struct iio_dev *indio_dev,
{
struct ad5064_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", st->pwr_down[chan->channel]);
+ return sysfs_emit(buf, "%d\n", st->pwr_down[chan->channel]);
}
static ssize_t ad5064_write_dac_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/ad5360.c b/drivers/iio/dac/ad5360.c
index 602dd2ba61b5..2d3b14c407d8 100644
--- a/drivers/iio/dac/ad5360.c
+++ b/drivers/iio/dac/ad5360.c
@@ -255,7 +255,7 @@ static ssize_t ad5360_read_dac_powerdown(struct device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad5360_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", (bool)(st->ctrl & AD5360_SF_CTRL_PWR_DOWN));
+ return sysfs_emit(buf, "%d\n", (bool)(st->ctrl & AD5360_SF_CTRL_PWR_DOWN));
}
static int ad5360_update_ctrl(struct iio_dev *indio_dev, unsigned int set,
diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c
index 37ef653564b0..53db5b4e4c53 100644
--- a/drivers/iio/dac/ad5380.c
+++ b/drivers/iio/dac/ad5380.c
@@ -85,7 +85,7 @@ static ssize_t ad5380_read_dac_powerdown(struct iio_dev *indio_dev,
{
struct ad5380_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", st->pwr_down);
+ return sysfs_emit(buf, "%d\n", st->pwr_down);
}
static ssize_t ad5380_write_dac_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c
index d87e21016863..488ec69967d6 100644
--- a/drivers/iio/dac/ad5446.c
+++ b/drivers/iio/dac/ad5446.c
@@ -100,7 +100,7 @@ static ssize_t ad5446_read_dac_powerdown(struct iio_dev *indio_dev,
{
struct ad5446_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", st->pwr_down);
+ return sysfs_emit(buf, "%d\n", st->pwr_down);
}
static ssize_t ad5446_write_dac_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
index e9297c25d4ef..19cdf9890d02 100644
--- a/drivers/iio/dac/ad5504.c
+++ b/drivers/iio/dac/ad5504.c
@@ -39,7 +39,7 @@
#define AD5504_DAC_PWRDN_3STATE 1
/**
- * struct ad5446_state - driver instance specific data
+ * struct ad5504_state - driver instance specific data
* @spi: spi_device
* @reg: supply regulator
* @vref_mv: actual reference voltage used
@@ -170,8 +170,8 @@ static ssize_t ad5504_read_dac_powerdown(struct iio_dev *indio_dev,
{
struct ad5504_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n",
- !(st->pwr_down_mask & (1 << chan->channel)));
+ return sysfs_emit(buf, "%d\n",
+ !(st->pwr_down_mask & (1 << chan->channel)));
}
static ssize_t ad5504_write_dac_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c
index 2b2b8edfd258..9bde86982912 100644
--- a/drivers/iio/dac/ad5624r_spi.c
+++ b/drivers/iio/dac/ad5624r_spi.c
@@ -117,8 +117,8 @@ static ssize_t ad5624r_read_dac_powerdown(struct iio_dev *indio_dev,
{
struct ad5624r_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n",
- !!(st->pwr_down_mask & (1 << chan->channel)));
+ return sysfs_emit(buf, "%d\n",
+ !!(st->pwr_down_mask & (1 << chan->channel)));
}
static ssize_t ad5624r_write_dac_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index 7d6792ac1020..fcb64f20ff64 100644
--- a/drivers/iio/dac/ad5686.c
+++ b/drivers/iio/dac/ad5686.c
@@ -57,7 +57,7 @@ static ssize_t ad5686_read_dac_powerdown(struct iio_dev *indio_dev,
{
struct ad5686_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", !!(st->pwr_down_mask &
+ return sysfs_emit(buf, "%d\n", !!(st->pwr_down_mask &
(0x3 << (chan->channel * 2))));
}
@@ -301,6 +301,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
.num_channels = 8,
.regmap_type = AD5686_REGMAP,
},
+ [ID_AD5673R] = {
+ .channels = ad5674r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 16,
+ .regmap_type = AD5686_REGMAP,
+ },
[ID_AD5674R] = {
.channels = ad5674r_channels,
.int_vref_mv = 2500,
@@ -324,6 +330,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
.num_channels = 8,
.regmap_type = AD5686_REGMAP,
},
+ [ID_AD5677R] = {
+ .channels = ad5679r_channels,
+ .int_vref_mv = 2500,
+ .num_channels = 16,
+ .regmap_type = AD5686_REGMAP,
+ },
[ID_AD5679R] = {
.channels = ad5679r_channels,
.int_vref_mv = 2500,
diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
index d9c8ba413fe9..f89a6f92b427 100644
--- a/drivers/iio/dac/ad5686.h
+++ b/drivers/iio/dac/ad5686.h
@@ -55,10 +55,12 @@ enum ad5686_supported_device_ids {
ID_AD5338R,
ID_AD5671R,
ID_AD5672R,
+ ID_AD5673R,
ID_AD5674R,
ID_AD5675R,
ID_AD5676,
ID_AD5676R,
+ ID_AD5677R,
ID_AD5679R,
ID_AD5681R,
ID_AD5682R,
diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
index a39eda7c02d2..24a6a4a5a2e0 100644
--- a/drivers/iio/dac/ad5696-i2c.c
+++ b/drivers/iio/dac/ad5696-i2c.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/*
- * AD5671R, AD5675R, AD5691R, AD5692R, AD5693, AD5693R,
- * AD5694, AD5694R, AD5695R, AD5696, AD5696R
+ * AD5338R, AD5671R, AD5673R, AD5675R, AD5677R, AD5691R, AD5692R, AD5693,
+ * AD5693R, AD5694, AD5694R, AD5695R, AD5696, AD5696R
* Digital to analog converters driver
*
* Copyright 2018 Analog Devices Inc.
@@ -74,7 +74,9 @@ static const struct i2c_device_id ad5686_i2c_id[] = {
{"ad5311r", ID_AD5311R},
{"ad5338r", ID_AD5338R},
{"ad5671r", ID_AD5671R},
+ {"ad5673r", ID_AD5673R},
{"ad5675r", ID_AD5675R},
+ {"ad5677r", ID_AD5677R},
{"ad5691r", ID_AD5691R},
{"ad5692r", ID_AD5692R},
{"ad5693", ID_AD5693},
diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c
index 0df28acf074a..cabc38d54085 100644
--- a/drivers/iio/dac/ad5755.c
+++ b/drivers/iio/dac/ad5755.c
@@ -399,8 +399,8 @@ static ssize_t ad5755_read_powerdown(struct iio_dev *indio_dev, uintptr_t priv,
{
struct ad5755_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n",
- (bool)(st->pwr_down & (1 << chan->channel)));
+ return sysfs_emit(buf, "%d\n",
+ (bool)(st->pwr_down & (1 << chan->channel)));
}
static ssize_t ad5755_write_powerdown(struct iio_dev *indio_dev, uintptr_t priv,
diff --git a/drivers/iio/dac/ad5758.c b/drivers/iio/dac/ad5758.c
index bd9ac8359d98..0572ef518101 100644
--- a/drivers/iio/dac/ad5758.c
+++ b/drivers/iio/dac/ad5758.c
@@ -574,7 +574,7 @@ static ssize_t ad5758_read_powerdown(struct iio_dev *indio_dev,
{
struct ad5758_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", st->pwr_down);
+ return sysfs_emit(buf, "%d\n", st->pwr_down);
}
static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/ad5766.c b/drivers/iio/dac/ad5766.c
index ef1618ea6a20..79837a4b3a41 100644
--- a/drivers/iio/dac/ad5766.c
+++ b/drivers/iio/dac/ad5766.c
@@ -89,7 +89,7 @@ static const char * const ad5766_dither_scales[] = {
/**
* struct ad5766_state - driver instance specific data
* @spi: SPI device
- * @lock: Lock used to restrict concurent access to SPI device
+ * @lock: Lock used to restrict concurrent access to SPI device
* @chip_info: Chip model specific constants
* @gpio_reset: Reset GPIO, used to reset the device
* @crt_range: Current selected output range
diff --git a/drivers/iio/dac/ad5770r.c b/drivers/iio/dac/ad5770r.c
index 84dcf149261f..7ab2ccf90863 100644
--- a/drivers/iio/dac/ad5770r.c
+++ b/drivers/iio/dac/ad5770r.c
@@ -118,7 +118,7 @@ struct ad5770r_out_range {
};
/**
- * struct ad5770R_state - driver instance specific data
+ * struct ad5770r_state - driver instance specific data
* @spi: spi_device
* @regmap: regmap
* @vref_reg: fixed regulator for reference configuration
@@ -433,7 +433,7 @@ static ssize_t ad5770r_read_dac_powerdown(struct iio_dev *indio_dev,
{
struct ad5770r_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", st->ch_pwr_down[chan->channel]);
+ return sysfs_emit(buf, "%d\n", st->ch_pwr_down[chan->channel]);
}
static ssize_t ad5770r_write_dac_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
index e3ffa4b9f84c..a0923b76e8b6 100644
--- a/drivers/iio/dac/ad5791.c
+++ b/drivers/iio/dac/ad5791.c
@@ -76,7 +76,7 @@ struct ad5791_chip_info {
* @chip_info: chip model specific constants
* @vref_mv: actual reference voltage used
* @vref_neg_mv: voltage of the negative supply
- * @ctrl: control regster cache
+ * @ctrl: control register cache
* @pwr_down_mode: current power down mode
* @pwr_down: true if device is powered down
* @data: spi transfer buffers
@@ -177,7 +177,7 @@ static ssize_t ad5791_read_dac_powerdown(struct iio_dev *indio_dev,
{
struct ad5791_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", st->pwr_down);
+ return sysfs_emit(buf, "%d\n", st->pwr_down);
}
static ssize_t ad5791_write_dac_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c
index dbb4645ab6b1..e1b6a92df12f 100644
--- a/drivers/iio/dac/ad7303.c
+++ b/drivers/iio/dac/ad7303.c
@@ -65,7 +65,7 @@ static ssize_t ad7303_read_dac_powerdown(struct iio_dev *indio_dev,
{
struct ad7303_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", (bool)(st->config &
+ return sysfs_emit(buf, "%d\n", (bool)(st->config &
AD7303_CFG_POWER_DOWN(chan->channel)));
}
diff --git a/drivers/iio/dac/ltc2632.c b/drivers/iio/dac/ltc2632.c
index 4002ed0868be..53e4b887d372 100644
--- a/drivers/iio/dac/ltc2632.c
+++ b/drivers/iio/dac/ltc2632.c
@@ -135,8 +135,8 @@ static ssize_t ltc2632_read_dac_powerdown(struct iio_dev *indio_dev,
{
struct ltc2632_state *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n",
- !!(st->powerdown_cache_mask & (1 << chan->channel)));
+ return sysfs_emit(buf, "%d\n",
+ !!(st->powerdown_cache_mask & (1 << chan->channel)));
}
static ssize_t ltc2632_write_dac_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c
index daa60386bf0c..a6ef555153f4 100644
--- a/drivers/iio/dac/max517.c
+++ b/drivers/iio/dac/max517.c
@@ -153,7 +153,6 @@ static int max517_probe(struct i2c_client *client,
if (!indio_dev)
return -ENOMEM;
data = iio_priv(indio_dev);
- i2c_set_clientdata(client, indio_dev);
data->client = client;
switch (id->driver_data) {
@@ -186,13 +185,7 @@ static int max517_probe(struct i2c_client *client,
data->vref_mv[chan] = platform_data->vref_mv[chan];
}
- return iio_device_register(indio_dev);
-}
-
-static int max517_remove(struct i2c_client *client)
-{
- iio_device_unregister(i2c_get_clientdata(client));
- return 0;
+ return devm_iio_device_register(&client->dev, indio_dev);
}
static const struct i2c_device_id max517_id[] = {
@@ -211,7 +204,6 @@ static struct i2c_driver max517_driver = {
.pm = &max517_pm_ops,
},
.probe = max517_probe,
- .remove = max517_remove,
.id_table = max517_id,
};
module_i2c_driver(max517_driver);
diff --git a/drivers/iio/dac/max5821.c b/drivers/iio/dac/max5821.c
index d6bb24db49c4..bd6e75699a63 100644
--- a/drivers/iio/dac/max5821.c
+++ b/drivers/iio/dac/max5821.c
@@ -84,7 +84,7 @@ static ssize_t max5821_read_dac_powerdown(struct iio_dev *indio_dev,
{
struct max5821_data *st = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", st->powerdown[chan->channel]);
+ return sysfs_emit(buf, "%d\n", st->powerdown[chan->channel]);
}
static int max5821_sync_powerdown_mode(struct max5821_data *data,
diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
index beb9a15b7c74..34b14aafb630 100644
--- a/drivers/iio/dac/mcp4725.c
+++ b/drivers/iio/dac/mcp4725.c
@@ -167,7 +167,7 @@ static ssize_t mcp4725_read_powerdown(struct iio_dev *indio_dev,
{
struct mcp4725_data *data = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", data->powerdown);
+ return sysfs_emit(buf, "%d\n", data->powerdown);
}
static ssize_t mcp4725_write_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c
index 12dec68c16f7..a5b0a52bf86e 100644
--- a/drivers/iio/dac/stm32-dac.c
+++ b/drivers/iio/dac/stm32-dac.c
@@ -210,7 +210,7 @@ static ssize_t stm32_dac_read_powerdown(struct iio_dev *indio_dev,
if (ret < 0)
return ret;
- return sprintf(buf, "%d\n", ret ? 0 : 1);
+ return sysfs_emit(buf, "%d\n", ret ? 0 : 1);
}
static ssize_t stm32_dac_write_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/ti-dac082s085.c b/drivers/iio/dac/ti-dac082s085.c
index de33c1fc6e0b..5c14bfb16521 100644
--- a/drivers/iio/dac/ti-dac082s085.c
+++ b/drivers/iio/dac/ti-dac082s085.c
@@ -121,7 +121,7 @@ static ssize_t ti_dac_read_powerdown(struct iio_dev *indio_dev,
{
struct ti_dac_chip *ti_dac = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", ti_dac->powerdown);
+ return sysfs_emit(buf, "%d\n", ti_dac->powerdown);
}
static ssize_t ti_dac_write_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/ti-dac5571.c b/drivers/iio/dac/ti-dac5571.c
index d3295767a079..2a5ba1b08a1d 100644
--- a/drivers/iio/dac/ti-dac5571.c
+++ b/drivers/iio/dac/ti-dac5571.c
@@ -166,7 +166,7 @@ static ssize_t dac5571_read_powerdown(struct iio_dev *indio_dev,
{
struct dac5571_data *data = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", data->powerdown[chan->channel]);
+ return sysfs_emit(buf, "%d\n", data->powerdown[chan->channel]);
}
static ssize_t dac5571_write_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dac/ti-dac7311.c b/drivers/iio/dac/ti-dac7311.c
index 63171e42f987..9d0b253be841 100644
--- a/drivers/iio/dac/ti-dac7311.c
+++ b/drivers/iio/dac/ti-dac7311.c
@@ -110,7 +110,7 @@ static ssize_t ti_dac_read_powerdown(struct iio_dev *indio_dev,
{
struct ti_dac_chip *ti_dac = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", ti_dac->powerdown);
+ return sysfs_emit(buf, "%d\n", ti_dac->powerdown);
}
static ssize_t ti_dac_write_powerdown(struct iio_dev *indio_dev,
diff --git a/drivers/iio/dummy/iio_simple_dummy_buffer.c b/drivers/iio/dummy/iio_simple_dummy_buffer.c
index 5512d5edc707..59aa60d4ca37 100644
--- a/drivers/iio/dummy/iio_simple_dummy_buffer.c
+++ b/drivers/iio/dummy/iio_simple_dummy_buffer.c
@@ -16,9 +16,9 @@
#include <linux/bitmap.h>
#include <linux/iio/iio.h>
-#include <linux/iio/trigger_consumer.h>
#include <linux/iio/buffer.h>
-#include <linux/iio/kfifo_buf.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
#include "iio_simple_dummy.h"
@@ -103,64 +103,9 @@ static const struct iio_buffer_setup_ops iio_simple_dummy_buffer_setup_ops = {
int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev)
{
- int ret;
- struct iio_buffer *buffer;
-
- /* Allocate a buffer to use - here a kfifo */
- buffer = iio_kfifo_allocate();
- if (!buffer) {
- ret = -ENOMEM;
- goto error_ret;
- }
-
- iio_device_attach_buffer(indio_dev, buffer);
-
- /*
- * Tell the core what device type specific functions should
- * be run on either side of buffer capture enable / disable.
- */
- indio_dev->setup_ops = &iio_simple_dummy_buffer_setup_ops;
-
- /*
- * Configure a polling function.
- * When a trigger event with this polling function connected
- * occurs, this function is run. Typically this grabs data
- * from the device.
- *
- * NULL for the bottom half. This is normally implemented only if we
- * either want to ping a capture now pin (no sleeping) or grab
- * a timestamp as close as possible to a data ready trigger firing.
- *
- * IRQF_ONESHOT ensures irqs are masked such that only one instance
- * of the handler can run at a time.
- *
- * "iio_simple_dummy_consumer%d" formatting string for the irq 'name'
- * as seen under /proc/interrupts. Remaining parameters as per printk.
- */
- indio_dev->pollfunc = iio_alloc_pollfunc(NULL,
- &iio_simple_dummy_trigger_h,
- IRQF_ONESHOT,
- indio_dev,
- "iio_simple_dummy_consumer%d",
- indio_dev->id);
-
- if (!indio_dev->pollfunc) {
- ret = -ENOMEM;
- goto error_free_buffer;
- }
-
- /*
- * Notify the core that this device is capable of buffered capture
- * driven by a trigger.
- */
- indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
-
- return 0;
-
-error_free_buffer:
- iio_kfifo_free(indio_dev->buffer);
-error_ret:
- return ret;
+ return iio_triggered_buffer_setup(indio_dev, NULL,
+ iio_simple_dummy_trigger_h,
+ &iio_simple_dummy_buffer_setup_ops);
}
/**
@@ -169,6 +114,5 @@ error_ret:
*/
void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev)
{
- iio_dealloc_pollfunc(indio_dev->pollfunc);
- iio_kfifo_free(indio_dev->buffer);
+ iio_triggered_buffer_cleanup(indio_dev);
}
diff --git a/drivers/iio/gyro/adxrs290.c b/drivers/iio/gyro/adxrs290.c
index c45d8226cc2b..cec5e1f17c22 100644
--- a/drivers/iio/gyro/adxrs290.c
+++ b/drivers/iio/gyro/adxrs290.c
@@ -593,7 +593,6 @@ static int adxrs290_probe_trigger(struct iio_dev *indio_dev)
if (!st->dready_trig)
return -ENOMEM;
- st->dready_trig->dev.parent = &st->spi->dev;
st->dready_trig->ops = &adxrs290_trigger_ops;
iio_trigger_set_drvdata(st->dready_trig, indio_dev);
diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
index 029ef4c34604..b11ebd9bb7a4 100644
--- a/drivers/iio/gyro/bmg160_core.c
+++ b/drivers/iio/gyro/bmg160_core.c
@@ -1148,14 +1148,12 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
if (!data->motion_trig)
return -ENOMEM;
- data->dready_trig->dev.parent = dev;
data->dready_trig->ops = &bmg160_trigger_ops;
iio_trigger_set_drvdata(data->dready_trig, indio_dev);
ret = iio_trigger_register(data->dready_trig);
if (ret)
return ret;
- data->motion_trig->dev.parent = dev;
data->motion_trig->ops = &bmg160_trigger_ops;
iio_trigger_set_drvdata(data->motion_trig, indio_dev);
ret = iio_trigger_register(data->motion_trig);
diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c
index 129eead8febc..1a20c6b88e7d 100644
--- a/drivers/iio/gyro/fxas21002c_core.c
+++ b/drivers/iio/gyro/fxas21002c_core.c
@@ -875,7 +875,6 @@ static int fxas21002c_trigger_probe(struct fxas21002c_data *data)
if (ret < 0)
return ret;
- data->dready_trig->dev.parent = dev;
data->dready_trig->ops = &fxas21002c_trigger_ops;
iio_trigger_set_drvdata(data->dready_trig, indio_dev);
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index fb0d678ece1a..dad26ee4fd1f 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -45,6 +45,10 @@ static const u32 gyro_3d_addresses[GYRO_3D_CHANNEL_MAX] = {
HID_USAGE_SENSOR_ANGL_VELOCITY_Z_AXIS
};
+static const u32 gryo_3d_sensitivity_addresses[] = {
+ HID_USAGE_SENSOR_DATA_ANGL_VELOCITY,
+};
+
/* Channel definitions */
static const struct iio_chan_spec gyro_3d_channels[] = {
{
@@ -271,17 +275,6 @@ static int gyro_3d_parse_report(struct platform_device *pdev,
&st->gyro[CHANNEL_SCAN_INDEX_X],
&st->scale_pre_decml, &st->scale_post_decml);
- /* Set Sensitivity field ids, when there is no individual modifier */
- if (st->common_attributes.sensitivity.index < 0) {
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_DATA_ANGL_VELOCITY,
- &st->common_attributes.sensitivity);
- dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
- st->common_attributes.sensitivity.index,
- st->common_attributes.sensitivity.report_id);
- }
return ret;
}
@@ -305,7 +298,9 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
ret = hid_sensor_parse_common_attributes(hsdev,
HID_USAGE_SENSOR_GYRO_3D,
- &gyro_state->common_attributes);
+ &gyro_state->common_attributes,
+ gryo_3d_sensitivity_addresses,
+ ARRAY_SIZE(gryo_3d_sensitivity_addresses));
if (ret) {
dev_err(&pdev->dev, "failed to setup common attributes\n");
return ret;
diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c
index 1c3c1bd53374..af0aaa146f0c 100644
--- a/drivers/iio/gyro/itg3200_buffer.c
+++ b/drivers/iio/gyro/itg3200_buffer.c
@@ -113,7 +113,7 @@ int itg3200_probe_trigger(struct iio_dev *indio_dev)
int ret;
struct itg3200 *st = iio_priv(indio_dev);
- st->trig = iio_trigger_alloc("%s-dev%d", indio_dev->name,
+ st->trig = iio_trigger_alloc(&st->i2c->dev, "%s-dev%d", indio_dev->name,
indio_dev->id);
if (!st->trig)
return -ENOMEM;
@@ -127,7 +127,6 @@ int itg3200_probe_trigger(struct iio_dev *indio_dev)
goto error_free_trig;
- st->trig->dev.parent = &st->i2c->dev;
st->trig->ops = &itg3200_trigger_ops;
iio_trigger_set_drvdata(st->trig, indio_dev);
ret = iio_trigger_register(st->trig);
diff --git a/drivers/iio/gyro/ssp_gyro_sensor.c b/drivers/iio/gyro/ssp_gyro_sensor.c
index ac7c170a20de..46ed12771d2f 100644
--- a/drivers/iio/gyro/ssp_gyro_sensor.c
+++ b/drivers/iio/gyro/ssp_gyro_sensor.c
@@ -96,7 +96,6 @@ static int ssp_gyro_probe(struct platform_device *pdev)
int ret;
struct iio_dev *indio_dev;
struct ssp_sensor_data *spd;
- struct iio_buffer *buffer;
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*spd));
if (!indio_dev)
@@ -109,18 +108,15 @@ static int ssp_gyro_probe(struct platform_device *pdev)
indio_dev->name = ssp_gyro_name;
indio_dev->info = &ssp_gyro_iio_info;
- indio_dev->modes = INDIO_BUFFER_SOFTWARE;
indio_dev->channels = ssp_gyro_channels;
indio_dev->num_channels = ARRAY_SIZE(ssp_gyro_channels);
indio_dev->available_scan_masks = ssp_gyro_scan_mask;
- buffer = devm_iio_kfifo_allocate(&pdev->dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
-
- indio_dev->setup_ops = &ssp_gyro_buffer_ops;
+ ret = devm_iio_kfifo_buffer_setup(&pdev->dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ &ssp_gyro_buffer_ops);
+ if (ret)
+ return ret;
platform_set_drvdata(pdev, indio_dev);
diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c
index 38734e4ce360..1fa8d51d5080 100644
--- a/drivers/iio/health/afe4403.c
+++ b/drivers/iio/health/afe4403.c
@@ -531,7 +531,6 @@ static int afe4403_probe(struct spi_device *spi)
iio_trigger_set_drvdata(afe->trig, indio_dev);
afe->trig->ops = &afe4403_trigger_ops;
- afe->trig->dev.parent = afe->dev;
ret = iio_trigger_register(afe->trig);
if (ret) {
diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c
index 61fe4932d81d..e1476bf79fe2 100644
--- a/drivers/iio/health/afe4404.c
+++ b/drivers/iio/health/afe4404.c
@@ -538,7 +538,6 @@ static int afe4404_probe(struct i2c_client *client,
iio_trigger_set_drvdata(afe->trig, indio_dev);
afe->trig->ops = &afe4404_trigger_ops;
- afe->trig->dev.parent = afe->dev;
ret = iio_trigger_register(afe->trig);
if (ret) {
diff --git a/drivers/iio/health/max30100.c b/drivers/iio/health/max30100.c
index 38aa2030f3c6..36ba7611d9ce 100644
--- a/drivers/iio/health/max30100.c
+++ b/drivers/iio/health/max30100.c
@@ -418,7 +418,6 @@ static int max30100_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct max30100_data *data;
- struct iio_buffer *buffer;
struct iio_dev *indio_dev;
int ret;
@@ -426,19 +425,18 @@ static int max30100_probe(struct i2c_client *client,
if (!indio_dev)
return -ENOMEM;
- buffer = devm_iio_kfifo_allocate(&client->dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
-
indio_dev->name = MAX30100_DRV_NAME;
indio_dev->channels = max30100_channels;
indio_dev->info = &max30100_info;
indio_dev->num_channels = ARRAY_SIZE(max30100_channels);
indio_dev->available_scan_masks = max30100_scan_masks;
- indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE);
- indio_dev->setup_ops = &max30100_buffer_setup_ops;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+
+ ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ &max30100_buffer_setup_ops);
+ if (ret)
+ return ret;
data = iio_priv(indio_dev);
data->indio_dev = indio_dev;
diff --git a/drivers/iio/health/max30102.c b/drivers/iio/health/max30102.c
index b35557a54ee2..2292876c55e2 100644
--- a/drivers/iio/health/max30102.c
+++ b/drivers/iio/health/max30102.c
@@ -506,7 +506,6 @@ static int max30102_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct max30102_data *data;
- struct iio_buffer *buffer;
struct iio_dev *indio_dev;
int ret;
unsigned int reg;
@@ -515,16 +514,9 @@ static int max30102_probe(struct i2c_client *client,
if (!indio_dev)
return -ENOMEM;
- buffer = devm_iio_kfifo_allocate(&client->dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
-
indio_dev->name = MAX30102_DRV_NAME;
indio_dev->info = &max30102_info;
- indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE);
- indio_dev->setup_ops = &max30102_buffer_setup_ops;
+ indio_dev->modes = INDIO_DIRECT_MODE;
data = iio_priv(indio_dev);
data->indio_dev = indio_dev;
@@ -549,6 +541,12 @@ static int max30102_probe(struct i2c_client *client,
return -ENODEV;
}
+ ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ &max30102_buffer_setup_ops);
+ if (ret)
+ return ret;
+
data->regmap = devm_regmap_init_i2c(client, &max30102_regmap_config);
if (IS_ERR(data->regmap)) {
dev_err(&client->dev, "regmap initialization failed\n");
diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c
index 02ad1767c845..23bc9c784ef4 100644
--- a/drivers/iio/humidity/am2315.c
+++ b/drivers/iio/humidity/am2315.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
* Aosong AM2315 relative humidity and temperature
*
* Copyright (c) 2016, Intel Corporation.
diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c
index d62705448ae2..74383abc0d44 100644
--- a/drivers/iio/humidity/hid-sensor-humidity.c
+++ b/drivers/iio/humidity/hid-sensor-humidity.c
@@ -25,6 +25,10 @@ struct hid_humidity_state {
int value_offset;
};
+static const u32 humidity_sensitivity_addresses[] = {
+ HID_USAGE_SENSOR_ATMOSPHERIC_HUMIDITY,
+};
+
/* Channel definitions */
static const struct iio_chan_spec humidity_channels[] = {
{
@@ -176,14 +180,6 @@ static int humidity_parse_report(struct platform_device *pdev,
&st->scale_pre_decml,
&st->scale_post_decml);
- /* Set Sensitivity field ids, when there is no individual modifier */
- if (st->common_attributes.sensitivity.index < 0)
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_ATMOSPHERIC_HUMIDITY,
- &st->common_attributes.sensitivity);
-
return ret;
}
@@ -212,7 +208,9 @@ static int hid_humidity_probe(struct platform_device *pdev)
ret = hid_sensor_parse_common_attributes(hsdev,
HID_USAGE_SENSOR_HUMIDITY,
- &humid_st->common_attributes);
+ &humid_st->common_attributes,
+ humidity_sensitivity_addresses,
+ ARRAY_SIZE(humidity_sensitivity_addresses));
if (ret)
return ret;
diff --git a/drivers/iio/humidity/hts221_buffer.c b/drivers/iio/humidity/hts221_buffer.c
index 95e56917677f..f29692b9d2db 100644
--- a/drivers/iio/humidity/hts221_buffer.c
+++ b/drivers/iio/humidity/hts221_buffer.c
@@ -135,7 +135,6 @@ int hts221_allocate_trigger(struct iio_dev *iio_dev)
iio_trigger_set_drvdata(hw->trig, iio_dev);
hw->trig->ops = &hts221_trigger_ops;
- hw->trig->dev.parent = hw->dev;
iio_dev->trig = iio_trigger_get(hw->trig);
return devm_iio_trigger_register(hw->dev, hw->trig);
diff --git a/drivers/iio/iio_core.h b/drivers/iio/iio_core.h
index fced02cadcc3..8f4a9b264962 100644
--- a/drivers/iio/iio_core.h
+++ b/drivers/iio/iio_core.h
@@ -12,11 +12,17 @@
#include <linux/kernel.h>
#include <linux/device.h>
+struct iio_buffer;
struct iio_chan_spec;
struct iio_dev;
extern struct device_type iio_device_type;
+struct iio_dev_buffer_pair {
+ struct iio_dev *indio_dev;
+ struct iio_buffer *buffer;
+};
+
#define IIO_IOCTL_UNHANDLED 1
struct iio_ioctl_handler {
struct list_head entry;
@@ -43,9 +49,13 @@ int __iio_add_chan_devattr(const char *postfix,
u64 mask,
enum iio_shared_by shared_by,
struct device *dev,
+ struct iio_buffer *buffer,
struct list_head *attr_list);
void iio_free_chan_devattr_list(struct list_head *attr_list);
+int iio_device_register_sysfs_group(struct iio_dev *indio_dev,
+ const struct attribute_group *group);
+
ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);
/* Event interface flags */
@@ -54,34 +64,36 @@ ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);
#ifdef CONFIG_IIO_BUFFER
struct poll_table_struct;
-__poll_t iio_buffer_poll(struct file *filp,
- struct poll_table_struct *wait);
-ssize_t iio_buffer_read_outer(struct file *filp, char __user *buf,
- size_t n, loff_t *f_ps);
+__poll_t iio_buffer_poll_wrapper(struct file *filp,
+ struct poll_table_struct *wait);
+ssize_t iio_buffer_read_wrapper(struct file *filp, char __user *buf,
+ size_t n, loff_t *f_ps);
-int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev);
-void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev);
+int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev);
+void iio_buffers_free_sysfs_and_mask(struct iio_dev *indio_dev);
-#define iio_buffer_poll_addr (&iio_buffer_poll)
-#define iio_buffer_read_outer_addr (&iio_buffer_read_outer)
+#define iio_buffer_poll_addr (&iio_buffer_poll_wrapper)
+#define iio_buffer_read_outer_addr (&iio_buffer_read_wrapper)
void iio_disable_all_buffers(struct iio_dev *indio_dev);
void iio_buffer_wakeup_poll(struct iio_dev *indio_dev);
+void iio_device_detach_buffers(struct iio_dev *indio_dev);
#else
#define iio_buffer_poll_addr NULL
#define iio_buffer_read_outer_addr NULL
-static inline int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
+static inline int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
{
return 0;
}
-static inline void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev) {}
+static inline void iio_buffers_free_sysfs_and_mask(struct iio_dev *indio_dev) {}
static inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {}
static inline void iio_buffer_wakeup_poll(struct iio_dev *indio_dev) {}
+static inline void iio_device_detach_buffers(struct iio_dev *indio_dev) {}
#endif
diff --git a/drivers/iio/iio_core_trigger.h b/drivers/iio/iio_core_trigger.h
index 374816bc3e73..e1a56824e07f 100644
--- a/drivers/iio/iio_core_trigger.h
+++ b/drivers/iio/iio_core_trigger.h
@@ -9,8 +9,10 @@
/**
* iio_device_register_trigger_consumer() - set up an iio_dev to use triggers
* @indio_dev: iio_dev associated with the device that will consume the trigger
+ *
+ * Return 0 if successful, negative otherwise
**/
-void iio_device_register_trigger_consumer(struct iio_dev *indio_dev);
+int iio_device_register_trigger_consumer(struct iio_dev *indio_dev);
/**
* iio_device_unregister_trigger_consumer() - reverse the registration process
diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c
index 785a4ce606d8..768aa493a1a6 100644
--- a/drivers/iio/imu/adis16400.c
+++ b/drivers/iio/imu/adis16400.c
@@ -504,7 +504,6 @@ static int adis16400_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int val, int val2, long info)
{
struct adis16400_state *st = iio_priv(indio_dev);
- struct mutex *slock = &st->adis.state_lock;
int ret, sps;
switch (info) {
@@ -517,18 +516,18 @@ static int adis16400_write_raw(struct iio_dev *indio_dev,
* Need to cache values so we can update if the frequency
* changes.
*/
- mutex_lock(slock);
+ adis_dev_lock(&st->adis);
st->filt_int = val;
/* Work out update to current value */
sps = st->variant->get_freq(st);
if (sps < 0) {
- mutex_unlock(slock);
+ adis_dev_unlock(&st->adis);
return sps;
}
ret = __adis16400_set_filter(indio_dev, sps,
val * 1000 + val2 / 1000);
- mutex_unlock(slock);
+ adis_dev_unlock(&st->adis);
return ret;
case IIO_CHAN_INFO_SAMP_FREQ:
sps = val * 1000 + val2 / 1000;
@@ -536,9 +535,9 @@ static int adis16400_write_raw(struct iio_dev *indio_dev,
if (sps <= 0)
return -EINVAL;
- mutex_lock(slock);
+ adis_dev_lock(&st->adis);
ret = st->variant->set_freq(st, sps);
- mutex_unlock(slock);
+ adis_dev_unlock(&st->adis);
return ret;
default:
return -EINVAL;
@@ -549,7 +548,6 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int *val, int *val2, long info)
{
struct adis16400_state *st = iio_priv(indio_dev);
- struct mutex *slock = &st->adis.state_lock;
int16_t val16;
int ret;
@@ -605,17 +603,17 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
*val = st->variant->temp_offset;
return IIO_VAL_INT;
case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
- mutex_lock(slock);
+ adis_dev_lock(&st->adis);
/* Need both the number of taps and the sampling frequency */
ret = __adis_read_reg_16(&st->adis,
ADIS16400_SENS_AVG,
&val16);
if (ret) {
- mutex_unlock(slock);
+ adis_dev_unlock(&st->adis);
return ret;
}
ret = st->variant->get_freq(st);
- mutex_unlock(slock);
+ adis_dev_unlock(&st->adis);
if (ret)
return ret;
ret /= adis16400_3db_divisors[val16 & 0x07];
@@ -623,9 +621,9 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
*val2 = (ret % 1000) * 1000;
return IIO_VAL_INT_PLUS_MICRO;
case IIO_CHAN_INFO_SAMP_FREQ:
- mutex_lock(slock);
+ adis_dev_lock(&st->adis);
ret = st->variant->get_freq(st);
- mutex_unlock(slock);
+ adis_dev_unlock(&st->adis);
if (ret)
return ret;
*val = ret / 1000;
diff --git a/drivers/iio/imu/adis16460.c b/drivers/iio/imu/adis16460.c
index 74a161e39733..73bf45e859b8 100644
--- a/drivers/iio/imu/adis16460.c
+++ b/drivers/iio/imu/adis16460.c
@@ -403,12 +403,12 @@ static int adis16460_probe(struct spi_device *spi)
if (ret)
return ret;
+ /* We cannot mask the interrupt, so ensure it isn't auto enabled */
+ st->adis.irq_flag |= IRQF_NO_AUTOEN;
ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev, NULL);
if (ret)
return ret;
- adis16460_enable_irq(&st->adis, 0);
-
ret = __adis_initial_startup(&st->adis);
if (ret)
return ret;
diff --git a/drivers/iio/imu/adis16475.c b/drivers/iio/imu/adis16475.c
index 197d48240991..1de62fc79e0f 100644
--- a/drivers/iio/imu/adis16475.c
+++ b/drivers/iio/imu/adis16475.c
@@ -17,6 +17,8 @@
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/irq.h>
+#include <linux/lcm.h>
+#include <linux/math.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/property.h>
@@ -101,6 +103,7 @@ struct adis16475 {
u32 clk_freq;
bool burst32;
unsigned long lsb_flag;
+ u16 sync_mode;
/* Alignment needed for the timestamp */
__be16 data[ADIS16475_MAX_SCAN_DATA] __aligned(8);
};
@@ -117,6 +120,11 @@ enum {
ADIS16475_SCAN_CRC_FAILURE,
};
+static bool low_rate_allow;
+module_param(low_rate_allow, bool, 0444);
+MODULE_PARM_DESC(low_rate_allow,
+ "Allow IMU rates below the minimum advisable when external clk is used in SCALED mode (default: N)");
+
#ifdef CONFIG_DEBUG_FS
static ssize_t adis16475_show_firmware_revision(struct file *file,
char __user *userbuf,
@@ -253,25 +261,92 @@ static int adis16475_get_freq(struct adis16475 *st, u32 *freq)
{
int ret;
u16 dec;
+ u32 sample_rate = st->clk_freq;
+
+ adis_dev_lock(&st->adis);
+
+ if (st->sync_mode == ADIS16475_SYNC_SCALED) {
+ u16 sync_scale;
+
+ ret = __adis_read_reg_16(&st->adis, ADIS16475_REG_UP_SCALE, &sync_scale);
+ if (ret)
+ goto error;
+
+ sample_rate = st->clk_freq * sync_scale;
+ }
- ret = adis_read_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, &dec);
+ ret = __adis_read_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, &dec);
if (ret)
- return -EINVAL;
+ goto error;
+
+ adis_dev_unlock(&st->adis);
- *freq = DIV_ROUND_CLOSEST(st->clk_freq, dec + 1);
+ *freq = DIV_ROUND_CLOSEST(sample_rate, dec + 1);
return 0;
+error:
+ adis_dev_unlock(&st->adis);
+ return ret;
}
static int adis16475_set_freq(struct adis16475 *st, const u32 freq)
{
u16 dec;
int ret;
+ u32 sample_rate = st->clk_freq;
if (!freq)
return -EINVAL;
- dec = DIV_ROUND_CLOSEST(st->clk_freq, freq);
+ adis_dev_lock(&st->adis);
+ /*
+ * When using sync scaled mode, the input clock needs to be scaled so that we have
+ * an IMU sample rate between (optimally) 1900 and 2100. After this, we can use the
+ * decimation filter to lower the sampling rate in order to get what the user wants.
+ * Optimally, the user sample rate is a multiple of both the IMU sample rate and
+ * the input clock. Hence, calculating the sync_scale dynamically gives us better
+ * chances of achieving a perfect/integer value for DEC_RATE. The math here is:
+ * 1. lcm of the input clock and the desired output rate.
+ * 2. get the highest multiple of the previous result lower than the adis max rate.
+ * 3. The last result becomes the IMU sample rate. Use that to calculate SYNC_SCALE
+ * and DEC_RATE (to get the user output rate)
+ */
+ if (st->sync_mode == ADIS16475_SYNC_SCALED) {
+ unsigned long scaled_rate = lcm(st->clk_freq, freq);
+ int sync_scale;
+
+ /*
+ * If lcm is bigger than the IMU maximum sampling rate there's no perfect
+ * solution. In this case, we get the highest multiple of the input clock
+ * lower than the IMU max sample rate.
+ */
+ if (scaled_rate > 2100000)
+ scaled_rate = 2100000 / st->clk_freq * st->clk_freq;
+ else
+ scaled_rate = 2100000 / scaled_rate * scaled_rate;
+
+ /*
+ * This is not an hard requirement but it's not advised to run the IMU
+ * with a sample rate lower than 4000Hz due to possible undersampling
+ * issues. However, there are users that might really want to take the risk.
+ * Hence, we provide a module parameter for them. If set, we allow sample
+ * rates lower than 4KHz. By default, we won't allow this and we just roundup
+ * the rate to the next multiple of the input clock bigger than 4KHz. This
+ * is done like this as in some cases (when DEC_RATE is 0) might give
+ * us the closest value to the one desired by the user...
+ */
+ if (scaled_rate < 1900000 && !low_rate_allow)
+ scaled_rate = roundup(1900000, st->clk_freq);
+
+ sync_scale = scaled_rate / st->clk_freq;
+ ret = __adis_write_reg_16(&st->adis, ADIS16475_REG_UP_SCALE, sync_scale);
+ if (ret)
+ goto error;
+
+ sample_rate = scaled_rate;
+ }
+
+ dec = DIV_ROUND_CLOSEST(sample_rate, freq);
if (dec)
dec--;
@@ -281,7 +356,7 @@ static int adis16475_set_freq(struct adis16475 *st, const u32 freq)
ret = adis_write_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, dec);
if (ret)
- return ret;
+ goto error;
/*
* If decimation is used, then gyro and accel data will have meaningful
@@ -290,6 +365,9 @@ static int adis16475_set_freq(struct adis16475 *st, const u32 freq)
assign_bit(ADIS16475_LSB_DEC_MASK, &st->lsb_flag, dec);
return 0;
+error:
+ adis_dev_unlock(&st->adis);
+ return ret;
}
/* The values are approximated. */
@@ -1085,6 +1163,7 @@ static int adis16475_config_sync_mode(struct adis16475 *st)
}
sync = &st->info->sync[sync_mode];
+ st->sync_mode = sync->sync_mode;
/* All the other modes require external input signal */
if (sync->sync_mode != ADIS16475_SYNC_OUTPUT) {
@@ -1112,37 +1191,20 @@ static int adis16475_config_sync_mode(struct adis16475 *st)
if (sync->sync_mode == ADIS16475_SYNC_SCALED) {
u16 up_scale;
- u32 scaled_out_freq = 0;
+
/*
- * If we are in scaled mode, we must have an up_scale.
- * In scaled mode the allowable input clock range is
- * 1 Hz to 128 Hz, and the allowable output range is
- * 1900 to 2100 Hz. Hence, a scale must be given to
- * get the allowable output.
+ * In sync scaled mode, the IMU sample rate is the clk_freq * sync_scale.
+ * Hence, default the IMU sample rate to the highest multiple of the input
+ * clock lower than the IMU max sample rate. The optimal range is
+ * 1900-2100 sps...
*/
- ret = device_property_read_u32(dev,
- "adi,scaled-output-hz",
- &scaled_out_freq);
- if (ret) {
- dev_err(dev, "adi,scaled-output-hz must be given when in scaled sync mode");
- return -EINVAL;
- } else if (scaled_out_freq < 1900 ||
- scaled_out_freq > 2100) {
- dev_err(dev, "Invalid value: %u for adi,scaled-output-hz",
- scaled_out_freq);
- return -EINVAL;
- }
-
- up_scale = DIV_ROUND_CLOSEST(scaled_out_freq,
- st->clk_freq);
+ up_scale = 2100 / st->clk_freq;
ret = __adis_write_reg_16(&st->adis,
ADIS16475_REG_UP_SCALE,
up_scale);
if (ret)
return ret;
-
- st->clk_freq = scaled_out_freq;
}
st->clk_freq *= 1000;
@@ -1196,6 +1258,9 @@ static int adis16475_config_irq_pin(struct adis16475 *st)
return -EINVAL;
}
+ /* We cannot mask the interrupt so ensure it's not enabled at request */
+ st->adis.irq_flag |= IRQF_NO_AUTOEN;
+
val = ADIS16475_MSG_CTRL_DR_POL(polarity);
ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL,
ADIS16475_MSG_CTRL_DR_POL_MASK, val);
@@ -1300,8 +1365,6 @@ static int adis16475_probe(struct spi_device *spi)
if (ret)
return ret;
- adis16475_enable_irq(&st->adis, false);
-
ret = devm_iio_device_register(&spi->dev, indio_dev);
if (ret)
return ret;
diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index dfe86c589325..f81b86690b76 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -10,6 +10,7 @@
#include <linux/of_irq.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
+#include <linux/math.h>
#include <linux/mutex.h>
#include <linux/device.h>
#include <linux/kernel.h>
@@ -17,6 +18,7 @@
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/module.h>
+#include <linux/lcm.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
@@ -170,6 +172,11 @@ static const char * const adis16480_int_pin_names[4] = {
[ADIS16480_PIN_DIO4] = "DIO4",
};
+static bool low_rate_allow;
+module_param(low_rate_allow, bool, 0444);
+MODULE_PARM_DESC(low_rate_allow,
+ "Allow IMU rates below the minimum advisable when external clk is used in PPS mode (default: N)");
+
#ifdef CONFIG_DEBUG_FS
static ssize_t adis16480_show_firmware_revision(struct file *file,
@@ -312,7 +319,8 @@ static int adis16480_debugfs_init(struct iio_dev *indio_dev)
static int adis16480_set_freq(struct iio_dev *indio_dev, int val, int val2)
{
struct adis16480 *st = iio_priv(indio_dev);
- unsigned int t, reg;
+ unsigned int t, sample_rate = st->clk_freq;
+ int ret;
if (val < 0 || val2 < 0)
return -EINVAL;
@@ -321,28 +329,65 @@ static int adis16480_set_freq(struct iio_dev *indio_dev, int val, int val2)
if (t == 0)
return -EINVAL;
+ adis_dev_lock(&st->adis);
/*
- * When using PPS mode, the rate of data collection is equal to the
- * product of the external clock frequency and the scale factor in the
- * SYNC_SCALE register.
- * When using sync mode, or internal clock, the output data rate is
- * equal with the clock frequency divided by DEC_RATE + 1.
+ * When using PPS mode, the input clock needs to be scaled so that we have an IMU
+ * sample rate between (optimally) 4000 and 4250. After this, we can use the
+ * decimation filter to lower the sampling rate in order to get what the user wants.
+ * Optimally, the user sample rate is a multiple of both the IMU sample rate and
+ * the input clock. Hence, calculating the sync_scale dynamically gives us better
+ * chances of achieving a perfect/integer value for DEC_RATE. The math here is:
+ * 1. lcm of the input clock and the desired output rate.
+ * 2. get the highest multiple of the previous result lower than the adis max rate.
+ * 3. The last result becomes the IMU sample rate. Use that to calculate SYNC_SCALE
+ * and DEC_RATE (to get the user output rate)
*/
if (st->clk_mode == ADIS16480_CLK_PPS) {
- t = t / st->clk_freq;
- reg = ADIS16495_REG_SYNC_SCALE;
- } else {
- t = st->clk_freq / t;
- reg = ADIS16480_REG_DEC_RATE;
+ unsigned long scaled_rate = lcm(st->clk_freq, t);
+ int sync_scale;
+
+ /*
+ * If lcm is bigger than the IMU maximum sampling rate there's no perfect
+ * solution. In this case, we get the highest multiple of the input clock
+ * lower than the IMU max sample rate.
+ */
+ if (scaled_rate > st->chip_info->int_clk)
+ scaled_rate = st->chip_info->int_clk / st->clk_freq * st->clk_freq;
+ else
+ scaled_rate = st->chip_info->int_clk / scaled_rate * scaled_rate;
+
+ /*
+ * This is not an hard requirement but it's not advised to run the IMU
+ * with a sample rate lower than 4000Hz due to possible undersampling
+ * issues. However, there are users that might really want to take the risk.
+ * Hence, we provide a module parameter for them. If set, we allow sample
+ * rates lower than 4KHz. By default, we won't allow this and we just roundup
+ * the rate to the next multiple of the input clock bigger than 4KHz. This
+ * is done like this as in some cases (when DEC_RATE is 0) might give
+ * us the closest value to the one desired by the user...
+ */
+ if (scaled_rate < 4000000 && !low_rate_allow)
+ scaled_rate = roundup(4000000, st->clk_freq);
+
+ sync_scale = scaled_rate / st->clk_freq;
+ ret = __adis_write_reg_16(&st->adis, ADIS16495_REG_SYNC_SCALE, sync_scale);
+ if (ret)
+ goto error;
+
+ sample_rate = scaled_rate;
}
+ t = DIV_ROUND_CLOSEST(sample_rate, t);
+ if (t)
+ t--;
+
if (t > st->chip_info->max_dec_rate)
t = st->chip_info->max_dec_rate;
- if ((t != 0) && (st->clk_mode != ADIS16480_CLK_PPS))
- t--;
-
- return adis_write_reg_16(&st->adis, reg, t);
+ ret = __adis_write_reg_16(&st->adis, ADIS16480_REG_DEC_RATE, t);
+error:
+ adis_dev_unlock(&st->adis);
+ return ret;
}
static int adis16480_get_freq(struct iio_dev *indio_dev, int *val, int *val2)
@@ -350,34 +395,35 @@ static int adis16480_get_freq(struct iio_dev *indio_dev, int *val, int *val2)
struct adis16480 *st = iio_priv(indio_dev);
uint16_t t;
int ret;
- unsigned int freq;
- unsigned int reg;
+ unsigned int freq, sample_rate = st->clk_freq;
- if (st->clk_mode == ADIS16480_CLK_PPS)
- reg = ADIS16495_REG_SYNC_SCALE;
- else
- reg = ADIS16480_REG_DEC_RATE;
+ adis_dev_lock(&st->adis);
+
+ if (st->clk_mode == ADIS16480_CLK_PPS) {
+ u16 sync_scale;
+
+ ret = __adis_read_reg_16(&st->adis, ADIS16495_REG_SYNC_SCALE, &sync_scale);
+ if (ret)
+ goto error;
- ret = adis_read_reg_16(&st->adis, reg, &t);
+ sample_rate = st->clk_freq * sync_scale;
+ }
+
+ ret = __adis_read_reg_16(&st->adis, ADIS16480_REG_DEC_RATE, &t);
if (ret)
- return ret;
+ goto error;
- /*
- * When using PPS mode, the rate of data collection is equal to the
- * product of the external clock frequency and the scale factor in the
- * SYNC_SCALE register.
- * When using sync mode, or internal clock, the output data rate is
- * equal with the clock frequency divided by DEC_RATE + 1.
- */
- if (st->clk_mode == ADIS16480_CLK_PPS)
- freq = st->clk_freq * t;
- else
- freq = st->clk_freq / (t + 1);
+ adis_dev_unlock(&st->adis);
+
+ freq = DIV_ROUND_CLOSEST(sample_rate, (t + 1));
*val = freq / 1000;
*val2 = (freq % 1000) * 1000;
return IIO_VAL_INT_PLUS_MICRO;
+error:
+ adis_dev_unlock(&st->adis);
+ return ret;
}
enum {
@@ -552,7 +598,6 @@ static int adis16480_set_filter_freq(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, unsigned int freq)
{
struct adis16480 *st = iio_priv(indio_dev);
- struct mutex *slock = &st->adis.state_lock;
unsigned int enable_mask, offset, reg;
unsigned int diff, best_diff;
unsigned int i, best_freq;
@@ -563,7 +608,7 @@ static int adis16480_set_filter_freq(struct iio_dev *indio_dev,
offset = ad16480_filter_data[chan->scan_index][1];
enable_mask = BIT(offset + 2);
- mutex_lock(slock);
+ adis_dev_lock(&st->adis);
ret = __adis_read_reg_16(&st->adis, reg, &val);
if (ret)
@@ -591,7 +636,7 @@ static int adis16480_set_filter_freq(struct iio_dev *indio_dev,
ret = __adis_write_reg_16(&st->adis, reg, val);
out_unlock:
- mutex_unlock(slock);
+ adis_dev_unlock(&st->adis);
return ret;
}
@@ -1278,6 +1323,20 @@ static int adis16480_probe(struct spi_device *spi)
st->clk_freq = clk_get_rate(st->ext_clk);
st->clk_freq *= 1000; /* micro */
+ if (st->clk_mode == ADIS16480_CLK_PPS) {
+ u16 sync_scale;
+
+ /*
+ * In PPS mode, the IMU sample rate is the clk_freq * sync_scale. Hence,
+ * default the IMU sample rate to the highest multiple of the input clock
+ * lower than the IMU max sample rate. The internal sample rate is the
+ * max...
+ */
+ sync_scale = st->chip_info->int_clk / st->clk_freq;
+ ret = __adis_write_reg_16(&st->adis, ADIS16495_REG_SYNC_SCALE, sync_scale);
+ if (ret)
+ return ret;
+ }
} else {
st->clk_freq = st->chip_info->int_clk;
}
diff --git a/drivers/iio/imu/adis_trigger.c b/drivers/iio/imu/adis_trigger.c
index 64e0ba51cb18..fa5540fabacc 100644
--- a/drivers/iio/imu/adis_trigger.c
+++ b/drivers/iio/imu/adis_trigger.c
@@ -27,27 +27,21 @@ static const struct iio_trigger_ops adis_trigger_ops = {
.set_trigger_state = &adis_data_rdy_trigger_set_state,
};
-static void adis_trigger_setup(struct adis *adis)
-{
- adis->trig->dev.parent = &adis->spi->dev;
- adis->trig->ops = &adis_trigger_ops;
- iio_trigger_set_drvdata(adis->trig, adis);
-}
-
static int adis_validate_irq_flag(struct adis *adis)
{
+ unsigned long direction = adis->irq_flag & IRQF_TRIGGER_MASK;
/*
* Typically this devices have data ready either on the rising edge or
* on the falling edge of the data ready pin. This checks enforces that
* one of those is set in the drivers... It defaults to
- * IRQF_TRIGGER_RISING for backward compatibility wiht devices that
+ * IRQF_TRIGGER_RISING for backward compatibility with devices that
* don't support changing the pin polarity.
*/
- if (!adis->irq_flag) {
- adis->irq_flag = IRQF_TRIGGER_RISING;
+ if (direction == IRQF_TRIGGER_NONE) {
+ adis->irq_flag |= IRQF_TRIGGER_RISING;
return 0;
- } else if (adis->irq_flag != IRQF_TRIGGER_RISING &&
- adis->irq_flag != IRQF_TRIGGER_FALLING) {
+ } else if (direction != IRQF_TRIGGER_RISING &&
+ direction != IRQF_TRIGGER_FALLING) {
dev_err(&adis->spi->dev, "Invalid IRQ mask: %08lx\n",
adis->irq_flag);
return -EINVAL;
@@ -72,7 +66,8 @@ int devm_adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)
if (!adis->trig)
return -ENOMEM;
- adis_trigger_setup(adis);
+ adis->trig->ops = &adis_trigger_ops;
+ iio_trigger_set_drvdata(adis->trig, adis);
ret = adis_validate_irq_flag(adis);
if (ret)
diff --git a/drivers/iio/imu/fxos8700_i2c.c b/drivers/iio/imu/fxos8700_i2c.c
index 3ceb76366313..40a570325b0a 100644
--- a/drivers/iio/imu/fxos8700_i2c.c
+++ b/drivers/iio/imu/fxos8700_i2c.c
@@ -26,8 +26,7 @@ static int fxos8700_i2c_probe(struct i2c_client *client,
regmap = devm_regmap_init_i2c(client, &fxos8700_regmap_config);
if (IS_ERR(regmap)) {
- dev_err(&client->dev, "Failed to register i2c regmap %d\n",
- (int)PTR_ERR(regmap));
+ dev_err(&client->dev, "Failed to register i2c regmap %ld\n", PTR_ERR(regmap));
return PTR_ERR(regmap);
}
diff --git a/drivers/iio/imu/fxos8700_spi.c b/drivers/iio/imu/fxos8700_spi.c
index 57e7bb6444e7..27e694cce173 100644
--- a/drivers/iio/imu/fxos8700_spi.c
+++ b/drivers/iio/imu/fxos8700_spi.c
@@ -17,8 +17,7 @@ static int fxos8700_spi_probe(struct spi_device *spi)
regmap = devm_regmap_init_spi(spi, &fxos8700_regmap_config);
if (IS_ERR(regmap)) {
- dev_err(&spi->dev, "Failed to register spi regmap %d\n",
- (int)PTR_ERR(regmap));
+ dev_err(&spi->dev, "Failed to register spi regmap %ld\n", PTR_ERR(regmap));
return PTR_ERR(regmap);
}
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
index 3441b0d61c5d..383cc3250342 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
@@ -709,7 +709,6 @@ struct iio_dev *inv_icm42600_accel_init(struct inv_icm42600_state *st)
const char *name;
struct inv_icm42600_timestamp *ts;
struct iio_dev *indio_dev;
- struct iio_buffer *buffer;
int ret;
name = devm_kasprintf(dev, GFP_KERNEL, "%s-accel", st->name);
@@ -720,23 +719,22 @@ struct iio_dev *inv_icm42600_accel_init(struct inv_icm42600_state *st)
if (!indio_dev)
return ERR_PTR(-ENOMEM);
- buffer = devm_iio_kfifo_allocate(dev);
- if (!buffer)
- return ERR_PTR(-ENOMEM);
-
ts = iio_priv(indio_dev);
inv_icm42600_timestamp_init(ts, inv_icm42600_odr_to_period(st->conf.accel.odr));
iio_device_set_drvdata(indio_dev, st);
indio_dev->name = name;
indio_dev->info = &inv_icm42600_accel_info;
- indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
+ indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = inv_icm42600_accel_channels;
indio_dev->num_channels = ARRAY_SIZE(inv_icm42600_accel_channels);
indio_dev->available_scan_masks = inv_icm42600_accel_scan_masks;
- indio_dev->setup_ops = &inv_icm42600_buffer_ops;
- iio_device_attach_buffer(indio_dev, buffer);
+ ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ &inv_icm42600_buffer_ops);
+ if (ret)
+ return ERR_PTR(ret);
ret = devm_iio_device_register(dev, indio_dev);
if (ret)
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
index aee7b9ff4bf4..cec1dd0e0464 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
@@ -720,7 +720,6 @@ struct iio_dev *inv_icm42600_gyro_init(struct inv_icm42600_state *st)
const char *name;
struct inv_icm42600_timestamp *ts;
struct iio_dev *indio_dev;
- struct iio_buffer *buffer;
int ret;
name = devm_kasprintf(dev, GFP_KERNEL, "%s-gyro", st->name);
@@ -731,23 +730,23 @@ struct iio_dev *inv_icm42600_gyro_init(struct inv_icm42600_state *st)
if (!indio_dev)
return ERR_PTR(-ENOMEM);
- buffer = devm_iio_kfifo_allocate(dev);
- if (!buffer)
- return ERR_PTR(-ENOMEM);
-
ts = iio_priv(indio_dev);
inv_icm42600_timestamp_init(ts, inv_icm42600_odr_to_period(st->conf.gyro.odr));
iio_device_set_drvdata(indio_dev, st);
indio_dev->name = name;
indio_dev->info = &inv_icm42600_gyro_info;
- indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
+ indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = inv_icm42600_gyro_channels;
indio_dev->num_channels = ARRAY_SIZE(inv_icm42600_gyro_channels);
indio_dev->available_scan_masks = inv_icm42600_gyro_scan_masks;
indio_dev->setup_ops = &inv_icm42600_buffer_ops;
- iio_device_attach_buffer(indio_dev, buffer);
+ ret = devm_iio_kfifo_buffer_setup(dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ &inv_icm42600_buffer_ops);
+ if (ret)
+ return ERR_PTR(ret);
ret = devm_iio_device_register(dev, indio_dev);
if (ret)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 453c51c79655..6244a07048df 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -731,12 +731,16 @@ inv_mpu6050_read_raw(struct iio_dev *indio_dev,
}
}
-static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val)
+static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val,
+ int val2)
{
int result, i;
+ if (val != 0)
+ return -EINVAL;
+
for (i = 0; i < ARRAY_SIZE(gyro_scale_6050); ++i) {
- if (gyro_scale_6050[i] == val) {
+ if (gyro_scale_6050[i] == val2) {
result = inv_mpu6050_set_gyro_fsr(st, i);
if (result)
return result;
@@ -767,13 +771,17 @@ static int inv_write_raw_get_fmt(struct iio_dev *indio_dev,
return -EINVAL;
}
-static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val)
+static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val,
+ int val2)
{
int result, i;
u8 d;
+ if (val != 0)
+ return -EINVAL;
+
for (i = 0; i < ARRAY_SIZE(accel_scale); ++i) {
- if (accel_scale[i] == val) {
+ if (accel_scale[i] == val2) {
d = (i << INV_MPU6050_ACCL_CONFIG_FSR_SHIFT);
result = regmap_write(st->map, st->reg->accl_config, d);
if (result)
@@ -814,10 +822,10 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_SCALE:
switch (chan->type) {
case IIO_ANGL_VEL:
- result = inv_mpu6050_write_gyro_scale(st, val2);
+ result = inv_mpu6050_write_gyro_scale(st, val, val2);
break;
case IIO_ACCEL:
- result = inv_mpu6050_write_accel_scale(st, val2);
+ result = inv_mpu6050_write_accel_scale(st, val, val2);
break;
default:
result = -EINVAL;
@@ -1458,15 +1466,21 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
st->plat_data = *pdata;
}
- desc = irq_get_irq_data(irq);
- if (!desc) {
- dev_err(dev, "Could not find IRQ %d\n", irq);
- return -EINVAL;
- }
+ if (irq > 0) {
+ desc = irq_get_irq_data(irq);
+ if (!desc) {
+ dev_err(dev, "Could not find IRQ %d\n", irq);
+ return -EINVAL;
+ }
- irq_type = irqd_get_trigger_type(desc);
- if (!irq_type)
+ irq_type = irqd_get_trigger_type(desc);
+ if (!irq_type)
+ irq_type = IRQF_TRIGGER_RISING;
+ } else {
+ /* Doesn't really matter, use the default */
irq_type = IRQF_TRIGGER_RISING;
+ }
+
if (irq_type & IRQF_TRIGGER_RISING) // rising or both-edge
st->irq_mask = INV_MPU6050_ACTIVE_HIGH;
else if (irq_type == IRQF_TRIGGER_FALLING)
@@ -1591,20 +1605,26 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
}
indio_dev->info = &mpu_info;
- indio_dev->modes = INDIO_BUFFER_TRIGGERED;
- result = devm_iio_triggered_buffer_setup(dev, indio_dev,
- iio_pollfunc_store_time,
- inv_mpu6050_read_fifo,
- NULL);
- if (result) {
- dev_err(dev, "configure buffer fail %d\n", result);
- return result;
- }
- result = inv_mpu6050_probe_trigger(indio_dev, irq_type);
- if (result) {
- dev_err(dev, "trigger probe fail %d\n", result);
- return result;
+ if (irq > 0) {
+ /*
+ * The driver currently only supports buffered capture with its
+ * own trigger. So no IRQ, no trigger, no buffer
+ */
+ result = devm_iio_triggered_buffer_setup(dev, indio_dev,
+ iio_pollfunc_store_time,
+ inv_mpu6050_read_fifo,
+ NULL);
+ if (result) {
+ dev_err(dev, "configure buffer fail %d\n", result);
+ return result;
+ }
+
+ result = inv_mpu6050_probe_trigger(indio_dev, irq_type);
+ if (result) {
+ dev_err(dev, "trigger probe fail %d\n", result);
+ return result;
+ }
}
result = devm_iio_device_register(dev, indio_dev);
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
index f7b5a70be30f..de8ed1446d60 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
@@ -11,6 +11,16 @@ static unsigned int inv_scan_query_mpu6050(struct iio_dev *indio_dev)
struct inv_mpu6050_state *st = iio_priv(indio_dev);
unsigned int mask;
+ /*
+ * If the MPU6050 is just used as a trigger, then the scan mask
+ * is not allocated so we simply enable the temperature channel
+ * as a dummy and bail out.
+ */
+ if (!indio_dev->active_scan_mask) {
+ st->chip_config.temp_fifo_enable = true;
+ return INV_MPU6050_SENSOR_TEMP;
+ }
+
st->chip_config.gyro_fifo_enable =
test_bit(INV_MPU6050_SCAN_GYRO_X,
indio_dev->active_scan_mask) ||
diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c
index 4377047d503a..fc5a60fcfec0 100644
--- a/drivers/iio/imu/kmx61.c
+++ b/drivers/iio/imu/kmx61.c
@@ -1268,7 +1268,6 @@ static struct iio_trigger *kmx61_trigger_setup(struct kmx61_data *data,
if (!trig)
return ERR_PTR(-ENOMEM);
- trig->dev.parent = &data->client->dev;
trig->ops = &kmx61_trigger_ops;
iio_trigger_set_drvdata(trig, indio_dev);
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
index f1103ecedd64..16730a780964 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
@@ -739,20 +739,17 @@ static const struct iio_buffer_setup_ops st_lsm6dsx_buffer_ops = {
int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
{
- struct iio_buffer *buffer;
- int i;
+ int i, ret;
for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
if (!hw->iio_devs[i])
continue;
- buffer = devm_iio_kfifo_allocate(hw->dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(hw->iio_devs[i], buffer);
- hw->iio_devs[i]->modes |= INDIO_BUFFER_SOFTWARE;
- hw->iio_devs[i]->setup_ops = &st_lsm6dsx_buffer_ops;
+ ret = devm_iio_kfifo_buffer_setup(hw->dev, hw->iio_devs[i],
+ INDIO_BUFFER_SOFTWARE,
+ &st_lsm6dsx_buffer_ops);
+ if (ret)
+ return ret;
}
return 0;
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
index ec8d4351390a..8b4fc2c15622 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
@@ -29,8 +29,7 @@ static int st_lsm6dsx_i2c_probe(struct i2c_client *client,
regmap = devm_regmap_init_i2c(client, &st_lsm6dsx_i2c_regmap_config);
if (IS_ERR(regmap)) {
- dev_err(&client->dev, "Failed to register i2c regmap %d\n",
- (int)PTR_ERR(regmap));
+ dev_err(&client->dev, "Failed to register i2c regmap %ld\n", PTR_ERR(regmap));
return PTR_ERR(regmap);
}
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
index 57e633121bdc..8d4201b86e87 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
@@ -34,8 +34,7 @@ static int st_lsm6dsx_i3c_probe(struct i3c_device *i3cdev)
regmap = devm_regmap_init_i3c(i3cdev, &st_lsm6dsx_i3c_regmap_config);
if (IS_ERR(regmap)) {
- dev_err(&i3cdev->dev, "Failed to register i3c regmap %d\n",
- (int)PTR_ERR(regmap));
+ dev_err(&i3cdev->dev, "Failed to register i3c regmap %ld\n", PTR_ERR(regmap));
return PTR_ERR(regmap);
}
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
index 349ec9c1890d..e80110b6b280 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
@@ -29,8 +29,7 @@ static int st_lsm6dsx_spi_probe(struct spi_device *spi)
regmap = devm_regmap_init_spi(spi, &st_lsm6dsx_spi_regmap_config);
if (IS_ERR(regmap)) {
- dev_err(&spi->dev, "Failed to register spi regmap %d\n",
- (int)PTR_ERR(regmap));
+ dev_err(&spi->dev, "Failed to register spi regmap %ld\n", PTR_ERR(regmap));
return PTR_ERR(regmap);
}
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 2f7426a2f47c..9a8e16c7e9af 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -9,9 +9,11 @@
* - Better memory allocation techniques?
* - Alternative access techniques?
*/
+#include <linux/anon_inodes.h>
#include <linux/kernel.h>
#include <linux/export.h>
#include <linux/device.h>
+#include <linux/file.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/slab.h>
@@ -89,7 +91,7 @@ static bool iio_buffer_ready(struct iio_dev *indio_dev, struct iio_buffer *buf,
}
/**
- * iio_buffer_read_outer() - chrdev read for buffer access
+ * iio_buffer_read() - chrdev read for buffer access
* @filp: File structure pointer for the char device
* @buf: Destination buffer for iio buffer read
* @n: First n bytes to read
@@ -101,11 +103,12 @@ static bool iio_buffer_ready(struct iio_dev *indio_dev, struct iio_buffer *buf,
* Return: negative values corresponding to error codes or ret != 0
* for ending the reading activity
**/
-ssize_t iio_buffer_read_outer(struct file *filp, char __user *buf,
- size_t n, loff_t *f_ps)
+static ssize_t iio_buffer_read(struct file *filp, char __user *buf,
+ size_t n, loff_t *f_ps)
{
- struct iio_dev *indio_dev = filp->private_data;
- struct iio_buffer *rb = indio_dev->buffer;
+ struct iio_dev_buffer_pair *ib = filp->private_data;
+ struct iio_buffer *rb = ib->buffer;
+ struct iio_dev *indio_dev = ib->indio_dev;
DEFINE_WAIT_FUNC(wait, woken_wake_function);
size_t datum_size;
size_t to_wait;
@@ -167,11 +170,12 @@ ssize_t iio_buffer_read_outer(struct file *filp, char __user *buf,
* Return: (EPOLLIN | EPOLLRDNORM) if data is available for reading
* or 0 for other cases
*/
-__poll_t iio_buffer_poll(struct file *filp,
- struct poll_table_struct *wait)
+static __poll_t iio_buffer_poll(struct file *filp,
+ struct poll_table_struct *wait)
{
- struct iio_dev *indio_dev = filp->private_data;
- struct iio_buffer *rb = indio_dev->buffer;
+ struct iio_dev_buffer_pair *ib = filp->private_data;
+ struct iio_buffer *rb = ib->buffer;
+ struct iio_dev *indio_dev = ib->indio_dev;
if (!indio_dev->info || rb == NULL)
return 0;
@@ -182,6 +186,32 @@ __poll_t iio_buffer_poll(struct file *filp,
return 0;
}
+ssize_t iio_buffer_read_wrapper(struct file *filp, char __user *buf,
+ size_t n, loff_t *f_ps)
+{
+ struct iio_dev_buffer_pair *ib = filp->private_data;
+ struct iio_buffer *rb = ib->buffer;
+
+ /* check if buffer was opened through new API */
+ if (test_bit(IIO_BUSY_BIT_POS, &rb->flags))
+ return -EBUSY;
+
+ return iio_buffer_read(filp, buf, n, f_ps);
+}
+
+__poll_t iio_buffer_poll_wrapper(struct file *filp,
+ struct poll_table_struct *wait)
+{
+ struct iio_dev_buffer_pair *ib = filp->private_data;
+ struct iio_buffer *rb = ib->buffer;
+
+ /* check if buffer was opened through new API */
+ if (test_bit(IIO_BUSY_BIT_POS, &rb->flags))
+ return 0;
+
+ return iio_buffer_poll(filp, wait);
+}
+
/**
* iio_buffer_wakeup_poll - Wakes up the buffer waitqueue
* @indio_dev: The IIO device
@@ -191,12 +221,14 @@ __poll_t iio_buffer_poll(struct file *filp,
*/
void iio_buffer_wakeup_poll(struct iio_dev *indio_dev)
{
- struct iio_buffer *buffer = indio_dev->buffer;
-
- if (!buffer)
- return;
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+ struct iio_buffer *buffer;
+ unsigned int i;
- wake_up(&buffer->pollq);
+ for (i = 0; i < iio_dev_opaque->attached_buffers_cnt; i++) {
+ buffer = iio_dev_opaque->attached_buffers[i];
+ wake_up(&buffer->pollq);
+ }
}
void iio_buffer_init(struct iio_buffer *buffer)
@@ -210,11 +242,25 @@ void iio_buffer_init(struct iio_buffer *buffer)
}
EXPORT_SYMBOL(iio_buffer_init);
+void iio_device_detach_buffers(struct iio_dev *indio_dev)
+{
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+ struct iio_buffer *buffer;
+ unsigned int i;
+
+ for (i = 0; i < iio_dev_opaque->attached_buffers_cnt; i++) {
+ buffer = iio_dev_opaque->attached_buffers[i];
+ iio_buffer_put(buffer);
+ }
+
+ kfree(iio_dev_opaque->attached_buffers);
+}
+
static ssize_t iio_show_scan_index(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return sprintf(buf, "%u\n", to_iio_dev_attr(attr)->c->scan_index);
+ return sysfs_emit(buf, "%u\n", to_iio_dev_attr(attr)->c->scan_index);
}
static ssize_t iio_show_fixed_type(struct device *dev,
@@ -232,15 +278,15 @@ static ssize_t iio_show_fixed_type(struct device *dev,
#endif
}
if (this_attr->c->scan_type.repeat > 1)
- return sprintf(buf, "%s:%c%d/%dX%d>>%u\n",
+ return sysfs_emit(buf, "%s:%c%d/%dX%d>>%u\n",
iio_endian_prefix[type],
this_attr->c->scan_type.sign,
this_attr->c->scan_type.realbits,
this_attr->c->scan_type.storagebits,
this_attr->c->scan_type.repeat,
this_attr->c->scan_type.shift);
- else
- return sprintf(buf, "%s:%c%d/%d>>%u\n",
+ else
+ return sysfs_emit(buf, "%s:%c%d/%d>>%u\n",
iio_endian_prefix[type],
this_attr->c->scan_type.sign,
this_attr->c->scan_type.realbits,
@@ -253,14 +299,13 @@ static ssize_t iio_scan_el_show(struct device *dev,
char *buf)
{
int ret;
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct iio_buffer *buffer = indio_dev->buffer;
+ struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
/* Ensure ret is 0 or 1. */
ret = !!test_bit(to_iio_dev_attr(attr)->address,
buffer->scan_mask);
- return sprintf(buf, "%d\n", ret);
+ return sysfs_emit(buf, "%d\n", ret);
}
/* Note NULL used as error indicator as it doesn't make sense. */
@@ -367,8 +412,8 @@ static ssize_t iio_scan_el_store(struct device *dev,
int ret;
bool state;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct iio_buffer *buffer = indio_dev->buffer;
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+ struct iio_buffer *buffer = this_attr->buffer;
ret = strtobool(buf, &state);
if (ret < 0)
@@ -402,10 +447,9 @@ static ssize_t iio_scan_el_ts_show(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;
+ struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
- return sprintf(buf, "%d\n", buffer->scan_timestamp);
+ return sysfs_emit(buf, "%d\n", buffer->scan_timestamp);
}
static ssize_t iio_scan_el_ts_store(struct device *dev,
@@ -415,7 +459,7 @@ static ssize_t iio_scan_el_ts_store(struct device *dev,
{
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct iio_buffer *buffer = indio_dev->buffer;
+ struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
bool state;
ret = strtobool(buf, &state);
@@ -447,7 +491,8 @@ static int iio_buffer_add_channel_sysfs(struct iio_dev *indio_dev,
0,
IIO_SEPARATE,
&indio_dev->dev,
- &buffer->scan_el_dev_attr_list);
+ buffer,
+ &buffer->buffer_attr_list);
if (ret)
return ret;
attrcount++;
@@ -458,7 +503,8 @@ static int iio_buffer_add_channel_sysfs(struct iio_dev *indio_dev,
0,
0,
&indio_dev->dev,
- &buffer->scan_el_dev_attr_list);
+ buffer,
+ &buffer->buffer_attr_list);
if (ret)
return ret;
attrcount++;
@@ -470,7 +516,8 @@ static int iio_buffer_add_channel_sysfs(struct iio_dev *indio_dev,
chan->scan_index,
0,
&indio_dev->dev,
- &buffer->scan_el_dev_attr_list);
+ buffer,
+ &buffer->buffer_attr_list);
else
ret = __iio_add_chan_devattr("en",
chan,
@@ -479,7 +526,8 @@ static int iio_buffer_add_channel_sysfs(struct iio_dev *indio_dev,
chan->scan_index,
0,
&indio_dev->dev,
- &buffer->scan_el_dev_attr_list);
+ buffer,
+ &buffer->buffer_attr_list);
if (ret)
return ret;
attrcount++;
@@ -491,10 +539,9 @@ static ssize_t iio_buffer_read_length(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;
+ struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
- return sprintf(buf, "%d\n", buffer->length);
+ return sysfs_emit(buf, "%d\n", buffer->length);
}
static ssize_t iio_buffer_write_length(struct device *dev,
@@ -502,7 +549,7 @@ static ssize_t iio_buffer_write_length(struct device *dev,
const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct iio_buffer *buffer = indio_dev->buffer;
+ struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
unsigned int val;
int ret;
@@ -534,10 +581,9 @@ static ssize_t iio_buffer_show_enable(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;
+ struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
- return sprintf(buf, "%d\n", iio_buffer_is_active(buffer));
+ return sysfs_emit(buf, "%d\n", iio_buffer_is_active(buffer));
}
static unsigned int iio_storage_bytes_for_si(struct iio_dev *indio_dev,
@@ -1150,7 +1196,7 @@ static ssize_t iio_buffer_store_enable(struct device *dev,
int ret;
bool requested_state;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct iio_buffer *buffer = indio_dev->buffer;
+ struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
bool inlist;
ret = strtobool(buf, &requested_state);
@@ -1175,16 +1221,13 @@ done:
return (ret < 0) ? ret : len;
}
-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;
+ struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
- return sprintf(buf, "%u\n", buffer->watermark);
+ return sysfs_emit(buf, "%u\n", buffer->watermark);
}
static ssize_t iio_buffer_store_watermark(struct device *dev,
@@ -1193,7 +1236,7 @@ static ssize_t iio_buffer_store_watermark(struct device *dev,
size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct iio_buffer *buffer = indio_dev->buffer;
+ struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
unsigned int val;
int ret;
@@ -1226,10 +1269,9 @@ static ssize_t iio_dma_show_data_available(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;
+ struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
- return sprintf(buf, "%zu\n", iio_buffer_data_available(buffer));
+ return sysfs_emit(buf, "%zu\n", iio_buffer_data_available(buffer));
}
static DEVICE_ATTR(length, S_IRUGO | S_IWUSR, iio_buffer_read_length,
@@ -1252,45 +1294,194 @@ static struct attribute *iio_buffer_attrs[] = {
&dev_attr_data_available.attr,
};
-static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
- struct iio_dev *indio_dev)
+#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
+
+static struct attribute *iio_buffer_wrap_attr(struct iio_buffer *buffer,
+ struct attribute *attr)
{
- struct iio_dev_attr *p;
- struct attribute **attr;
- int ret, i, attrn, attrcount;
- const struct iio_chan_spec *channels;
+ struct device_attribute *dattr = to_dev_attr(attr);
+ struct iio_dev_attr *iio_attr;
- attrcount = 0;
- if (buffer->attrs) {
- while (buffer->attrs[attrcount] != NULL)
- attrcount++;
- }
+ iio_attr = kzalloc(sizeof(*iio_attr), GFP_KERNEL);
+ if (!iio_attr)
+ return NULL;
+
+ iio_attr->buffer = buffer;
+ memcpy(&iio_attr->dev_attr, dattr, sizeof(iio_attr->dev_attr));
+ iio_attr->dev_attr.attr.name = kstrdup_const(attr->name, GFP_KERNEL);
+ sysfs_attr_init(&iio_attr->dev_attr.attr);
+
+ list_add(&iio_attr->l, &buffer->buffer_attr_list);
+
+ return &iio_attr->dev_attr.attr;
+}
+
+static int iio_buffer_register_legacy_sysfs_groups(struct iio_dev *indio_dev,
+ struct attribute **buffer_attrs,
+ int buffer_attrcount,
+ int scan_el_attrcount)
+{
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+ struct attribute_group *group;
+ struct attribute **attrs;
+ int ret;
- attr = kcalloc(attrcount + ARRAY_SIZE(iio_buffer_attrs) + 1,
- sizeof(struct attribute *), GFP_KERNEL);
- if (!attr)
+ attrs = kcalloc(buffer_attrcount + 1, sizeof(*attrs), GFP_KERNEL);
+ if (!attrs)
return -ENOMEM;
- memcpy(attr, iio_buffer_attrs, sizeof(iio_buffer_attrs));
- if (!buffer->access->set_length)
- attr[0] = &dev_attr_length_ro.attr;
+ memcpy(attrs, buffer_attrs, buffer_attrcount * sizeof(*attrs));
- if (buffer->access->flags & INDIO_BUFFER_FLAG_FIXED_WATERMARK)
- attr[2] = &dev_attr_watermark_ro.attr;
+ group = &iio_dev_opaque->legacy_buffer_group;
+ group->attrs = attrs;
+ group->name = "buffer";
- if (buffer->attrs)
- memcpy(&attr[ARRAY_SIZE(iio_buffer_attrs)], buffer->attrs,
- sizeof(struct attribute *) * attrcount);
+ ret = iio_device_register_sysfs_group(indio_dev, group);
+ if (ret)
+ goto error_free_buffer_attrs;
- attr[attrcount + ARRAY_SIZE(iio_buffer_attrs)] = NULL;
+ attrs = kcalloc(scan_el_attrcount + 1, sizeof(*attrs), GFP_KERNEL);
+ if (!attrs) {
+ ret = -ENOMEM;
+ goto error_free_buffer_attrs;
+ }
- buffer->buffer_group.name = "buffer";
- buffer->buffer_group.attrs = attr;
+ memcpy(attrs, &buffer_attrs[buffer_attrcount],
+ scan_el_attrcount * sizeof(*attrs));
+
+ group = &iio_dev_opaque->legacy_scan_el_group;
+ group->attrs = attrs;
+ group->name = "scan_elements";
+
+ ret = iio_device_register_sysfs_group(indio_dev, group);
+ if (ret)
+ goto error_free_scan_el_attrs;
+
+ return 0;
+
+error_free_buffer_attrs:
+ kfree(iio_dev_opaque->legacy_buffer_group.attrs);
+error_free_scan_el_attrs:
+ kfree(iio_dev_opaque->legacy_scan_el_group.attrs);
+
+ return ret;
+}
+
+static void iio_buffer_unregister_legacy_sysfs_groups(struct iio_dev *indio_dev)
+{
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
- indio_dev->groups[indio_dev->groupcounter++] = &buffer->buffer_group;
+ kfree(iio_dev_opaque->legacy_buffer_group.attrs);
+ kfree(iio_dev_opaque->legacy_scan_el_group.attrs);
+}
+
+static int iio_buffer_chrdev_release(struct inode *inode, struct file *filep)
+{
+ struct iio_dev_buffer_pair *ib = filep->private_data;
+ struct iio_dev *indio_dev = ib->indio_dev;
+ struct iio_buffer *buffer = ib->buffer;
+
+ wake_up(&buffer->pollq);
+
+ kfree(ib);
+ clear_bit(IIO_BUSY_BIT_POS, &buffer->flags);
+ iio_device_put(indio_dev);
+
+ return 0;
+}
+
+static const struct file_operations iio_buffer_chrdev_fileops = {
+ .owner = THIS_MODULE,
+ .llseek = noop_llseek,
+ .read = iio_buffer_read,
+ .poll = iio_buffer_poll,
+ .release = iio_buffer_chrdev_release,
+};
+
+static long iio_device_buffer_getfd(struct iio_dev *indio_dev, unsigned long arg)
+{
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+ int __user *ival = (int __user *)arg;
+ struct iio_dev_buffer_pair *ib;
+ struct iio_buffer *buffer;
+ int fd, idx, ret;
+
+ if (copy_from_user(&idx, ival, sizeof(idx)))
+ return -EFAULT;
+
+ if (idx >= iio_dev_opaque->attached_buffers_cnt)
+ return -ENODEV;
- attrcount = 0;
- INIT_LIST_HEAD(&buffer->scan_el_dev_attr_list);
+ iio_device_get(indio_dev);
+
+ buffer = iio_dev_opaque->attached_buffers[idx];
+
+ if (test_and_set_bit(IIO_BUSY_BIT_POS, &buffer->flags)) {
+ ret = -EBUSY;
+ goto error_iio_dev_put;
+ }
+
+ ib = kzalloc(sizeof(*ib), GFP_KERNEL);
+ if (!ib) {
+ ret = -ENOMEM;
+ goto error_clear_busy_bit;
+ }
+
+ ib->indio_dev = indio_dev;
+ ib->buffer = buffer;
+
+ fd = anon_inode_getfd("iio:buffer", &iio_buffer_chrdev_fileops,
+ ib, O_RDWR | O_CLOEXEC);
+ if (fd < 0) {
+ ret = fd;
+ goto error_free_ib;
+ }
+
+ if (copy_to_user(ival, &fd, sizeof(fd))) {
+ put_unused_fd(fd);
+ ret = -EFAULT;
+ goto error_free_ib;
+ }
+
+ return 0;
+
+error_free_ib:
+ kfree(ib);
+error_clear_busy_bit:
+ clear_bit(IIO_BUSY_BIT_POS, &buffer->flags);
+error_iio_dev_put:
+ iio_device_put(indio_dev);
+ return ret;
+}
+
+static long iio_device_buffer_ioctl(struct iio_dev *indio_dev, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ switch (cmd) {
+ case IIO_BUFFER_GET_FD_IOCTL:
+ return iio_device_buffer_getfd(indio_dev, arg);
+ default:
+ return IIO_IOCTL_UNHANDLED;
+ }
+}
+
+static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
+ struct iio_dev *indio_dev,
+ int index)
+{
+ struct iio_dev_attr *p;
+ struct attribute **attr;
+ int ret, i, attrn, scan_el_attrcount, buffer_attrcount;
+ const struct iio_chan_spec *channels;
+
+ buffer_attrcount = 0;
+ if (buffer->attrs) {
+ while (buffer->attrs[buffer_attrcount] != NULL)
+ buffer_attrcount++;
+ }
+
+ scan_el_attrcount = 0;
+ INIT_LIST_HEAD(&buffer->buffer_attr_list);
channels = indio_dev->channels;
if (channels) {
/* new magic */
@@ -1302,7 +1493,7 @@ static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
&channels[i]);
if (ret < 0)
goto error_cleanup_dynamic;
- attrcount += ret;
+ scan_el_attrcount += ret;
if (channels[i].type == IIO_TIMESTAMP)
indio_dev->scan_index_timestamp =
channels[i].scan_index;
@@ -1317,37 +1508,93 @@ static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
}
}
- buffer->scan_el_group.name = iio_scan_elements_group_name;
-
- buffer->scan_el_group.attrs = kcalloc(attrcount + 1,
- sizeof(buffer->scan_el_group.attrs[0]),
- GFP_KERNEL);
- if (buffer->scan_el_group.attrs == NULL) {
+ attrn = buffer_attrcount + scan_el_attrcount + ARRAY_SIZE(iio_buffer_attrs);
+ attr = kcalloc(attrn + 1, sizeof(* attr), GFP_KERNEL);
+ if (!attr) {
ret = -ENOMEM;
goto error_free_scan_mask;
}
+
+ memcpy(attr, iio_buffer_attrs, sizeof(iio_buffer_attrs));
+ if (!buffer->access->set_length)
+ attr[0] = &dev_attr_length_ro.attr;
+
+ if (buffer->access->flags & INDIO_BUFFER_FLAG_FIXED_WATERMARK)
+ attr[2] = &dev_attr_watermark_ro.attr;
+
+ if (buffer->attrs)
+ memcpy(&attr[ARRAY_SIZE(iio_buffer_attrs)], buffer->attrs,
+ sizeof(struct attribute *) * buffer_attrcount);
+
+ buffer_attrcount += ARRAY_SIZE(iio_buffer_attrs);
+
+ for (i = 0; i < buffer_attrcount; i++) {
+ struct attribute *wrapped;
+
+ wrapped = iio_buffer_wrap_attr(buffer, attr[i]);
+ if (!wrapped) {
+ ret = -ENOMEM;
+ goto error_free_scan_mask;
+ }
+ attr[i] = wrapped;
+ }
+
attrn = 0;
+ list_for_each_entry(p, &buffer->buffer_attr_list, l)
+ attr[attrn++] = &p->dev_attr.attr;
- list_for_each_entry(p, &buffer->scan_el_dev_attr_list, l)
- buffer->scan_el_group.attrs[attrn++] = &p->dev_attr.attr;
- indio_dev->groups[indio_dev->groupcounter++] = &buffer->scan_el_group;
+ buffer->buffer_group.name = kasprintf(GFP_KERNEL, "buffer%d", index);
+ if (!buffer->buffer_group.name) {
+ ret = -ENOMEM;
+ goto error_free_buffer_attrs;
+ }
+
+ buffer->buffer_group.attrs = attr;
+
+ ret = iio_device_register_sysfs_group(indio_dev, &buffer->buffer_group);
+ if (ret)
+ goto error_free_buffer_attr_group_name;
+
+ /* we only need to register the legacy groups for the first buffer */
+ if (index > 0)
+ return 0;
+
+ ret = iio_buffer_register_legacy_sysfs_groups(indio_dev, attr,
+ buffer_attrcount,
+ scan_el_attrcount);
+ if (ret)
+ goto error_free_buffer_attr_group_name;
return 0;
+error_free_buffer_attr_group_name:
+ kfree(buffer->buffer_group.name);
+error_free_buffer_attrs:
+ kfree(buffer->buffer_group.attrs);
error_free_scan_mask:
bitmap_free(buffer->scan_mask);
error_cleanup_dynamic:
- iio_free_chan_devattr_list(&buffer->scan_el_dev_attr_list);
- kfree(buffer->buffer_group.attrs);
+ iio_free_chan_devattr_list(&buffer->buffer_attr_list);
return ret;
}
-int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
+static void __iio_buffer_free_sysfs_and_mask(struct iio_buffer *buffer)
+{
+ bitmap_free(buffer->scan_mask);
+ kfree(buffer->buffer_group.name);
+ kfree(buffer->buffer_group.attrs);
+ iio_free_chan_devattr_list(&buffer->buffer_attr_list);
+}
+
+int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
{
- struct iio_buffer *buffer = indio_dev->buffer;
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
const struct iio_chan_spec *channels;
- int i;
+ struct iio_buffer *buffer;
+ int unwind_idx;
+ int ret, i;
+ size_t sz;
channels = indio_dev->channels;
if (channels) {
@@ -1358,28 +1605,58 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
indio_dev->masklength = ml;
}
- if (!buffer)
+ if (!iio_dev_opaque->attached_buffers_cnt)
return 0;
- return __iio_buffer_alloc_sysfs_and_mask(buffer, indio_dev);
-}
+ for (i = 0; i < iio_dev_opaque->attached_buffers_cnt; i++) {
+ buffer = iio_dev_opaque->attached_buffers[i];
+ ret = __iio_buffer_alloc_sysfs_and_mask(buffer, indio_dev, i);
+ if (ret) {
+ unwind_idx = i;
+ goto error_unwind_sysfs_and_mask;
+ }
+ }
+ unwind_idx = iio_dev_opaque->attached_buffers_cnt - 1;
-static void __iio_buffer_free_sysfs_and_mask(struct iio_buffer *buffer)
-{
- bitmap_free(buffer->scan_mask);
- kfree(buffer->buffer_group.attrs);
- kfree(buffer->scan_el_group.attrs);
- iio_free_chan_devattr_list(&buffer->scan_el_dev_attr_list);
+ sz = sizeof(*(iio_dev_opaque->buffer_ioctl_handler));
+ iio_dev_opaque->buffer_ioctl_handler = kzalloc(sz, GFP_KERNEL);
+ if (!iio_dev_opaque->buffer_ioctl_handler) {
+ ret = -ENOMEM;
+ goto error_unwind_sysfs_and_mask;
+ }
+
+ iio_dev_opaque->buffer_ioctl_handler->ioctl = iio_device_buffer_ioctl;
+ iio_device_ioctl_handler_register(indio_dev,
+ iio_dev_opaque->buffer_ioctl_handler);
+
+ return 0;
+
+error_unwind_sysfs_and_mask:
+ for (; unwind_idx >= 0; unwind_idx--) {
+ buffer = iio_dev_opaque->attached_buffers[unwind_idx];
+ __iio_buffer_free_sysfs_and_mask(buffer);
+ }
+ return ret;
}
-void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev)
+void iio_buffers_free_sysfs_and_mask(struct iio_dev *indio_dev)
{
- struct iio_buffer *buffer = indio_dev->buffer;
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+ struct iio_buffer *buffer;
+ int i;
- if (!buffer)
+ if (!iio_dev_opaque->attached_buffers_cnt)
return;
- __iio_buffer_free_sysfs_and_mask(buffer);
+ iio_device_ioctl_handler_unregister(iio_dev_opaque->buffer_ioctl_handler);
+ kfree(iio_dev_opaque->buffer_ioctl_handler);
+
+ iio_buffer_unregister_legacy_sysfs_groups(indio_dev);
+
+ for (i = iio_dev_opaque->attached_buffers_cnt - 1; i >= 0; i--) {
+ buffer = iio_dev_opaque->attached_buffers[i];
+ __iio_buffer_free_sysfs_and_mask(buffer);
+ }
}
/**
@@ -1497,13 +1774,37 @@ EXPORT_SYMBOL_GPL(iio_buffer_put);
* @indio_dev: The device the buffer should be attached to
* @buffer: The buffer to attach to the device
*
+ * Return 0 if successful, negative if error.
+ *
* This function attaches a buffer to a IIO device. The buffer stays attached to
- * the device until the device is freed. The function should only be called at
- * most once per device.
+ * the device until the device is freed. For legacy reasons, the first attached
+ * buffer will also be assigned to 'indio_dev->buffer'.
+ * The array allocated here, will be free'd via the iio_device_detach_buffers()
+ * call which is handled by the iio_device_free().
*/
-void iio_device_attach_buffer(struct iio_dev *indio_dev,
- struct iio_buffer *buffer)
+int iio_device_attach_buffer(struct iio_dev *indio_dev,
+ struct iio_buffer *buffer)
{
- indio_dev->buffer = iio_buffer_get(buffer);
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+ struct iio_buffer **new, **old = iio_dev_opaque->attached_buffers;
+ unsigned int cnt = iio_dev_opaque->attached_buffers_cnt;
+
+ cnt++;
+
+ new = krealloc(old, sizeof(*new) * cnt, GFP_KERNEL);
+ if (!new)
+ return -ENOMEM;
+ iio_dev_opaque->attached_buffers = new;
+
+ buffer = iio_buffer_get(buffer);
+
+ /* first buffer is legacy; attach it to the IIO device directly */
+ if (!indio_dev->buffer)
+ indio_dev->buffer = buffer;
+
+ iio_dev_opaque->attached_buffers[cnt - 1] = buffer;
+ iio_dev_opaque->attached_buffers_cnt = cnt;
+
+ return 0;
}
EXPORT_SYMBOL_GPL(iio_device_attach_buffer);
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 7db761afa578..d92c58a94fe4 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -157,6 +157,7 @@ static const char * const iio_chan_info_postfix[] = {
[IIO_CHAN_INFO_PHASE] = "phase",
[IIO_CHAN_INFO_HARDWAREGAIN] = "hardwaregain",
[IIO_CHAN_INFO_HYSTERESIS] = "hysteresis",
+ [IIO_CHAN_INFO_HYSTERESIS_RELATIVE] = "hysteresis_relative",
[IIO_CHAN_INFO_INT_TIME] = "integration_time",
[IIO_CHAN_INFO_ENABLE] = "en",
[IIO_CHAN_INFO_CALIBHEIGHT] = "calibheight",
@@ -233,7 +234,7 @@ ssize_t iio_read_const_attr(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return sprintf(buf, "%s\n", to_iio_const_attr(attr)->string);
+ return sysfs_emit(buf, "%s\n", to_iio_const_attr(attr)->string);
}
EXPORT_SYMBOL(iio_read_const_attr);
@@ -503,7 +504,7 @@ ssize_t iio_enum_available_read(struct iio_dev *indio_dev,
for (i = 0; i < e->num_items; ++i) {
if (!e->items[i])
continue;
- len += scnprintf(buf + len, PAGE_SIZE - len, "%s ", e->items[i]);
+ len += sysfs_emit_at(buf, len, "%s ", e->items[i]);
}
/* replace last space with a newline */
@@ -528,7 +529,7 @@ ssize_t iio_enum_read(struct iio_dev *indio_dev,
else if (i >= e->num_items || !e->items[i])
return -EINVAL;
- return snprintf(buf, PAGE_SIZE, "%s\n", e->items[i]);
+ return sysfs_emit(buf, "%s\n", e->items[i]);
}
EXPORT_SYMBOL_GPL(iio_enum_read);
@@ -579,10 +580,10 @@ ssize_t iio_show_mount_matrix(struct iio_dev *indio_dev, uintptr_t priv,
if (!mtx)
mtx = &iio_mount_idmatrix;
- return snprintf(buf, PAGE_SIZE, "%s, %s, %s; %s, %s, %s; %s, %s, %s\n",
- mtx->rotation[0], mtx->rotation[1], mtx->rotation[2],
- mtx->rotation[3], mtx->rotation[4], mtx->rotation[5],
- mtx->rotation[6], mtx->rotation[7], mtx->rotation[8]);
+ return sysfs_emit(buf, "%s, %s, %s; %s, %s, %s; %s, %s, %s\n",
+ mtx->rotation[0], mtx->rotation[1], mtx->rotation[2],
+ mtx->rotation[3], mtx->rotation[4], mtx->rotation[5],
+ mtx->rotation[6], mtx->rotation[7], mtx->rotation[8]);
}
EXPORT_SYMBOL_GPL(iio_show_mount_matrix);
@@ -622,59 +623,62 @@ int iio_read_mount_matrix(struct device *dev, const char *propname,
}
EXPORT_SYMBOL(iio_read_mount_matrix);
-static ssize_t __iio_format_value(char *buf, size_t len, unsigned int type,
+static ssize_t __iio_format_value(char *buf, size_t offset, unsigned int type,
int size, const int *vals)
{
- unsigned long long tmp;
int tmp0, tmp1;
s64 tmp2;
bool scale_db = false;
switch (type) {
case IIO_VAL_INT:
- return scnprintf(buf, len, "%d", vals[0]);
+ return sysfs_emit_at(buf, offset, "%d", vals[0]);
case IIO_VAL_INT_PLUS_MICRO_DB:
scale_db = true;
fallthrough;
case IIO_VAL_INT_PLUS_MICRO:
if (vals[1] < 0)
- return scnprintf(buf, len, "-%d.%06u%s", abs(vals[0]),
- -vals[1], scale_db ? " dB" : "");
+ return sysfs_emit_at(buf, offset, "-%d.%06u%s",
+ abs(vals[0]), -vals[1],
+ scale_db ? " dB" : "");
else
- return scnprintf(buf, len, "%d.%06u%s", vals[0], vals[1],
- scale_db ? " dB" : "");
+ return sysfs_emit_at(buf, offset, "%d.%06u%s", vals[0],
+ vals[1], scale_db ? " dB" : "");
case IIO_VAL_INT_PLUS_NANO:
if (vals[1] < 0)
- return scnprintf(buf, len, "-%d.%09u", abs(vals[0]),
- -vals[1]);
+ return sysfs_emit_at(buf, offset, "-%d.%09u",
+ abs(vals[0]), -vals[1]);
else
- return scnprintf(buf, len, "%d.%09u", vals[0], vals[1]);
+ return sysfs_emit_at(buf, offset, "%d.%09u", vals[0],
+ vals[1]);
case IIO_VAL_FRACTIONAL:
tmp2 = div_s64((s64)vals[0] * 1000000000LL, vals[1]);
tmp1 = vals[1];
tmp0 = (int)div_s64_rem(tmp2, 1000000000, &tmp1);
if ((tmp2 < 0) && (tmp0 == 0))
- return snprintf(buf, len, "-0.%09u", abs(tmp1));
+ return sysfs_emit_at(buf, offset, "-0.%09u", abs(tmp1));
else
- return snprintf(buf, len, "%d.%09u", tmp0, abs(tmp1));
+ return sysfs_emit_at(buf, offset, "%d.%09u", tmp0,
+ abs(tmp1));
case IIO_VAL_FRACTIONAL_LOG2:
- tmp = shift_right((s64)vals[0] * 1000000000LL, vals[1]);
- tmp0 = (int)div_s64_rem(tmp, 1000000000LL, &tmp1);
- return scnprintf(buf, len, "%d.%09u", tmp0, abs(tmp1));
+ tmp2 = shift_right((s64)vals[0] * 1000000000LL, vals[1]);
+ tmp0 = (int)div_s64_rem(tmp2, 1000000000LL, &tmp1);
+ if (tmp0 == 0 && tmp2 < 0)
+ return sysfs_emit_at(buf, offset, "-0.%09u", abs(tmp1));
+ else
+ return sysfs_emit_at(buf, offset, "%d.%09u", tmp0,
+ abs(tmp1));
case IIO_VAL_INT_MULTIPLE:
{
int i;
int l = 0;
- for (i = 0; i < size; ++i) {
- l += scnprintf(&buf[l], len - l, "%d ", vals[i]);
- if (l >= len)
- break;
- }
+ for (i = 0; i < size; ++i)
+ l += sysfs_emit_at(buf, offset + l, "%d ", vals[i]);
return l;
}
case IIO_VAL_CHAR:
- return scnprintf(buf, len, "%c", (char)vals[0]);
+ return sysfs_emit_at(buf, offset, "%c", (char)vals[0]);
default:
return 0;
}
@@ -698,11 +702,11 @@ ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals)
{
ssize_t len;
- len = __iio_format_value(buf, PAGE_SIZE, type, size, vals);
+ len = __iio_format_value(buf, 0, type, size, vals);
if (len >= PAGE_SIZE - 1)
return -EFBIG;
- return len + sprintf(buf + len, "\n");
+ return len + sysfs_emit_at(buf, len, "\n");
}
EXPORT_SYMBOL_GPL(iio_format_value);
@@ -760,22 +764,21 @@ static ssize_t iio_format_list(char *buf, const int *vals, int type, int length,
break;
}
- len = scnprintf(buf, PAGE_SIZE, prefix);
+ len = sysfs_emit(buf, prefix);
for (i = 0; i <= length - stride; i += stride) {
if (i != 0) {
- len += scnprintf(buf + len, PAGE_SIZE - len, " ");
+ len += sysfs_emit_at(buf, len, " ");
if (len >= PAGE_SIZE)
return -EFBIG;
}
- len += __iio_format_value(buf + len, PAGE_SIZE - len, type,
- stride, &vals[i]);
+ len += __iio_format_value(buf, len, type, stride, &vals[i]);
if (len >= PAGE_SIZE)
return -EFBIG;
}
- len += scnprintf(buf + len, PAGE_SIZE - len, "%s\n", suffix);
+ len += sysfs_emit_at(buf, len, "%s\n", suffix);
return len;
}
@@ -1114,6 +1117,7 @@ int __iio_add_chan_devattr(const char *postfix,
u64 mask,
enum iio_shared_by shared_by,
struct device *dev,
+ struct iio_buffer *buffer,
struct list_head *attr_list)
{
int ret;
@@ -1129,6 +1133,7 @@ int __iio_add_chan_devattr(const char *postfix,
goto error_iio_dev_attr_free;
iio_attr->c = chan;
iio_attr->address = mask;
+ iio_attr->buffer = buffer;
list_for_each_entry(t, attr_list, l)
if (strcmp(t->dev_attr.attr.name,
iio_attr->dev_attr.attr.name) == 0) {
@@ -1165,6 +1170,7 @@ static int iio_device_add_channel_label(struct iio_dev *indio_dev,
0,
IIO_SEPARATE,
&indio_dev->dev,
+ NULL,
&iio_dev_opaque->channel_attr_list);
if (ret < 0)
return ret;
@@ -1190,6 +1196,7 @@ static int iio_device_add_info_mask_type(struct iio_dev *indio_dev,
i,
shared_by,
&indio_dev->dev,
+ NULL,
&iio_dev_opaque->channel_attr_list);
if ((ret == -EBUSY) && (shared_by != IIO_SEPARATE))
continue;
@@ -1226,6 +1233,7 @@ static int iio_device_add_info_mask_type_avail(struct iio_dev *indio_dev,
i,
shared_by,
&indio_dev->dev,
+ NULL,
&iio_dev_opaque->channel_attr_list);
kfree(avail_postfix);
if ((ret == -EBUSY) && (shared_by != IIO_SEPARATE))
@@ -1322,6 +1330,7 @@ static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev,
i,
ext_info->shared,
&indio_dev->dev,
+ NULL,
&iio_dev_opaque->channel_attr_list);
i++;
if (ret == -EBUSY && ext_info->shared)
@@ -1349,7 +1358,7 @@ void iio_free_chan_devattr_list(struct list_head *attr_list)
struct iio_dev_attr *p, *n;
list_for_each_entry_safe(p, n, attr_list, l) {
- kfree(p->dev_attr.attr.name);
+ kfree_const(p->dev_attr.attr.name);
list_del(&p->l);
kfree(p);
}
@@ -1360,7 +1369,7 @@ static ssize_t iio_show_dev_name(struct device *dev,
char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- return snprintf(buf, PAGE_SIZE, "%s\n", indio_dev->name);
+ return sysfs_emit(buf, "%s\n", indio_dev->name);
}
static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
@@ -1370,7 +1379,7 @@ static ssize_t iio_show_dev_label(struct device *dev,
char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- return snprintf(buf, PAGE_SIZE, "%s\n", indio_dev->label);
+ return sysfs_emit(buf, "%s\n", indio_dev->label);
}
static DEVICE_ATTR(label, S_IRUGO, iio_show_dev_label, NULL);
@@ -1452,6 +1461,25 @@ static ssize_t iio_store_timestamp_clock(struct device *dev,
return len;
}
+int iio_device_register_sysfs_group(struct iio_dev *indio_dev,
+ const struct attribute_group *group)
+{
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+ const struct attribute_group **new, **old = iio_dev_opaque->groups;
+ unsigned int cnt = iio_dev_opaque->groupcounter;
+
+ new = krealloc(old, sizeof(*new) * (cnt + 2), GFP_KERNEL);
+ if (!new)
+ return -ENOMEM;
+
+ new[iio_dev_opaque->groupcounter++] = group;
+ new[iio_dev_opaque->groupcounter] = NULL;
+
+ iio_dev_opaque->groups = new;
+
+ return 0;
+}
+
static DEVICE_ATTR(current_timestamp_clock, S_IRUGO | S_IWUSR,
iio_show_timestamp_clock, iio_store_timestamp_clock);
@@ -1525,8 +1553,10 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev)
if (clk)
iio_dev_opaque->chan_attr_group.attrs[attrn++] = clk;
- indio_dev->groups[indio_dev->groupcounter++] =
- &iio_dev_opaque->chan_attr_group;
+ ret = iio_device_register_sysfs_group(indio_dev,
+ &iio_dev_opaque->chan_attr_group);
+ if (ret)
+ goto error_clear_attrs;
return 0;
@@ -1543,6 +1573,7 @@ static void iio_device_unregister_sysfs(struct iio_dev *indio_dev)
iio_free_chan_devattr_list(&iio_dev_opaque->channel_attr_list);
kfree(iio_dev_opaque->chan_attr_group.attrs);
iio_dev_opaque->chan_attr_group.attrs = NULL;
+ kfree(iio_dev_opaque->groups);
}
static void iio_dev_release(struct device *device)
@@ -1555,7 +1586,7 @@ static void iio_dev_release(struct device *device)
iio_device_unregister_eventset(indio_dev);
iio_device_unregister_sysfs(indio_dev);
- iio_buffer_put(indio_dev->buffer);
+ iio_device_detach_buffers(indio_dev);
ida_simple_remove(&iio_ida, indio_dev->id);
kfree(iio_dev_opaque);
@@ -1574,7 +1605,7 @@ struct device_type iio_device_type = {
struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv)
{
struct iio_dev_opaque *iio_dev_opaque;
- struct iio_dev *dev;
+ struct iio_dev *indio_dev;
size_t alloc_size;
alloc_size = sizeof(struct iio_dev_opaque);
@@ -1587,32 +1618,31 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv)
if (!iio_dev_opaque)
return NULL;
- dev = &iio_dev_opaque->indio_dev;
- dev->priv = (char *)iio_dev_opaque +
+ indio_dev = &iio_dev_opaque->indio_dev;
+ indio_dev->priv = (char *)iio_dev_opaque +
ALIGN(sizeof(struct iio_dev_opaque), IIO_ALIGN);
- dev->dev.parent = parent;
- dev->dev.groups = dev->groups;
- dev->dev.type = &iio_device_type;
- dev->dev.bus = &iio_bus_type;
- device_initialize(&dev->dev);
- dev_set_drvdata(&dev->dev, (void *)dev);
- mutex_init(&dev->mlock);
- mutex_init(&dev->info_exist_lock);
+ indio_dev->dev.parent = parent;
+ indio_dev->dev.type = &iio_device_type;
+ indio_dev->dev.bus = &iio_bus_type;
+ device_initialize(&indio_dev->dev);
+ iio_device_set_drvdata(indio_dev, (void *)indio_dev);
+ mutex_init(&indio_dev->mlock);
+ mutex_init(&indio_dev->info_exist_lock);
INIT_LIST_HEAD(&iio_dev_opaque->channel_attr_list);
- dev->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL);
- if (dev->id < 0) {
+ indio_dev->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL);
+ if (indio_dev->id < 0) {
/* cannot use a dev_err as the name isn't available */
pr_err("failed to get device id\n");
kfree(iio_dev_opaque);
return NULL;
}
- dev_set_name(&dev->dev, "iio:device%d", dev->id);
+ dev_set_name(&indio_dev->dev, "iio:device%d", indio_dev->id);
INIT_LIST_HEAD(&iio_dev_opaque->buffer_list);
INIT_LIST_HEAD(&iio_dev_opaque->ioctl_handlers);
- return dev;
+ return indio_dev;
}
EXPORT_SYMBOL(iio_device_alloc);
@@ -1676,13 +1706,24 @@ static int iio_chrdev_open(struct inode *inode, struct file *filp)
{
struct iio_dev *indio_dev = container_of(inode->i_cdev,
struct iio_dev, chrdev);
+ struct iio_dev_buffer_pair *ib;
if (test_and_set_bit(IIO_BUSY_BIT_POS, &indio_dev->flags))
return -EBUSY;
iio_device_get(indio_dev);
- filp->private_data = indio_dev;
+ ib = kmalloc(sizeof(*ib), GFP_KERNEL);
+ if (!ib) {
+ iio_device_put(indio_dev);
+ clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);
+ return -ENOMEM;
+ }
+
+ ib->indio_dev = indio_dev;
+ ib->buffer = indio_dev->buffer;
+
+ filp->private_data = ib;
return 0;
}
@@ -1696,8 +1737,10 @@ static int iio_chrdev_open(struct inode *inode, struct file *filp)
*/
static int iio_chrdev_release(struct inode *inode, struct file *filp)
{
+ struct iio_dev_buffer_pair *ib = filp->private_data;
struct iio_dev *indio_dev = container_of(inode->i_cdev,
struct iio_dev, chrdev);
+ kfree(ib);
clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);
iio_device_put(indio_dev);
@@ -1719,7 +1762,8 @@ void iio_device_ioctl_handler_unregister(struct iio_ioctl_handler *h)
static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
- struct iio_dev *indio_dev = filp->private_data;
+ struct iio_dev_buffer_pair *ib = filp->private_data;
+ struct iio_dev *indio_dev = ib->indio_dev;
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
struct iio_ioctl_handler *h;
int ret = -ENODEV;
@@ -1761,6 +1805,15 @@ static const struct file_operations iio_buffer_fileops = {
.release = iio_chrdev_release,
};
+static const struct file_operations iio_event_fileops = {
+ .owner = THIS_MODULE,
+ .llseek = noop_llseek,
+ .unlocked_ioctl = iio_ioctl,
+ .compat_ioctl = compat_ptr_ioctl,
+ .open = iio_chrdev_open,
+ .release = iio_chrdev_release,
+};
+
static int iio_check_unique_scan_index(struct iio_dev *indio_dev)
{
int i, j;
@@ -1788,6 +1841,8 @@ static const struct iio_buffer_setup_ops noop_ring_setup_ops;
int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
{
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+ const char *label;
int ret;
if (!indio_dev->info)
@@ -1798,19 +1853,17 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
if (!indio_dev->dev.of_node && indio_dev->dev.parent)
indio_dev->dev.of_node = indio_dev->dev.parent->of_node;
- indio_dev->label = of_get_property(indio_dev->dev.of_node, "label",
- NULL);
+ label = of_get_property(indio_dev->dev.of_node, "label", NULL);
+ if (label)
+ indio_dev->label = label;
ret = iio_check_unique_scan_index(indio_dev);
if (ret < 0)
return ret;
- /* configure elements for the chrdev */
- indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id);
-
iio_device_register_debugfs(indio_dev);
- ret = iio_buffer_alloc_sysfs_and_mask(indio_dev);
+ ret = iio_buffers_alloc_sysfs_and_mask(indio_dev);
if (ret) {
dev_err(indio_dev->dev.parent,
"Failed to create buffer sysfs interfaces\n");
@@ -1836,9 +1889,18 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
indio_dev->setup_ops == NULL)
indio_dev->setup_ops = &noop_ring_setup_ops;
- cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
+ if (iio_dev_opaque->attached_buffers_cnt)
+ cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
+ else if (iio_dev_opaque->event_interface)
+ cdev_init(&indio_dev->chrdev, &iio_event_fileops);
+
+ if (iio_dev_opaque->attached_buffers_cnt || iio_dev_opaque->event_interface) {
+ indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id);
+ indio_dev->chrdev.owner = this_mod;
+ }
- indio_dev->chrdev.owner = this_mod;
+ /* assign device groups now; they should be all registered now */
+ indio_dev->dev.groups = iio_dev_opaque->groups;
ret = cdev_device_add(&indio_dev->chrdev, &indio_dev->dev);
if (ret < 0)
@@ -1851,7 +1913,7 @@ error_unreg_eventset:
error_free_sysfs:
iio_device_unregister_sysfs(indio_dev);
error_buffer_free_sysfs:
- iio_buffer_free_sysfs_and_mask(indio_dev);
+ iio_buffers_free_sysfs_and_mask(indio_dev);
error_unreg_debugfs:
iio_device_unregister_debugfs(indio_dev);
return ret;
@@ -1885,7 +1947,7 @@ void iio_device_unregister(struct iio_dev *indio_dev)
mutex_unlock(&indio_dev->info_exist_lock);
- iio_buffer_free_sysfs_and_mask(indio_dev);
+ iio_buffers_free_sysfs_and_mask(indio_dev);
}
EXPORT_SYMBOL(iio_device_unregister);
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c
index 7e532117ac55..d0732eac0f0a 100644
--- a/drivers/iio/industrialio-event.c
+++ b/drivers/iio/industrialio-event.c
@@ -245,6 +245,7 @@ static const char * const iio_ev_info_text[] = {
[IIO_EV_INFO_PERIOD] = "period",
[IIO_EV_INFO_HIGH_PASS_FILTER_3DB] = "high_pass_filter_3db",
[IIO_EV_INFO_LOW_PASS_FILTER_3DB] = "low_pass_filter_3db",
+ [IIO_EV_INFO_TIMEOUT] = "timeout",
};
static enum iio_event_direction iio_ev_attr_dir(struct iio_dev_attr *attr)
@@ -297,7 +298,7 @@ static ssize_t iio_ev_state_show(struct device *dev,
if (val < 0)
return val;
else
- return sprintf(buf, "%d\n", val);
+ return sysfs_emit(buf, "%d\n", val);
}
static ssize_t iio_ev_value_show(struct device *dev,
@@ -385,6 +386,7 @@ static int iio_device_add_event(struct iio_dev *indio_dev,
ret = __iio_add_chan_devattr(postfix, chan, show, store,
(i << 16) | spec_index, shared_by, &indio_dev->dev,
+ NULL,
&iio_dev_opaque->event_interface->dev_attr_list);
kfree(postfix);
@@ -544,7 +546,10 @@ int iio_device_register_eventset(struct iio_dev *indio_dev)
/* Add all elements from the list. */
list_for_each_entry(p, &ev_int->dev_attr_list, l)
ev_int->group.attrs[attrn++] = &p->dev_attr.attr;
- indio_dev->groups[indio_dev->groupcounter++] = &ev_int->group;
+
+ ret = iio_device_register_sysfs_group(indio_dev, &ev_int->group);
+ if (ret)
+ goto error_free_setup_event_lines;
ev_int->ioctl_handler.ioctl = iio_event_ioctl;
iio_device_ioctl_handler_register(&iio_dev_opaque->indio_dev,
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index ea3c9859b258..b2c94abbb487 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -50,7 +50,7 @@ static ssize_t iio_trigger_read_name(struct device *dev,
char *buf)
{
struct iio_trigger *trig = to_iio_trigger(dev);
- return sprintf(buf, "%s\n", trig->name);
+ return sysfs_emit(buf, "%s\n", trig->name);
}
static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
@@ -75,8 +75,7 @@ int __iio_trigger_register(struct iio_trigger *trig_info,
return trig_info->id;
/* Set the name used for the sysfs directory etc */
- dev_set_name(&trig_info->dev, "trigger%ld",
- (unsigned long) trig_info->id);
+ dev_set_name(&trig_info->dev, "trigger%d", trig_info->id);
ret = device_add(&trig_info->dev);
if (ret)
@@ -212,6 +211,7 @@ EXPORT_SYMBOL(iio_trigger_notify_done);
static int iio_trigger_get_irq(struct iio_trigger *trig)
{
int ret;
+
mutex_lock(&trig->pool_lock);
ret = bitmap_find_free_region(trig->pool,
CONFIG_IIO_CONSUMERS_PER_TRIGGER,
@@ -240,9 +240,9 @@ static void iio_trigger_put_irq(struct iio_trigger *trig, int irq)
int iio_trigger_attach_poll_func(struct iio_trigger *trig,
struct iio_poll_func *pf)
{
+ bool notinuse =
+ bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
int ret = 0;
- bool notinuse
- = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
/* Prevent the module from being removed whilst attached to a trigger */
__module_get(pf->indio_dev->driver_module);
@@ -291,11 +291,10 @@ out_put_module:
int iio_trigger_detach_poll_func(struct iio_trigger *trig,
struct iio_poll_func *pf)
{
+ bool no_other_users =
+ bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) == 1;
int ret = 0;
- bool no_other_users
- = (bitmap_weight(trig->pool,
- CONFIG_IIO_CONSUMERS_PER_TRIGGER)
- == 1);
+
if (trig->ops && trig->ops->set_trigger_state && no_other_users) {
ret = trig->ops->set_trigger_state(trig, false);
if (ret)
@@ -313,6 +312,7 @@ int iio_trigger_detach_poll_func(struct iio_trigger *trig,
irqreturn_t iio_pollfunc_store_time(int irq, void *p)
{
struct iio_poll_func *pf = p;
+
pf->timestamp = iio_get_time_ns(pf->indio_dev);
return IRQ_WAKE_THREAD;
}
@@ -375,7 +375,7 @@ static ssize_t iio_trigger_read_current(struct device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
if (indio_dev->trig)
- return sprintf(buf, "%s\n", indio_dev->trig->name);
+ return sysfs_emit(buf, "%s\n", indio_dev->trig->name);
return 0;
}
@@ -499,23 +499,23 @@ static const struct device_type iio_trig_type = {
static void iio_trig_subirqmask(struct irq_data *d)
{
struct irq_chip *chip = irq_data_get_irq_chip(d);
- struct iio_trigger *trig
- = container_of(chip,
- struct iio_trigger, subirq_chip);
+ struct iio_trigger *trig = container_of(chip, struct iio_trigger, subirq_chip);
+
trig->subirqs[d->irq - trig->subirq_base].enabled = false;
}
static void iio_trig_subirqunmask(struct irq_data *d)
{
struct irq_chip *chip = irq_data_get_irq_chip(d);
- struct iio_trigger *trig
- = container_of(chip,
- struct iio_trigger, subirq_chip);
+ struct iio_trigger *trig = container_of(chip, struct iio_trigger, subirq_chip);
+
trig->subirqs[d->irq - trig->subirq_base].enabled = true;
}
-static __printf(1, 0)
-struct iio_trigger *viio_trigger_alloc(const char *fmt, va_list vargs)
+static __printf(2, 0)
+struct iio_trigger *viio_trigger_alloc(struct device *parent,
+ const char *fmt,
+ va_list vargs)
{
struct iio_trigger *trig;
int i;
@@ -524,6 +524,7 @@ struct iio_trigger *viio_trigger_alloc(const char *fmt, va_list vargs)
if (!trig)
return NULL;
+ trig->dev.parent = parent;
trig->dev.type = &iio_trig_type;
trig->dev.bus = &iio_bus_type;
device_initialize(&trig->dev);
@@ -559,13 +560,23 @@ free_trig:
return NULL;
}
-struct iio_trigger *iio_trigger_alloc(const char *fmt, ...)
+/**
+ * iio_trigger_alloc - Allocate a trigger
+ * @parent: Device to allocate iio_trigger for
+ * @fmt: trigger name format. If it includes format
+ * specifiers, the additional arguments following
+ * format are formatted and inserted in the resulting
+ * string replacing their respective specifiers.
+ * RETURNS:
+ * Pointer to allocated iio_trigger on success, NULL on failure.
+ */
+struct iio_trigger *iio_trigger_alloc(struct device *parent, const char *fmt, ...)
{
struct iio_trigger *trig;
va_list vargs;
va_start(vargs, fmt);
- trig = viio_trigger_alloc(fmt, vargs);
+ trig = viio_trigger_alloc(parent, fmt, vargs);
va_end(vargs);
return trig;
@@ -586,20 +597,19 @@ static void devm_iio_trigger_release(struct device *dev, void *res)
/**
* devm_iio_trigger_alloc - Resource-managed iio_trigger_alloc()
- * @dev: Device to allocate iio_trigger for
+ * Managed iio_trigger_alloc. iio_trigger allocated with this function is
+ * automatically freed on driver detach.
+ * @parent: Device to allocate iio_trigger for
* @fmt: trigger name format. If it includes format
* specifiers, the additional arguments following
* format are formatted and inserted in the resulting
* string replacing their respective specifiers.
*
- * Managed iio_trigger_alloc. iio_trigger allocated with this function is
- * automatically freed on driver detach.
*
* RETURNS:
* Pointer to allocated iio_trigger on success, NULL on failure.
*/
-struct iio_trigger *devm_iio_trigger_alloc(struct device *dev,
- const char *fmt, ...)
+struct iio_trigger *devm_iio_trigger_alloc(struct device *parent, const char *fmt, ...)
{
struct iio_trigger **ptr, *trig;
va_list vargs;
@@ -611,11 +621,11 @@ struct iio_trigger *devm_iio_trigger_alloc(struct device *dev,
/* use raw alloc_dr for kmalloc caller tracing */
va_start(vargs, fmt);
- trig = viio_trigger_alloc(fmt, vargs);
+ trig = viio_trigger_alloc(parent, fmt, vargs);
va_end(vargs);
if (trig) {
*ptr = trig;
- devres_add(dev, ptr);
+ devres_add(parent, ptr);
} else {
devres_free(ptr);
}
@@ -684,7 +694,7 @@ EXPORT_SYMBOL(iio_trigger_using_own);
* device, -EINVAL otherwise.
*/
int iio_trigger_validate_own_device(struct iio_trigger *trig,
- struct iio_dev *indio_dev)
+ struct iio_dev *indio_dev)
{
if (indio_dev->dev.parent != trig->dev.parent)
return -EINVAL;
@@ -692,10 +702,10 @@ int iio_trigger_validate_own_device(struct iio_trigger *trig,
}
EXPORT_SYMBOL(iio_trigger_validate_own_device);
-void iio_device_register_trigger_consumer(struct iio_dev *indio_dev)
+int iio_device_register_trigger_consumer(struct iio_dev *indio_dev)
{
- indio_dev->groups[indio_dev->groupcounter++] =
- &iio_trigger_consumer_attr_group;
+ return iio_device_register_sysfs_group(indio_dev,
+ &iio_trigger_consumer_attr_group);
}
void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev)
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index db77a2d4a56b..9c22697b7e83 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -688,7 +688,8 @@ int iio_read_channel_offset(struct iio_channel *chan, int *val, int *val2)
}
EXPORT_SYMBOL_GPL(iio_read_channel_offset);
-int iio_read_channel_processed(struct iio_channel *chan, int *val)
+int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,
+ unsigned int scale)
{
int ret;
@@ -701,11 +702,15 @@ int iio_read_channel_processed(struct iio_channel *chan, int *val)
if (iio_channel_has_info(chan->channel, IIO_CHAN_INFO_PROCESSED)) {
ret = iio_channel_read(chan, val, NULL,
IIO_CHAN_INFO_PROCESSED);
+ if (ret < 0)
+ goto err_unlock;
+ *val *= scale;
} else {
ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_RAW);
if (ret < 0)
goto err_unlock;
- ret = iio_convert_raw_to_processed_unlocked(chan, *val, val, 1);
+ ret = iio_convert_raw_to_processed_unlocked(chan, *val, val,
+ scale);
}
err_unlock:
@@ -713,6 +718,13 @@ err_unlock:
return ret;
}
+EXPORT_SYMBOL_GPL(iio_read_channel_processed_scale);
+
+int iio_read_channel_processed(struct iio_channel *chan, int *val)
+{
+ /* This is just a special case with scale factor 1 */
+ return iio_read_channel_processed_scale(chan, val, 1);
+}
EXPORT_SYMBOL_GPL(iio_read_channel_processed);
int iio_read_channel_scale(struct iio_channel *chan, int *val, int *val2)
diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c
index 2be7180e2cbf..30393f08e082 100644
--- a/drivers/iio/light/acpi-als.c
+++ b/drivers/iio/light/acpi-als.c
@@ -16,11 +16,14 @@
#include <linux/module.h>
#include <linux/acpi.h>
#include <linux/err.h>
+#include <linux/irq.h>
#include <linux/mutex.h>
#include <linux/iio/iio.h>
#include <linux/iio/buffer.h>
-#include <linux/iio/kfifo_buf.h>
+#include <linux/iio/trigger.h>
+#include <linux/iio/triggered_buffer.h>
+#include <linux/iio/trigger_consumer.h>
#define ACPI_ALS_CLASS "als"
#define ACPI_ALS_DEVICE_NAME "acpi-als"
@@ -45,24 +48,23 @@ static const struct iio_chan_spec acpi_als_channels[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_PROCESSED),
},
+ IIO_CHAN_SOFT_TIMESTAMP(1),
};
/*
* The event buffer contains timestamp and all the data from
* the ACPI0008 block. There are multiple, but so far we only
- * support _ALI (illuminance). Once someone adds new channels
- * to acpi_als_channels[], the evt_buffer below will grow
- * automatically.
+ * support _ALI (illuminance): One channel, padding and timestamp.
*/
-#define ACPI_ALS_EVT_NR_SOURCES ARRAY_SIZE(acpi_als_channels)
#define ACPI_ALS_EVT_BUFFER_SIZE \
- (sizeof(s64) + (ACPI_ALS_EVT_NR_SOURCES * sizeof(s32)))
+ (sizeof(s32) + sizeof(s32) + sizeof(s64))
struct acpi_als {
struct acpi_device *device;
struct mutex lock;
+ struct iio_trigger *trig;
- s32 evt_buffer[ACPI_ALS_EVT_BUFFER_SIZE];
+ s32 evt_buffer[ACPI_ALS_EVT_BUFFER_SIZE / sizeof(s32)] __aligned(8);
};
/*
@@ -104,33 +106,19 @@ static void acpi_als_notify(struct acpi_device *device, u32 event)
{
struct iio_dev *indio_dev = acpi_driver_data(device);
struct acpi_als *als = iio_priv(indio_dev);
- s32 *buffer = als->evt_buffer;
- s64 time_ns = iio_get_time_ns(indio_dev);
- s32 val;
- int ret;
-
- mutex_lock(&als->lock);
- memset(buffer, 0, ACPI_ALS_EVT_BUFFER_SIZE);
-
- switch (event) {
- case ACPI_ALS_NOTIFY_ILLUMINANCE:
- ret = acpi_als_read_value(als, ACPI_ALS_ILLUMINANCE, &val);
- if (ret < 0)
- goto out;
- *buffer++ = val;
- break;
- default:
- /* Unhandled event */
- dev_dbg(&device->dev, "Unhandled ACPI ALS event (%08x)!\n",
- event);
- goto out;
+ if (iio_buffer_enabled(indio_dev) && iio_trigger_using_own(indio_dev)) {
+ switch (event) {
+ case ACPI_ALS_NOTIFY_ILLUMINANCE:
+ iio_trigger_poll_chained(als->trig);
+ break;
+ default:
+ /* Unhandled event */
+ dev_dbg(&device->dev,
+ "Unhandled ACPI ALS event (%08x)!\n",
+ event);
+ }
}
-
- iio_push_to_buffers_with_timestamp(indio_dev, als->evt_buffer, time_ns);
-
-out:
- mutex_unlock(&als->lock);
}
static int acpi_als_read_raw(struct iio_dev *indio_dev,
@@ -161,13 +149,49 @@ static const struct iio_info acpi_als_info = {
.read_raw = acpi_als_read_raw,
};
+static irqreturn_t acpi_als_trigger_handler(int irq, void *p)
+{
+ struct iio_poll_func *pf = p;
+ struct iio_dev *indio_dev = pf->indio_dev;
+ struct acpi_als *als = iio_priv(indio_dev);
+ s32 *buffer = als->evt_buffer;
+ s32 val;
+ int ret;
+
+ mutex_lock(&als->lock);
+
+ ret = acpi_als_read_value(als, ACPI_ALS_ILLUMINANCE, &val);
+ if (ret < 0)
+ goto out;
+ *buffer = val;
+
+ /*
+ * When coming from own trigger via polls, set polling function
+ * timestamp here. Given ACPI notifier is already in a thread and call
+ * function directly, there is no need to set the timestamp in the
+ * notify function.
+ *
+ * If the timestamp was actually 0, the timestamp is set one more time.
+ */
+ if (!pf->timestamp)
+ pf->timestamp = iio_get_time_ns(indio_dev);
+
+ iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp);
+out:
+ mutex_unlock(&als->lock);
+ iio_trigger_notify_done(indio_dev->trig);
+
+ return IRQ_HANDLED;
+}
+
static int acpi_als_add(struct acpi_device *device)
{
- struct acpi_als *als;
+ struct device *dev = &device->dev;
struct iio_dev *indio_dev;
- struct iio_buffer *buffer;
+ struct acpi_als *als;
+ int ret;
- indio_dev = devm_iio_device_alloc(&device->dev, sizeof(*als));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*als));
if (!indio_dev)
return -ENOMEM;
@@ -179,17 +203,30 @@ static int acpi_als_add(struct acpi_device *device)
indio_dev->name = ACPI_ALS_DEVICE_NAME;
indio_dev->info = &acpi_als_info;
- indio_dev->modes = INDIO_BUFFER_SOFTWARE;
indio_dev->channels = acpi_als_channels;
indio_dev->num_channels = ARRAY_SIZE(acpi_als_channels);
- buffer = devm_iio_kfifo_allocate(&device->dev);
- if (!buffer)
+ als->trig = devm_iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name, indio_dev->id);
+ if (!als->trig)
return -ENOMEM;
- iio_device_attach_buffer(indio_dev, buffer);
+ ret = devm_iio_trigger_register(dev, als->trig);
+ if (ret)
+ return ret;
+ /*
+ * Set hardware trigger by default to let events flow when
+ * BIOS support notification.
+ */
+ indio_dev->trig = iio_trigger_get(als->trig);
+
+ ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
+ iio_pollfunc_store_time,
+ acpi_als_trigger_handler,
+ NULL);
+ if (ret)
+ return ret;
- return devm_iio_device_register(&device->dev, indio_dev);
+ return devm_iio_device_register(dev, indio_dev);
}
static const struct acpi_device_id acpi_als_device_ids[] = {
diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c
index df0647856e5d..4141c0fa7bc4 100644
--- a/drivers/iio/light/apds9960.c
+++ b/drivers/iio/light/apds9960.c
@@ -988,7 +988,6 @@ static int apds9960_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct apds9960_data *data;
- struct iio_buffer *buffer;
struct iio_dev *indio_dev;
int ret;
@@ -996,19 +995,18 @@ static int apds9960_probe(struct i2c_client *client,
if (!indio_dev)
return -ENOMEM;
- buffer = devm_iio_kfifo_allocate(&client->dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
-
indio_dev->info = &apds9960_info;
indio_dev->name = APDS9960_DRV_NAME;
indio_dev->channels = apds9960_channels;
indio_dev->num_channels = ARRAY_SIZE(apds9960_channels);
indio_dev->available_scan_masks = apds9960_scan_masks;
- indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE);
- indio_dev->setup_ops = &apds9960_buffer_setup_ops;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+
+ ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ &apds9960_buffer_setup_ops);
+ if (ret)
+ return ret;
data = iio_priv(indio_dev);
i2c_set_clientdata(client, indio_dev);
diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
index 75d6b5fcf2cc..de472f23d1cb 100644
--- a/drivers/iio/light/cros_ec_light_prox.c
+++ b/drivers/iio/light/cros_ec_light_prox.c
@@ -182,8 +182,7 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev)
ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
cros_ec_sensors_capture,
- cros_ec_sensors_push_data,
- true);
+ cros_ec_sensors_push_data);
if (ret)
return ret;
diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c
index 7ba7aa59437c..d048ae257c51 100644
--- a/drivers/iio/light/gp2ap002.c
+++ b/drivers/iio/light/gp2ap002.c
@@ -465,8 +465,7 @@ static int gp2ap002_probe(struct i2c_client *client,
regmap = devm_regmap_init(dev, &gp2ap002_regmap_bus, dev, &config);
if (IS_ERR(regmap)) {
- dev_err(dev, "Failed to register i2c regmap %d\n",
- (int)PTR_ERR(regmap));
+ dev_err(dev, "Failed to register i2c regmap %ld\n", PTR_ERR(regmap));
return PTR_ERR(regmap);
}
gp2ap002->map = regmap;
diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c
index e2850c1a7353..d1d9f2d319e4 100644
--- a/drivers/iio/light/gp2ap020a00f.c
+++ b/drivers/iio/light/gp2ap020a00f.c
@@ -1551,7 +1551,6 @@ static int gp2ap020a00f_probe(struct i2c_client *client,
}
data->trig->ops = &gp2ap020a00f_trigger_ops;
- data->trig->dev.parent = &data->client->dev;
init_irq_work(&data->work, gp2ap020a00f_iio_trigger_work);
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 4093f2353d95..85c8a05b73cb 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -39,6 +39,11 @@ struct als_state {
s64 timestamp;
};
+static const u32 als_sensitivity_addresses[] = {
+ HID_USAGE_SENSOR_DATA_LIGHT,
+ HID_USAGE_SENSOR_LIGHT_ILLUM,
+};
+
/* Channel definitions */
static const struct iio_chan_spec als_channels[] = {
{
@@ -49,7 +54,8 @@ static const struct iio_chan_spec als_channels[] = {
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
- BIT(IIO_CHAN_INFO_HYSTERESIS),
+ BIT(IIO_CHAN_INFO_HYSTERESIS) |
+ BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
.scan_index = CHANNEL_SCAN_INDEX_INTENSITY,
},
{
@@ -58,7 +64,8 @@ static const struct iio_chan_spec als_channels[] = {
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
- BIT(IIO_CHAN_INFO_HYSTERESIS),
+ BIT(IIO_CHAN_INFO_HYSTERESIS) |
+ BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
.scan_index = CHANNEL_SCAN_INDEX_ILLUM,
},
IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
@@ -136,6 +143,10 @@ static int als_read_raw(struct iio_dev *indio_dev,
ret_type = hid_sensor_read_raw_hyst_value(
&als_state->common_attributes, val, val2);
break;
+ case IIO_CHAN_INFO_HYSTERESIS_RELATIVE:
+ ret_type = hid_sensor_read_raw_hyst_rel_value(
+ &als_state->common_attributes, val, val2);
+ break;
default:
ret_type = -EINVAL;
break;
@@ -163,6 +174,10 @@ static int als_write_raw(struct iio_dev *indio_dev,
ret = hid_sensor_write_raw_hyst_value(
&als_state->common_attributes, val, val2);
break;
+ case IIO_CHAN_INFO_HYSTERESIS_RELATIVE:
+ ret = hid_sensor_write_raw_hyst_rel_value(
+ &als_state->common_attributes, val, val2);
+ break;
default:
ret = -EINVAL;
}
@@ -252,17 +267,6 @@ static int als_parse_report(struct platform_device *pdev,
&st->als_illum,
&st->scale_pre_decml, &st->scale_post_decml);
- /* Set Sensitivity field ids, when there is no individual modifier */
- if (st->common_attributes.sensitivity.index < 0) {
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_DATA_LIGHT,
- &st->common_attributes.sensitivity);
- dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
- st->common_attributes.sensitivity.index,
- st->common_attributes.sensitivity.report_id);
- }
return ret;
}
@@ -285,7 +289,9 @@ static int hid_als_probe(struct platform_device *pdev)
als_state->common_attributes.pdev = pdev;
ret = hid_sensor_parse_common_attributes(hsdev, HID_USAGE_SENSOR_ALS,
- &als_state->common_attributes);
+ &als_state->common_attributes,
+ als_sensitivity_addresses,
+ ARRAY_SIZE(als_sensitivity_addresses));
if (ret) {
dev_err(&pdev->dev, "failed to setup common attributes\n");
return ret;
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index e9e00ce0c6d4..17d167c3d595 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -28,6 +28,11 @@ struct prox_state {
int scale_precision;
};
+static const u32 prox_sensitivity_addresses[] = {
+ HID_USAGE_SENSOR_HUMAN_PRESENCE,
+ HID_USAGE_SENSOR_DATA_PRESENCE,
+};
+
/* Channel definitions */
static const struct iio_chan_spec prox_channels[] = {
{
@@ -220,29 +225,6 @@ static int prox_parse_report(struct platform_device *pdev,
dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr.index,
st->prox_attr.report_id);
- /* Set Sensitivity field ids, when there is no individual modifier */
- if (st->common_attributes.sensitivity.index < 0) {
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_DATA_PRESENCE,
- &st->common_attributes.sensitivity);
- dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
- st->common_attributes.sensitivity.index,
- st->common_attributes.sensitivity.report_id);
- }
- if (st->common_attributes.sensitivity.index < 0)
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_HUMAN_PRESENCE,
- &st->common_attributes.sensitivity);
-
- st->scale_precision = hid_sensor_format_scale(
- hsdev->usage,
- &st->prox_attr,
- &st->scale_pre_decml, &st->scale_post_decml);
-
return ret;
}
@@ -266,7 +248,9 @@ static int hid_prox_probe(struct platform_device *pdev)
prox_state->common_attributes.pdev = pdev;
ret = hid_sensor_parse_common_attributes(hsdev, HID_USAGE_SENSOR_PROX,
- &prox_state->common_attributes);
+ &prox_state->common_attributes,
+ prox_sensitivity_addresses,
+ ARRAY_SIZE(prox_sensitivity_addresses));
if (ret) {
dev_err(&pdev->dev, "failed to setup common attributes\n");
return ret;
diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c
index 2d48d61909a4..52963da401a7 100644
--- a/drivers/iio/light/opt3001.c
+++ b/drivers/iio/light/opt3001.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
* opt3001.c - Texas Instruments OPT3001 Light Sensor
*
* Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com
diff --git a/drivers/iio/light/rpr0521.c b/drivers/iio/light/rpr0521.c
index 31224a33bade..033578f444e4 100644
--- a/drivers/iio/light/rpr0521.c
+++ b/drivers/iio/light/rpr0521.c
@@ -990,7 +990,6 @@ static int rpr0521_probe(struct i2c_client *client,
ret = -ENOMEM;
goto err_pm_disable;
}
- data->drdy_trigger0->dev.parent = indio_dev->dev.parent;
data->drdy_trigger0->ops = &rpr0521_trigger_ops;
indio_dev->available_scan_masks = rpr0521_available_scan_masks;
iio_trigger_set_drvdata(data->drdy_trigger0, indio_dev);
diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c
index b304801c7916..9b5c99823943 100644
--- a/drivers/iio/light/si1145.c
+++ b/drivers/iio/light/si1145.c
@@ -1247,7 +1247,6 @@ static int si1145_probe_trigger(struct iio_dev *indio_dev)
if (!trig)
return -ENOMEM;
- trig->dev.parent = &client->dev;
trig->ops = &si1145_trigger_ops;
iio_trigger_set_drvdata(trig, indio_dev);
diff --git a/drivers/iio/light/st_uvis25_core.c b/drivers/iio/light/st_uvis25_core.c
index 1055594b2276..41a2ce5a2d53 100644
--- a/drivers/iio/light/st_uvis25_core.c
+++ b/drivers/iio/light/st_uvis25_core.c
@@ -210,7 +210,6 @@ static int st_uvis25_allocate_trigger(struct iio_dev *iio_dev)
return -ENOMEM;
iio_trigger_set_drvdata(hw->trig, iio_dev);
- hw->trig->dev.parent = dev;
return devm_iio_trigger_register(dev, hw->trig);
}
diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index a2827d03ab0f..07e91846307c 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
* Sensortek STK3310/STK3311 Ambient Light and Proximity Sensor
*
* Copyright (c) 2015, Intel Corporation.
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index fff4b36b8b58..2f7916f95689 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -1002,7 +1002,6 @@ static int vcnl4010_probe_trigger(struct iio_dev *indio_dev)
if (!trigger)
return -ENOMEM;
- trigger->dev.parent = &client->dev;
trigger->ops = &vcnl4010_trigger_ops;
iio_trigger_set_drvdata(trigger, indio_dev);
diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c
index 73a28e30dddc..ae87740d9cef 100644
--- a/drivers/iio/light/vcnl4035.c
+++ b/drivers/iio/light/vcnl4035.c
@@ -511,7 +511,6 @@ static int vcnl4035_probe_trigger(struct iio_dev *indio_dev)
if (!data->drdy_trigger0)
return -ENOMEM;
- data->drdy_trigger0->dev.parent = indio_dev->dev.parent;
data->drdy_trigger0->ops = &vcnl4035_trigger_ops;
iio_trigger_set_drvdata(data->drdy_trigger0, indio_dev);
ret = devm_iio_trigger_register(indio_dev->dev.parent,
diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c
index b2f3129e1b4f..00f9766bad5c 100644
--- a/drivers/iio/magnetometer/bmc150_magn.c
+++ b/drivers/iio/magnetometer/bmc150_magn.c
@@ -922,7 +922,6 @@ int bmc150_magn_probe(struct device *dev, struct regmap *regmap,
goto err_poweroff;
}
- data->dready_trig->dev.parent = dev;
data->dready_trig->ops = &bmc150_magn_trigger_ops;
iio_trigger_set_drvdata(data->dready_trig, indio_dev);
ret = iio_trigger_register(data->dready_trig);
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index fa48044b7f5b..b78691523dd4 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -62,6 +62,11 @@ static const u32 magn_3d_addresses[MAGN_3D_CHANNEL_MAX] = {
HID_USAGE_SENSOR_TIME_TIMESTAMP,
};
+static const u32 magn_3d_sensitivity_addresses[] = {
+ HID_USAGE_SENSOR_DATA_ORIENTATION,
+ HID_USAGE_SENSOR_ORIENT_MAGN_FLUX,
+};
+
/* Channel definitions */
static const struct iio_chan_spec magn_3d_channels[] = {
{
@@ -448,27 +453,6 @@ static int magn_3d_parse_report(struct platform_device *pdev,
&st->rot_attr.scale_pre_decml,
&st->rot_attr.scale_post_decml);
- /* Set Sensitivity field ids, when there is no individual modifier */
- if (st->magn_flux_attributes.sensitivity.index < 0) {
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_DATA_ORIENTATION,
- &st->magn_flux_attributes.sensitivity);
- dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
- st->magn_flux_attributes.sensitivity.index,
- st->magn_flux_attributes.sensitivity.report_id);
- }
- if (st->magn_flux_attributes.sensitivity.index < 0) {
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_ORIENT_MAGN_FLUX,
- &st->magn_flux_attributes.sensitivity);
- dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
- st->magn_flux_attributes.sensitivity.index,
- st->magn_flux_attributes.sensitivity.report_id);
- }
if (st->rot_attributes.sensitivity.index < 0) {
sensor_hub_input_get_attribute_info(hsdev,
HID_FEATURE_REPORT, usage_id,
@@ -507,12 +491,16 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
ret = hid_sensor_parse_common_attributes(hsdev,
HID_USAGE_SENSOR_COMPASS_3D,
- &magn_state->magn_flux_attributes);
+ &magn_state->magn_flux_attributes,
+ magn_3d_sensitivity_addresses,
+ ARRAY_SIZE(magn_3d_sensitivity_addresses));
if (ret) {
dev_err(&pdev->dev, "failed to setup common attributes\n");
return ret;
}
magn_state->rot_attributes = magn_state->magn_flux_attributes;
+ /* sensitivity of rot_attribute is not the same as magn_flux_attributes */
+ magn_state->rot_attributes.sensitivity.index = -1;
ret = magn_3d_parse_report(pdev, hsdev,
&channels, &chan_count,
diff --git a/drivers/iio/magnetometer/rm3100-core.c b/drivers/iio/magnetometer/rm3100-core.c
index 7242897a05e9..dd811da9cb6d 100644
--- a/drivers/iio/magnetometer/rm3100-core.c
+++ b/drivers/iio/magnetometer/rm3100-core.c
@@ -579,7 +579,6 @@ int rm3100_common_probe(struct device *dev, struct regmap *regmap, int irq)
if (!data->drdy_trig)
return -ENOMEM;
- data->drdy_trig->dev.parent = dev;
ret = devm_iio_trigger_register(dev, data->drdy_trig);
if (ret < 0)
return ret;
diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h
index 204b285725c8..7ba6a6ba5c58 100644
--- a/drivers/iio/magnetometer/st_magn.h
+++ b/drivers/iio/magnetometer/st_magn.h
@@ -21,6 +21,7 @@
#define LSM303AGR_MAGN_DEV_NAME "lsm303agr_magn"
#define LIS2MDL_MAGN_DEV_NAME "lis2mdl"
#define LSM9DS1_MAGN_DEV_NAME "lsm9ds1_magn"
+#define IIS2MDC_MAGN_DEV_NAME "iis2mdc"
const struct st_sensor_settings *st_magn_get_settings(const char *name);
int st_magn_common_probe(struct iio_dev *indio_dev);
diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
index 79de721e6015..71faebd07feb 100644
--- a/drivers/iio/magnetometer/st_magn_core.c
+++ b/drivers/iio/magnetometer/st_magn_core.c
@@ -337,6 +337,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
.sensors_supported = {
[0] = LSM303AGR_MAGN_DEV_NAME,
[1] = LIS2MDL_MAGN_DEV_NAME,
+ [2] = IIS2MDC_MAGN_DEV_NAME,
},
.ch = (struct iio_chan_spec *)st_magn_3_16bit_channels,
.odr = {
diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
index c6bb4ce77594..36f4e7b53b24 100644
--- a/drivers/iio/magnetometer/st_magn_i2c.c
+++ b/drivers/iio/magnetometer/st_magn_i2c.c
@@ -46,6 +46,10 @@ static const struct of_device_id st_magn_of_match[] = {
.compatible = "st,lsm9ds1-magn",
.data = LSM9DS1_MAGN_DEV_NAME,
},
+ {
+ .compatible = "st,iis2mdc",
+ .data = IIS2MDC_MAGN_DEV_NAME,
+ },
{},
};
MODULE_DEVICE_TABLE(of, st_magn_of_match);
@@ -101,6 +105,7 @@ static const struct i2c_device_id st_magn_id_table[] = {
{ LSM303AGR_MAGN_DEV_NAME },
{ LIS2MDL_MAGN_DEV_NAME },
{ LSM9DS1_MAGN_DEV_NAME },
+ { IIS2MDC_MAGN_DEV_NAME },
{},
};
MODULE_DEVICE_TABLE(i2c, st_magn_id_table);
diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c
index 3d08d74c367d..0e2323dfc687 100644
--- a/drivers/iio/magnetometer/st_magn_spi.c
+++ b/drivers/iio/magnetometer/st_magn_spi.c
@@ -41,6 +41,10 @@ static const struct of_device_id st_magn_of_match[] = {
.compatible = "st,lsm9ds1-magn",
.data = LSM9DS1_MAGN_DEV_NAME,
},
+ {
+ .compatible = "st,iis2mdc",
+ .data = IIS2MDC_MAGN_DEV_NAME,
+ },
{}
};
MODULE_DEVICE_TABLE(of, st_magn_of_match);
@@ -92,6 +96,7 @@ static const struct spi_device_id st_magn_id_table[] = {
{ LSM303AGR_MAGN_DEV_NAME },
{ LIS2MDL_MAGN_DEV_NAME },
{ LSM9DS1_MAGN_DEV_NAME },
+ { IIS2MDC_MAGN_DEV_NAME },
{},
};
MODULE_DEVICE_TABLE(spi, st_magn_id_table);
diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c
index d46f23d82b3d..2f2f8cb3c26c 100644
--- a/drivers/iio/magnetometer/yamaha-yas530.c
+++ b/drivers/iio/magnetometer/yamaha-yas530.c
@@ -32,13 +32,14 @@
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/random.h>
-#include <linux/unaligned/be_byteshift.h>
#include <linux/iio/buffer.h>
#include <linux/iio/iio.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
+#include <asm/unaligned.h>
+
/* This register map covers YAS530 and YAS532 but differs in YAS 537 and YAS539 */
#define YAS5XX_DEVICE_ID 0x80
#define YAS5XX_ACTUATE_INIT_COIL 0x81
@@ -887,6 +888,7 @@ static int yas5xx_probe(struct i2c_client *i2c,
strncpy(yas5xx->name, "yas532", sizeof(yas5xx->name));
break;
default:
+ ret = -ENODEV;
dev_err(dev, "unhandled device ID %02x\n", yas5xx->devid);
goto assert_reset;
}
diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
index 52ebef30f9be..7af48d336285 100644
--- a/drivers/iio/orientation/hid-sensor-incl-3d.c
+++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
@@ -47,6 +47,11 @@ static const u32 incl_3d_addresses[INCLI_3D_CHANNEL_MAX] = {
HID_USAGE_SENSOR_ORIENT_TILT_Z
};
+static const u32 incl_3d_sensitivity_addresses[] = {
+ HID_USAGE_SENSOR_DATA_ORIENTATION,
+ HID_USAGE_SENSOR_ORIENT_TILT,
+};
+
/* Channel definitions */
static const struct iio_chan_spec incl_3d_channels[] = {
{
@@ -291,17 +296,6 @@ static int incl_3d_parse_report(struct platform_device *pdev,
&st->incl[CHANNEL_SCAN_INDEX_X],
&st->scale_pre_decml, &st->scale_post_decml);
- /* Set Sensitivity field ids, when there is no individual modifier */
- if (st->common_attributes.sensitivity.index < 0) {
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_DATA_ORIENTATION,
- &st->common_attributes.sensitivity);
- dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
- st->common_attributes.sensitivity.index,
- st->common_attributes.sensitivity.report_id);
- }
return ret;
}
@@ -327,7 +321,9 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
ret = hid_sensor_parse_common_attributes(hsdev,
HID_USAGE_SENSOR_INCLINOMETER_3D,
- &incl_state->common_attributes);
+ &incl_state->common_attributes,
+ incl_3d_sensitivity_addresses,
+ ARRAY_SIZE(incl_3d_sensitivity_addresses));
if (ret) {
dev_err(&pdev->dev, "failed to setup common attributes\n");
return ret;
diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
index 18e4ef060096..cf7f57a47681 100644
--- a/drivers/iio/orientation/hid-sensor-rotation.c
+++ b/drivers/iio/orientation/hid-sensor-rotation.c
@@ -21,7 +21,7 @@ struct dev_rot_state {
struct hid_sensor_common common_attributes;
struct hid_sensor_hub_attribute_info quaternion;
struct {
- u32 sampled_vals[4] __aligned(16);
+ s32 sampled_vals[4] __aligned(16);
u64 timestamp __aligned(8);
} scan;
int scale_pre_decml;
@@ -31,6 +31,11 @@ struct dev_rot_state {
s64 timestamp;
};
+static const u32 rotation_sensitivity_addresses[] = {
+ HID_USAGE_SENSOR_DATA_ORIENTATION,
+ HID_USAGE_SENSOR_ORIENT_QUATERNION,
+};
+
/* Channel definitions */
static const struct iio_chan_spec dev_rot_channels[] = {
{
@@ -170,8 +175,15 @@ static int dev_rot_capture_sample(struct hid_sensor_hub_device *hsdev,
struct dev_rot_state *rot_state = iio_priv(indio_dev);
if (usage_id == HID_USAGE_SENSOR_ORIENT_QUATERNION) {
- memcpy(&rot_state->scan.sampled_vals, raw_data,
- sizeof(rot_state->scan.sampled_vals));
+ if (raw_len / 4 == sizeof(s16)) {
+ rot_state->scan.sampled_vals[0] = ((s16 *)raw_data)[0];
+ rot_state->scan.sampled_vals[1] = ((s16 *)raw_data)[1];
+ rot_state->scan.sampled_vals[2] = ((s16 *)raw_data)[2];
+ rot_state->scan.sampled_vals[3] = ((s16 *)raw_data)[3];
+ } else {
+ memcpy(&rot_state->scan.sampled_vals, raw_data,
+ sizeof(rot_state->scan.sampled_vals));
+ }
dev_dbg(&indio_dev->dev, "Recd Quat len:%zu::%zu\n", raw_len,
sizeof(rot_state->scan.sampled_vals));
@@ -214,18 +226,6 @@ static int dev_rot_parse_report(struct platform_device *pdev,
&st->quaternion,
&st->scale_pre_decml, &st->scale_post_decml);
- /* Set Sensitivity field ids, when there is no individual modifier */
- if (st->common_attributes.sensitivity.index < 0) {
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_DATA_ORIENTATION,
- &st->common_attributes.sensitivity);
- dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
- st->common_attributes.sensitivity.index,
- st->common_attributes.sensitivity.report_id);
- }
-
return 0;
}
@@ -263,8 +263,11 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
return -EINVAL;
}
- ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage,
- &rot_state->common_attributes);
+ ret = hid_sensor_parse_common_attributes(hsdev,
+ hsdev->usage,
+ &rot_state->common_attributes,
+ rotation_sensitivity_addresses,
+ ARRAY_SIZE(rotation_sensitivity_addresses));
if (ret) {
dev_err(&pdev->dev, "failed to setup common attributes\n");
return ret;
diff --git a/drivers/iio/position/hid-sensor-custom-intel-hinge.c b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
index 64a7fa7db6af..fd77e7ee87f3 100644
--- a/drivers/iio/position/hid-sensor-custom-intel-hinge.c
+++ b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
@@ -47,6 +47,10 @@ struct hinge_state {
u64 timestamp;
};
+static const u32 hinge_sensitivity_addresses[] = {
+ HID_USAGE_SENSOR_DATA_FIELD_CUSTOM_VALUE(1),
+};
+
/* Channel definitions */
static const struct iio_chan_spec hinge_channels[] = {
{
@@ -251,18 +255,6 @@ static int hinge_parse_report(struct platform_device *pdev,
&st->hinge[CHANNEL_SCAN_INDEX_HINGE_ANGLE],
&st->scale_pre_decml, &st->scale_post_decml);
- /* Set Sensitivity field ids, when there is no individual modifier */
- if (st->common_attributes.sensitivity.index < 0) {
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_DATA_FIELD_CUSTOM_VALUE(1),
- &st->common_attributes.sensitivity);
- dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
- st->common_attributes.sensitivity.index,
- st->common_attributes.sensitivity.report_id);
- }
-
return ret;
}
@@ -289,7 +281,9 @@ static int hid_hinge_probe(struct platform_device *pdev)
st->labels[i] = hinge_labels[i];
ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage,
- &st->common_attributes);
+ &st->common_attributes,
+ hinge_sensitivity_addresses,
+ ARRAY_SIZE(hinge_sensitivity_addresses));
if (ret) {
dev_err(&pdev->dev, "failed to setup common attributes\n");
return ret;
diff --git a/drivers/iio/potentiometer/max5481.c b/drivers/iio/potentiometer/max5481.c
index a88ed0eb3adc..6e22b538091f 100644
--- a/drivers/iio/potentiometer/max5481.c
+++ b/drivers/iio/potentiometer/max5481.c
@@ -136,7 +136,7 @@ static int max5481_probe(struct spi_device *spi)
if (!indio_dev)
return -ENOMEM;
- dev_set_drvdata(&spi->dev, indio_dev);
+ spi_set_drvdata(spi, indio_dev);
data = iio_priv(indio_dev);
data->spi = spi;
@@ -163,7 +163,7 @@ static int max5481_probe(struct spi_device *spi)
static int max5481_remove(struct spi_device *spi)
{
- struct iio_dev *indio_dev = dev_get_drvdata(&spi->dev);
+ struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct max5481_data *data = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
diff --git a/drivers/iio/potentiometer/max5487.c b/drivers/iio/potentiometer/max5487.c
index 7ec51976ec99..1c0d46a96200 100644
--- a/drivers/iio/potentiometer/max5487.c
+++ b/drivers/iio/potentiometer/max5487.c
@@ -92,7 +92,7 @@ static int max5487_spi_probe(struct spi_device *spi)
if (!indio_dev)
return -ENOMEM;
- dev_set_drvdata(&spi->dev, indio_dev);
+ spi_set_drvdata(spi, indio_dev);
data = iio_priv(indio_dev);
data->spi = spi;
@@ -114,7 +114,7 @@ static int max5487_spi_probe(struct spi_device *spi)
static int max5487_spi_remove(struct spi_device *spi)
{
- struct iio_dev *indio_dev = dev_get_drvdata(&spi->dev);
+ struct iio_dev *indio_dev = spi_get_drvdata(spi);
iio_device_unregister(indio_dev);
diff --git a/drivers/iio/potentiostat/lmp91000.c b/drivers/iio/potentiostat/lmp91000.c
index f34ca769dc20..8a9c576616ee 100644
--- a/drivers/iio/potentiostat/lmp91000.c
+++ b/drivers/iio/potentiostat/lmp91000.c
@@ -322,7 +322,7 @@ static int lmp91000_probe(struct i2c_client *client,
return PTR_ERR(data->regmap);
}
- data->trig = devm_iio_trigger_alloc(data->dev, "%s-mux%d",
+ data->trig = devm_iio_trigger_alloc(dev, "%s-mux%d",
indio_dev->name, indio_dev->id);
if (!data->trig) {
dev_err(dev, "cannot allocate iio trigger.\n");
@@ -330,7 +330,6 @@ static int lmp91000_probe(struct i2c_client *client,
}
data->trig->ops = &lmp91000_trigger_ops;
- data->trig->dev.parent = dev;
init_completion(&data->completion);
ret = lmp91000_read_config(data);
diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c
index aa043cb9ac42..2f882e109423 100644
--- a/drivers/iio/pressure/cros_ec_baro.c
+++ b/drivers/iio/pressure/cros_ec_baro.c
@@ -139,8 +139,7 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
ret = cros_ec_sensors_core_init(pdev, indio_dev, true,
cros_ec_sensors_capture,
- cros_ec_sensors_push_data,
- true);
+ cros_ec_sensors_push_data);
if (ret)
return ret;
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index 5c458788f346..c416d261e3e3 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -29,6 +29,11 @@ struct press_state {
int value_offset;
};
+static const u32 press_sensitivity_addresses[] = {
+ HID_USAGE_SENSOR_DATA_ATMOSPHERIC_PRESSURE,
+ HID_USAGE_SENSOR_ATMOSPHERIC_PRESSURE
+};
+
/* Channel definitions */
static const struct iio_chan_spec press_channels[] = {
{
@@ -225,17 +230,6 @@ static int press_parse_report(struct platform_device *pdev,
&st->press_attr,
&st->scale_pre_decml, &st->scale_post_decml);
- /* Set Sensitivity field ids, when there is no individual modifier */
- if (st->common_attributes.sensitivity.index < 0) {
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_DATA_ATMOSPHERIC_PRESSURE,
- &st->common_attributes.sensitivity);
- dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n",
- st->common_attributes.sensitivity.index,
- st->common_attributes.sensitivity.report_id);
- }
return ret;
}
@@ -260,7 +254,9 @@ static int hid_press_probe(struct platform_device *pdev)
ret = hid_sensor_parse_common_attributes(hsdev,
HID_USAGE_SENSOR_PRESSURE,
- &press_state->common_attributes);
+ &press_state->common_attributes,
+ press_sensitivity_addresses,
+ ARRAY_SIZE(press_sensitivity_addresses));
if (ret) {
dev_err(&pdev->dev, "failed to setup common attributes\n");
return ret;
diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
index 2cecbe0adb3f..a93411216aee 100644
--- a/drivers/iio/pressure/zpa2326.c
+++ b/drivers/iio/pressure/zpa2326.c
@@ -103,7 +103,7 @@ static const struct zpa2326_frequency *zpa2326_highest_frequency(void)
}
/**
- * struct zpa_private - Per-device internal private state
+ * struct zpa2326_private - Per-device internal private state
* @timestamp: Buffered samples ready datum.
* @regmap: Underlying I2C / SPI bus adapter used to abstract slave register
* accesses.
@@ -1382,7 +1382,7 @@ static const struct iio_trigger_ops zpa2326_trigger_ops = {
};
/**
- * zpa2326_init_trigger() - Create an interrupt driven / hardware trigger
+ * zpa2326_init_managed_trigger() - Create interrupt driven / hardware trigger
* allowing to notify external devices a new sample is
* ready.
* @parent: Hardware sampling device @indio_dev is a child of.
@@ -1413,7 +1413,6 @@ static int zpa2326_init_managed_trigger(struct device *parent,
return -ENOMEM;
/* Basic setup. */
- trigger->dev.parent = parent;
trigger->ops = &zpa2326_trigger_ops;
private->trigger = trigger;
diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig
index 12672a0e89ed..7c7203ca3ac6 100644
--- a/drivers/iio/proximity/Kconfig
+++ b/drivers/iio/proximity/Kconfig
@@ -21,6 +21,17 @@ endmenu
menu "Proximity and distance sensors"
+config CROS_EC_MKBP_PROXIMITY
+ tristate "ChromeOS EC MKBP Proximity sensor"
+ depends on CROS_EC
+ help
+ Say Y here to enable the proximity sensor implemented via the ChromeOS EC MKBP
+ switches protocol. You must enable one bus option (CROS_EC_I2C or CROS_EC_SPI)
+ to use this.
+
+ To compile this driver as a module, choose M here: the
+ module will be called cros_ec_mkbp_proximity.
+
config ISL29501
tristate "Intersil ISL29501 Time Of Flight sensor"
depends on I2C
diff --git a/drivers/iio/proximity/Makefile b/drivers/iio/proximity/Makefile
index 9c1aca1a8b79..cbdac09433eb 100644
--- a/drivers/iio/proximity/Makefile
+++ b/drivers/iio/proximity/Makefile
@@ -5,6 +5,7 @@
# When adding new entries keep the list in alphabetical order
obj-$(CONFIG_AS3935) += as3935.o
+obj-$(CONFIG_CROS_EC_MKBP_PROXIMITY) += cros_ec_mkbp_proximity.o
obj-$(CONFIG_ISL29501) += isl29501.o
obj-$(CONFIG_LIDAR_LITE_V2) += pulsedlight-lidar-lite-v2.o
obj-$(CONFIG_MB1232) += mb1232.o
diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
index b79ada839e01..edc4a35ae66d 100644
--- a/drivers/iio/proximity/as3935.c
+++ b/drivers/iio/proximity/as3935.c
@@ -411,7 +411,6 @@ static int as3935_probe(struct spi_device *spi)
st->trig = trig;
st->noise_tripped = jiffies - HZ;
- trig->dev.parent = indio_dev->dev.parent;
iio_trigger_set_drvdata(trig, indio_dev);
trig->ops = &iio_interrupt_trigger_ops;
diff --git a/drivers/iio/proximity/cros_ec_mkbp_proximity.c b/drivers/iio/proximity/cros_ec_mkbp_proximity.c
new file mode 100644
index 000000000000..8213b0081713
--- /dev/null
+++ b/drivers/iio/proximity/cros_ec_mkbp_proximity.c
@@ -0,0 +1,271 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Driver for cros-ec proximity sensor exposed through MKBP switch
+ *
+ * Copyright 2021 Google LLC.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/notifier.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
+
+#include <linux/iio/events.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+
+#include <asm/unaligned.h>
+
+struct cros_ec_mkbp_proximity_data {
+ struct cros_ec_device *ec;
+ struct iio_dev *indio_dev;
+ struct mutex lock;
+ struct notifier_block notifier;
+ int last_proximity;
+ bool enabled;
+};
+
+static const struct iio_event_spec cros_ec_mkbp_proximity_events[] = {
+ {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_EITHER,
+ .mask_separate = BIT(IIO_EV_INFO_ENABLE),
+ },
+};
+
+static const struct iio_chan_spec cros_ec_mkbp_proximity_chan_spec[] = {
+ {
+ .type = IIO_PROXIMITY,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .event_spec = cros_ec_mkbp_proximity_events,
+ .num_event_specs = ARRAY_SIZE(cros_ec_mkbp_proximity_events),
+ },
+};
+
+static int cros_ec_mkbp_proximity_parse_state(const void *data)
+{
+ u32 switches = get_unaligned_le32(data);
+
+ return !!(switches & BIT(EC_MKBP_FRONT_PROXIMITY));
+}
+
+static int cros_ec_mkbp_proximity_query(struct cros_ec_device *ec_dev,
+ int *state)
+{
+ struct {
+ struct cros_ec_command msg;
+ union {
+ struct ec_params_mkbp_info params;
+ u32 switches;
+ };
+ } __packed buf = { };
+ struct ec_params_mkbp_info *params = &buf.params;
+ struct cros_ec_command *msg = &buf.msg;
+ u32 *switches = &buf.switches;
+ size_t insize = sizeof(*switches);
+ int ret;
+
+ msg->command = EC_CMD_MKBP_INFO;
+ msg->version = 1;
+ msg->outsize = sizeof(*params);
+ msg->insize = insize;
+
+ params->info_type = EC_MKBP_INFO_CURRENT;
+ params->event_type = EC_MKBP_EVENT_SWITCH;
+
+ ret = cros_ec_cmd_xfer_status(ec_dev, msg);
+ if (ret < 0)
+ return ret;
+
+ if (ret != insize) {
+ dev_warn(ec_dev->dev, "wrong result size: %d != %zu\n", ret,
+ insize);
+ return -EPROTO;
+ }
+
+ *state = cros_ec_mkbp_proximity_parse_state(switches);
+ return IIO_VAL_INT;
+}
+
+static void cros_ec_mkbp_proximity_push_event(struct cros_ec_mkbp_proximity_data *data, int state)
+{
+ s64 timestamp;
+ u64 ev;
+ int dir;
+ struct iio_dev *indio_dev = data->indio_dev;
+ struct cros_ec_device *ec = data->ec;
+
+ mutex_lock(&data->lock);
+ if (state != data->last_proximity) {
+ if (data->enabled) {
+ timestamp = ktime_to_ns(ec->last_event_time);
+ if (iio_device_get_clock(indio_dev) != CLOCK_BOOTTIME)
+ timestamp = iio_get_time_ns(indio_dev);
+
+ dir = state ? IIO_EV_DIR_FALLING : IIO_EV_DIR_RISING;
+ ev = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 0,
+ IIO_EV_TYPE_THRESH, dir);
+ iio_push_event(indio_dev, ev, timestamp);
+ }
+ data->last_proximity = state;
+ }
+ mutex_unlock(&data->lock);
+}
+
+static int cros_ec_mkbp_proximity_notify(struct notifier_block *nb,
+ unsigned long queued_during_suspend,
+ void *_ec)
+{
+ struct cros_ec_mkbp_proximity_data *data;
+ struct cros_ec_device *ec = _ec;
+ u8 event_type = ec->event_data.event_type & EC_MKBP_EVENT_TYPE_MASK;
+ void *switches;
+ int state;
+
+ if (event_type == EC_MKBP_EVENT_SWITCH) {
+ data = container_of(nb, struct cros_ec_mkbp_proximity_data,
+ notifier);
+
+ switches = &ec->event_data.data.switches;
+ state = cros_ec_mkbp_proximity_parse_state(switches);
+ cros_ec_mkbp_proximity_push_event(data, state);
+ }
+
+ return NOTIFY_OK;
+}
+
+static int cros_ec_mkbp_proximity_read_raw(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan, int *val,
+ int *val2, long mask)
+{
+ struct cros_ec_mkbp_proximity_data *data = iio_priv(indio_dev);
+ struct cros_ec_device *ec = data->ec;
+
+ if (chan->type == IIO_PROXIMITY && mask == IIO_CHAN_INFO_RAW)
+ return cros_ec_mkbp_proximity_query(ec, val);
+
+ return -EINVAL;
+}
+
+static int cros_ec_mkbp_proximity_read_event_config(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir)
+{
+ struct cros_ec_mkbp_proximity_data *data = iio_priv(indio_dev);
+
+ return data->enabled;
+}
+
+static int cros_ec_mkbp_proximity_write_event_config(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir, int state)
+{
+ struct cros_ec_mkbp_proximity_data *data = iio_priv(indio_dev);
+
+ mutex_lock(&data->lock);
+ data->enabled = state;
+ mutex_unlock(&data->lock);
+
+ return 0;
+}
+
+static const struct iio_info cros_ec_mkbp_proximity_info = {
+ .read_raw = cros_ec_mkbp_proximity_read_raw,
+ .read_event_config = cros_ec_mkbp_proximity_read_event_config,
+ .write_event_config = cros_ec_mkbp_proximity_write_event_config,
+};
+
+static __maybe_unused int cros_ec_mkbp_proximity_resume(struct device *dev)
+{
+ struct cros_ec_mkbp_proximity_data *data = dev_get_drvdata(dev);
+ struct cros_ec_device *ec = data->ec;
+ int ret, state;
+
+ ret = cros_ec_mkbp_proximity_query(ec, &state);
+ if (ret < 0) {
+ dev_warn(dev, "failed to fetch proximity state on resume: %d\n",
+ ret);
+ } else {
+ cros_ec_mkbp_proximity_push_event(data, state);
+ }
+
+ return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(cros_ec_mkbp_proximity_pm_ops, NULL,
+ cros_ec_mkbp_proximity_resume);
+
+static int cros_ec_mkbp_proximity_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct cros_ec_device *ec = dev_get_drvdata(dev->parent);
+ struct iio_dev *indio_dev;
+ struct cros_ec_mkbp_proximity_data *data;
+ int ret;
+
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ data = iio_priv(indio_dev);
+ data->ec = ec;
+ data->indio_dev = indio_dev;
+ data->last_proximity = -1; /* Unknown to start */
+ mutex_init(&data->lock);
+ platform_set_drvdata(pdev, data);
+
+ indio_dev->name = dev->driver->name;
+ indio_dev->info = &cros_ec_mkbp_proximity_info;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->channels = cros_ec_mkbp_proximity_chan_spec;
+ indio_dev->num_channels = ARRAY_SIZE(cros_ec_mkbp_proximity_chan_spec);
+
+ ret = devm_iio_device_register(dev, indio_dev);
+ if (ret)
+ return ret;
+
+ data->notifier.notifier_call = cros_ec_mkbp_proximity_notify;
+ blocking_notifier_chain_register(&ec->event_notifier, &data->notifier);
+
+ return 0;
+}
+
+static int cros_ec_mkbp_proximity_remove(struct platform_device *pdev)
+{
+ struct cros_ec_mkbp_proximity_data *data = platform_get_drvdata(pdev);
+ struct cros_ec_device *ec = data->ec;
+
+ blocking_notifier_chain_unregister(&ec->event_notifier,
+ &data->notifier);
+
+ return 0;
+}
+
+static const struct of_device_id cros_ec_mkbp_proximity_of_match[] = {
+ { .compatible = "google,cros-ec-mkbp-proximity" },
+ {}
+};
+MODULE_DEVICE_TABLE(of, cros_ec_mkbp_proximity_of_match);
+
+static struct platform_driver cros_ec_mkbp_proximity_driver = {
+ .driver = {
+ .name = "cros-ec-mkbp-proximity",
+ .of_match_table = cros_ec_mkbp_proximity_of_match,
+ .pm = &cros_ec_mkbp_proximity_pm_ops,
+ },
+ .probe = cros_ec_mkbp_proximity_probe,
+ .remove = cros_ec_mkbp_proximity_remove,
+};
+module_platform_driver(cros_ec_mkbp_proximity_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("ChromeOS EC MKBP proximity sensor driver");
diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c
index 37fd0b65a014..327ebb7ddbb9 100644
--- a/drivers/iio/proximity/sx9310.c
+++ b/drivers/iio/proximity/sx9310.c
@@ -763,7 +763,11 @@ static int sx9310_write_far_debounce(struct sx9310_data *data, int val)
int ret;
unsigned int regval;
- val = ilog2(val);
+ if (val > 0)
+ val = ilog2(val);
+ if (!FIELD_FIT(SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_MASK, val))
+ return -EINVAL;
+
regval = FIELD_PREP(SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_MASK, val);
mutex_lock(&data->mutex);
@@ -780,7 +784,11 @@ static int sx9310_write_close_debounce(struct sx9310_data *data, int val)
int ret;
unsigned int regval;
- val = ilog2(val);
+ if (val > 0)
+ val = ilog2(val);
+ if (!FIELD_FIT(SX9310_REG_PROX_CTRL10_CLOSE_DEBOUNCE_MASK, val))
+ return -EINVAL;
+
regval = FIELD_PREP(SX9310_REG_PROX_CTRL10_CLOSE_DEBOUNCE_MASK, val);
mutex_lock(&data->mutex);
@@ -1213,17 +1221,17 @@ static int sx9310_init_compensation(struct iio_dev *indio_dev)
}
static const struct sx9310_reg_default *
-sx9310_get_default_reg(struct sx9310_data *data, int i,
+sx9310_get_default_reg(struct sx9310_data *data, int idx,
struct sx9310_reg_default *reg_def)
{
- int ret;
const struct device_node *np = data->client->dev.of_node;
- u32 combined[SX9310_NUM_CHANNELS] = { 4, 4, 4, 4 };
+ u32 combined[SX9310_NUM_CHANNELS];
+ u32 start = 0, raw = 0, pos = 0;
unsigned long comb_mask = 0;
+ int ret, i, count;
const char *res;
- u32 start = 0, raw = 0, pos = 0;
- memcpy(reg_def, &sx9310_default_regs[i], sizeof(*reg_def));
+ memcpy(reg_def, &sx9310_default_regs[idx], sizeof(*reg_def));
if (!np)
return reg_def;
@@ -1234,15 +1242,31 @@ sx9310_get_default_reg(struct sx9310_data *data, int i,
reg_def->def |= SX9310_REG_PROX_CTRL2_SHIELDEN_GROUND;
}
- reg_def->def &= ~SX9310_REG_PROX_CTRL2_COMBMODE_MASK;
- of_property_read_u32_array(np, "semtech,combined-sensors",
- combined, ARRAY_SIZE(combined));
- for (i = 0; i < ARRAY_SIZE(combined); i++) {
- if (combined[i] <= SX9310_NUM_CHANNELS)
- comb_mask |= BIT(combined[i]);
+ count = of_property_count_elems_of_size(np, "semtech,combined-sensors",
+ sizeof(u32));
+ if (count > 0 && count <= ARRAY_SIZE(combined)) {
+ ret = of_property_read_u32_array(np, "semtech,combined-sensors",
+ combined, count);
+ if (ret)
+ break;
+ } else {
+ /*
+ * Either the property does not exist in the DT or the
+ * number of entries is incorrect.
+ */
+ break;
}
+ for (i = 0; i < count; i++) {
+ if (combined[i] >= SX9310_NUM_CHANNELS) {
+ /* Invalid sensor (invalid DT). */
+ break;
+ }
+ comb_mask |= BIT(combined[i]);
+ }
+ if (i < count)
+ break;
- comb_mask &= 0xf;
+ reg_def->def &= ~SX9310_REG_PROX_CTRL2_COMBMODE_MASK;
if (comb_mask == (BIT(3) | BIT(2) | BIT(1) | BIT(0)))
reg_def->def |= SX9310_REG_PROX_CTRL2_COMBMODE_CS0_CS1_CS2_CS3;
else if (comb_mask == (BIT(1) | BIT(2)))
@@ -1453,7 +1477,6 @@ static int sx9310_probe(struct i2c_client *client)
if (!data->trig)
return -ENOMEM;
- data->trig->dev.parent = dev;
data->trig->ops = &sx9310_trigger_ops;
iio_trigger_set_drvdata(data->trig, indio_dev);
diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index acb821cbad46..a87f4a8e4327 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -758,7 +758,7 @@ static const struct sx9500_reg_default sx9500_default_regs[] = {
.reg = SX9500_REG_PROX_CTRL5,
/*
* Debouncer off, lowest average negative filter,
- * highest average postive filter.
+ * highest average positive filter.
*/
.def = 0x0f,
},
@@ -950,7 +950,6 @@ static int sx9500_probe(struct i2c_client *client,
if (!data->trig)
return -ENOMEM;
- data->trig->dev.parent = &client->dev;
data->trig->ops = &sx9500_trigger_ops;
iio_trigger_set_drvdata(data->trig, indio_dev);
diff --git a/drivers/iio/proximity/vcnl3020.c b/drivers/iio/proximity/vcnl3020.c
index 37264f801ad0..43817f6b3086 100644
--- a/drivers/iio/proximity/vcnl3020.c
+++ b/drivers/iio/proximity/vcnl3020.c
@@ -40,6 +40,17 @@
#define VCNL_ON_DEMAND_TIMEOUT_US 100000
#define VCNL_POLL_US 20000
+static const int vcnl3020_prox_sampling_frequency[][2] = {
+ {1, 950000},
+ {3, 906250},
+ {7, 812500},
+ {16, 625000},
+ {31, 250000},
+ {62, 500000},
+ {125, 0},
+ {250, 0},
+};
+
/**
* struct vcnl3020_data - vcnl3020 specific data.
* @regmap: device register map.
@@ -165,10 +176,51 @@ err_unlock:
return rc;
}
+static int vcnl3020_read_proxy_samp_freq(struct vcnl3020_data *data, int *val,
+ int *val2)
+{
+ int rc;
+ unsigned int prox_rate;
+
+ rc = regmap_read(data->regmap, VCNL_PROXIMITY_RATE, &prox_rate);
+ if (rc)
+ return rc;
+
+ if (prox_rate >= ARRAY_SIZE(vcnl3020_prox_sampling_frequency))
+ return -EINVAL;
+
+ *val = vcnl3020_prox_sampling_frequency[prox_rate][0];
+ *val2 = vcnl3020_prox_sampling_frequency[prox_rate][1];
+
+ return 0;
+}
+
+static int vcnl3020_write_proxy_samp_freq(struct vcnl3020_data *data, int val,
+ int val2)
+{
+ unsigned int i;
+ int index = -1;
+
+ for (i = 0; i < ARRAY_SIZE(vcnl3020_prox_sampling_frequency); i++) {
+ if (val == vcnl3020_prox_sampling_frequency[i][0] &&
+ val2 == vcnl3020_prox_sampling_frequency[i][1]) {
+ index = i;
+ break;
+ }
+ }
+
+ if (index < 0)
+ return -EINVAL;
+
+ return regmap_write(data->regmap, VCNL_PROXIMITY_RATE, index);
+}
+
static const struct iio_chan_spec vcnl3020_channels[] = {
{
.type = IIO_PROXIMITY,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_SAMP_FREQ),
+ .info_mask_separate_available = BIT(IIO_CHAN_INFO_SAMP_FREQ),
},
};
@@ -185,6 +237,47 @@ static int vcnl3020_read_raw(struct iio_dev *indio_dev,
if (rc)
return rc;
return IIO_VAL_INT;
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ rc = vcnl3020_read_proxy_samp_freq(data, val, val2);
+ if (rc < 0)
+ return rc;
+ return IIO_VAL_INT_PLUS_MICRO;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int vcnl3020_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val, int val2, long mask)
+{
+ int rc;
+ struct vcnl3020_data *data = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ rc = iio_device_claim_direct_mode(indio_dev);
+ if (rc)
+ return rc;
+ rc = vcnl3020_write_proxy_samp_freq(data, val, val2);
+ iio_device_release_direct_mode(indio_dev);
+ return rc;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int vcnl3020_read_avail(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ const int **vals, int *type, int *length,
+ long mask)
+{
+ switch (mask) {
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ *vals = (int *)vcnl3020_prox_sampling_frequency;
+ *type = IIO_VAL_INT_PLUS_MICRO;
+ *length = 2 * ARRAY_SIZE(vcnl3020_prox_sampling_frequency);
+ return IIO_AVAIL_LIST;
default:
return -EINVAL;
}
@@ -192,6 +285,8 @@ static int vcnl3020_read_raw(struct iio_dev *indio_dev,
static const struct iio_info vcnl3020_info = {
.read_raw = vcnl3020_read_raw,
+ .write_raw = vcnl3020_write_raw,
+ .read_avail = vcnl3020_read_avail,
};
static const struct regmap_config vcnl3020_regmap_config = {
diff --git a/drivers/iio/temperature/hid-sensor-temperature.c b/drivers/iio/temperature/hid-sensor-temperature.c
index da9a247097fa..dc534ed784c3 100644
--- a/drivers/iio/temperature/hid-sensor-temperature.c
+++ b/drivers/iio/temperature/hid-sensor-temperature.c
@@ -25,6 +25,10 @@ struct temperature_state {
int value_offset;
};
+static const u32 temperature_sensitivity_addresses[] = {
+ HID_USAGE_SENSOR_DATA_ENVIRONMENTAL_TEMPERATURE,
+};
+
/* Channel definitions */
static const struct iio_chan_spec temperature_channels[] = {
{
@@ -173,14 +177,6 @@ static int temperature_parse_report(struct platform_device *pdev,
&st->temperature_attr,
&st->scale_pre_decml, &st->scale_post_decml);
- /* Set Sensitivity field ids, when there is no individual modifier */
- if (st->common_attributes.sensitivity.index < 0)
- sensor_hub_input_get_attribute_info(hsdev,
- HID_FEATURE_REPORT, usage_id,
- HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS |
- HID_USAGE_SENSOR_DATA_ENVIRONMENTAL_TEMPERATURE,
- &st->common_attributes.sensitivity);
-
return ret;
}
@@ -209,7 +205,9 @@ static int hid_temperature_probe(struct platform_device *pdev)
ret = hid_sensor_parse_common_attributes(hsdev,
HID_USAGE_SENSOR_TEMPERATURE,
- &temp_st->common_attributes);
+ &temp_st->common_attributes,
+ temperature_sensitivity_addresses,
+ ARRAY_SIZE(temperature_sensitivity_addresses));
if (ret)
return ret;
diff --git a/drivers/iio/temperature/tmp007.c b/drivers/iio/temperature/tmp007.c
index ad2b35c65548..b422371a4674 100644
--- a/drivers/iio/temperature/tmp007.c
+++ b/drivers/iio/temperature/tmp007.c
@@ -439,6 +439,13 @@ static bool tmp007_identify(struct i2c_client *client)
return (manf_id == TMP007_MANUFACTURER_MAGIC && dev_id == TMP007_DEVICE_MAGIC);
}
+static void tmp007_powerdown_action_cb(void *priv)
+{
+ struct tmp007_data *data = priv;
+
+ tmp007_powerdown(data);
+}
+
static int tmp007_probe(struct i2c_client *client,
const struct i2c_device_id *tmp007_id)
{
@@ -489,6 +496,10 @@ static int tmp007_probe(struct i2c_client *client,
if (ret < 0)
return ret;
+ ret = devm_add_action_or_reset(&client->dev, tmp007_powerdown_action_cb, data);
+ if (ret)
+ return ret;
+
/*
* Only the following flags can activate ALERT pin. Data conversion/validity flags
* flags can still be polled for getting temperature data
@@ -502,7 +513,7 @@ static int tmp007_probe(struct i2c_client *client,
ret = i2c_smbus_read_word_swapped(data->client, TMP007_STATUS_MASK);
if (ret < 0)
- goto error_powerdown;
+ return ret;
data->status_mask = ret;
data->status_mask |= (TMP007_STATUS_OHF | TMP007_STATUS_OLF
@@ -510,7 +521,7 @@ static int tmp007_probe(struct i2c_client *client,
ret = i2c_smbus_write_word_swapped(data->client, TMP007_STATUS_MASK, data->status_mask);
if (ret < 0)
- goto error_powerdown;
+ return ret;
if (client->irq) {
ret = devm_request_threaded_irq(&client->dev, client->irq,
@@ -519,27 +530,11 @@ static int tmp007_probe(struct i2c_client *client,
tmp007_id->name, indio_dev);
if (ret) {
dev_err(&client->dev, "irq request error %d\n", -ret);
- goto error_powerdown;
+ return ret;
}
}
- return iio_device_register(indio_dev);
-
-error_powerdown:
- tmp007_powerdown(data);
-
- return ret;
-}
-
-static int tmp007_remove(struct i2c_client *client)
-{
- struct iio_dev *indio_dev = i2c_get_clientdata(client);
- struct tmp007_data *data = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
- tmp007_powerdown(data);
-
- return 0;
+ return devm_iio_device_register(&client->dev, indio_dev);
}
#ifdef CONFIG_PM_SLEEP
@@ -582,7 +577,6 @@ static struct i2c_driver tmp007_driver = {
.pm = &tmp007_pm_ops,
},
.probe = tmp007_probe,
- .remove = tmp007_remove,
.id_table = tmp007_id,
};
module_i2c_driver(tmp007_driver);
diff --git a/drivers/iio/test/Kconfig b/drivers/iio/test/Kconfig
new file mode 100644
index 000000000000..679a7794af20
--- /dev/null
+++ b/drivers/iio/test/Kconfig
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Industrial I/O subsystem unit tests configuration
+#
+
+# Keep in alphabetical order
+config IIO_TEST_FORMAT
+ bool "Test IIO formatting functions"
+ depends on KUNIT=y
diff --git a/drivers/iio/test/Makefile b/drivers/iio/test/Makefile
new file mode 100644
index 000000000000..f1099b495301
--- /dev/null
+++ b/drivers/iio/test/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for the industrial I/O unit tests.
+#
+
+# Keep in alphabetical order
+obj-$(CONFIG_IIO_TEST_FORMAT) += iio-test-format.o
diff --git a/drivers/iio/test/iio-test-format.c b/drivers/iio/test/iio-test-format.c
new file mode 100644
index 000000000000..55a0cfe9181d
--- /dev/null
+++ b/drivers/iio/test/iio-test-format.c
@@ -0,0 +1,198 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Unit tests for IIO formatting functions
+ *
+ * Copyright (c) 2020 Lars-Peter Clausen <lars@metafoo.de>
+ */
+
+#include <kunit/test.h>
+#include <linux/iio/iio.h>
+
+#define IIO_TEST_FORMAT_EXPECT_EQ(_test, _buf, _ret, _val) do { \
+ KUNIT_EXPECT_EQ(_test, (int)strlen(_buf), _ret); \
+ KUNIT_EXPECT_STREQ(_test, (_buf), (_val)); \
+ } while (0)
+
+static void iio_test_iio_format_value_integer(struct kunit *test)
+{
+ char *buf = kunit_kmalloc(test, PAGE_SIZE, GFP_KERNEL);
+ int val;
+ int ret;
+
+ val = 42;
+ ret = iio_format_value(buf, IIO_VAL_INT, 1, &val);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "42\n");
+
+ val = -23;
+ ret = iio_format_value(buf, IIO_VAL_INT, 1, &val);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-23\n");
+
+ val = 0;
+ ret = iio_format_value(buf, IIO_VAL_INT, 1, &val);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "0\n");
+
+ val = INT_MAX;
+ ret = iio_format_value(buf, IIO_VAL_INT, 1, &val);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "2147483647\n");
+
+ val = INT_MIN;
+ ret = iio_format_value(buf, IIO_VAL_INT, 1, &val);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-2147483648\n");
+}
+
+static void iio_test_iio_format_value_fixedpoint(struct kunit *test)
+{
+ char *buf = kunit_kmalloc(test, PAGE_SIZE, GFP_KERNEL);
+ int values[2];
+ int ret;
+
+ /* positive >= 1 */
+ values[0] = 1;
+ values[1] = 10;
+
+ ret = iio_format_value(buf, IIO_VAL_INT_PLUS_MICRO, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "1.000010\n");
+
+ ret = iio_format_value(buf, IIO_VAL_INT_PLUS_MICRO_DB, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "1.000010 dB\n");
+
+ ret = iio_format_value(buf, IIO_VAL_INT_PLUS_NANO, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "1.000000010\n");
+
+ /* positive < 1 */
+ values[0] = 0;
+ values[1] = 12;
+
+ ret = iio_format_value(buf, IIO_VAL_INT_PLUS_MICRO, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "0.000012\n");
+
+ ret = iio_format_value(buf, IIO_VAL_INT_PLUS_MICRO_DB, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "0.000012 dB\n");
+
+ ret = iio_format_value(buf, IIO_VAL_INT_PLUS_NANO, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "0.000000012\n");
+
+ /* negative <= -1 */
+ values[0] = -1;
+ values[1] = 10;
+
+ ret = iio_format_value(buf, IIO_VAL_INT_PLUS_MICRO, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-1.000010\n");
+
+ ret = iio_format_value(buf, IIO_VAL_INT_PLUS_MICRO_DB, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-1.000010 dB\n");
+
+ ret = iio_format_value(buf, IIO_VAL_INT_PLUS_NANO, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-1.000000010\n");
+
+ /* negative > -1 */
+ values[0] = 0;
+ values[1] = -123;
+ ret = iio_format_value(buf, IIO_VAL_INT_PLUS_MICRO, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-0.000123\n");
+
+ ret = iio_format_value(buf, IIO_VAL_INT_PLUS_MICRO_DB, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-0.000123 dB\n");
+
+ ret = iio_format_value(buf, IIO_VAL_INT_PLUS_NANO, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-0.000000123\n");
+}
+
+static void iio_test_iio_format_value_fractional(struct kunit *test)
+{
+ char *buf = kunit_kmalloc(test, PAGE_SIZE, GFP_KERNEL);
+ int values[2];
+ int ret;
+
+ /* positive < 1 */
+ values[0] = 1;
+ values[1] = 10;
+ ret = iio_format_value(buf, IIO_VAL_FRACTIONAL, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "0.100000000\n");
+
+ /* positive >= 1 */
+ values[0] = 100;
+ values[1] = 3;
+ ret = iio_format_value(buf, IIO_VAL_FRACTIONAL, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "33.333333333\n");
+
+ /* negative > -1 */
+ values[0] = -1;
+ values[1] = 1000000000;
+ ret = iio_format_value(buf, IIO_VAL_FRACTIONAL, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-0.000000001\n");
+
+ /* negative <= -1 */
+ values[0] = -200;
+ values[1] = 3;
+ ret = iio_format_value(buf, IIO_VAL_FRACTIONAL, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-66.666666666\n");
+
+ /* Zero */
+ values[0] = 0;
+ values[1] = -10;
+ ret = iio_format_value(buf, IIO_VAL_FRACTIONAL, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "0.000000000\n");
+}
+
+static void iio_test_iio_format_value_fractional_log2(struct kunit *test)
+{
+ char *buf = kunit_kmalloc(test, PAGE_SIZE, GFP_KERNEL);
+ int values[2];
+ int ret;
+
+ /* positive < 1 */
+ values[0] = 123;
+ values[1] = 10;
+ ret = iio_format_value(buf, IIO_VAL_FRACTIONAL_LOG2, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "0.120117187\n");
+
+ /* positive >= 1 */
+ values[0] = 1234567;
+ values[1] = 10;
+ ret = iio_format_value(buf, IIO_VAL_FRACTIONAL_LOG2, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "1205.631835937\n");
+
+ /* negative > -1 */
+ values[0] = -123;
+ values[1] = 10;
+ ret = iio_format_value(buf, IIO_VAL_FRACTIONAL_LOG2, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-0.120117187\n");
+
+ /* negative <= -1 */
+ values[0] = -1234567;
+ values[1] = 10;
+ ret = iio_format_value(buf, IIO_VAL_FRACTIONAL_LOG2, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-1205.631835937\n");
+
+ /* Zero */
+ values[0] = 0;
+ values[1] = 10;
+ ret = iio_format_value(buf, IIO_VAL_FRACTIONAL_LOG2, 2, values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "0.000000000\n");
+}
+
+static void iio_test_iio_format_value_multiple(struct kunit *test)
+{
+ char *buf = kunit_kmalloc(test, PAGE_SIZE, GFP_KERNEL);
+ int values[] = {1, -2, 3, -4, 5};
+ int ret;
+
+ ret = iio_format_value(buf, IIO_VAL_INT_MULTIPLE,
+ ARRAY_SIZE(values), values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "1 -2 3 -4 5 \n");
+}
+
+static struct kunit_case iio_format_test_cases[] = {
+ KUNIT_CASE(iio_test_iio_format_value_integer),
+ KUNIT_CASE(iio_test_iio_format_value_fixedpoint),
+ KUNIT_CASE(iio_test_iio_format_value_fractional),
+ KUNIT_CASE(iio_test_iio_format_value_fractional_log2),
+ KUNIT_CASE(iio_test_iio_format_value_multiple),
+ {}
+};
+
+static struct kunit_suite iio_format_test_suite = {
+ .name = "iio-format",
+ .test_cases = iio_format_test_cases,
+};
+kunit_test_suite(iio_format_test_suite);
diff --git a/drivers/iio/trigger/iio-trig-hrtimer.c b/drivers/iio/trigger/iio-trig-hrtimer.c
index 410de837d041..716c795d08fb 100644
--- a/drivers/iio/trigger/iio-trig-hrtimer.c
+++ b/drivers/iio/trigger/iio-trig-hrtimer.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
-/**
+/*
* The industrial I/O periodic hrtimer trigger driver
*
* Copyright (C) Intuitive Aerial AB
@@ -16,13 +16,16 @@
#include <linux/iio/trigger.h>
#include <linux/iio/sw_trigger.h>
+/* Defined locally, not in time64.h yet. */
+#define PSEC_PER_SEC 1000000000000LL
+
/* default sampling frequency - 100Hz */
#define HRTIMER_DEFAULT_SAMPLING_FREQUENCY 100
struct iio_hrtimer_info {
struct iio_sw_trigger swt;
struct hrtimer timer;
- unsigned long sampling_frequency;
+ int sampling_frequency[2];
ktime_t period;
};
@@ -38,7 +41,9 @@ ssize_t iio_hrtimer_show_sampling_frequency(struct device *dev,
struct iio_trigger *trig = to_iio_trigger(dev);
struct iio_hrtimer_info *info = iio_trigger_get_drvdata(trig);
- return snprintf(buf, PAGE_SIZE, "%lu\n", info->sampling_frequency);
+ return iio_format_value(buf, IIO_VAL_INT_PLUS_MICRO,
+ ARRAY_SIZE(info->sampling_frequency),
+ info->sampling_frequency);
}
static
@@ -48,18 +53,26 @@ ssize_t iio_hrtimer_store_sampling_frequency(struct device *dev,
{
struct iio_trigger *trig = to_iio_trigger(dev);
struct iio_hrtimer_info *info = iio_trigger_get_drvdata(trig);
- unsigned long val;
- int ret;
+ unsigned long long val;
+ u64 period;
+ int integer, fract, ret;
- ret = kstrtoul(buf, 10, &val);
+ ret = iio_str_to_fixpoint(buf, 100, &integer, &fract);
if (ret)
return ret;
+ if (integer < 0 || fract < 0)
+ return -ERANGE;
+
+ val = fract + 1000ULL * integer; /* mHz */
- if (!val || val > NSEC_PER_SEC)
+ if (!val || val > UINT_MAX)
return -EINVAL;
- info->sampling_frequency = val;
- info->period = NSEC_PER_SEC / val;
+ info->sampling_frequency[0] = integer; /* Hz */
+ info->sampling_frequency[1] = fract * 1000; /* uHz */
+ period = PSEC_PER_SEC;
+ do_div(period, val);
+ info->period = period; /* nS */
return len;
}
@@ -122,7 +135,7 @@ static struct iio_sw_trigger *iio_trig_hrtimer_probe(const char *name)
if (!trig_info)
return ERR_PTR(-ENOMEM);
- trig_info->swt.trigger = iio_trigger_alloc("%s", name);
+ trig_info->swt.trigger = iio_trigger_alloc(NULL, "%s", name);
if (!trig_info->swt.trigger) {
ret = -ENOMEM;
goto err_free_trig_info;
@@ -135,8 +148,8 @@ static struct iio_sw_trigger *iio_trig_hrtimer_probe(const char *name)
hrtimer_init(&trig_info->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
trig_info->timer.function = iio_hrtimer_trig_handler;
- trig_info->sampling_frequency = HRTIMER_DEFAULT_SAMPLING_FREQUENCY;
- trig_info->period = NSEC_PER_SEC / trig_info->sampling_frequency;
+ trig_info->sampling_frequency[0] = HRTIMER_DEFAULT_SAMPLING_FREQUENCY;
+ trig_info->period = NSEC_PER_SEC / trig_info->sampling_frequency[0];
ret = iio_trigger_register(trig_info->swt.trigger);
if (ret)
diff --git a/drivers/iio/trigger/iio-trig-interrupt.c b/drivers/iio/trigger/iio-trig-interrupt.c
index 94a487caf421..f746c460bf2a 100644
--- a/drivers/iio/trigger/iio-trig-interrupt.c
+++ b/drivers/iio/trigger/iio-trig-interrupt.c
@@ -45,7 +45,7 @@ static int iio_interrupt_trigger_probe(struct platform_device *pdev)
irq = irq_res->start;
- trig = iio_trigger_alloc("irqtrig%d", irq);
+ trig = iio_trigger_alloc(NULL, "irqtrig%d", irq);
if (!trig) {
ret = -ENOMEM;
goto error_ret;
diff --git a/drivers/iio/trigger/iio-trig-loop.c b/drivers/iio/trigger/iio-trig-loop.c
index 4a00668e3258..96ec06bbe546 100644
--- a/drivers/iio/trigger/iio-trig-loop.c
+++ b/drivers/iio/trigger/iio-trig-loop.c
@@ -84,7 +84,7 @@ static struct iio_sw_trigger *iio_trig_loop_probe(const char *name)
if (!trig_info)
return ERR_PTR(-ENOMEM);
- trig_info->swt.trigger = iio_trigger_alloc("%s", name);
+ trig_info->swt.trigger = iio_trigger_alloc(NULL, "%s", name);
if (!trig_info->swt.trigger) {
ret = -ENOMEM;
goto err_free_trig_info;
diff --git a/drivers/iio/trigger/iio-trig-sysfs.c b/drivers/iio/trigger/iio-trig-sysfs.c
index 0f6b512a5c37..e9adfff45b39 100644
--- a/drivers/iio/trigger/iio-trig-sysfs.c
+++ b/drivers/iio/trigger/iio-trig-sysfs.c
@@ -149,7 +149,7 @@ static int iio_sysfs_trigger_probe(int id)
goto out1;
}
t->id = id;
- t->trig = iio_trigger_alloc("sysfstrig%d", id);
+ t->trig = iio_trigger_alloc(&iio_sysfs_trig_dev, "sysfstrig%d", id);
if (!t->trig) {
ret = -ENOMEM;
goto free_t;
@@ -157,7 +157,6 @@ static int iio_sysfs_trigger_probe(int id)
t->trig->dev.groups = iio_sysfs_trigger_attr_groups;
t->trig->ops = &iio_sysfs_trigger_ops;
- t->trig->dev.parent = &iio_sysfs_trig_dev;
iio_trigger_set_drvdata(t->trig, t);
t->work = IRQ_WORK_INIT_HARD(iio_sysfs_trigger_work);
diff --git a/drivers/most/Kconfig b/drivers/most/Kconfig
index ebfe84e69715..4b8145b9e7ad 100644
--- a/drivers/most/Kconfig
+++ b/drivers/most/Kconfig
@@ -32,4 +32,14 @@ config MOST_CDEV
To compile this driver as a module, choose M here: the
module will be called most_cdev.
+
+config MOST_SND
+ tristate "Sound"
+ depends on SND
+ select SND_PCM
+ help
+ Say Y here if you want to commumicate via ALSA/sound devices.
+
+ To compile this driver as a module, choose M here: the
+ module will be called most_sound.
endif
diff --git a/drivers/most/Makefile b/drivers/most/Makefile
index 8b53ca46633f..60db6cd3787a 100644
--- a/drivers/most/Makefile
+++ b/drivers/most/Makefile
@@ -5,3 +5,4 @@ most_core-y := core.o \
obj-$(CONFIG_MOST_USB_HDM) += most_usb.o
obj-$(CONFIG_MOST_CDEV) += most_cdev.o
+obj-$(CONFIG_MOST_SND) += most_snd.o
diff --git a/drivers/staging/most/sound/sound.c b/drivers/most/most_snd.c
index c87f6a037874..c87f6a037874 100644
--- a/drivers/staging/most/sound/sound.c
+++ b/drivers/most/most_snd.c
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 77c43134bc9e..ea1d284741cb 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -422,6 +422,15 @@ config REGULATOR_HI655X
This driver provides support for the voltage regulators of the
Hisilicon Hi655x PMIC device.
+config REGULATOR_HI6421V600
+ tristate "HiSilicon Hi6421v600 PMIC voltage regulator support"
+ depends on MFD_HI6421_SPMI && OF
+ select REGMAP
+ help
+ This driver provides support for the voltage regulators on
+ HiSilicon Hi6421v600 PMU / Codec IC.
+ This is used on Kirin 3670 boards, like HiKey 970.
+
config REGULATOR_ISL9305
tristate "Intersil ISL9305 regulator"
depends on I2C
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 44d2f8bf4b74..11c145886c98 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -49,6 +49,7 @@ obj-$(CONFIG_REGULATOR_FAN53880) += fan53880.o
obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
obj-$(CONFIG_REGULATOR_HI6421) += hi6421-regulator.o
obj-$(CONFIG_REGULATOR_HI6421V530) += hi6421v530-regulator.o
+obj-$(CONFIG_REGULATOR_HI6421V600) += hi6421v600-regulator.o
obj-$(CONFIG_REGULATOR_HI655X) += hi655x-regulator.o
obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
obj-$(CONFIG_REGULATOR_ISL9305) += isl9305.o
diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/regulator/hi6421v600-regulator.c
index f6a14e9c3cbf..f6a14e9c3cbf 100644
--- a/drivers/staging/hikey9xx/hi6421v600-regulator.c
+++ b/drivers/regulator/hi6421v600-regulator.c
diff --git a/drivers/rtc/rtc-hid-sensor-time.c b/drivers/rtc/rtc-hid-sensor-time.c
index 1b42ee0758d2..47cd12db2356 100644
--- a/drivers/rtc/rtc-hid-sensor-time.c
+++ b/drivers/rtc/rtc-hid-sensor-time.c
@@ -238,7 +238,9 @@ static int hid_time_probe(struct platform_device *pdev)
ret = hid_sensor_parse_common_attributes(hsdev,
HID_USAGE_SENSOR_TIME,
- &time_state->common_attributes);
+ &time_state->common_attributes,
+ NULL,
+ 0);
if (ret) {
dev_err(&pdev->dev, "failed to setup common attributes!\n");
return ret;
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index b22f73d7bfc4..808e78d6cd98 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -26,8 +26,6 @@ if STAGING
source "drivers/staging/wlan-ng/Kconfig"
-source "drivers/staging/comedi/Kconfig"
-
source "drivers/staging/olpc_dcon/Kconfig"
source "drivers/staging/rtl8192u/Kconfig"
@@ -98,8 +96,6 @@ source "drivers/staging/ralink-gdma/Kconfig"
source "drivers/staging/mt7621-dts/Kconfig"
-source "drivers/staging/gasket/Kconfig"
-
source "drivers/staging/axis-fifo/Kconfig"
source "drivers/staging/fieldbus/Kconfig"
@@ -108,8 +104,6 @@ source "drivers/staging/kpc2000/Kconfig"
source "drivers/staging/qlge/Kconfig"
-source "drivers/staging/wimax/Kconfig"
-
source "drivers/staging/wfx/Kconfig"
source "drivers/staging/hikey9xx/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 2245059e69c7..5a871f0ff2f4 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -3,7 +3,6 @@
obj-y += media/
obj-$(CONFIG_PRISM2_USB) += wlan-ng/
-obj-$(CONFIG_COMEDI) += comedi/
obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/
obj-$(CONFIG_RTL8192U) += rtl8192u/
obj-$(CONFIG_RTL8192E) += rtl8192e/
@@ -39,11 +38,9 @@ obj-$(CONFIG_PCI_MT7621) += mt7621-pci/
obj-$(CONFIG_SOC_MT7621) += mt7621-dma/
obj-$(CONFIG_DMA_RALINK) += ralink-gdma/
obj-$(CONFIG_SOC_MT7621) += mt7621-dts/
-obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/
obj-$(CONFIG_XIL_AXIS_FIFO) += axis-fifo/
obj-$(CONFIG_FIELDBUS_DEV) += fieldbus/
obj-$(CONFIG_KPC2000) += kpc2000/
obj-$(CONFIG_QLGE) += qlge/
-obj-$(CONFIG_WIMAX) += wimax/
obj-$(CONFIG_WFX) += wfx/
obj-y += hikey9xx/
diff --git a/drivers/staging/android/uapi/ashmem.h b/drivers/staging/android/uapi/ashmem.h
index 5442e0019dcd..134efacb3219 100644
--- a/drivers/staging/android/uapi/ashmem.h
+++ b/drivers/staging/android/uapi/ashmem.h
@@ -1,7 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 */
/*
- * drivers/staging/android/uapi/ashmem.h
- *
* Copyright 2008 Google Inc.
* Author: Robert Love
*/
diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
index 2bb1c2e9cb57..ed9281089738 100644
--- a/drivers/staging/axis-fifo/axis-fifo.c
+++ b/drivers/staging/axis-fifo/axis-fifo.c
@@ -853,7 +853,6 @@ static int axis_fifo_probe(struct platform_device *pdev)
fifo->base_addr = devm_ioremap_resource(fifo->dt_device, r_mem);
if (IS_ERR(fifo->base_addr)) {
rc = PTR_ERR(fifo->base_addr);
- dev_err(fifo->dt_device, "can't remap IO resource (%d)\n", rc);
goto err_initial;
}
diff --git a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
index e52a64be93f3..39367712ef54 100644
--- a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
+++ b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
@@ -15,6 +15,7 @@
#include <linux/of.h>
#include <linux/module.h>
#include <linux/err.h>
+#include <linux/iopoll.h>
#define WZRD_NUM_OUTPUTS 7
#define WZRD_ACLK_MAX_FREQ 250000000UL
@@ -26,19 +27,41 @@
#define WZRD_CLKFBOUT_MULT_SHIFT 8
#define WZRD_CLKFBOUT_MULT_MASK (0xff << WZRD_CLKFBOUT_MULT_SHIFT)
+#define WZRD_CLKFBOUT_FRAC_SHIFT 16
+#define WZRD_CLKFBOUT_FRAC_MASK (0x3ff << WZRD_CLKFBOUT_FRAC_SHIFT)
#define WZRD_DIVCLK_DIVIDE_SHIFT 0
#define WZRD_DIVCLK_DIVIDE_MASK (0xff << WZRD_DIVCLK_DIVIDE_SHIFT)
#define WZRD_CLKOUT_DIVIDE_SHIFT 0
+#define WZRD_CLKOUT_DIVIDE_WIDTH 8
#define WZRD_CLKOUT_DIVIDE_MASK (0xff << WZRD_DIVCLK_DIVIDE_SHIFT)
+#define WZRD_CLKOUT_FRAC_SHIFT 8
+#define WZRD_CLKOUT_FRAC_MASK 0x3ff
+
+#define WZRD_DR_MAX_INT_DIV_VALUE 255
+#define WZRD_DR_STATUS_REG_OFFSET 0x04
+#define WZRD_DR_LOCK_BIT_MASK 0x00000001
+#define WZRD_DR_INIT_REG_OFFSET 0x25C
+#define WZRD_DR_DIV_TO_PHASE_OFFSET 4
+#define WZRD_DR_BEGIN_DYNA_RECONF 0x03
+
+#define WZRD_USEC_POLL 10
+#define WZRD_TIMEOUT_POLL 1000
+/* Get the mask from width */
+#define div_mask(width) ((1 << (width)) - 1)
+
+/* Extract divider instance from clock hardware instance */
+#define to_clk_wzrd_divider(_hw) container_of(_hw, struct clk_wzrd_divider, hw)
enum clk_wzrd_int_clks {
wzrd_clk_mul,
wzrd_clk_mul_div,
+ wzrd_clk_mul_frac,
wzrd_clk_int_max
};
/**
- * struct clk_wzrd:
+ * struct clk_wzrd - Clock wizard private data structure
+ *
* @clk_data: Clock data
* @nb: Notifier block
* @base: Memory base
@@ -61,6 +84,29 @@ struct clk_wzrd {
bool suspended;
};
+/**
+ * struct clk_wzrd_divider - clock divider specific to clk_wzrd
+ *
+ * @hw: handle between common and hardware-specific interfaces
+ * @base: base address of register containing the divider
+ * @offset: offset address of register containing the divider
+ * @shift: shift to the divider bit field
+ * @width: width of the divider bit field
+ * @flags: clk_wzrd divider flags
+ * @table: array of value/divider pairs, last entry should have div = 0
+ * @lock: register lock
+ */
+struct clk_wzrd_divider {
+ struct clk_hw hw;
+ void __iomem *base;
+ u16 offset;
+ u8 shift;
+ u8 width;
+ u8 flags;
+ const struct clk_div_table *table;
+ spinlock_t *lock; /* divider lock */
+};
+
#define to_clk_wzrd(_nb) container_of(_nb, struct clk_wzrd, nb)
/* maximum frequencies for input/output clocks per speed grade */
@@ -70,6 +116,242 @@ static const unsigned long clk_wzrd_max_freq[] = {
1066000000UL
};
+/* spin lock variable for clk_wzrd */
+static DEFINE_SPINLOCK(clkwzrd_lock);
+
+static unsigned long clk_wzrd_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+ struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+ void __iomem *div_addr = divider->base + divider->offset;
+ unsigned int val;
+
+ val = readl(div_addr) >> divider->shift;
+ val &= div_mask(divider->width);
+
+ return divider_recalc_rate(hw, parent_rate, val, divider->table,
+ divider->flags, divider->width);
+}
+
+static int clk_wzrd_dynamic_reconfig(struct clk_hw *hw, unsigned long rate,
+ unsigned long parent_rate)
+{
+ int err;
+ u32 value;
+ unsigned long flags = 0;
+ struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+ void __iomem *div_addr = divider->base + divider->offset;
+
+ if (divider->lock)
+ spin_lock_irqsave(divider->lock, flags);
+ else
+ __acquire(divider->lock);
+
+ value = DIV_ROUND_CLOSEST(parent_rate, rate);
+
+ /* Cap the value to max */
+ min_t(u32, value, WZRD_DR_MAX_INT_DIV_VALUE);
+
+ /* Set divisor and clear phase offset */
+ writel(value, div_addr);
+ writel(0x00, div_addr + WZRD_DR_DIV_TO_PHASE_OFFSET);
+
+ /* Check status register */
+ err = readl_poll_timeout(divider->base + WZRD_DR_STATUS_REG_OFFSET,
+ value, value & WZRD_DR_LOCK_BIT_MASK,
+ WZRD_USEC_POLL, WZRD_TIMEOUT_POLL);
+ if (err)
+ goto err_reconfig;
+
+ /* Initiate reconfiguration */
+ writel(WZRD_DR_BEGIN_DYNA_RECONF,
+ divider->base + WZRD_DR_INIT_REG_OFFSET);
+
+ /* Check status register */
+ err = readl_poll_timeout(divider->base + WZRD_DR_STATUS_REG_OFFSET,
+ value, value & WZRD_DR_LOCK_BIT_MASK,
+ WZRD_USEC_POLL, WZRD_TIMEOUT_POLL);
+err_reconfig:
+ if (divider->lock)
+ spin_unlock_irqrestore(divider->lock, flags);
+ else
+ __release(divider->lock);
+ return err;
+}
+
+static long clk_wzrd_round_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long *prate)
+{
+ u8 div;
+
+ /*
+ * since we don't change parent rate we just round rate to closest
+ * achievable
+ */
+ div = DIV_ROUND_CLOSEST(*prate, rate);
+
+ return *prate / div;
+}
+
+static const struct clk_ops clk_wzrd_clk_divider_ops = {
+ .round_rate = clk_wzrd_round_rate,
+ .set_rate = clk_wzrd_dynamic_reconfig,
+ .recalc_rate = clk_wzrd_recalc_rate,
+};
+
+static unsigned long clk_wzrd_recalc_ratef(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+ unsigned int val;
+ u32 div, frac;
+ struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+ void __iomem *div_addr = divider->base + divider->offset;
+
+ val = readl(div_addr);
+ div = val & div_mask(divider->width);
+ frac = (val >> WZRD_CLKOUT_FRAC_SHIFT) & WZRD_CLKOUT_FRAC_MASK;
+
+ return mult_frac(parent_rate, 1000, (div * 1000) + frac);
+}
+
+static int clk_wzrd_dynamic_reconfig_f(struct clk_hw *hw, unsigned long rate,
+ unsigned long parent_rate)
+{
+ int err;
+ u32 value, pre;
+ unsigned long rate_div, f, clockout0_div;
+ struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+ void __iomem *div_addr = divider->base + divider->offset;
+
+ rate_div = ((parent_rate * 1000) / rate);
+ clockout0_div = rate_div / 1000;
+
+ pre = DIV_ROUND_CLOSEST((parent_rate * 1000), rate);
+ f = (u32)(pre - (clockout0_div * 1000));
+ f = f & WZRD_CLKOUT_FRAC_MASK;
+ f = f << WZRD_CLKOUT_DIVIDE_WIDTH;
+
+ value = (f | (clockout0_div & WZRD_CLKOUT_DIVIDE_MASK));
+
+ /* Set divisor and clear phase offset */
+ writel(value, div_addr);
+ writel(0x0, div_addr + WZRD_DR_DIV_TO_PHASE_OFFSET);
+
+ /* Check status register */
+ err = readl_poll_timeout(divider->base + WZRD_DR_STATUS_REG_OFFSET, value,
+ value & WZRD_DR_LOCK_BIT_MASK,
+ WZRD_USEC_POLL, WZRD_TIMEOUT_POLL);
+ if (err)
+ return err;
+
+ /* Initiate reconfiguration */
+ writel(WZRD_DR_BEGIN_DYNA_RECONF,
+ divider->base + WZRD_DR_INIT_REG_OFFSET);
+
+ /* Check status register */
+ return readl_poll_timeout(divider->base + WZRD_DR_STATUS_REG_OFFSET, value,
+ value & WZRD_DR_LOCK_BIT_MASK,
+ WZRD_USEC_POLL, WZRD_TIMEOUT_POLL);
+}
+
+static long clk_wzrd_round_rate_f(struct clk_hw *hw, unsigned long rate,
+ unsigned long *prate)
+{
+ return rate;
+}
+
+static const struct clk_ops clk_wzrd_clk_divider_ops_f = {
+ .round_rate = clk_wzrd_round_rate_f,
+ .set_rate = clk_wzrd_dynamic_reconfig_f,
+ .recalc_rate = clk_wzrd_recalc_ratef,
+};
+
+static struct clk *clk_wzrd_register_divf(struct device *dev,
+ const char *name,
+ const char *parent_name,
+ unsigned long flags,
+ void __iomem *base, u16 offset,
+ u8 shift, u8 width,
+ u8 clk_divider_flags,
+ const struct clk_div_table *table,
+ spinlock_t *lock)
+{
+ struct clk_wzrd_divider *div;
+ struct clk_hw *hw;
+ struct clk_init_data init;
+ int ret;
+
+ div = devm_kzalloc(dev, sizeof(*div), GFP_KERNEL);
+ if (!div)
+ return ERR_PTR(-ENOMEM);
+
+ init.name = name;
+
+ init.ops = &clk_wzrd_clk_divider_ops_f;
+
+ init.flags = flags;
+ init.parent_names = &parent_name;
+ init.num_parents = 1;
+
+ div->base = base;
+ div->offset = offset;
+ div->shift = shift;
+ div->width = width;
+ div->flags = clk_divider_flags;
+ div->lock = lock;
+ div->hw.init = &init;
+ div->table = table;
+
+ hw = &div->hw;
+ ret = devm_clk_hw_register(dev, hw);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return hw->clk;
+}
+
+static struct clk *clk_wzrd_register_divider(struct device *dev,
+ const char *name,
+ const char *parent_name,
+ unsigned long flags,
+ void __iomem *base, u16 offset,
+ u8 shift, u8 width,
+ u8 clk_divider_flags,
+ const struct clk_div_table *table,
+ spinlock_t *lock)
+{
+ struct clk_wzrd_divider *div;
+ struct clk_hw *hw;
+ struct clk_init_data init;
+ int ret;
+
+ div = devm_kzalloc(dev, sizeof(*div), GFP_KERNEL);
+ if (!div)
+ return ERR_PTR(-ENOMEM);
+
+ init.name = name;
+ init.ops = &clk_wzrd_clk_divider_ops;
+ init.flags = flags;
+ init.parent_names = &parent_name;
+ init.num_parents = 1;
+
+ div->base = base;
+ div->offset = offset;
+ div->shift = shift;
+ div->width = width;
+ div->flags = clk_divider_flags;
+ div->lock = lock;
+ div->hw.init = &init;
+ div->table = table;
+
+ hw = &div->hw;
+ ret = devm_clk_hw_register(dev, hw);
+ if (ret)
+ hw = ERR_PTR(ret);
+
+ return hw->clk;
+}
+
static int clk_wzrd_clk_notifier(struct notifier_block *nb, unsigned long event,
void *data)
{
@@ -131,11 +413,14 @@ static SIMPLE_DEV_PM_OPS(clk_wzrd_dev_pm_ops, clk_wzrd_suspend,
static int clk_wzrd_probe(struct platform_device *pdev)
{
int i, ret;
- u32 reg;
+ u32 reg, reg_f, mult;
unsigned long rate;
const char *clk_name;
+ void __iomem *ctrl_reg;
struct clk_wzrd *clk_wzrd;
struct device_node *np = pdev->dev.of_node;
+ int nr_outputs;
+ unsigned long flags = 0;
clk_wzrd = devm_kzalloc(&pdev->dev, sizeof(*clk_wzrd), GFP_KERNEL);
if (!clk_wzrd)
@@ -146,7 +431,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
if (IS_ERR(clk_wzrd->base))
return PTR_ERR(clk_wzrd->base);
- ret = of_property_read_u32(np, "speed-grade", &clk_wzrd->speed_grade);
+ ret = of_property_read_u32(np, "xlnx,speed-grade", &clk_wzrd->speed_grade);
if (!ret) {
if (clk_wzrd->speed_grade < 1 || clk_wzrd->speed_grade > 3) {
dev_warn(&pdev->dev, "invalid speed grade '%d'\n",
@@ -181,46 +466,50 @@ static int clk_wzrd_probe(struct platform_device *pdev)
goto err_disable_clk;
}
- /* we don't support fractional div/mul yet */
- reg = readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0)) &
- WZRD_CLKFBOUT_FRAC_EN;
- reg |= readl(clk_wzrd->base + WZRD_CLK_CFG_REG(2)) &
- WZRD_CLKOUT0_FRAC_EN;
- if (reg)
- dev_warn(&pdev->dev, "fractional div/mul not supported\n");
-
- /* register multiplier */
- reg = (readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0)) &
- WZRD_CLKFBOUT_MULT_MASK) >> WZRD_CLKFBOUT_MULT_SHIFT;
+ reg = readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0));
+ reg_f = reg & WZRD_CLKFBOUT_FRAC_MASK;
+ reg_f = reg_f >> WZRD_CLKFBOUT_FRAC_SHIFT;
+
+ reg = reg & WZRD_CLKFBOUT_MULT_MASK;
+ reg = reg >> WZRD_CLKFBOUT_MULT_SHIFT;
+ mult = (reg * 1000) + reg_f;
clk_name = kasprintf(GFP_KERNEL, "%s_mul", dev_name(&pdev->dev));
if (!clk_name) {
ret = -ENOMEM;
goto err_disable_clk;
}
+
+ ret = of_property_read_u32(np, "nr-outputs", &nr_outputs);
+ if (ret || nr_outputs > WZRD_NUM_OUTPUTS) {
+ ret = -EINVAL;
+ goto err_disable_clk;
+ }
+ if (nr_outputs == 1)
+ flags = CLK_SET_RATE_PARENT;
+
clk_wzrd->clks_internal[wzrd_clk_mul] = clk_register_fixed_factor
(&pdev->dev, clk_name,
__clk_get_name(clk_wzrd->clk_in1),
- 0, reg, 1);
- kfree(clk_name);
+ 0, mult, 1000);
if (IS_ERR(clk_wzrd->clks_internal[wzrd_clk_mul])) {
dev_err(&pdev->dev, "unable to register fixed-factor clock\n");
ret = PTR_ERR(clk_wzrd->clks_internal[wzrd_clk_mul]);
goto err_disable_clk;
}
- /* register div */
- reg = (readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0)) &
- WZRD_DIVCLK_DIVIDE_MASK) >> WZRD_DIVCLK_DIVIDE_SHIFT;
clk_name = kasprintf(GFP_KERNEL, "%s_mul_div", dev_name(&pdev->dev));
if (!clk_name) {
ret = -ENOMEM;
goto err_rm_int_clk;
}
- clk_wzrd->clks_internal[wzrd_clk_mul_div] = clk_register_fixed_factor
+ ctrl_reg = clk_wzrd->base + WZRD_CLK_CFG_REG(0);
+ /* register div */
+ clk_wzrd->clks_internal[wzrd_clk_mul_div] = clk_register_divider
(&pdev->dev, clk_name,
__clk_get_name(clk_wzrd->clks_internal[wzrd_clk_mul]),
- 0, 1, reg);
+ flags, ctrl_reg, 0, 8, CLK_DIVIDER_ONE_BASED |
+ CLK_DIVIDER_ALLOW_ZERO, &clkwzrd_lock);
if (IS_ERR(clk_wzrd->clks_internal[wzrd_clk_mul_div])) {
dev_err(&pdev->dev, "unable to register divider clock\n");
ret = PTR_ERR(clk_wzrd->clks_internal[wzrd_clk_mul_div]);
@@ -228,25 +517,37 @@ static int clk_wzrd_probe(struct platform_device *pdev)
}
/* register div per output */
- for (i = WZRD_NUM_OUTPUTS - 1; i >= 0 ; i--) {
+ for (i = nr_outputs - 1; i >= 0 ; i--) {
const char *clkout_name;
- if (of_property_read_string_index(np, "clock-output-names", i,
- &clkout_name)) {
- dev_err(&pdev->dev,
- "clock output name not specified\n");
- ret = -EINVAL;
- goto err_rm_int_clks;
+ clkout_name = kasprintf(GFP_KERNEL, "%s_out%d", dev_name(&pdev->dev), i);
+ if (!clkout_name) {
+ ret = -ENOMEM;
+ goto err_rm_int_clk;
}
- reg = readl(clk_wzrd->base + WZRD_CLK_CFG_REG(2) + i * 12);
- reg &= WZRD_CLKOUT_DIVIDE_MASK;
- reg >>= WZRD_CLKOUT_DIVIDE_SHIFT;
- clk_wzrd->clkout[i] = clk_register_fixed_factor
- (&pdev->dev, clkout_name, clk_name, 0, 1, reg);
+
+ if (!i)
+ clk_wzrd->clkout[i] = clk_wzrd_register_divf
+ (&pdev->dev, clkout_name,
+ clk_name, flags,
+ clk_wzrd->base, (WZRD_CLK_CFG_REG(2) + i * 12),
+ WZRD_CLKOUT_DIVIDE_SHIFT,
+ WZRD_CLKOUT_DIVIDE_WIDTH,
+ CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
+ NULL, &clkwzrd_lock);
+ else
+ clk_wzrd->clkout[i] = clk_wzrd_register_divider
+ (&pdev->dev, clkout_name,
+ clk_name, 0,
+ clk_wzrd->base, (WZRD_CLK_CFG_REG(2) + i * 12),
+ WZRD_CLKOUT_DIVIDE_SHIFT,
+ WZRD_CLKOUT_DIVIDE_WIDTH,
+ CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
+ NULL, &clkwzrd_lock);
if (IS_ERR(clk_wzrd->clkout[i])) {
int j;
- for (j = i + 1; j < WZRD_NUM_OUTPUTS; j++)
+ for (j = i + 1; j < nr_outputs; j++)
clk_unregister(clk_wzrd->clkout[j]);
dev_err(&pdev->dev,
"unable to register divider clock\n");
diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
index 3536c03ff523..741147a4f0fe 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -38,7 +38,6 @@ static struct gpio_desc *vbus_gpio;
static int vbus_irq;
static const char driver_name[] = "emxx_udc";
-static const char driver_desc[] = DRIVER_DESC;
/*===========================================================================*/
/* Prototype */
diff --git a/drivers/staging/fbtft/fbtft-sysfs.c b/drivers/staging/fbtft/fbtft-sysfs.c
index 26e52cc2de64..39e8d28066cb 100644
--- a/drivers/staging/fbtft/fbtft-sysfs.c
+++ b/drivers/staging/fbtft/fbtft-sysfs.c
@@ -199,7 +199,7 @@ static ssize_t show_debug(struct device *device,
struct fb_info *fb_info = dev_get_drvdata(device);
struct fbtft_par *par = fb_info->par;
- return snprintf(buf, PAGE_SIZE, "%lu\n", par->debug);
+ return sysfs_emit(buf, "%lu\n", par->debug);
}
static struct device_attribute debug_device_attr =
diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c
index 549cb7d51af8..c97df91124a4 100644
--- a/drivers/staging/fieldbus/anybuss/host.c
+++ b/drivers/staging/fieldbus/anybuss/host.c
@@ -1406,32 +1406,26 @@ void anybuss_host_common_remove(struct anybuss_host *host)
}
EXPORT_SYMBOL_GPL(anybuss_host_common_remove);
-static void host_release(struct device *dev, void *res)
+static void host_release(void *res)
{
- struct anybuss_host **dr = res;
-
- anybuss_host_common_remove(*dr);
+ anybuss_host_common_remove(res);
}
struct anybuss_host * __must_check
devm_anybuss_host_common_probe(struct device *dev,
const struct anybuss_ops *ops)
{
- struct anybuss_host **dr;
struct anybuss_host *host;
-
- dr = devres_alloc(host_release, sizeof(struct anybuss_host *),
- GFP_KERNEL);
- if (!dr)
- return ERR_PTR(-ENOMEM);
+ int ret;
host = anybuss_host_common_probe(dev, ops);
- if (IS_ERR(host)) {
- devres_free(dr);
+ if (IS_ERR(host))
return host;
- }
- *dr = host;
- devres_add(dev, dr);
+
+ ret = devm_add_action_or_reset(dev, host_release, host);
+ if (ret)
+ return ERR_PTR(ret);
+
return host;
}
EXPORT_SYMBOL_GPL(devm_anybuss_host_common_probe);
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
index c368082aae1a..2cc461b26897 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -1318,8 +1318,8 @@ static int fwtty_break_ctl(struct tty_struct *tty, int state)
if (state == -1) {
set_bit(STOP_TX, &port->flags);
ret = wait_event_interruptible_timeout(port->wait_tx,
- !test_bit(IN_TX, &port->flags),
- 10);
+ !test_bit(IN_TX, &port->flags),
+ 10);
if (ret == 0 || ret == -ERESTARTSYS) {
clear_bit(STOP_TX, &port->flags);
fwtty_restart_tx(port);
@@ -2632,7 +2632,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer,
rcode = RCODE_COMPLETE;
- fwtty_dbg(&peer->unit, "mgmt: hdr.code: %04hx\n", pkt->hdr.code);
+ fwtty_dbg(&peer->unit, "mgmt: hdr.code: %04x\n", pkt->hdr.code);
switch (be16_to_cpu(pkt->hdr.code) & FWSC_CODE_MASK) {
case FWSC_VIRT_CABLE_PLUG:
diff --git a/drivers/staging/gasket/Kconfig b/drivers/staging/gasket/Kconfig
deleted file mode 100644
index d9bef8ca41ef..000000000000
--- a/drivers/staging/gasket/Kconfig
+++ /dev/null
@@ -1,25 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-menu "Gasket devices"
-
-config STAGING_GASKET_FRAMEWORK
- tristate "Gasket framework"
- depends on PCI && (X86_64 || ARM64)
- help
- This framework supports Gasket-compatible devices, such as Apex.
- It is required for any of the following module(s).
-
- To compile this driver as a module, choose M here. The module
- will be called "gasket".
-
-config STAGING_APEX_DRIVER
- tristate "Apex Driver"
- depends on STAGING_GASKET_FRAMEWORK
- help
- This driver supports the Apex Edge TPU device. See
- https://cloud.google.com/edge-tpu/ for more information.
- Say Y if you want to include this driver in the kernel.
-
- To compile this driver as a module, choose M here. The module
- will be called "apex".
-
-endmenu
diff --git a/drivers/staging/gasket/Makefile b/drivers/staging/gasket/Makefile
deleted file mode 100644
index ce03e256f501..000000000000
--- a/drivers/staging/gasket/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile for Gasket framework and dependent drivers.
-#
-
-obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket.o
-obj-$(CONFIG_STAGING_APEX_DRIVER) += apex.o
-
-gasket-objs := gasket_core.o gasket_ioctl.o gasket_interrupt.o gasket_page_table.o gasket_sysfs.o
-apex-objs := apex_driver.o
diff --git a/drivers/staging/gasket/TODO b/drivers/staging/gasket/TODO
deleted file mode 100644
index 5b1865f8af2d..000000000000
--- a/drivers/staging/gasket/TODO
+++ /dev/null
@@ -1,22 +0,0 @@
-This is a list of things that need to be done to get this driver out of the
-staging directory.
-
-- Implement the gasket framework's functionality through UIO instead of
- introducing a new user-space drivers framework that is quite similar.
-
- UIO provides the necessary bits to implement user-space drivers. Meanwhile
- the gasket APIs adds some extra conveniences like PCI BAR mapping, and
- MSI interrupts. Add these features to the UIO subsystem, then re-implement
- the Apex driver as a basic UIO driver instead (include/linux/uio_driver.h)
-
-- Document sysfs files with Documentation/ABI/ entries.
-
-- Use misc interface instead of major number for driver version description.
-
-- Add descriptions of module_param's
-
-- apex_get_status() should actually check status.
-
-- "drivers" should never be dealing with "raw" sysfs calls or mess around with
- kobjects at all. The driver core should handle all of this for you
- automaically. There should not be a need for raw attribute macros.
diff --git a/drivers/staging/gasket/apex.h b/drivers/staging/gasket/apex.h
deleted file mode 100644
index 3bbceffff5e4..000000000000
--- a/drivers/staging/gasket/apex.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Apex kernel-userspace interface definitions.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-#ifndef __APEX_H__
-#define __APEX_H__
-
-#include <linux/ioctl.h>
-
-/* Clock Gating ioctl. */
-struct apex_gate_clock_ioctl {
- /* Enter or leave clock gated state. */
- u64 enable;
-
- /* If set, enter clock gating state, regardless of custom block's
- * internal idle state
- */
- u64 force_idle;
-};
-
-/* Base number for all Apex-common IOCTLs */
-#define APEX_IOCTL_BASE 0x7F
-
-/* Enable/Disable clock gating. */
-#define APEX_IOCTL_GATE_CLOCK \
- _IOW(APEX_IOCTL_BASE, 0, struct apex_gate_clock_ioctl)
-
-#endif /* __APEX_H__ */
diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c
deleted file mode 100644
index f12f81c8dd2f..000000000000
--- a/drivers/staging/gasket/apex_driver.c
+++ /dev/null
@@ -1,726 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Driver for the Apex chip.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-
-#include <linux/compiler.h>
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/init.h>
-#include <linux/mm.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/pci.h>
-#include <linux/printk.h>
-#include <linux/sched.h>
-#include <linux/uaccess.h>
-
-#include "apex.h"
-
-#include "gasket_core.h"
-#include "gasket_interrupt.h"
-#include "gasket_page_table.h"
-#include "gasket_sysfs.h"
-
-/* Constants */
-#define APEX_DEVICE_NAME "Apex"
-#define APEX_DRIVER_VERSION "1.0"
-
-/* CSRs are in BAR 2. */
-#define APEX_BAR_INDEX 2
-
-#define APEX_PCI_VENDOR_ID 0x1ac1
-#define APEX_PCI_DEVICE_ID 0x089a
-
-/* Bar Offsets. */
-#define APEX_BAR_OFFSET 0
-#define APEX_CM_OFFSET 0x1000000
-
-/* The sizes of each Apex BAR 2. */
-#define APEX_BAR_BYTES 0x100000
-#define APEX_CH_MEM_BYTES (PAGE_SIZE * MAX_NUM_COHERENT_PAGES)
-
-/* The number of user-mappable memory ranges in BAR2 of a Apex chip. */
-#define NUM_REGIONS 3
-
-/* The number of nodes in a Apex chip. */
-#define NUM_NODES 1
-
-/*
- * The total number of entries in the page table. Should match the value read
- * from the register APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_SIZE.
- */
-#define APEX_PAGE_TABLE_TOTAL_ENTRIES 8192
-
-#define APEX_EXTENDED_SHIFT 63 /* Extended address bit position. */
-
-/* Check reset 120 times */
-#define APEX_RESET_RETRY 120
-/* Wait 100 ms between checks. Total 12 sec wait maximum. */
-#define APEX_RESET_DELAY 100
-
-/* Enumeration of the supported sysfs entries. */
-enum sysfs_attribute_type {
- ATTR_KERNEL_HIB_PAGE_TABLE_SIZE,
- ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE,
- ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES,
-};
-
-/*
- * Register offsets into BAR2 memory.
- * Only values necessary for driver implementation are defined.
- */
-enum apex_bar2_regs {
- APEX_BAR2_REG_SCU_BASE = 0x1A300,
- APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_SIZE = 0x46000,
- APEX_BAR2_REG_KERNEL_HIB_EXTENDED_TABLE = 0x46008,
- APEX_BAR2_REG_KERNEL_HIB_TRANSLATION_ENABLE = 0x46010,
- APEX_BAR2_REG_KERNEL_HIB_INSTR_QUEUE_INTVECCTL = 0x46018,
- APEX_BAR2_REG_KERNEL_HIB_INPUT_ACTV_QUEUE_INTVECCTL = 0x46020,
- APEX_BAR2_REG_KERNEL_HIB_PARAM_QUEUE_INTVECCTL = 0x46028,
- APEX_BAR2_REG_KERNEL_HIB_OUTPUT_ACTV_QUEUE_INTVECCTL = 0x46030,
- APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL = 0x46038,
- APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL = 0x46040,
- APEX_BAR2_REG_KERNEL_HIB_FATAL_ERR_INTVECCTL = 0x46048,
- APEX_BAR2_REG_KERNEL_HIB_DMA_PAUSE = 0x46050,
- APEX_BAR2_REG_KERNEL_HIB_DMA_PAUSE_MASK = 0x46058,
- APEX_BAR2_REG_KERNEL_HIB_STATUS_BLOCK_DELAY = 0x46060,
- APEX_BAR2_REG_KERNEL_HIB_MSIX_PENDING_BIT_ARRAY0 = 0x46068,
- APEX_BAR2_REG_KERNEL_HIB_MSIX_PENDING_BIT_ARRAY1 = 0x46070,
- APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_INIT = 0x46078,
- APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE_INIT = 0x46080,
- APEX_BAR2_REG_KERNEL_WIRE_INT_PENDING_BIT_ARRAY = 0x48778,
- APEX_BAR2_REG_KERNEL_WIRE_INT_MASK_ARRAY = 0x48780,
- APEX_BAR2_REG_USER_HIB_DMA_PAUSE = 0x486D8,
- APEX_BAR2_REG_USER_HIB_DMA_PAUSED = 0x486E0,
- APEX_BAR2_REG_IDLEGENERATOR_IDLEGEN_IDLEREGISTER = 0x4A000,
- APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE = 0x50000,
-
- /* Error registers - Used mostly for debug */
- APEX_BAR2_REG_USER_HIB_ERROR_STATUS = 0x86f0,
- APEX_BAR2_REG_SCALAR_CORE_ERROR_STATUS = 0x41a0,
-};
-
-/* Addresses for packed registers. */
-#define APEX_BAR2_REG_AXI_QUIESCE (APEX_BAR2_REG_SCU_BASE + 0x2C)
-#define APEX_BAR2_REG_GCB_CLOCK_GATE (APEX_BAR2_REG_SCU_BASE + 0x14)
-#define APEX_BAR2_REG_SCU_0 (APEX_BAR2_REG_SCU_BASE + 0xc)
-#define APEX_BAR2_REG_SCU_1 (APEX_BAR2_REG_SCU_BASE + 0x10)
-#define APEX_BAR2_REG_SCU_2 (APEX_BAR2_REG_SCU_BASE + 0x14)
-#define APEX_BAR2_REG_SCU_3 (APEX_BAR2_REG_SCU_BASE + 0x18)
-#define APEX_BAR2_REG_SCU_4 (APEX_BAR2_REG_SCU_BASE + 0x1c)
-#define APEX_BAR2_REG_SCU_5 (APEX_BAR2_REG_SCU_BASE + 0x20)
-
-#define SCU3_RG_PWR_STATE_OVR_BIT_OFFSET 26
-#define SCU3_RG_PWR_STATE_OVR_MASK_WIDTH 2
-#define SCU3_CUR_RST_GCB_BIT_MASK 0x10
-#define SCU2_RG_RST_GCB_BIT_MASK 0xc
-
-/* Configuration for page table. */
-static struct gasket_page_table_config apex_page_table_configs[NUM_NODES] = {
- {
- .id = 0,
- .mode = GASKET_PAGE_TABLE_MODE_NORMAL,
- .total_entries = APEX_PAGE_TABLE_TOTAL_ENTRIES,
- .base_reg = APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE,
- .extended_reg = APEX_BAR2_REG_KERNEL_HIB_EXTENDED_TABLE,
- .extended_bit = APEX_EXTENDED_SHIFT,
- },
-};
-
-/* The regions in the BAR2 space that can be mapped into user space. */
-static const struct gasket_mappable_region mappable_regions[NUM_REGIONS] = {
- { 0x40000, 0x1000 },
- { 0x44000, 0x1000 },
- { 0x48000, 0x1000 },
-};
-
-/* Gasket device interrupts enums must be dense (i.e., no empty slots). */
-enum apex_interrupt {
- APEX_INTERRUPT_INSTR_QUEUE = 0,
- APEX_INTERRUPT_INPUT_ACTV_QUEUE = 1,
- APEX_INTERRUPT_PARAM_QUEUE = 2,
- APEX_INTERRUPT_OUTPUT_ACTV_QUEUE = 3,
- APEX_INTERRUPT_SC_HOST_0 = 4,
- APEX_INTERRUPT_SC_HOST_1 = 5,
- APEX_INTERRUPT_SC_HOST_2 = 6,
- APEX_INTERRUPT_SC_HOST_3 = 7,
- APEX_INTERRUPT_TOP_LEVEL_0 = 8,
- APEX_INTERRUPT_TOP_LEVEL_1 = 9,
- APEX_INTERRUPT_TOP_LEVEL_2 = 10,
- APEX_INTERRUPT_TOP_LEVEL_3 = 11,
- APEX_INTERRUPT_FATAL_ERR = 12,
- APEX_INTERRUPT_COUNT = 13,
-};
-
-/* Interrupt descriptors for Apex */
-static struct gasket_interrupt_desc apex_interrupts[] = {
- {
- APEX_INTERRUPT_INSTR_QUEUE,
- APEX_BAR2_REG_KERNEL_HIB_INSTR_QUEUE_INTVECCTL,
- UNPACKED,
- },
- {
- APEX_INTERRUPT_INPUT_ACTV_QUEUE,
- APEX_BAR2_REG_KERNEL_HIB_INPUT_ACTV_QUEUE_INTVECCTL,
- UNPACKED
- },
- {
- APEX_INTERRUPT_PARAM_QUEUE,
- APEX_BAR2_REG_KERNEL_HIB_PARAM_QUEUE_INTVECCTL,
- UNPACKED
- },
- {
- APEX_INTERRUPT_OUTPUT_ACTV_QUEUE,
- APEX_BAR2_REG_KERNEL_HIB_OUTPUT_ACTV_QUEUE_INTVECCTL,
- UNPACKED
- },
- {
- APEX_INTERRUPT_SC_HOST_0,
- APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL,
- PACK_0
- },
- {
- APEX_INTERRUPT_SC_HOST_1,
- APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL,
- PACK_1
- },
- {
- APEX_INTERRUPT_SC_HOST_2,
- APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL,
- PACK_2
- },
- {
- APEX_INTERRUPT_SC_HOST_3,
- APEX_BAR2_REG_KERNEL_HIB_SC_HOST_INTVECCTL,
- PACK_3
- },
- {
- APEX_INTERRUPT_TOP_LEVEL_0,
- APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL,
- PACK_0
- },
- {
- APEX_INTERRUPT_TOP_LEVEL_1,
- APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL,
- PACK_1
- },
- {
- APEX_INTERRUPT_TOP_LEVEL_2,
- APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL,
- PACK_2
- },
- {
- APEX_INTERRUPT_TOP_LEVEL_3,
- APEX_BAR2_REG_KERNEL_HIB_TOP_LEVEL_INTVECCTL,
- PACK_3
- },
- {
- APEX_INTERRUPT_FATAL_ERR,
- APEX_BAR2_REG_KERNEL_HIB_FATAL_ERR_INTVECCTL,
- UNPACKED
- },
-};
-
-/* Allows device to enter power save upon driver close(). */
-static int allow_power_save = 1;
-
-/* Allows SW based clock gating. */
-static int allow_sw_clock_gating;
-
-/* Allows HW based clock gating. */
-/* Note: this is not mutual exclusive with SW clock gating. */
-static int allow_hw_clock_gating = 1;
-
-/* Act as if only GCB is instantiated. */
-static int bypass_top_level;
-
-module_param(allow_power_save, int, 0644);
-module_param(allow_sw_clock_gating, int, 0644);
-module_param(allow_hw_clock_gating, int, 0644);
-module_param(bypass_top_level, int, 0644);
-
-/* Check the device status registers and return device status ALIVE or DEAD. */
-static int apex_get_status(struct gasket_dev *gasket_dev)
-{
- /* TODO: Check device status. */
- return GASKET_STATUS_ALIVE;
-}
-
-/* Enter GCB reset state. */
-static int apex_enter_reset(struct gasket_dev *gasket_dev)
-{
- if (bypass_top_level)
- return 0;
-
- /*
- * Software reset:
- * Enable sleep mode
- * - Software force GCB idle
- * - Enable GCB idle
- */
- gasket_read_modify_write_64(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_IDLEGENERATOR_IDLEGEN_IDLEREGISTER,
- 0x0, 1, 32);
-
- /* - Initiate DMA pause */
- gasket_dev_write_64(gasket_dev, 1, APEX_BAR_INDEX,
- APEX_BAR2_REG_USER_HIB_DMA_PAUSE);
-
- /* - Wait for DMA pause complete. */
- if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_USER_HIB_DMA_PAUSED, 1, 1,
- APEX_RESET_DELAY, APEX_RESET_RETRY)) {
- dev_err(gasket_dev->dev,
- "DMAs did not quiesce within timeout (%d ms)\n",
- APEX_RESET_RETRY * APEX_RESET_DELAY);
- return -ETIMEDOUT;
- }
-
- /* - Enable GCB reset (0x1 to rg_rst_gcb) */
- gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_2, 0x1, 2, 2);
-
- /* - Enable GCB clock Gate (0x1 to rg_gated_gcb) */
- gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_2, 0x1, 2, 18);
-
- /* - Enable GCB memory shut down (0x3 to rg_force_ram_sd) */
- gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_3, 0x3, 2, 14);
-
- /* - Wait for RAM shutdown. */
- if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_3, BIT(6), BIT(6),
- APEX_RESET_DELAY, APEX_RESET_RETRY)) {
- dev_err(gasket_dev->dev,
- "RAM did not shut down within timeout (%d ms)\n",
- APEX_RESET_RETRY * APEX_RESET_DELAY);
- return -ETIMEDOUT;
- }
-
- return 0;
-}
-
-/* Quit GCB reset state. */
-static int apex_quit_reset(struct gasket_dev *gasket_dev)
-{
- u32 val0, val1;
-
- if (bypass_top_level)
- return 0;
-
- /*
- * Disable sleep mode:
- * - Disable GCB memory shut down:
- * - b00: Not forced (HW controlled)
- * - b1x: Force disable
- */
- gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_3, 0x0, 2, 14);
-
- /*
- * - Disable software clock gate:
- * - b00: Not forced (HW controlled)
- * - b1x: Force disable
- */
- gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_2, 0x0, 2, 18);
-
- /*
- * - Disable GCB reset (rg_rst_gcb):
- * - b00: Not forced (HW controlled)
- * - b1x: Force disable = Force not Reset
- */
- gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_2, 0x2, 2, 2);
-
- /* - Wait for RAM enable. */
- if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_3, BIT(6), 0,
- APEX_RESET_DELAY, APEX_RESET_RETRY)) {
- dev_err(gasket_dev->dev,
- "RAM did not enable within timeout (%d ms)\n",
- APEX_RESET_RETRY * APEX_RESET_DELAY);
- return -ETIMEDOUT;
- }
-
- /* - Wait for Reset complete. */
- if (gasket_wait_with_reschedule(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_3,
- SCU3_CUR_RST_GCB_BIT_MASK, 0,
- APEX_RESET_DELAY, APEX_RESET_RETRY)) {
- dev_err(gasket_dev->dev,
- "GCB did not leave reset within timeout (%d ms)\n",
- APEX_RESET_RETRY * APEX_RESET_DELAY);
- return -ETIMEDOUT;
- }
-
- if (!allow_hw_clock_gating) {
- val0 = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_3);
- /* Inactive and Sleep mode are disabled. */
- gasket_read_modify_write_32(gasket_dev,
- APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_3, 0x3,
- SCU3_RG_PWR_STATE_OVR_MASK_WIDTH,
- SCU3_RG_PWR_STATE_OVR_BIT_OFFSET);
- val1 = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_3);
- dev_dbg(gasket_dev->dev,
- "Disallow HW clock gating 0x%x -> 0x%x\n", val0, val1);
- } else {
- val0 = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_3);
- /* Inactive mode enabled - Sleep mode disabled. */
- gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_3, 2,
- SCU3_RG_PWR_STATE_OVR_MASK_WIDTH,
- SCU3_RG_PWR_STATE_OVR_BIT_OFFSET);
- val1 = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_3);
- dev_dbg(gasket_dev->dev, "Allow HW clock gating 0x%x -> 0x%x\n",
- val0, val1);
- }
-
- return 0;
-}
-
-/* Reset the Apex hardware. Called on final close via device_close_cb. */
-static int apex_device_cleanup(struct gasket_dev *gasket_dev)
-{
- u64 scalar_error;
- u64 hib_error;
- int ret = 0;
-
- hib_error = gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_USER_HIB_ERROR_STATUS);
- scalar_error = gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCALAR_CORE_ERROR_STATUS);
-
- dev_dbg(gasket_dev->dev,
- "%s 0x%p hib_error 0x%llx scalar_error 0x%llx\n",
- __func__, gasket_dev, hib_error, scalar_error);
-
- if (allow_power_save)
- ret = apex_enter_reset(gasket_dev);
-
- return ret;
-}
-
-/* Determine if GCB is in reset state. */
-static bool is_gcb_in_reset(struct gasket_dev *gasket_dev)
-{
- u32 val = gasket_dev_read_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_SCU_3);
-
- /* Masks rg_rst_gcb bit of SCU_CTRL_2 */
- return (val & SCU3_CUR_RST_GCB_BIT_MASK);
-}
-
-/* Reset the hardware, then quit reset. Called on device open. */
-static int apex_reset(struct gasket_dev *gasket_dev)
-{
- int ret;
-
- if (bypass_top_level)
- return 0;
-
- if (!is_gcb_in_reset(gasket_dev)) {
- /* We are not in reset - toggle the reset bit so as to force
- * re-init of custom block
- */
- dev_dbg(gasket_dev->dev, "%s: toggle reset\n", __func__);
-
- ret = apex_enter_reset(gasket_dev);
- if (ret)
- return ret;
- }
- return apex_quit_reset(gasket_dev);
-}
-
-/*
- * Check permissions for Apex ioctls.
- * Returns true if the current user may execute this ioctl, and false otherwise.
- */
-static bool apex_ioctl_check_permissions(struct file *filp, uint cmd)
-{
- return !!(filp->f_mode & FMODE_WRITE);
-}
-
-/* Gates or un-gates Apex clock. */
-static long apex_clock_gating(struct gasket_dev *gasket_dev,
- struct apex_gate_clock_ioctl __user *argp)
-{
- struct apex_gate_clock_ioctl ibuf;
-
- if (bypass_top_level || !allow_sw_clock_gating)
- return 0;
-
- if (copy_from_user(&ibuf, argp, sizeof(ibuf)))
- return -EFAULT;
-
- dev_dbg(gasket_dev->dev, "%s %llu\n", __func__, ibuf.enable);
-
- if (ibuf.enable) {
- /* Quiesce AXI, gate GCB clock. */
- gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_AXI_QUIESCE, 0x1, 1,
- 16);
- gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_GCB_CLOCK_GATE, 0x1,
- 2, 18);
- } else {
- /* Un-gate GCB clock, un-quiesce AXI. */
- gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_GCB_CLOCK_GATE, 0x0,
- 2, 18);
- gasket_read_modify_write_32(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_AXI_QUIESCE, 0x0, 1,
- 16);
- }
- return 0;
-}
-
-/* Apex-specific ioctl handler. */
-static long apex_ioctl(struct file *filp, uint cmd, void __user *argp)
-{
- struct gasket_dev *gasket_dev = filp->private_data;
-
- if (!apex_ioctl_check_permissions(filp, cmd))
- return -EPERM;
-
- switch (cmd) {
- case APEX_IOCTL_GATE_CLOCK:
- return apex_clock_gating(gasket_dev, argp);
- default:
- return -ENOTTY; /* unknown command */
- }
-}
-
-/* Display driver sysfs entries. */
-static ssize_t sysfs_show(struct device *device, struct device_attribute *attr,
- char *buf)
-{
- int ret;
- struct gasket_dev *gasket_dev;
- struct gasket_sysfs_attribute *gasket_attr;
- enum sysfs_attribute_type type;
- struct gasket_page_table *gpt;
- uint val;
-
- gasket_dev = gasket_sysfs_get_device_data(device);
- if (!gasket_dev) {
- dev_err(device, "No Apex device sysfs mapping found\n");
- return -ENODEV;
- }
-
- gasket_attr = gasket_sysfs_get_attr(device, attr);
- if (!gasket_attr) {
- dev_err(device, "No Apex device sysfs attr data found\n");
- gasket_sysfs_put_device_data(device, gasket_dev);
- return -ENODEV;
- }
-
- type = (enum sysfs_attribute_type)gasket_attr->data.attr_type;
- gpt = gasket_dev->page_table[0];
- switch (type) {
- case ATTR_KERNEL_HIB_PAGE_TABLE_SIZE:
- val = gasket_page_table_num_entries(gpt);
- break;
- case ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE:
- val = gasket_page_table_num_simple_entries(gpt);
- break;
- case ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES:
- val = gasket_page_table_num_active_pages(gpt);
- break;
- default:
- dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n",
- attr->attr.name);
- ret = 0;
- goto exit;
- }
- ret = scnprintf(buf, PAGE_SIZE, "%u\n", val);
-exit:
- gasket_sysfs_put_attr(device, gasket_attr);
- gasket_sysfs_put_device_data(device, gasket_dev);
- return ret;
-}
-
-static struct gasket_sysfs_attribute apex_sysfs_attrs[] = {
- GASKET_SYSFS_RO(node_0_page_table_entries, sysfs_show,
- ATTR_KERNEL_HIB_PAGE_TABLE_SIZE),
- GASKET_SYSFS_RO(node_0_simple_page_table_entries, sysfs_show,
- ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE),
- GASKET_SYSFS_RO(node_0_num_mapped_pages, sysfs_show,
- ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES),
- GASKET_END_OF_ATTR_ARRAY
-};
-
-/* On device open, perform a core reinit reset. */
-static int apex_device_open_cb(struct gasket_dev *gasket_dev)
-{
- return gasket_reset_nolock(gasket_dev);
-}
-
-static const struct pci_device_id apex_pci_ids[] = {
- { PCI_DEVICE(APEX_PCI_VENDOR_ID, APEX_PCI_DEVICE_ID) }, { 0 }
-};
-
-static int apex_pci_probe(struct pci_dev *pci_dev,
- const struct pci_device_id *id)
-{
- int ret;
- ulong page_table_ready, msix_table_ready;
- int retries = 0;
- struct gasket_dev *gasket_dev;
-
- ret = pci_enable_device(pci_dev);
- if (ret) {
- dev_err(&pci_dev->dev, "error enabling PCI device\n");
- return ret;
- }
-
- pci_set_master(pci_dev);
-
- ret = gasket_pci_add_device(pci_dev, &gasket_dev);
- if (ret) {
- dev_err(&pci_dev->dev, "error adding gasket device\n");
- pci_disable_device(pci_dev);
- return ret;
- }
-
- pci_set_drvdata(pci_dev, gasket_dev);
- apex_reset(gasket_dev);
-
- while (retries < APEX_RESET_RETRY) {
- page_table_ready =
- gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_KERNEL_HIB_PAGE_TABLE_INIT);
- msix_table_ready =
- gasket_dev_read_64(gasket_dev, APEX_BAR_INDEX,
- APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE_INIT);
- if (page_table_ready && msix_table_ready)
- break;
- schedule_timeout(msecs_to_jiffies(APEX_RESET_DELAY));
- retries++;
- }
-
- if (retries == APEX_RESET_RETRY) {
- if (!page_table_ready)
- dev_err(gasket_dev->dev, "Page table init timed out\n");
- if (!msix_table_ready)
- dev_err(gasket_dev->dev, "MSI-X table init timed out\n");
- ret = -ETIMEDOUT;
- goto remove_device;
- }
-
- ret = gasket_sysfs_create_entries(gasket_dev->dev_info.device,
- apex_sysfs_attrs);
- if (ret)
- dev_err(&pci_dev->dev, "error creating device sysfs entries\n");
-
- ret = gasket_enable_device(gasket_dev);
- if (ret) {
- dev_err(&pci_dev->dev, "error enabling gasket device\n");
- goto remove_device;
- }
-
- /* Place device in low power mode until opened */
- if (allow_power_save)
- apex_enter_reset(gasket_dev);
-
- return 0;
-
-remove_device:
- gasket_pci_remove_device(pci_dev);
- pci_disable_device(pci_dev);
- return ret;
-}
-
-static void apex_pci_remove(struct pci_dev *pci_dev)
-{
- struct gasket_dev *gasket_dev = pci_get_drvdata(pci_dev);
-
- gasket_disable_device(gasket_dev);
- gasket_pci_remove_device(pci_dev);
- pci_disable_device(pci_dev);
-}
-
-static const struct gasket_driver_desc apex_desc = {
- .name = "apex",
- .driver_version = APEX_DRIVER_VERSION,
- .major = 120,
- .minor = 0,
- .module = THIS_MODULE,
- .pci_id_table = apex_pci_ids,
-
- .num_page_tables = NUM_NODES,
- .page_table_bar_index = APEX_BAR_INDEX,
- .page_table_configs = apex_page_table_configs,
- .page_table_extended_bit = APEX_EXTENDED_SHIFT,
-
- .bar_descriptions = {
- GASKET_UNUSED_BAR,
- GASKET_UNUSED_BAR,
- { APEX_BAR_BYTES, (VM_WRITE | VM_READ), APEX_BAR_OFFSET,
- NUM_REGIONS, mappable_regions, PCI_BAR },
- GASKET_UNUSED_BAR,
- GASKET_UNUSED_BAR,
- GASKET_UNUSED_BAR,
- },
- .coherent_buffer_description = {
- APEX_CH_MEM_BYTES,
- (VM_WRITE | VM_READ),
- APEX_CM_OFFSET,
- },
- .interrupt_type = PCI_MSIX,
- .interrupt_bar_index = APEX_BAR_INDEX,
- .num_interrupts = APEX_INTERRUPT_COUNT,
- .interrupts = apex_interrupts,
- .interrupt_pack_width = 7,
-
- .device_open_cb = apex_device_open_cb,
- .device_close_cb = apex_device_cleanup,
-
- .ioctl_handler_cb = apex_ioctl,
- .device_status_cb = apex_get_status,
- .hardware_revision_cb = NULL,
- .device_reset_cb = apex_reset,
-};
-
-static struct pci_driver apex_pci_driver = {
- .name = "apex",
- .probe = apex_pci_probe,
- .remove = apex_pci_remove,
- .id_table = apex_pci_ids,
-};
-
-static int __init apex_init(void)
-{
- int ret;
-
- ret = gasket_register_device(&apex_desc);
- if (ret)
- return ret;
- ret = pci_register_driver(&apex_pci_driver);
- if (ret)
- gasket_unregister_device(&apex_desc);
- return ret;
-}
-
-static void apex_exit(void)
-{
- pci_unregister_driver(&apex_pci_driver);
- gasket_unregister_device(&apex_desc);
-}
-MODULE_DESCRIPTION("Google Apex driver");
-MODULE_VERSION(APEX_DRIVER_VERSION);
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("John Joseph <jnjoseph@google.com>");
-MODULE_DEVICE_TABLE(pci, apex_pci_ids);
-module_init(apex_init);
-module_exit(apex_exit);
diff --git a/drivers/staging/gasket/gasket.h b/drivers/staging/gasket/gasket.h
deleted file mode 100644
index a0f065c517a5..000000000000
--- a/drivers/staging/gasket/gasket.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Common Gasket device kernel and user space declarations.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-#ifndef __GASKET_H__
-#define __GASKET_H__
-
-#include <linux/ioctl.h>
-#include <linux/types.h>
-
-/* ioctl structure declarations */
-
-/* Ioctl structures are padded to a multiple of 64 bits */
-/* and padded to put 64 bit values on 64 bit boundaries. */
-/* Unsigned 64 bit integers are used to hold pointers. */
-/* This helps compatibility between 32 and 64 bits. */
-
-/*
- * Common structure for ioctls associating an eventfd with a device interrupt,
- * when using the Gasket interrupt module.
- */
-struct gasket_interrupt_eventfd {
- u64 interrupt;
- u64 event_fd;
-};
-
-/*
- * Common structure for ioctls mapping and unmapping buffers when using the
- * Gasket page_table module.
- */
-struct gasket_page_table_ioctl {
- u64 page_table_index;
- u64 size;
- u64 host_address;
- u64 device_address;
-};
-
-/*
- * Common structure for ioctls mapping and unmapping buffers when using the
- * Gasket page_table module.
- * dma_address: phys addr start of coherent memory, allocated by kernel
- */
-struct gasket_coherent_alloc_config_ioctl {
- u64 page_table_index;
- u64 enable;
- u64 size;
- u64 dma_address;
-};
-
-/* Base number for all Gasket-common IOCTLs */
-#define GASKET_IOCTL_BASE 0xDC
-
-/* Reset the device. */
-#define GASKET_IOCTL_RESET _IO(GASKET_IOCTL_BASE, 0)
-
-/* Associate the specified [event]fd with the specified interrupt. */
-#define GASKET_IOCTL_SET_EVENTFD \
- _IOW(GASKET_IOCTL_BASE, 1, struct gasket_interrupt_eventfd)
-
-/*
- * Clears any eventfd associated with the specified interrupt. The (ulong)
- * argument is the interrupt number to clear.
- */
-#define GASKET_IOCTL_CLEAR_EVENTFD _IOW(GASKET_IOCTL_BASE, 2, unsigned long)
-
-/*
- * [Loopbacks only] Requests that the loopback device send the specified
- * interrupt to the host. The (ulong) argument is the number of the interrupt to
- * send.
- */
-#define GASKET_IOCTL_LOOPBACK_INTERRUPT \
- _IOW(GASKET_IOCTL_BASE, 3, unsigned long)
-
-/* Queries the kernel for the number of page tables supported by the device. */
-#define GASKET_IOCTL_NUMBER_PAGE_TABLES _IOR(GASKET_IOCTL_BASE, 4, u64)
-
-/*
- * Queries the kernel for the maximum size of the page table. Only the size and
- * page_table_index fields are used from the struct gasket_page_table_ioctl.
- */
-#define GASKET_IOCTL_PAGE_TABLE_SIZE \
- _IOWR(GASKET_IOCTL_BASE, 5, struct gasket_page_table_ioctl)
-
-/*
- * Queries the kernel for the current simple page table size. Only the size and
- * page_table_index fields are used from the struct gasket_page_table_ioctl.
- */
-#define GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE \
- _IOWR(GASKET_IOCTL_BASE, 6, struct gasket_page_table_ioctl)
-
-/*
- * Tells the kernel to change the split between the number of simple and
- * extended entries in the given page table. Only the size and page_table_index
- * fields are used from the struct gasket_page_table_ioctl.
- */
-#define GASKET_IOCTL_PARTITION_PAGE_TABLE \
- _IOW(GASKET_IOCTL_BASE, 7, struct gasket_page_table_ioctl)
-
-/*
- * Tells the kernel to map size bytes at host_address to device_address in
- * page_table_index page table.
- */
-#define GASKET_IOCTL_MAP_BUFFER \
- _IOW(GASKET_IOCTL_BASE, 8, struct gasket_page_table_ioctl)
-
-/*
- * Tells the kernel to unmap size bytes at host_address from device_address in
- * page_table_index page table.
- */
-#define GASKET_IOCTL_UNMAP_BUFFER \
- _IOW(GASKET_IOCTL_BASE, 9, struct gasket_page_table_ioctl)
-
-/* Clear the interrupt counts stored for this device. */
-#define GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS _IO(GASKET_IOCTL_BASE, 10)
-
-/* Enable/Disable and configure the coherent allocator. */
-#define GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR \
- _IOWR(GASKET_IOCTL_BASE, 11, struct gasket_coherent_alloc_config_ioctl)
-
-#endif /* __GASKET_H__ */
diff --git a/drivers/staging/gasket/gasket_constants.h b/drivers/staging/gasket/gasket_constants.h
deleted file mode 100644
index 9ea9c8833f27..000000000000
--- a/drivers/staging/gasket/gasket_constants.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright (C) 2018 Google, Inc. */
-#ifndef __GASKET_CONSTANTS_H__
-#define __GASKET_CONSTANTS_H__
-
-#define GASKET_FRAMEWORK_VERSION "1.1.2"
-
-/*
- * The maximum number of simultaneous device types supported by the framework.
- */
-#define GASKET_FRAMEWORK_DESC_MAX 2
-
-/* The maximum devices per each type. */
-#define GASKET_DEV_MAX 256
-
-/* The number of supported Gasket page tables per device. */
-#define GASKET_MAX_NUM_PAGE_TABLES 1
-
-/* Maximum length of device names (driver name + minor number suffix + NULL). */
-#define GASKET_NAME_MAX 32
-
-/* Device status enumeration. */
-enum gasket_status {
- /*
- * A device is DEAD if it has not been initialized or has had an error.
- */
- GASKET_STATUS_DEAD = 0,
- /*
- * A device is LAMED if the hardware is healthy but the kernel was
- * unable to enable some functionality (e.g. interrupts).
- */
- GASKET_STATUS_LAMED,
-
- /* A device is ALIVE if it is ready for operation. */
- GASKET_STATUS_ALIVE,
-
- /*
- * This status is set when the driver is exiting and waiting for all
- * handles to be closed.
- */
- GASKET_STATUS_DRIVER_EXIT,
-};
-
-#endif
diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c
deleted file mode 100644
index 28dab302183b..000000000000
--- a/drivers/staging/gasket/gasket_core.c
+++ /dev/null
@@ -1,1815 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Gasket generic driver framework. This file contains the implementation
- * for the Gasket generic driver framework - the functionality that is common
- * across Gasket devices.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include "gasket_core.h"
-
-#include "gasket_interrupt.h"
-#include "gasket_ioctl.h"
-#include "gasket_page_table.h"
-#include "gasket_sysfs.h"
-
-#include <linux/capability.h>
-#include <linux/compiler.h>
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/init.h>
-#include <linux/of.h>
-#include <linux/pid_namespace.h>
-#include <linux/printk.h>
-#include <linux/sched.h>
-
-#ifdef GASKET_KERNEL_TRACE_SUPPORT
-#define CREATE_TRACE_POINTS
-#include <trace/events/gasket_mmap.h>
-#else
-#define trace_gasket_mmap_exit(x)
-#define trace_gasket_mmap_entry(x, ...)
-#endif
-
-/*
- * "Private" members of gasket_driver_desc.
- *
- * Contains internal per-device type tracking data, i.e., data not appropriate
- * as part of the public interface for the generic framework.
- */
-struct gasket_internal_desc {
- /* Device-specific-driver-provided configuration information. */
- const struct gasket_driver_desc *driver_desc;
-
- /* Protects access to per-driver data (i.e. this structure). */
- struct mutex mutex;
-
- /* Kernel-internal device class. */
- struct class *class;
-
- /* Instantiated / present devices of this type. */
- struct gasket_dev *devs[GASKET_DEV_MAX];
-};
-
-/* do_map_region() needs be able to return more than just true/false. */
-enum do_map_region_status {
- /* The region was successfully mapped. */
- DO_MAP_REGION_SUCCESS,
-
- /* Attempted to map region and failed. */
- DO_MAP_REGION_FAILURE,
-
- /* The requested region to map was not part of a mappable region. */
- DO_MAP_REGION_INVALID,
-};
-
-/* Global data definitions. */
-/* Mutex - only for framework-wide data. Other data should be protected by
- * finer-grained locks.
- */
-static DEFINE_MUTEX(g_mutex);
-
-/* List of all registered device descriptions & their supporting data. */
-static struct gasket_internal_desc g_descs[GASKET_FRAMEWORK_DESC_MAX];
-
-/* Mapping of statuses to human-readable strings. Must end with {0,NULL}. */
-static const struct gasket_num_name gasket_status_name_table[] = {
- { GASKET_STATUS_DEAD, "DEAD" },
- { GASKET_STATUS_ALIVE, "ALIVE" },
- { GASKET_STATUS_LAMED, "LAMED" },
- { GASKET_STATUS_DRIVER_EXIT, "DRIVER_EXITING" },
- { 0, NULL },
-};
-
-/* Enumeration of the automatic Gasket framework sysfs nodes. */
-enum gasket_sysfs_attribute_type {
- ATTR_BAR_OFFSETS,
- ATTR_BAR_SIZES,
- ATTR_DRIVER_VERSION,
- ATTR_FRAMEWORK_VERSION,
- ATTR_DEVICE_TYPE,
- ATTR_HARDWARE_REVISION,
- ATTR_PCI_ADDRESS,
- ATTR_STATUS,
- ATTR_IS_DEVICE_OWNED,
- ATTR_DEVICE_OWNER,
- ATTR_WRITE_OPEN_COUNT,
- ATTR_RESET_COUNT,
- ATTR_USER_MEM_RANGES
-};
-
-/* Perform a standard Gasket callback. */
-static inline int
-check_and_invoke_callback(struct gasket_dev *gasket_dev,
- int (*cb_function)(struct gasket_dev *))
-{
- int ret = 0;
-
- if (cb_function) {
- mutex_lock(&gasket_dev->mutex);
- ret = cb_function(gasket_dev);
- mutex_unlock(&gasket_dev->mutex);
- }
- return ret;
-}
-
-/* Perform a standard Gasket callback without grabbing gasket_dev->mutex. */
-static inline int
-gasket_check_and_invoke_callback_nolock(struct gasket_dev *gasket_dev,
- int (*cb_function)(struct gasket_dev *))
-{
- int ret = 0;
-
- if (cb_function)
- ret = cb_function(gasket_dev);
- return ret;
-}
-
-/*
- * Return nonzero if the gasket_cdev_info is owned by the current thread group
- * ID.
- */
-static int gasket_owned_by_current_tgid(struct gasket_cdev_info *info)
-{
- return (info->ownership.is_owned &&
- (info->ownership.owner == current->tgid));
-}
-
-/*
- * Find the next free gasket_internal_dev slot.
- *
- * Returns the located slot number on success or a negative number on failure.
- */
-static int gasket_find_dev_slot(struct gasket_internal_desc *internal_desc,
- const char *kobj_name)
-{
- int i;
-
- mutex_lock(&internal_desc->mutex);
-
- /* Search for a previous instance of this device. */
- for (i = 0; i < GASKET_DEV_MAX; i++) {
- if (internal_desc->devs[i] &&
- strcmp(internal_desc->devs[i]->kobj_name, kobj_name) == 0) {
- pr_err("Duplicate device %s\n", kobj_name);
- mutex_unlock(&internal_desc->mutex);
- return -EBUSY;
- }
- }
-
- /* Find a free device slot. */
- for (i = 0; i < GASKET_DEV_MAX; i++) {
- if (!internal_desc->devs[i])
- break;
- }
-
- if (i == GASKET_DEV_MAX) {
- pr_err("Too many registered devices; max %d\n", GASKET_DEV_MAX);
- mutex_unlock(&internal_desc->mutex);
- return -EBUSY;
- }
-
- mutex_unlock(&internal_desc->mutex);
- return i;
-}
-
-/*
- * Allocate and initialize a Gasket device structure, add the device to the
- * device list.
- *
- * Returns 0 if successful, a negative error code otherwise.
- */
-static int gasket_alloc_dev(struct gasket_internal_desc *internal_desc,
- struct device *parent, struct gasket_dev **pdev)
-{
- int dev_idx;
- const struct gasket_driver_desc *driver_desc =
- internal_desc->driver_desc;
- struct gasket_dev *gasket_dev;
- struct gasket_cdev_info *dev_info;
- const char *parent_name = dev_name(parent);
-
- pr_debug("Allocating a Gasket device, parent %s.\n", parent_name);
-
- *pdev = NULL;
-
- dev_idx = gasket_find_dev_slot(internal_desc, parent_name);
- if (dev_idx < 0)
- return dev_idx;
-
- gasket_dev = *pdev = kzalloc(sizeof(*gasket_dev), GFP_KERNEL);
- if (!gasket_dev) {
- pr_err("no memory for device, parent %s\n", parent_name);
- return -ENOMEM;
- }
- internal_desc->devs[dev_idx] = gasket_dev;
-
- mutex_init(&gasket_dev->mutex);
-
- gasket_dev->internal_desc = internal_desc;
- gasket_dev->dev_idx = dev_idx;
- snprintf(gasket_dev->kobj_name, GASKET_NAME_MAX, "%s", parent_name);
- gasket_dev->dev = get_device(parent);
- /* gasket_bar_data is uninitialized. */
- gasket_dev->num_page_tables = driver_desc->num_page_tables;
- /* max_page_table_size and *page table are uninit'ed */
- /* interrupt_data is not initialized. */
- /* status is 0, or GASKET_STATUS_DEAD */
-
- dev_info = &gasket_dev->dev_info;
- snprintf(dev_info->name, GASKET_NAME_MAX, "%s_%u", driver_desc->name,
- gasket_dev->dev_idx);
- dev_info->devt =
- MKDEV(driver_desc->major, driver_desc->minor +
- gasket_dev->dev_idx);
- dev_info->device =
- device_create(internal_desc->class, parent, dev_info->devt,
- gasket_dev, dev_info->name);
-
- /* cdev has not yet been added; cdev_added is 0 */
- dev_info->gasket_dev_ptr = gasket_dev;
- /* ownership is all 0, indicating no owner or opens. */
-
- return 0;
-}
-
-/* Free a Gasket device. */
-static void gasket_free_dev(struct gasket_dev *gasket_dev)
-{
- struct gasket_internal_desc *internal_desc = gasket_dev->internal_desc;
-
- mutex_lock(&internal_desc->mutex);
- internal_desc->devs[gasket_dev->dev_idx] = NULL;
- mutex_unlock(&internal_desc->mutex);
- put_device(gasket_dev->dev);
- kfree(gasket_dev);
-}
-
-/*
- * Maps the specified bar into kernel space.
- *
- * Returns 0 on success, a negative error code otherwise.
- * A zero-sized BAR will not be mapped, but is not an error.
- */
-static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num)
-{
- struct gasket_internal_desc *internal_desc = gasket_dev->internal_desc;
- const struct gasket_driver_desc *driver_desc =
- internal_desc->driver_desc;
- ulong desc_bytes = driver_desc->bar_descriptions[bar_num].size;
- struct gasket_bar_data *data;
- int ret;
-
- if (desc_bytes == 0)
- return 0;
-
- if (driver_desc->bar_descriptions[bar_num].type != PCI_BAR) {
- /* not PCI: skip this entry */
- return 0;
- }
-
- data = &gasket_dev->bar_data[bar_num];
-
- /*
- * pci_resource_start and pci_resource_len return a "resource_size_t",
- * which is safely castable to ulong (which itself is the arg to
- * request_mem_region).
- */
- data->phys_base =
- (ulong)pci_resource_start(gasket_dev->pci_dev, bar_num);
- if (!data->phys_base) {
- dev_err(gasket_dev->dev, "Cannot get BAR%u base address\n",
- bar_num);
- return -EINVAL;
- }
-
- data->length_bytes =
- (ulong)pci_resource_len(gasket_dev->pci_dev, bar_num);
- if (data->length_bytes < desc_bytes) {
- dev_err(gasket_dev->dev,
- "PCI BAR %u space is too small: %lu; expected >= %lu\n",
- bar_num, data->length_bytes, desc_bytes);
- return -ENOMEM;
- }
-
- if (!request_mem_region(data->phys_base, data->length_bytes,
- gasket_dev->dev_info.name)) {
- dev_err(gasket_dev->dev,
- "Cannot get BAR %d memory region %p\n",
- bar_num, &gasket_dev->pci_dev->resource[bar_num]);
- return -EINVAL;
- }
-
- data->virt_base = ioremap(data->phys_base, data->length_bytes);
- if (!data->virt_base) {
- dev_err(gasket_dev->dev,
- "Cannot remap BAR %d memory region %p\n",
- bar_num, &gasket_dev->pci_dev->resource[bar_num]);
- ret = -ENOMEM;
- goto fail;
- }
-
- dma_set_mask(&gasket_dev->pci_dev->dev, DMA_BIT_MASK(64));
- dma_set_coherent_mask(&gasket_dev->pci_dev->dev, DMA_BIT_MASK(64));
-
- return 0;
-
-fail:
- iounmap(data->virt_base);
- release_mem_region(data->phys_base, data->length_bytes);
- return ret;
-}
-
-/*
- * Releases PCI BAR mapping.
- *
- * A zero-sized or not-mapped BAR will not be unmapped, but is not an error.
- */
-static void gasket_unmap_pci_bar(struct gasket_dev *dev, int bar_num)
-{
- ulong base, bytes;
- struct gasket_internal_desc *internal_desc = dev->internal_desc;
- const struct gasket_driver_desc *driver_desc =
- internal_desc->driver_desc;
-
- if (driver_desc->bar_descriptions[bar_num].size == 0 ||
- !dev->bar_data[bar_num].virt_base)
- return;
-
- if (driver_desc->bar_descriptions[bar_num].type != PCI_BAR)
- return;
-
- iounmap(dev->bar_data[bar_num].virt_base);
- dev->bar_data[bar_num].virt_base = NULL;
-
- base = pci_resource_start(dev->pci_dev, bar_num);
- if (!base) {
- dev_err(dev->dev, "cannot get PCI BAR%u base address\n",
- bar_num);
- return;
- }
-
- bytes = pci_resource_len(dev->pci_dev, bar_num);
- release_mem_region(base, bytes);
-}
-
-/*
- * Setup PCI memory mapping for the specified device.
- *
- * Reads the BAR registers and sets up pointers to the device's memory mapped
- * IO space.
- *
- * Returns 0 on success and a negative value otherwise.
- */
-static int gasket_setup_pci(struct pci_dev *pci_dev,
- struct gasket_dev *gasket_dev)
-{
- int i, mapped_bars, ret;
-
- for (i = 0; i < PCI_STD_NUM_BARS; i++) {
- ret = gasket_map_pci_bar(gasket_dev, i);
- if (ret) {
- mapped_bars = i;
- goto fail;
- }
- }
-
- return 0;
-
-fail:
- for (i = 0; i < mapped_bars; i++)
- gasket_unmap_pci_bar(gasket_dev, i);
-
- return -ENOMEM;
-}
-
-/* Unmaps memory for the specified device. */
-static void gasket_cleanup_pci(struct gasket_dev *gasket_dev)
-{
- int i;
-
- for (i = 0; i < PCI_STD_NUM_BARS; i++)
- gasket_unmap_pci_bar(gasket_dev, i);
-}
-
-/* Determine the health of the Gasket device. */
-static int gasket_get_hw_status(struct gasket_dev *gasket_dev)
-{
- int status;
- int i;
- const struct gasket_driver_desc *driver_desc =
- gasket_dev->internal_desc->driver_desc;
-
- status = gasket_check_and_invoke_callback_nolock(gasket_dev,
- driver_desc->device_status_cb);
- if (status != GASKET_STATUS_ALIVE) {
- dev_dbg(gasket_dev->dev, "Hardware reported status %d.\n",
- status);
- return status;
- }
-
- status = gasket_interrupt_system_status(gasket_dev);
- if (status != GASKET_STATUS_ALIVE) {
- dev_dbg(gasket_dev->dev,
- "Interrupt system reported status %d.\n", status);
- return status;
- }
-
- for (i = 0; i < driver_desc->num_page_tables; ++i) {
- status = gasket_page_table_system_status(gasket_dev->page_table[i]);
- if (status != GASKET_STATUS_ALIVE) {
- dev_dbg(gasket_dev->dev,
- "Page table %d reported status %d.\n",
- i, status);
- return status;
- }
- }
-
- return GASKET_STATUS_ALIVE;
-}
-
-static ssize_t
-gasket_write_mappable_regions(char *buf,
- const struct gasket_driver_desc *driver_desc,
- int bar_index)
-{
- int i;
- ssize_t written;
- ssize_t total_written = 0;
- ulong min_addr, max_addr;
- struct gasket_bar_desc bar_desc =
- driver_desc->bar_descriptions[bar_index];
-
- if (bar_desc.permissions == GASKET_NOMAP)
- return 0;
- for (i = 0;
- i < bar_desc.num_mappable_regions && total_written < PAGE_SIZE;
- i++) {
- min_addr = bar_desc.mappable_regions[i].start -
- driver_desc->legacy_mmap_address_offset;
- max_addr = bar_desc.mappable_regions[i].start -
- driver_desc->legacy_mmap_address_offset +
- bar_desc.mappable_regions[i].length_bytes;
- written = scnprintf(buf, PAGE_SIZE - total_written,
- "0x%08lx-0x%08lx\n", min_addr, max_addr);
- total_written += written;
- buf += written;
- }
- return total_written;
-}
-
-static ssize_t gasket_sysfs_data_show(struct device *device,
- struct device_attribute *attr, char *buf)
-{
- int i, ret = 0;
- ssize_t current_written = 0;
- const struct gasket_driver_desc *driver_desc;
- struct gasket_dev *gasket_dev;
- struct gasket_sysfs_attribute *gasket_attr;
- const struct gasket_bar_desc *bar_desc;
- enum gasket_sysfs_attribute_type sysfs_type;
-
- gasket_dev = gasket_sysfs_get_device_data(device);
- if (!gasket_dev) {
- dev_err(device, "No sysfs mapping found for device\n");
- return 0;
- }
-
- gasket_attr = gasket_sysfs_get_attr(device, attr);
- if (!gasket_attr) {
- dev_err(device, "No sysfs attr found for device\n");
- gasket_sysfs_put_device_data(device, gasket_dev);
- return 0;
- }
-
- driver_desc = gasket_dev->internal_desc->driver_desc;
-
- sysfs_type =
- (enum gasket_sysfs_attribute_type)gasket_attr->data.attr_type;
- switch (sysfs_type) {
- case ATTR_BAR_OFFSETS:
- for (i = 0; i < PCI_STD_NUM_BARS; i++) {
- bar_desc = &driver_desc->bar_descriptions[i];
- if (bar_desc->size == 0)
- continue;
- current_written =
- snprintf(buf, PAGE_SIZE - ret, "%d: 0x%lx\n", i,
- (ulong)bar_desc->base);
- buf += current_written;
- ret += current_written;
- }
- break;
- case ATTR_BAR_SIZES:
- for (i = 0; i < PCI_STD_NUM_BARS; i++) {
- bar_desc = &driver_desc->bar_descriptions[i];
- if (bar_desc->size == 0)
- continue;
- current_written =
- snprintf(buf, PAGE_SIZE - ret, "%d: 0x%lx\n", i,
- (ulong)bar_desc->size);
- buf += current_written;
- ret += current_written;
- }
- break;
- case ATTR_DRIVER_VERSION:
- ret = snprintf(buf, PAGE_SIZE, "%s\n",
- gasket_dev->internal_desc->driver_desc->driver_version);
- break;
- case ATTR_FRAMEWORK_VERSION:
- ret = snprintf(buf, PAGE_SIZE, "%s\n",
- GASKET_FRAMEWORK_VERSION);
- break;
- case ATTR_DEVICE_TYPE:
- ret = snprintf(buf, PAGE_SIZE, "%s\n",
- gasket_dev->internal_desc->driver_desc->name);
- break;
- case ATTR_HARDWARE_REVISION:
- ret = snprintf(buf, PAGE_SIZE, "%d\n",
- gasket_dev->hardware_revision);
- break;
- case ATTR_PCI_ADDRESS:
- ret = snprintf(buf, PAGE_SIZE, "%s\n", gasket_dev->kobj_name);
- break;
- case ATTR_STATUS:
- ret = snprintf(buf, PAGE_SIZE, "%s\n",
- gasket_num_name_lookup(gasket_dev->status,
- gasket_status_name_table));
- break;
- case ATTR_IS_DEVICE_OWNED:
- ret = snprintf(buf, PAGE_SIZE, "%d\n",
- gasket_dev->dev_info.ownership.is_owned);
- break;
- case ATTR_DEVICE_OWNER:
- ret = snprintf(buf, PAGE_SIZE, "%d\n",
- gasket_dev->dev_info.ownership.owner);
- break;
- case ATTR_WRITE_OPEN_COUNT:
- ret = snprintf(buf, PAGE_SIZE, "%d\n",
- gasket_dev->dev_info.ownership.write_open_count);
- break;
- case ATTR_RESET_COUNT:
- ret = snprintf(buf, PAGE_SIZE, "%d\n", gasket_dev->reset_count);
- break;
- case ATTR_USER_MEM_RANGES:
- for (i = 0; i < PCI_STD_NUM_BARS; ++i) {
- current_written =
- gasket_write_mappable_regions(buf, driver_desc,
- i);
- buf += current_written;
- ret += current_written;
- }
- break;
- default:
- dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n",
- attr->attr.name);
- ret = 0;
- break;
- }
-
- gasket_sysfs_put_attr(device, gasket_attr);
- gasket_sysfs_put_device_data(device, gasket_dev);
- return ret;
-}
-
-/* These attributes apply to all Gasket driver instances. */
-static const struct gasket_sysfs_attribute gasket_sysfs_generic_attrs[] = {
- GASKET_SYSFS_RO(bar_offsets, gasket_sysfs_data_show, ATTR_BAR_OFFSETS),
- GASKET_SYSFS_RO(bar_sizes, gasket_sysfs_data_show, ATTR_BAR_SIZES),
- GASKET_SYSFS_RO(driver_version, gasket_sysfs_data_show,
- ATTR_DRIVER_VERSION),
- GASKET_SYSFS_RO(framework_version, gasket_sysfs_data_show,
- ATTR_FRAMEWORK_VERSION),
- GASKET_SYSFS_RO(device_type, gasket_sysfs_data_show, ATTR_DEVICE_TYPE),
- GASKET_SYSFS_RO(revision, gasket_sysfs_data_show,
- ATTR_HARDWARE_REVISION),
- GASKET_SYSFS_RO(pci_address, gasket_sysfs_data_show, ATTR_PCI_ADDRESS),
- GASKET_SYSFS_RO(status, gasket_sysfs_data_show, ATTR_STATUS),
- GASKET_SYSFS_RO(is_device_owned, gasket_sysfs_data_show,
- ATTR_IS_DEVICE_OWNED),
- GASKET_SYSFS_RO(device_owner, gasket_sysfs_data_show,
- ATTR_DEVICE_OWNER),
- GASKET_SYSFS_RO(write_open_count, gasket_sysfs_data_show,
- ATTR_WRITE_OPEN_COUNT),
- GASKET_SYSFS_RO(reset_count, gasket_sysfs_data_show, ATTR_RESET_COUNT),
- GASKET_SYSFS_RO(user_mem_ranges, gasket_sysfs_data_show,
- ATTR_USER_MEM_RANGES),
- GASKET_END_OF_ATTR_ARRAY
-};
-
-/* Add a char device and related info. */
-static int gasket_add_cdev(struct gasket_cdev_info *dev_info,
- const struct file_operations *file_ops,
- struct module *owner)
-{
- int ret;
-
- cdev_init(&dev_info->cdev, file_ops);
- dev_info->cdev.owner = owner;
- ret = cdev_add(&dev_info->cdev, dev_info->devt, 1);
- if (ret) {
- dev_err(dev_info->gasket_dev_ptr->dev,
- "cannot add char device [ret=%d]\n", ret);
- return ret;
- }
- dev_info->cdev_added = 1;
-
- return 0;
-}
-
-/* Disable device operations. */
-void gasket_disable_device(struct gasket_dev *gasket_dev)
-{
- const struct gasket_driver_desc *driver_desc =
- gasket_dev->internal_desc->driver_desc;
- int i;
-
- /* Only delete the device if it has been successfully added. */
- if (gasket_dev->dev_info.cdev_added)
- cdev_del(&gasket_dev->dev_info.cdev);
-
- gasket_dev->status = GASKET_STATUS_DEAD;
-
- gasket_interrupt_cleanup(gasket_dev);
-
- for (i = 0; i < driver_desc->num_page_tables; ++i) {
- if (gasket_dev->page_table[i]) {
- gasket_page_table_reset(gasket_dev->page_table[i]);
- gasket_page_table_cleanup(gasket_dev->page_table[i]);
- }
- }
-}
-EXPORT_SYMBOL(gasket_disable_device);
-
-/*
- * Registered driver descriptor lookup for PCI devices.
- *
- * Precondition: Called with g_mutex held (to avoid a race on return).
- * Returns NULL if no matching device was found.
- */
-static struct gasket_internal_desc *
-lookup_pci_internal_desc(struct pci_dev *pci_dev)
-{
- int i;
-
- __must_hold(&g_mutex);
- for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) {
- if (g_descs[i].driver_desc &&
- g_descs[i].driver_desc->pci_id_table &&
- pci_match_id(g_descs[i].driver_desc->pci_id_table, pci_dev))
- return &g_descs[i];
- }
-
- return NULL;
-}
-
-/*
- * Verifies that the user has permissions to perform the requested mapping and
- * that the provided descriptor/range is of adequate size to hold the range to
- * be mapped.
- */
-static bool gasket_mmap_has_permissions(struct gasket_dev *gasket_dev,
- struct vm_area_struct *vma,
- int bar_permissions)
-{
- int requested_permissions;
- /* Always allow sysadmin to access. */
- if (capable(CAP_SYS_ADMIN))
- return true;
-
- /* Never allow non-sysadmins to access to a dead device. */
- if (gasket_dev->status != GASKET_STATUS_ALIVE) {
- dev_dbg(gasket_dev->dev, "Device is dead.\n");
- return false;
- }
-
- /* Make sure that no wrong flags are set. */
- requested_permissions =
- (vma->vm_flags & VM_ACCESS_FLAGS);
- if (requested_permissions & ~(bar_permissions)) {
- dev_dbg(gasket_dev->dev,
- "Attempting to map a region with requested permissions 0x%x, but region has permissions 0x%x.\n",
- requested_permissions, bar_permissions);
- return false;
- }
-
- /* Do not allow a non-owner to write. */
- if ((vma->vm_flags & VM_WRITE) &&
- !gasket_owned_by_current_tgid(&gasket_dev->dev_info)) {
- dev_dbg(gasket_dev->dev,
- "Attempting to mmap a region for write without owning device.\n");
- return false;
- }
-
- return true;
-}
-
-/*
- * Verifies that the input address is within the region allocated to coherent
- * buffer.
- */
-static bool
-gasket_is_coherent_region(const struct gasket_driver_desc *driver_desc,
- ulong address)
-{
- struct gasket_coherent_buffer_desc coh_buff_desc =
- driver_desc->coherent_buffer_description;
-
- if (coh_buff_desc.permissions != GASKET_NOMAP) {
- if ((address >= coh_buff_desc.base) &&
- (address < coh_buff_desc.base + coh_buff_desc.size)) {
- return true;
- }
- }
- return false;
-}
-
-static int gasket_get_bar_index(const struct gasket_dev *gasket_dev,
- ulong phys_addr)
-{
- int i;
- const struct gasket_driver_desc *driver_desc;
-
- driver_desc = gasket_dev->internal_desc->driver_desc;
- for (i = 0; i < PCI_STD_NUM_BARS; ++i) {
- struct gasket_bar_desc bar_desc =
- driver_desc->bar_descriptions[i];
-
- if (bar_desc.permissions != GASKET_NOMAP) {
- if (phys_addr >= bar_desc.base &&
- phys_addr < (bar_desc.base + bar_desc.size)) {
- return i;
- }
- }
- }
- /* If we haven't found the address by now, it is invalid. */
- return -EINVAL;
-}
-
-/*
- * Sets the actual bounds to map, given the device's mappable region.
- *
- * Given the device's mappable region, along with the user-requested mapping
- * start offset and length of the user region, determine how much of this
- * mappable region can be mapped into the user's region (start/end offsets),
- * and the physical offset (phys_offset) into the BAR where the mapping should
- * begin (either the VMA's or region lower bound).
- *
- * In other words, this calculates the overlap between the VMA
- * (bar_offset, requested_length) and the given gasket_mappable_region.
- *
- * Returns true if there's anything to map, and false otherwise.
- */
-static bool
-gasket_mm_get_mapping_addrs(const struct gasket_mappable_region *region,
- ulong bar_offset, ulong requested_length,
- struct gasket_mappable_region *mappable_region,
- ulong *virt_offset)
-{
- ulong range_start = region->start;
- ulong range_length = region->length_bytes;
- ulong range_end = range_start + range_length;
-
- *virt_offset = 0;
- if (bar_offset + requested_length < range_start) {
- /*
- * If the requested region is completely below the range,
- * there is nothing to map.
- */
- return false;
- } else if (bar_offset <= range_start) {
- /* If the bar offset is below this range's start
- * but the requested length continues into it:
- * 1) Only map starting from the beginning of this
- * range's phys. offset, so we don't map unmappable
- * memory.
- * 2) The length of the virtual memory to not map is the
- * delta between the bar offset and the
- * mappable start (and since the mappable start is
- * bigger, start - req.)
- * 3) The map length is the minimum of the mappable
- * requested length (requested_length - virt_offset)
- * and the actual mappable length of the range.
- */
- mappable_region->start = range_start;
- *virt_offset = range_start - bar_offset;
- mappable_region->length_bytes =
- min(requested_length - *virt_offset, range_length);
- return true;
- } else if (bar_offset > range_start &&
- bar_offset < range_end) {
- /*
- * If the bar offset is within this range:
- * 1) Map starting from the bar offset.
- * 2) Because there is no forbidden memory between the
- * bar offset and the range start,
- * virt_offset is 0.
- * 3) The map length is the minimum of the requested
- * length and the remaining length in the buffer
- * (range_end - bar_offset)
- */
- mappable_region->start = bar_offset;
- *virt_offset = 0;
- mappable_region->length_bytes =
- min(requested_length, range_end - bar_offset);
- return true;
- }
-
- /*
- * If the requested [start] offset is above range_end,
- * there's nothing to map.
- */
- return false;
-}
-
-/*
- * Calculates the offset where the VMA range begins in its containing BAR.
- * The offset is written into bar_offset on success.
- * Returns zero on success, anything else on error.
- */
-static int gasket_mm_vma_bar_offset(const struct gasket_dev *gasket_dev,
- const struct vm_area_struct *vma,
- ulong *bar_offset)
-{
- ulong raw_offset;
- int bar_index;
- const struct gasket_driver_desc *driver_desc =
- gasket_dev->internal_desc->driver_desc;
-
- raw_offset = (vma->vm_pgoff << PAGE_SHIFT) +
- driver_desc->legacy_mmap_address_offset;
- bar_index = gasket_get_bar_index(gasket_dev, raw_offset);
- if (bar_index < 0) {
- dev_err(gasket_dev->dev,
- "Unable to find matching bar for address 0x%lx\n",
- raw_offset);
- trace_gasket_mmap_exit(bar_index);
- return bar_index;
- }
- *bar_offset =
- raw_offset - driver_desc->bar_descriptions[bar_index].base;
-
- return 0;
-}
-
-int gasket_mm_unmap_region(const struct gasket_dev *gasket_dev,
- struct vm_area_struct *vma,
- const struct gasket_mappable_region *map_region)
-{
- ulong bar_offset;
- ulong virt_offset;
- struct gasket_mappable_region mappable_region;
- int ret;
-
- if (map_region->length_bytes == 0)
- return 0;
-
- ret = gasket_mm_vma_bar_offset(gasket_dev, vma, &bar_offset);
- if (ret)
- return ret;
-
- if (!gasket_mm_get_mapping_addrs(map_region, bar_offset,
- vma->vm_end - vma->vm_start,
- &mappable_region, &virt_offset))
- return 1;
-
- /*
- * The length passed to zap_vma_ptes MUST BE A MULTIPLE OF
- * PAGE_SIZE! Trust me. I have the scars.
- *
- * Next multiple of y: ceil_div(x, y) * y
- */
- zap_vma_ptes(vma, vma->vm_start + virt_offset,
- DIV_ROUND_UP(mappable_region.length_bytes, PAGE_SIZE) *
- PAGE_SIZE);
- return 0;
-}
-EXPORT_SYMBOL(gasket_mm_unmap_region);
-
-/* Maps a virtual address + range to a physical offset of a BAR. */
-static enum do_map_region_status
-do_map_region(const struct gasket_dev *gasket_dev, struct vm_area_struct *vma,
- struct gasket_mappable_region *mappable_region)
-{
- /* Maximum size of a single call to io_remap_pfn_range. */
- /* I pulled this number out of thin air. */
- const ulong max_chunk_size = 64 * 1024 * 1024;
- ulong chunk_size, mapped_bytes = 0;
-
- const struct gasket_driver_desc *driver_desc =
- gasket_dev->internal_desc->driver_desc;
-
- ulong bar_offset, virt_offset;
- struct gasket_mappable_region region_to_map;
- ulong phys_offset, map_length;
- ulong virt_base, phys_base;
- int bar_index, ret;
-
- ret = gasket_mm_vma_bar_offset(gasket_dev, vma, &bar_offset);
- if (ret)
- return DO_MAP_REGION_INVALID;
-
- if (!gasket_mm_get_mapping_addrs(mappable_region, bar_offset,
- vma->vm_end - vma->vm_start,
- &region_to_map, &virt_offset))
- return DO_MAP_REGION_INVALID;
- phys_offset = region_to_map.start;
- map_length = region_to_map.length_bytes;
-
- virt_base = vma->vm_start + virt_offset;
- bar_index =
- gasket_get_bar_index(gasket_dev,
- (vma->vm_pgoff << PAGE_SHIFT) +
- driver_desc->legacy_mmap_address_offset);
-
- if (bar_index < 0)
- return DO_MAP_REGION_INVALID;
-
- phys_base = gasket_dev->bar_data[bar_index].phys_base + phys_offset;
- while (mapped_bytes < map_length) {
- /*
- * io_remap_pfn_range can take a while, so we chunk its
- * calls and call cond_resched between each.
- */
- chunk_size = min(max_chunk_size, map_length - mapped_bytes);
-
- cond_resched();
- ret = io_remap_pfn_range(vma, virt_base + mapped_bytes,
- (phys_base + mapped_bytes) >>
- PAGE_SHIFT, chunk_size,
- vma->vm_page_prot);
- if (ret) {
- dev_err(gasket_dev->dev,
- "Error remapping PFN range.\n");
- goto fail;
- }
- mapped_bytes += chunk_size;
- }
-
- return DO_MAP_REGION_SUCCESS;
-
-fail:
- /* Unmap the partial chunk we mapped. */
- mappable_region->length_bytes = mapped_bytes;
- if (gasket_mm_unmap_region(gasket_dev, vma, mappable_region))
- dev_err(gasket_dev->dev,
- "Error unmapping partial region 0x%lx (0x%lx bytes)\n",
- (ulong)virt_offset,
- (ulong)mapped_bytes);
-
- return DO_MAP_REGION_FAILURE;
-}
-
-/* Map a region of coherent memory. */
-static int gasket_mmap_coherent(struct gasket_dev *gasket_dev,
- struct vm_area_struct *vma)
-{
- const struct gasket_driver_desc *driver_desc =
- gasket_dev->internal_desc->driver_desc;
- const ulong requested_length = vma->vm_end - vma->vm_start;
- int ret;
- ulong permissions;
-
- if (requested_length == 0 || requested_length >
- gasket_dev->coherent_buffer.length_bytes) {
- trace_gasket_mmap_exit(-EINVAL);
- return -EINVAL;
- }
-
- permissions = driver_desc->coherent_buffer_description.permissions;
- if (!gasket_mmap_has_permissions(gasket_dev, vma, permissions)) {
- dev_err(gasket_dev->dev, "Permission checking failed.\n");
- trace_gasket_mmap_exit(-EPERM);
- return -EPERM;
- }
-
- vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-
- ret = remap_pfn_range(vma, vma->vm_start,
- (gasket_dev->coherent_buffer.phys_base) >>
- PAGE_SHIFT, requested_length, vma->vm_page_prot);
- if (ret) {
- dev_err(gasket_dev->dev, "Error remapping PFN range err=%d.\n",
- ret);
- trace_gasket_mmap_exit(ret);
- return ret;
- }
-
- /* Record the user virtual to dma_address mapping that was
- * created by the kernel.
- */
- gasket_set_user_virt(gasket_dev, requested_length,
- gasket_dev->coherent_buffer.phys_base,
- vma->vm_start);
- return 0;
-}
-
-/* Map a device's BARs into user space. */
-static int gasket_mmap(struct file *filp, struct vm_area_struct *vma)
-{
- int i, ret;
- int bar_index;
- int has_mapped_anything = 0;
- ulong permissions;
- ulong raw_offset, vma_size;
- bool is_coherent_region;
- const struct gasket_driver_desc *driver_desc;
- struct gasket_dev *gasket_dev = (struct gasket_dev *)filp->private_data;
- const struct gasket_bar_desc *bar_desc;
- struct gasket_mappable_region *map_regions = NULL;
- int num_map_regions = 0;
- enum do_map_region_status map_status;
-
- driver_desc = gasket_dev->internal_desc->driver_desc;
-
- if (vma->vm_start & ~PAGE_MASK) {
- dev_err(gasket_dev->dev,
- "Base address not page-aligned: 0x%lx\n",
- vma->vm_start);
- trace_gasket_mmap_exit(-EINVAL);
- return -EINVAL;
- }
-
- /* Calculate the offset of this range into physical mem. */
- raw_offset = (vma->vm_pgoff << PAGE_SHIFT) +
- driver_desc->legacy_mmap_address_offset;
- vma_size = vma->vm_end - vma->vm_start;
- trace_gasket_mmap_entry(gasket_dev->dev_info.name, raw_offset,
- vma_size);
-
- /*
- * Check if the raw offset is within a bar region. If not, check if it
- * is a coherent region.
- */
- bar_index = gasket_get_bar_index(gasket_dev, raw_offset);
- is_coherent_region = gasket_is_coherent_region(driver_desc, raw_offset);
- if (bar_index < 0 && !is_coherent_region) {
- dev_err(gasket_dev->dev,
- "Unable to find matching bar for address 0x%lx\n",
- raw_offset);
- trace_gasket_mmap_exit(bar_index);
- return bar_index;
- }
- if (bar_index > 0 && is_coherent_region) {
- dev_err(gasket_dev->dev,
- "double matching bar and coherent buffers for address 0x%lx\n",
- raw_offset);
- trace_gasket_mmap_exit(bar_index);
- return -EINVAL;
- }
-
- vma->vm_private_data = gasket_dev;
-
- if (is_coherent_region)
- return gasket_mmap_coherent(gasket_dev, vma);
-
- /* Everything in the rest of this function is for normal BAR mapping. */
-
- /*
- * Subtract the base of the bar from the raw offset to get the
- * memory location within the bar to map.
- */
- bar_desc = &driver_desc->bar_descriptions[bar_index];
- permissions = bar_desc->permissions;
- if (!gasket_mmap_has_permissions(gasket_dev, vma, permissions)) {
- dev_err(gasket_dev->dev, "Permission checking failed.\n");
- trace_gasket_mmap_exit(-EPERM);
- return -EPERM;
- }
-
- if (driver_desc->get_mappable_regions_cb) {
- ret = driver_desc->get_mappable_regions_cb(gasket_dev,
- bar_index,
- &map_regions,
- &num_map_regions);
- if (ret)
- return ret;
- } else {
- if (!gasket_mmap_has_permissions(gasket_dev, vma,
- bar_desc->permissions)) {
- dev_err(gasket_dev->dev,
- "Permission checking failed.\n");
- trace_gasket_mmap_exit(-EPERM);
- return -EPERM;
- }
- num_map_regions = bar_desc->num_mappable_regions;
- map_regions = kcalloc(num_map_regions,
- sizeof(*bar_desc->mappable_regions),
- GFP_KERNEL);
- if (map_regions) {
- memcpy(map_regions, bar_desc->mappable_regions,
- num_map_regions *
- sizeof(*bar_desc->mappable_regions));
- }
- }
-
- if (!map_regions || num_map_regions == 0) {
- dev_err(gasket_dev->dev, "No mappable regions returned!\n");
- return -EINVAL;
- }
-
- /* Marks the VMA's pages as uncacheable. */
- vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
- for (i = 0; i < num_map_regions; i++) {
- map_status = do_map_region(gasket_dev, vma, &map_regions[i]);
- /* Try the next region if this one was not mappable. */
- if (map_status == DO_MAP_REGION_INVALID)
- continue;
- if (map_status == DO_MAP_REGION_FAILURE) {
- ret = -ENOMEM;
- goto fail;
- }
-
- has_mapped_anything = 1;
- }
-
- kfree(map_regions);
-
- /* If we could not map any memory, the request was invalid. */
- if (!has_mapped_anything) {
- dev_err(gasket_dev->dev,
- "Map request did not contain a valid region.\n");
- trace_gasket_mmap_exit(-EINVAL);
- return -EINVAL;
- }
-
- trace_gasket_mmap_exit(0);
- return 0;
-
-fail:
- /* Need to unmap any mapped ranges. */
- num_map_regions = i;
- for (i = 0; i < num_map_regions; i++)
- if (gasket_mm_unmap_region(gasket_dev, vma,
- &bar_desc->mappable_regions[i]))
- dev_err(gasket_dev->dev, "Error unmapping range %d.\n",
- i);
- kfree(map_regions);
-
- return ret;
-}
-
-/*
- * Open the char device file.
- *
- * If the open is for writing, and the device is not owned, this process becomes
- * the owner. If the open is for writing and the device is already owned by
- * some other process, it is an error. If this process is the owner, increment
- * the open count.
- *
- * Returns 0 if successful, a negative error number otherwise.
- */
-static int gasket_open(struct inode *inode, struct file *filp)
-{
- int ret;
- struct gasket_dev *gasket_dev;
- const struct gasket_driver_desc *driver_desc;
- struct gasket_ownership *ownership;
- char task_name[TASK_COMM_LEN];
- struct gasket_cdev_info *dev_info =
- container_of(inode->i_cdev, struct gasket_cdev_info, cdev);
- struct pid_namespace *pid_ns = task_active_pid_ns(current);
- bool is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN);
-
- gasket_dev = dev_info->gasket_dev_ptr;
- driver_desc = gasket_dev->internal_desc->driver_desc;
- ownership = &dev_info->ownership;
- get_task_comm(task_name, current);
- filp->private_data = gasket_dev;
- inode->i_size = 0;
-
- dev_dbg(gasket_dev->dev,
- "Attempting to open with tgid %u (%s) (f_mode: 0%03o, fmode_write: %d is_root: %u)\n",
- current->tgid, task_name, filp->f_mode,
- (filp->f_mode & FMODE_WRITE), is_root);
-
- /* Always allow non-writing accesses. */
- if (!(filp->f_mode & FMODE_WRITE)) {
- dev_dbg(gasket_dev->dev, "Allowing read-only opening.\n");
- return 0;
- }
-
- mutex_lock(&gasket_dev->mutex);
-
- dev_dbg(gasket_dev->dev,
- "Current owner open count (owning tgid %u): %d.\n",
- ownership->owner, ownership->write_open_count);
-
- /* Opening a node owned by another TGID is an error (unless root) */
- if (ownership->is_owned && ownership->owner != current->tgid &&
- !is_root) {
- dev_err(gasket_dev->dev,
- "Process %u is opening a node held by %u.\n",
- current->tgid, ownership->owner);
- mutex_unlock(&gasket_dev->mutex);
- return -EPERM;
- }
-
- /* If the node is not owned, assign it to the current TGID. */
- if (!ownership->is_owned) {
- ret = gasket_check_and_invoke_callback_nolock(gasket_dev,
- driver_desc->device_open_cb);
- if (ret) {
- dev_err(gasket_dev->dev,
- "Error in device open cb: %d\n", ret);
- mutex_unlock(&gasket_dev->mutex);
- return ret;
- }
- ownership->is_owned = 1;
- ownership->owner = current->tgid;
- dev_dbg(gasket_dev->dev, "Device owner is now tgid %u\n",
- ownership->owner);
- }
-
- ownership->write_open_count++;
-
- dev_dbg(gasket_dev->dev, "New open count (owning tgid %u): %d\n",
- ownership->owner, ownership->write_open_count);
-
- mutex_unlock(&gasket_dev->mutex);
- return 0;
-}
-
-/*
- * Called on a close of the device file. If this process is the owner,
- * decrement the open count. On last close by the owner, free up buffers and
- * eventfd contexts, and release ownership.
- *
- * Returns 0 if successful, a negative error number otherwise.
- */
-static int gasket_release(struct inode *inode, struct file *file)
-{
- int i;
- struct gasket_dev *gasket_dev;
- struct gasket_ownership *ownership;
- const struct gasket_driver_desc *driver_desc;
- char task_name[TASK_COMM_LEN];
- struct gasket_cdev_info *dev_info =
- container_of(inode->i_cdev, struct gasket_cdev_info, cdev);
- struct pid_namespace *pid_ns = task_active_pid_ns(current);
- bool is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN);
-
- gasket_dev = dev_info->gasket_dev_ptr;
- driver_desc = gasket_dev->internal_desc->driver_desc;
- ownership = &dev_info->ownership;
- get_task_comm(task_name, current);
- mutex_lock(&gasket_dev->mutex);
-
- dev_dbg(gasket_dev->dev,
- "Releasing device node. Call origin: tgid %u (%s) (f_mode: 0%03o, fmode_write: %d, is_root: %u)\n",
- current->tgid, task_name, file->f_mode,
- (file->f_mode & FMODE_WRITE), is_root);
- dev_dbg(gasket_dev->dev, "Current open count (owning tgid %u): %d\n",
- ownership->owner, ownership->write_open_count);
-
- if (file->f_mode & FMODE_WRITE) {
- ownership->write_open_count--;
- if (ownership->write_open_count == 0) {
- dev_dbg(gasket_dev->dev, "Device is now free\n");
- ownership->is_owned = 0;
- ownership->owner = 0;
-
- /* Forces chip reset before we unmap the page tables. */
- driver_desc->device_reset_cb(gasket_dev);
-
- for (i = 0; i < driver_desc->num_page_tables; ++i) {
- gasket_page_table_unmap_all(gasket_dev->page_table[i]);
- gasket_page_table_garbage_collect(gasket_dev->page_table[i]);
- gasket_free_coherent_memory_all(gasket_dev, i);
- }
-
- /* Closes device, enters power save. */
- gasket_check_and_invoke_callback_nolock(gasket_dev,
- driver_desc->device_close_cb);
- }
- }
-
- dev_dbg(gasket_dev->dev, "New open count (owning tgid %u): %d\n",
- ownership->owner, ownership->write_open_count);
- mutex_unlock(&gasket_dev->mutex);
- return 0;
-}
-
-/*
- * Gasket ioctl dispatch function.
- *
- * Check if the ioctl is a generic ioctl. If not, pass the ioctl to the
- * ioctl_handler_cb registered in the driver description.
- * If the ioctl is a generic ioctl, pass it to gasket_ioctl_handler.
- */
-static long gasket_ioctl(struct file *filp, uint cmd, ulong arg)
-{
- struct gasket_dev *gasket_dev;
- const struct gasket_driver_desc *driver_desc;
- void __user *argp = (void __user *)arg;
- char path[256];
-
- gasket_dev = (struct gasket_dev *)filp->private_data;
- driver_desc = gasket_dev->internal_desc->driver_desc;
- if (!driver_desc) {
- dev_dbg(gasket_dev->dev,
- "Unable to find device descriptor for file %s\n",
- d_path(&filp->f_path, path, 256));
- return -ENODEV;
- }
-
- if (!gasket_is_supported_ioctl(cmd)) {
- /*
- * The ioctl handler is not a standard Gasket callback, since
- * it requires different arguments. This means we can't use
- * check_and_invoke_callback.
- */
- if (driver_desc->ioctl_handler_cb)
- return driver_desc->ioctl_handler_cb(filp, cmd, argp);
-
- dev_dbg(gasket_dev->dev, "Received unknown ioctl 0x%x\n", cmd);
- return -EINVAL;
- }
-
- return gasket_handle_ioctl(filp, cmd, argp);
-}
-
-/* File operations for all Gasket devices. */
-static const struct file_operations gasket_file_ops = {
- .owner = THIS_MODULE,
- .llseek = no_llseek,
- .mmap = gasket_mmap,
- .open = gasket_open,
- .release = gasket_release,
- .unlocked_ioctl = gasket_ioctl,
-};
-
-/* Perform final init and marks the device as active. */
-int gasket_enable_device(struct gasket_dev *gasket_dev)
-{
- int tbl_idx;
- int ret;
- const struct gasket_driver_desc *driver_desc =
- gasket_dev->internal_desc->driver_desc;
-
- ret = gasket_interrupt_init(gasket_dev);
- if (ret) {
- dev_err(gasket_dev->dev,
- "Critical failure to allocate interrupts: %d\n", ret);
- gasket_interrupt_cleanup(gasket_dev);
- return ret;
- }
-
- for (tbl_idx = 0; tbl_idx < driver_desc->num_page_tables; tbl_idx++) {
- dev_dbg(gasket_dev->dev, "Initializing page table %d.\n",
- tbl_idx);
- ret = gasket_page_table_init(&gasket_dev->page_table[tbl_idx],
- &gasket_dev->bar_data[driver_desc->page_table_bar_index],
- &driver_desc->page_table_configs[tbl_idx],
- gasket_dev->dev,
- gasket_dev->pci_dev);
- if (ret) {
- dev_err(gasket_dev->dev,
- "Couldn't init page table %d: %d\n",
- tbl_idx, ret);
- return ret;
- }
- /*
- * Make sure that the page table is clear and set to simple
- * addresses.
- */
- gasket_page_table_reset(gasket_dev->page_table[tbl_idx]);
- }
-
- /*
- * hardware_revision_cb returns a positive integer (the rev) if
- * successful.)
- */
- ret = check_and_invoke_callback(gasket_dev,
- driver_desc->hardware_revision_cb);
- if (ret < 0) {
- dev_err(gasket_dev->dev,
- "Error getting hardware revision: %d\n", ret);
- return ret;
- }
- gasket_dev->hardware_revision = ret;
-
- /* device_status_cb returns a device status, not an error code. */
- gasket_dev->status = gasket_get_hw_status(gasket_dev);
- if (gasket_dev->status == GASKET_STATUS_DEAD)
- dev_err(gasket_dev->dev, "Device reported as unhealthy.\n");
-
- ret = gasket_add_cdev(&gasket_dev->dev_info, &gasket_file_ops,
- driver_desc->module);
- if (ret)
- return ret;
-
- return 0;
-}
-EXPORT_SYMBOL(gasket_enable_device);
-
-static int __gasket_add_device(struct device *parent_dev,
- struct gasket_internal_desc *internal_desc,
- struct gasket_dev **gasket_devp)
-{
- int ret;
- struct gasket_dev *gasket_dev;
- const struct gasket_driver_desc *driver_desc =
- internal_desc->driver_desc;
-
- ret = gasket_alloc_dev(internal_desc, parent_dev, &gasket_dev);
- if (ret)
- return ret;
- if (IS_ERR(gasket_dev->dev_info.device)) {
- dev_err(parent_dev, "Cannot create %s device %s [ret = %ld]\n",
- driver_desc->name, gasket_dev->dev_info.name,
- PTR_ERR(gasket_dev->dev_info.device));
- ret = -ENODEV;
- goto free_gasket_dev;
- }
-
- ret = gasket_sysfs_create_mapping(gasket_dev->dev_info.device,
- gasket_dev);
- if (ret)
- goto remove_device;
-
- ret = gasket_sysfs_create_entries(gasket_dev->dev_info.device,
- gasket_sysfs_generic_attrs);
- if (ret)
- goto remove_sysfs_mapping;
-
- *gasket_devp = gasket_dev;
- return 0;
-
-remove_sysfs_mapping:
- gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
-remove_device:
- device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
-free_gasket_dev:
- gasket_free_dev(gasket_dev);
- return ret;
-}
-
-static void __gasket_remove_device(struct gasket_internal_desc *internal_desc,
- struct gasket_dev *gasket_dev)
-{
- gasket_sysfs_remove_mapping(gasket_dev->dev_info.device);
- device_destroy(internal_desc->class, gasket_dev->dev_info.devt);
- gasket_free_dev(gasket_dev);
-}
-
-/*
- * Add PCI gasket device.
- *
- * Called by Gasket device probe function.
- * Allocates device metadata and maps device memory. The device driver must
- * call gasket_enable_device after driver init is complete to place the device
- * in active use.
- */
-int gasket_pci_add_device(struct pci_dev *pci_dev,
- struct gasket_dev **gasket_devp)
-{
- int ret;
- struct gasket_internal_desc *internal_desc;
- struct gasket_dev *gasket_dev;
- struct device *parent;
-
- dev_dbg(&pci_dev->dev, "add PCI gasket device\n");
-
- mutex_lock(&g_mutex);
- internal_desc = lookup_pci_internal_desc(pci_dev);
- mutex_unlock(&g_mutex);
- if (!internal_desc) {
- dev_err(&pci_dev->dev,
- "PCI add device called for unknown driver type\n");
- return -ENODEV;
- }
-
- parent = &pci_dev->dev;
- ret = __gasket_add_device(parent, internal_desc, &gasket_dev);
- if (ret)
- return ret;
-
- gasket_dev->pci_dev = pci_dev;
- ret = gasket_setup_pci(pci_dev, gasket_dev);
- if (ret)
- goto cleanup_pci;
-
- /*
- * Once we've created the mapping structures successfully, attempt to
- * create a symlink to the pci directory of this object.
- */
- ret = sysfs_create_link(&gasket_dev->dev_info.device->kobj,
- &pci_dev->dev.kobj, dev_name(&pci_dev->dev));
- if (ret) {
- dev_err(gasket_dev->dev,
- "Cannot create sysfs pci link: %d\n", ret);
- goto cleanup_pci;
- }
-
- *gasket_devp = gasket_dev;
- return 0;
-
-cleanup_pci:
- gasket_cleanup_pci(gasket_dev);
- __gasket_remove_device(internal_desc, gasket_dev);
- return ret;
-}
-EXPORT_SYMBOL(gasket_pci_add_device);
-
-/* Remove a PCI gasket device. */
-void gasket_pci_remove_device(struct pci_dev *pci_dev)
-{
- int i;
- struct gasket_internal_desc *internal_desc;
- struct gasket_dev *gasket_dev = NULL;
- /* Find the device desc. */
- mutex_lock(&g_mutex);
- internal_desc = lookup_pci_internal_desc(pci_dev);
- if (!internal_desc) {
- mutex_unlock(&g_mutex);
- return;
- }
- mutex_unlock(&g_mutex);
-
- /* Now find the specific device */
- mutex_lock(&internal_desc->mutex);
- for (i = 0; i < GASKET_DEV_MAX; i++) {
- if (internal_desc->devs[i] &&
- internal_desc->devs[i]->pci_dev == pci_dev) {
- gasket_dev = internal_desc->devs[i];
- break;
- }
- }
- mutex_unlock(&internal_desc->mutex);
-
- if (!gasket_dev)
- return;
-
- dev_dbg(gasket_dev->dev, "remove %s PCI gasket device\n",
- internal_desc->driver_desc->name);
-
- gasket_cleanup_pci(gasket_dev);
- __gasket_remove_device(internal_desc, gasket_dev);
-}
-EXPORT_SYMBOL(gasket_pci_remove_device);
-
-/**
- * Lookup a name by number in a num_name table.
- * @num: Number to lookup.
- * @table: Array of num_name structures, the table for the lookup.
- *
- * Description: Searches for num in the table. If found, the
- * corresponding name is returned; otherwise NULL
- * is returned.
- *
- * The table must have a NULL name pointer at the end.
- */
-const char *gasket_num_name_lookup(uint num,
- const struct gasket_num_name *table)
-{
- uint i = 0;
-
- while (table[i].snn_name) {
- if (num == table[i].snn_num)
- break;
- ++i;
- }
-
- return table[i].snn_name;
-}
-EXPORT_SYMBOL(gasket_num_name_lookup);
-
-int gasket_reset(struct gasket_dev *gasket_dev)
-{
- int ret;
-
- mutex_lock(&gasket_dev->mutex);
- ret = gasket_reset_nolock(gasket_dev);
- mutex_unlock(&gasket_dev->mutex);
- return ret;
-}
-EXPORT_SYMBOL(gasket_reset);
-
-int gasket_reset_nolock(struct gasket_dev *gasket_dev)
-{
- int ret;
- int i;
- const struct gasket_driver_desc *driver_desc;
-
- driver_desc = gasket_dev->internal_desc->driver_desc;
- if (!driver_desc->device_reset_cb)
- return 0;
-
- ret = driver_desc->device_reset_cb(gasket_dev);
- if (ret) {
- dev_dbg(gasket_dev->dev, "Device reset cb returned %d.\n",
- ret);
- return ret;
- }
-
- /* Reinitialize the page tables and interrupt framework. */
- for (i = 0; i < driver_desc->num_page_tables; ++i)
- gasket_page_table_reset(gasket_dev->page_table[i]);
-
- ret = gasket_interrupt_reinit(gasket_dev);
- if (ret) {
- dev_dbg(gasket_dev->dev, "Unable to reinit interrupts: %d.\n",
- ret);
- return ret;
- }
-
- /* Get current device health. */
- gasket_dev->status = gasket_get_hw_status(gasket_dev);
- if (gasket_dev->status == GASKET_STATUS_DEAD) {
- dev_dbg(gasket_dev->dev, "Device reported as dead.\n");
- return -EINVAL;
- }
-
- return 0;
-}
-EXPORT_SYMBOL(gasket_reset_nolock);
-
-gasket_ioctl_permissions_cb_t
-gasket_get_ioctl_permissions_cb(struct gasket_dev *gasket_dev)
-{
- return gasket_dev->internal_desc->driver_desc->ioctl_permissions_cb;
-}
-EXPORT_SYMBOL(gasket_get_ioctl_permissions_cb);
-
-/* Get the driver structure for a given gasket_dev.
- * @dev: pointer to gasket_dev, implementing the requested driver.
- */
-const struct gasket_driver_desc *gasket_get_driver_desc(struct gasket_dev *dev)
-{
- return dev->internal_desc->driver_desc;
-}
-
-/* Get the device structure for a given gasket_dev.
- * @dev: pointer to gasket_dev, implementing the requested driver.
- */
-struct device *gasket_get_device(struct gasket_dev *dev)
-{
- return dev->dev;
-}
-
-/**
- * Asynchronously waits on device.
- * @gasket_dev: Device struct.
- * @bar: Bar
- * @offset: Register offset
- * @mask: Register mask
- * @val: Expected value
- * @max_retries: number of sleep periods
- * @delay_ms: Timeout in milliseconds
- *
- * Description: Busy waits for a specific combination of bits to be set on a
- * Gasket register.
- **/
-int gasket_wait_with_reschedule(struct gasket_dev *gasket_dev, int bar,
- u64 offset, u64 mask, u64 val,
- uint max_retries, u64 delay_ms)
-{
- uint retries = 0;
- u64 tmp;
-
- while (retries < max_retries) {
- tmp = gasket_dev_read_64(gasket_dev, bar, offset);
- if ((tmp & mask) == val)
- return 0;
- msleep(delay_ms);
- retries++;
- }
- dev_dbg(gasket_dev->dev, "%s timeout: reg %llx timeout (%llu ms)\n",
- __func__, offset, max_retries * delay_ms);
- return -ETIMEDOUT;
-}
-EXPORT_SYMBOL(gasket_wait_with_reschedule);
-
-/* See gasket_core.h for description. */
-int gasket_register_device(const struct gasket_driver_desc *driver_desc)
-{
- int i, ret;
- int desc_idx = -1;
- struct gasket_internal_desc *internal;
-
- pr_debug("Loading %s driver version %s\n", driver_desc->name,
- driver_desc->driver_version);
- /* Check for duplicates and find a free slot. */
- mutex_lock(&g_mutex);
-
- for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) {
- if (g_descs[i].driver_desc == driver_desc) {
- pr_err("%s driver already loaded/registered\n",
- driver_desc->name);
- mutex_unlock(&g_mutex);
- return -EBUSY;
- }
- }
-
- /* This and the above loop could be combined, but this reads easier. */
- for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) {
- if (!g_descs[i].driver_desc) {
- g_descs[i].driver_desc = driver_desc;
- desc_idx = i;
- break;
- }
- }
- mutex_unlock(&g_mutex);
-
- if (desc_idx == -1) {
- pr_err("too many drivers loaded, max %d\n",
- GASKET_FRAMEWORK_DESC_MAX);
- return -EBUSY;
- }
-
- internal = &g_descs[desc_idx];
- mutex_init(&internal->mutex);
- memset(internal->devs, 0, sizeof(struct gasket_dev *) * GASKET_DEV_MAX);
- internal->class =
- class_create(driver_desc->module, driver_desc->name);
-
- if (IS_ERR(internal->class)) {
- pr_err("Cannot register %s class [ret=%ld]\n",
- driver_desc->name, PTR_ERR(internal->class));
- ret = PTR_ERR(internal->class);
- goto unregister_gasket_driver;
- }
-
- ret = register_chrdev_region(MKDEV(driver_desc->major,
- driver_desc->minor), GASKET_DEV_MAX,
- driver_desc->name);
- if (ret) {
- pr_err("cannot register %s char driver [ret=%d]\n",
- driver_desc->name, ret);
- goto destroy_class;
- }
-
- return 0;
-
-destroy_class:
- class_destroy(internal->class);
-
-unregister_gasket_driver:
- mutex_lock(&g_mutex);
- g_descs[desc_idx].driver_desc = NULL;
- mutex_unlock(&g_mutex);
- return ret;
-}
-EXPORT_SYMBOL(gasket_register_device);
-
-/* See gasket_core.h for description. */
-void gasket_unregister_device(const struct gasket_driver_desc *driver_desc)
-{
- int i, desc_idx;
- struct gasket_internal_desc *internal_desc = NULL;
-
- mutex_lock(&g_mutex);
- for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) {
- if (g_descs[i].driver_desc == driver_desc) {
- internal_desc = &g_descs[i];
- desc_idx = i;
- break;
- }
- }
-
- if (!internal_desc) {
- mutex_unlock(&g_mutex);
- pr_err("request to unregister unknown desc: %s, %d:%d\n",
- driver_desc->name, driver_desc->major,
- driver_desc->minor);
- return;
- }
-
- unregister_chrdev_region(MKDEV(driver_desc->major, driver_desc->minor),
- GASKET_DEV_MAX);
-
- class_destroy(internal_desc->class);
-
- /* Finally, effectively "remove" the driver. */
- g_descs[desc_idx].driver_desc = NULL;
- mutex_unlock(&g_mutex);
-
- pr_debug("removed %s driver\n", driver_desc->name);
-}
-EXPORT_SYMBOL(gasket_unregister_device);
-
-static int __init gasket_init(void)
-{
- int i;
-
- mutex_lock(&g_mutex);
- for (i = 0; i < GASKET_FRAMEWORK_DESC_MAX; i++) {
- g_descs[i].driver_desc = NULL;
- mutex_init(&g_descs[i].mutex);
- }
-
- gasket_sysfs_init();
-
- mutex_unlock(&g_mutex);
- return 0;
-}
-
-MODULE_DESCRIPTION("Google Gasket driver framework");
-MODULE_VERSION(GASKET_FRAMEWORK_VERSION);
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("Rob Springer <rspringer@google.com>");
-module_init(gasket_init);
diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h
deleted file mode 100644
index c417acadb0d5..000000000000
--- a/drivers/staging/gasket/gasket_core.h
+++ /dev/null
@@ -1,638 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Gasket generic driver. Defines the set of data types and functions necessary
- * to define a driver using the Gasket generic driver framework.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-#ifndef __GASKET_CORE_H__
-#define __GASKET_CORE_H__
-
-#include <linux/cdev.h>
-#include <linux/compiler.h>
-#include <linux/device.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-
-#include "gasket_constants.h"
-
-/**
- * struct gasket_num_name - Map numbers to names.
- * @ein_num: Number.
- * @ein_name: Name associated with the number, a char pointer.
- *
- * This structure maps numbers to names. It is used to provide printable enum
- * names, e.g {0, "DEAD"} or {1, "ALIVE"}.
- */
-struct gasket_num_name {
- uint snn_num;
- const char *snn_name;
-};
-
-/*
- * Register location for packed interrupts.
- * Each value indicates the location of an interrupt field (in units of
- * gasket_driver_desc->interrupt_pack_width) within the containing register.
- * In other words, this indicates the shift to use when creating a mask to
- * extract/set bits within a register for a given interrupt.
- */
-enum gasket_interrupt_packing {
- PACK_0 = 0,
- PACK_1 = 1,
- PACK_2 = 2,
- PACK_3 = 3,
- UNPACKED = 4,
-};
-
-/* Type of the interrupt supported by the device. */
-enum gasket_interrupt_type {
- PCI_MSIX = 0,
-};
-
-/*
- * Used to describe a Gasket interrupt. Contains an interrupt index, a register,
- * and packing data for that interrupt. The register and packing data
- * fields are relevant only for PCI_MSIX interrupt type and can be
- * set to 0 for everything else.
- */
-struct gasket_interrupt_desc {
- /* Device-wide interrupt index/number. */
- int index;
- /* The register offset controlling this interrupt. */
- u64 reg;
- /* The location of this interrupt inside register reg, if packed. */
- int packing;
-};
-
-/*
- * This enum is used to identify memory regions being part of the physical
- * memory that belongs to a device.
- */
-enum mappable_area_type {
- PCI_BAR = 0, /* Default */
- BUS_REGION, /* For SYSBUS devices, i.e. AXI etc... */
- COHERENT_MEMORY
-};
-
-/*
- * Metadata for each BAR mapping.
- * This struct is used so as to track PCI memory, I/O space, AXI and coherent
- * memory area... i.e. memory objects which can be referenced in the device's
- * mmap function.
- */
-struct gasket_bar_data {
- /* Virtual base address. */
- u8 __iomem *virt_base;
-
- /* Physical base address. */
- ulong phys_base;
-
- /* Length of the mapping. */
- ulong length_bytes;
-
- /* Type of mappable area */
- enum mappable_area_type type;
-};
-
-/* Maintains device open ownership data. */
-struct gasket_ownership {
- /* 1 if the device is owned, 0 otherwise. */
- int is_owned;
-
- /* TGID of the owner. */
- pid_t owner;
-
- /* Count of current device opens in write mode. */
- int write_open_count;
-};
-
-/* Page table modes of operation. */
-enum gasket_page_table_mode {
- /* The page table is partitionable as normal, all simple by default. */
- GASKET_PAGE_TABLE_MODE_NORMAL,
-
- /* All entries are always simple. */
- GASKET_PAGE_TABLE_MODE_SIMPLE,
-
- /* All entries are always extended. No extended bit is used. */
- GASKET_PAGE_TABLE_MODE_EXTENDED,
-};
-
-/* Page table configuration. One per table. */
-struct gasket_page_table_config {
- /* The identifier/index of this page table. */
- int id;
-
- /* The operation mode of this page table. */
- enum gasket_page_table_mode mode;
-
- /* Total (first-level) entries in this page table. */
- ulong total_entries;
-
- /* Base register for the page table. */
- int base_reg;
-
- /*
- * Register containing the extended page table. This value is unused in
- * GASKET_PAGE_TABLE_MODE_SIMPLE and GASKET_PAGE_TABLE_MODE_EXTENDED
- * modes.
- */
- int extended_reg;
-
- /* The bit index indicating whether a PT entry is extended. */
- int extended_bit;
-};
-
-/* Maintains information about a device node. */
-struct gasket_cdev_info {
- /* The internal name of this device. */
- char name[GASKET_NAME_MAX];
-
- /* Device number. */
- dev_t devt;
-
- /* Kernel-internal device structure. */
- struct device *device;
-
- /* Character device for real. */
- struct cdev cdev;
-
- /* Flag indicating if cdev_add has been called for the devices. */
- int cdev_added;
-
- /* Pointer to the overall gasket_dev struct for this device. */
- struct gasket_dev *gasket_dev_ptr;
-
- /* Ownership data for the device in question. */
- struct gasket_ownership ownership;
-};
-
-/* Describes the offset and length of mmapable device BAR regions. */
-struct gasket_mappable_region {
- u64 start;
- u64 length_bytes;
-};
-
-/* Describe the offset, size, and permissions for a device bar. */
-struct gasket_bar_desc {
- /*
- * The size of each PCI BAR range, in bytes. If a value is 0, that BAR
- * will not be mapped into kernel space at all.
- * For devices with 64 bit BARs, only elements 0, 2, and 4 should be
- * populated, and 1, 3, and 5 should be set to 0.
- * For example, for a device mapping 1M in each of the first two 64-bit
- * BARs, this field would be set as { 0x100000, 0, 0x100000, 0, 0, 0 }
- * (one number per bar_desc struct.)
- */
- u64 size;
- /* The permissions for this bar. (Should be VM_WRITE/VM_READ/VM_EXEC,
- * and can be or'd.) If set to GASKET_NOMAP, the bar will
- * not be used for mmapping.
- */
- ulong permissions;
- /* The memory address corresponding to the base of this bar, if used. */
- u64 base;
- /* The number of mappable regions in this bar. */
- int num_mappable_regions;
-
- /* The mappable subregions of this bar. */
- const struct gasket_mappable_region *mappable_regions;
-
- /* Type of mappable area */
- enum mappable_area_type type;
-};
-
-/* Describes the offset, size, and permissions for a coherent buffer. */
-struct gasket_coherent_buffer_desc {
- /* The size of the coherent buffer. */
- u64 size;
-
- /* The permissions for this bar. (Should be VM_WRITE/VM_READ/VM_EXEC,
- * and can be or'd.) If set to GASKET_NOMAP, the bar will
- * not be used for mmaping.
- */
- ulong permissions;
-
- /* device side address. */
- u64 base;
-};
-
-/* Coherent buffer structure. */
-struct gasket_coherent_buffer {
- /* Virtual base address. */
- u8 *virt_base;
-
- /* Physical base address. */
- ulong phys_base;
-
- /* Length of the mapping. */
- ulong length_bytes;
-};
-
-/* Description of Gasket-specific permissions in the mmap field. */
-enum gasket_mapping_options { GASKET_NOMAP = 0 };
-
-/* This struct represents an undefined bar that should never be mapped. */
-#define GASKET_UNUSED_BAR \
- { \
- 0, GASKET_NOMAP, 0, 0, NULL, 0 \
- }
-
-/* Internal data for a Gasket device. See gasket_core.c for more information. */
-struct gasket_internal_desc;
-
-#define MAX_NUM_COHERENT_PAGES 16
-
-/*
- * Device data for Gasket device instances.
- *
- * This structure contains the data required to manage a Gasket device.
- */
-struct gasket_dev {
- /* Pointer to the internal driver description for this device. */
- struct gasket_internal_desc *internal_desc;
-
- /* Device info */
- struct device *dev;
-
- /* PCI subsystem metadata. */
- struct pci_dev *pci_dev;
-
- /* This device's index into internal_desc->devs. */
- int dev_idx;
-
- /* The name of this device, as reported by the kernel. */
- char kobj_name[GASKET_NAME_MAX];
-
- /* Virtual address of mapped BAR memory range. */
- struct gasket_bar_data bar_data[PCI_STD_NUM_BARS];
-
- /* Coherent buffer. */
- struct gasket_coherent_buffer coherent_buffer;
-
- /* Number of page tables for this device. */
- int num_page_tables;
-
- /* Address translations. Page tables have a private implementation. */
- struct gasket_page_table *page_table[GASKET_MAX_NUM_PAGE_TABLES];
-
- /* Interrupt data for this device. */
- struct gasket_interrupt_data *interrupt_data;
-
- /* Status for this device - GASKET_STATUS_ALIVE or _DEAD. */
- uint status;
-
- /* Number of times this device has been reset. */
- uint reset_count;
-
- /* Dev information for the cdev node. */
- struct gasket_cdev_info dev_info;
-
- /* Hardware revision value for this device. */
- int hardware_revision;
-
- /* Protects access to per-device data (i.e. this structure). */
- struct mutex mutex;
-
- /* cdev hash tracking/membership structure, Accel and legacy. */
- /* Unused until Accel is upstreamed. */
- struct hlist_node hlist_node;
- struct hlist_node legacy_hlist_node;
-};
-
-/* Type of the ioctl handler callback. */
-typedef long (*gasket_ioctl_handler_cb_t)(struct file *file, uint cmd,
- void __user *argp);
-/* Type of the ioctl permissions check callback. See below. */
-typedef int (*gasket_ioctl_permissions_cb_t)(struct file *filp, uint cmd,
- void __user *argp);
-
-/*
- * Device type descriptor.
- *
- * This structure contains device-specific data needed to identify and address a
- * type of device to be administered via the Gasket generic driver.
- *
- * Device IDs are per-driver. In other words, two drivers using the Gasket
- * framework will each have a distinct device 0 (for example).
- */
-struct gasket_driver_desc {
- /* The name of this device type. */
- const char *name;
-
- /* The name of this specific device model. */
- const char *chip_model;
-
- /* The version of the chip specified in chip_model. */
- const char *chip_version;
-
- /* The version of this driver: "1.0.0", "2.1.3", etc. */
- const char *driver_version;
-
- /*
- * Non-zero if we should create "legacy" (device and device-class-
- * specific) character devices and sysfs nodes.
- */
- /* Unused until Accel is upstreamed. */
- int legacy_support;
-
- /* Major and minor numbers identifying the device. */
- int major, minor;
-
- /* Module structure for this driver. */
- struct module *module;
-
- /* PCI ID table. */
- const struct pci_device_id *pci_id_table;
-
- /* The number of page tables handled by this driver. */
- int num_page_tables;
-
- /* The index of the bar containing the page tables. */
- int page_table_bar_index;
-
- /* Registers used to control each page table. */
- const struct gasket_page_table_config *page_table_configs;
-
- /* The bit index indicating whether a PT entry is extended. */
- int page_table_extended_bit;
-
- /*
- * Legacy mmap address adjusment for legacy devices only. Should be 0
- * for any new device.
- */
- ulong legacy_mmap_address_offset;
-
- /* Set of 6 bar descriptions that describe all PCIe bars.
- * Note that BUS/AXI devices (i.e. non PCI devices) use those.
- */
- struct gasket_bar_desc bar_descriptions[PCI_STD_NUM_BARS];
-
- /*
- * Coherent buffer description.
- */
- struct gasket_coherent_buffer_desc coherent_buffer_description;
-
- /* Interrupt type. (One of gasket_interrupt_type). */
- int interrupt_type;
-
- /* Index of the bar containing the interrupt registers to program. */
- int interrupt_bar_index;
-
- /* Number of interrupts in the gasket_interrupt_desc array */
- int num_interrupts;
-
- /* Description of the interrupts for this device. */
- const struct gasket_interrupt_desc *interrupts;
-
- /*
- * If this device packs multiple interrupt->MSI-X mappings into a
- * single register (i.e., "uses packed interrupts"), only a single bit
- * width is supported for each interrupt mapping (unpacked/"full-width"
- * interrupts are always supported). This value specifies that width. If
- * packed interrupts are not used, this value is ignored.
- */
- int interrupt_pack_width;
-
- /* Driver callback functions - all may be NULL */
- /*
- * device_open_cb: Callback for when a device node is opened in write
- * mode.
- * @dev: The gasket_dev struct for this driver instance.
- *
- * This callback should perform device-specific setup that needs to
- * occur only once when a device is first opened.
- */
- int (*device_open_cb)(struct gasket_dev *dev);
-
- /*
- * device_release_cb: Callback when a device is closed.
- * @gasket_dev: The gasket_dev struct for this driver instance.
- *
- * This callback is called whenever a device node fd is closed, as
- * opposed to device_close_cb, which is called when the _last_
- * descriptor for an open file is closed. This call is intended to
- * handle any per-user or per-fd cleanup.
- */
- int (*device_release_cb)(struct gasket_dev *gasket_dev,
- struct file *file);
-
- /*
- * device_close_cb: Callback for when a device node is closed for the
- * last time.
- * @dev: The gasket_dev struct for this driver instance.
- *
- * This callback should perform device-specific cleanup that only
- * needs to occur when the last reference to a device node is closed.
- *
- * This call is intended to handle and device-wide cleanup, as opposed
- * to per-fd cleanup (which should be handled by device_release_cb).
- */
- int (*device_close_cb)(struct gasket_dev *dev);
-
- /*
- * get_mappable_regions_cb: Get descriptors of mappable device memory.
- * @gasket_dev: Pointer to the struct gasket_dev for this device.
- * @bar_index: BAR for which to retrieve memory ranges.
- * @mappable_regions: Out-pointer to the list of mappable regions on the
- * device/BAR for this process.
- * @num_mappable_regions: Out-pointer for the size of mappable_regions.
- *
- * Called when handling mmap(), this callback is used to determine which
- * regions of device memory may be mapped by the current process. This
- * information is then compared to mmap request to determine which
- * regions to actually map.
- */
- int (*get_mappable_regions_cb)(struct gasket_dev *gasket_dev,
- int bar_index,
- struct gasket_mappable_region **mappable_regions,
- int *num_mappable_regions);
-
- /*
- * ioctl_permissions_cb: Check permissions for generic ioctls.
- * @filp: File structure pointer describing this node usage session.
- * @cmd: ioctl number to handle.
- * @arg: ioctl-specific data pointer.
- *
- * Returns 1 if the ioctl may be executed, 0 otherwise. If this callback
- * isn't specified a default routine will be used, that only allows the
- * original device opener (i.e, the "owner") to execute state-affecting
- * ioctls.
- */
- gasket_ioctl_permissions_cb_t ioctl_permissions_cb;
-
- /*
- * ioctl_handler_cb: Callback to handle device-specific ioctls.
- * @filp: File structure pointer describing this node usage session.
- * @cmd: ioctl number to handle.
- * @arg: ioctl-specific data pointer.
- *
- * Invoked whenever an ioctl is called that the generic Gasket
- * framework doesn't support. If no cb is registered, unknown ioctls
- * return -EINVAL. Should return an error status (either -EINVAL or
- * the error result of the ioctl being handled).
- */
- gasket_ioctl_handler_cb_t ioctl_handler_cb;
-
- /*
- * device_status_cb: Callback to determine device health.
- * @dev: Pointer to the gasket_dev struct for this device.
- *
- * Called to determine if the device is healthy or not. Should return
- * a member of the gasket_status_type enum.
- *
- */
- int (*device_status_cb)(struct gasket_dev *dev);
-
- /*
- * hardware_revision_cb: Get the device's hardware revision.
- * @dev: Pointer to the gasket_dev struct for this device.
- *
- * Called to determine the reported rev of the physical hardware.
- * Revision should be >0. A negative return value is an error.
- */
- int (*hardware_revision_cb)(struct gasket_dev *dev);
-
- /*
- * device_reset_cb: Reset the hardware in question.
- * @dev: Pointer to the gasket_dev structure for this device.
- *
- * Called by reset ioctls. This function should not
- * lock the gasket_dev mutex. It should return 0 on success
- * and an error on failure.
- */
- int (*device_reset_cb)(struct gasket_dev *dev);
-};
-
-/*
- * Register the specified device type with the framework.
- * @desc: Populated/initialized device type descriptor.
- *
- * This function does _not_ take ownership of desc; the underlying struct must
- * exist until the matching call to gasket_unregister_device.
- * This function should be called from your driver's module_init function.
- */
-int gasket_register_device(const struct gasket_driver_desc *desc);
-
-/*
- * Remove the specified device type from the framework.
- * @desc: Descriptor for the device type to unregister; it should have been
- * passed to gasket_register_device in a previous call.
- *
- * This function should be called from your driver's module_exit function.
- */
-void gasket_unregister_device(const struct gasket_driver_desc *desc);
-
-/* Add a PCI gasket device. */
-int gasket_pci_add_device(struct pci_dev *pci_dev,
- struct gasket_dev **gasket_devp);
-/* Remove a PCI gasket device. */
-void gasket_pci_remove_device(struct pci_dev *pci_dev);
-
-/* Enable a Gasket device. */
-int gasket_enable_device(struct gasket_dev *gasket_dev);
-
-/* Disable a Gasket device. */
-void gasket_disable_device(struct gasket_dev *gasket_dev);
-
-/*
- * Reset the Gasket device.
- * @gasket_dev: Gasket device struct.
- *
- * Calls device_reset_cb. Returns 0 on success and an error code othewrise.
- * gasket_reset_nolock will not lock the mutex, gasket_reset will.
- *
- */
-int gasket_reset(struct gasket_dev *gasket_dev);
-int gasket_reset_nolock(struct gasket_dev *gasket_dev);
-
-/*
- * Memory management functions. These will likely be spun off into their own
- * file in the future.
- */
-
-/* Unmaps the specified mappable region from a VMA. */
-int gasket_mm_unmap_region(const struct gasket_dev *gasket_dev,
- struct vm_area_struct *vma,
- const struct gasket_mappable_region *map_region);
-
-/*
- * Get the ioctl permissions callback.
- * @gasket_dev: Gasket device structure.
- */
-gasket_ioctl_permissions_cb_t
-gasket_get_ioctl_permissions_cb(struct gasket_dev *gasket_dev);
-
-/**
- * Lookup a name by number in a num_name table.
- * @num: Number to lookup.
- * @table: Array of num_name structures, the table for the lookup.
- *
- */
-const char *gasket_num_name_lookup(uint num,
- const struct gasket_num_name *table);
-
-/* Handy inlines */
-static inline ulong gasket_dev_read_64(struct gasket_dev *gasket_dev, int bar,
- ulong location)
-{
- return readq_relaxed(&gasket_dev->bar_data[bar].virt_base[location]);
-}
-
-static inline void gasket_dev_write_64(struct gasket_dev *dev, u64 value,
- int bar, ulong location)
-{
- writeq_relaxed(value, &dev->bar_data[bar].virt_base[location]);
-}
-
-static inline void gasket_dev_write_32(struct gasket_dev *dev, u32 value,
- int bar, ulong location)
-{
- writel_relaxed(value, &dev->bar_data[bar].virt_base[location]);
-}
-
-static inline u32 gasket_dev_read_32(struct gasket_dev *dev, int bar,
- ulong location)
-{
- return readl_relaxed(&dev->bar_data[bar].virt_base[location]);
-}
-
-static inline void gasket_read_modify_write_64(struct gasket_dev *dev, int bar,
- ulong location, u64 value,
- u64 mask_width, u64 mask_shift)
-{
- u64 mask, tmp;
-
- tmp = gasket_dev_read_64(dev, bar, location);
- mask = ((1ULL << mask_width) - 1) << mask_shift;
- tmp = (tmp & ~mask) | (value << mask_shift);
- gasket_dev_write_64(dev, tmp, bar, location);
-}
-
-static inline void gasket_read_modify_write_32(struct gasket_dev *dev, int bar,
- ulong location, u32 value,
- u32 mask_width, u32 mask_shift)
-{
- u32 mask, tmp;
-
- tmp = gasket_dev_read_32(dev, bar, location);
- mask = ((1 << mask_width) - 1) << mask_shift;
- tmp = (tmp & ~mask) | (value << mask_shift);
- gasket_dev_write_32(dev, tmp, bar, location);
-}
-
-/* Get the Gasket driver structure for a given device. */
-const struct gasket_driver_desc *gasket_get_driver_desc(struct gasket_dev *dev);
-
-/* Get the device structure for a given device. */
-struct device *gasket_get_device(struct gasket_dev *dev);
-
-/* Helper function, Asynchronous waits on a given set of bits. */
-int gasket_wait_with_reschedule(struct gasket_dev *gasket_dev, int bar,
- u64 offset, u64 mask, u64 val,
- uint max_retries, u64 delay_ms);
-
-#endif /* __GASKET_CORE_H__ */
diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c
deleted file mode 100644
index 864342acfd86..000000000000
--- a/drivers/staging/gasket/gasket_interrupt.c
+++ /dev/null
@@ -1,515 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright (C) 2018 Google, Inc. */
-
-#include "gasket_interrupt.h"
-
-#include "gasket_constants.h"
-#include "gasket_core.h"
-#include "gasket_sysfs.h"
-#include <linux/device.h>
-#include <linux/interrupt.h>
-#include <linux/printk.h>
-#ifdef GASKET_KERNEL_TRACE_SUPPORT
-#define CREATE_TRACE_POINTS
-#include <trace/events/gasket_interrupt.h>
-#else
-#define trace_gasket_interrupt_event(x, ...)
-#endif
-/* Retry attempts if the requested number of interrupts aren't available. */
-#define MSIX_RETRY_COUNT 3
-
-/* Instance interrupt management data. */
-struct gasket_interrupt_data {
- /* The name associated with this interrupt data. */
- const char *name;
-
- /* Interrupt type. See gasket_interrupt_type in gasket_core.h */
- int type;
-
- /* The PCI device [if any] associated with the owning device. */
- struct pci_dev *pci_dev;
-
- /* Set to 1 if MSI-X has successfully been configred, 0 otherwise. */
- int msix_configured;
-
- /* The number of interrupts requested by the owning device. */
- int num_interrupts;
-
- /* A pointer to the interrupt descriptor struct for this device. */
- const struct gasket_interrupt_desc *interrupts;
-
- /* The index of the bar into which interrupts should be mapped. */
- int interrupt_bar_index;
-
- /* The width of a single interrupt in a packed interrupt register. */
- int pack_width;
-
- /*
- * Design-wise, these elements should be bundled together, but
- * pci_enable_msix's interface requires that they be managed
- * individually (requires array of struct msix_entry).
- */
-
- /* The number of successfully configured interrupts. */
- int num_configured;
-
- /* The MSI-X data for each requested/configured interrupt. */
- struct msix_entry *msix_entries;
-
- /* The eventfd "callback" data for each interrupt. */
- struct eventfd_ctx **eventfd_ctxs;
-
- /* The number of times each interrupt has been called. */
- ulong *interrupt_counts;
-
- /* Linux IRQ number. */
- int irq;
-};
-
-/* Structures to display interrupt counts in sysfs. */
-enum interrupt_sysfs_attribute_type {
- ATTR_INTERRUPT_COUNTS,
-};
-
-/* Set up device registers for interrupt handling. */
-static void gasket_interrupt_setup(struct gasket_dev *gasket_dev)
-{
- int i;
- int pack_shift;
- ulong mask;
- ulong value;
- struct gasket_interrupt_data *interrupt_data =
- gasket_dev->interrupt_data;
-
- if (!interrupt_data) {
- dev_dbg(gasket_dev->dev, "Interrupt data is not initialized\n");
- return;
- }
-
- dev_dbg(gasket_dev->dev, "Running interrupt setup\n");
-
- /* Setup the MSIX table. */
-
- for (i = 0; i < interrupt_data->num_interrupts; i++) {
- /*
- * If the interrupt is not packed, we can write the index into
- * the register directly. If not, we need to deal with a read-
- * modify-write and shift based on the packing index.
- */
- dev_dbg(gasket_dev->dev,
- "Setting up interrupt index %d with index 0x%llx and packing %d\n",
- interrupt_data->interrupts[i].index,
- interrupt_data->interrupts[i].reg,
- interrupt_data->interrupts[i].packing);
- if (interrupt_data->interrupts[i].packing == UNPACKED) {
- value = interrupt_data->interrupts[i].index;
- } else {
- switch (interrupt_data->interrupts[i].packing) {
- case PACK_0:
- pack_shift = 0;
- break;
- case PACK_1:
- pack_shift = interrupt_data->pack_width;
- break;
- case PACK_2:
- pack_shift = 2 * interrupt_data->pack_width;
- break;
- case PACK_3:
- pack_shift = 3 * interrupt_data->pack_width;
- break;
- default:
- dev_dbg(gasket_dev->dev,
- "Found interrupt description with unknown enum %d\n",
- interrupt_data->interrupts[i].packing);
- return;
- }
-
- mask = ~(0xFFFF << pack_shift);
- value = gasket_dev_read_64(gasket_dev,
- interrupt_data->interrupt_bar_index,
- interrupt_data->interrupts[i].reg);
- value &= mask;
- value |= interrupt_data->interrupts[i].index
- << pack_shift;
- }
- gasket_dev_write_64(gasket_dev, value,
- interrupt_data->interrupt_bar_index,
- interrupt_data->interrupts[i].reg);
- }
-}
-
-static void
-gasket_handle_interrupt(struct gasket_interrupt_data *interrupt_data,
- int interrupt_index)
-{
- struct eventfd_ctx *ctx;
-
- trace_gasket_interrupt_event(interrupt_data->name, interrupt_index);
- ctx = interrupt_data->eventfd_ctxs[interrupt_index];
- if (ctx)
- eventfd_signal(ctx, 1);
-
- ++(interrupt_data->interrupt_counts[interrupt_index]);
-}
-
-static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id)
-{
- struct gasket_interrupt_data *interrupt_data = dev_id;
- int interrupt = -1;
- int i;
-
- /* If this linear lookup is a problem, we can maintain a map/hash. */
- for (i = 0; i < interrupt_data->num_interrupts; i++) {
- if (interrupt_data->msix_entries[i].vector == irq) {
- interrupt = interrupt_data->msix_entries[i].entry;
- break;
- }
- }
- if (interrupt == -1) {
- pr_err("Received unknown irq %d\n", irq);
- return IRQ_HANDLED;
- }
- gasket_handle_interrupt(interrupt_data, interrupt);
- return IRQ_HANDLED;
-}
-
-static int
-gasket_interrupt_msix_init(struct gasket_interrupt_data *interrupt_data)
-{
- int ret = 1;
- int i;
-
- interrupt_data->msix_entries =
- kcalloc(interrupt_data->num_interrupts,
- sizeof(*interrupt_data->msix_entries), GFP_KERNEL);
- if (!interrupt_data->msix_entries)
- return -ENOMEM;
-
- for (i = 0; i < interrupt_data->num_interrupts; i++) {
- interrupt_data->msix_entries[i].entry = i;
- interrupt_data->msix_entries[i].vector = 0;
- interrupt_data->eventfd_ctxs[i] = NULL;
- }
-
- /* Retry MSIX_RETRY_COUNT times if not enough IRQs are available. */
- for (i = 0; i < MSIX_RETRY_COUNT && ret > 0; i++)
- ret = pci_enable_msix_exact(interrupt_data->pci_dev,
- interrupt_data->msix_entries,
- interrupt_data->num_interrupts);
-
- if (ret)
- return ret > 0 ? -EBUSY : ret;
- interrupt_data->msix_configured = 1;
-
- for (i = 0; i < interrupt_data->num_interrupts; i++) {
- ret = request_irq(interrupt_data->msix_entries[i].vector,
- gasket_msix_interrupt_handler, 0,
- interrupt_data->name, interrupt_data);
-
- if (ret) {
- dev_err(&interrupt_data->pci_dev->dev,
- "Cannot get IRQ for interrupt %d, vector %d; "
- "%d\n",
- i, interrupt_data->msix_entries[i].vector, ret);
- return ret;
- }
-
- interrupt_data->num_configured++;
- }
-
- return 0;
-}
-
-/*
- * On QCM DragonBoard, we exit gasket_interrupt_msix_init() and kernel interrupt
- * setup code with MSIX vectors masked. This is wrong because nothing else in
- * the driver will normally touch the MSIX vectors.
- *
- * As a temporary hack, force unmasking there.
- *
- * TODO: Figure out why QCM kernel doesn't unmask the MSIX vectors, after
- * gasket_interrupt_msix_init(), and remove this code.
- */
-static void force_msix_interrupt_unmasking(struct gasket_dev *gasket_dev)
-{
- int i;
-#define MSIX_VECTOR_SIZE 16
-#define MSIX_MASK_BIT_OFFSET 12
-#define APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE 0x46800
- for (i = 0; i < gasket_dev->interrupt_data->num_configured; i++) {
- /* Check if the MSIX vector is unmasked */
- ulong location = APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE +
- MSIX_MASK_BIT_OFFSET + i * MSIX_VECTOR_SIZE;
- u32 mask =
- gasket_dev_read_32(gasket_dev,
- gasket_dev->interrupt_data->interrupt_bar_index,
- location);
- if (!(mask & 1))
- continue;
- /* Unmask the msix vector (clear 32 bits) */
- gasket_dev_write_32(gasket_dev, 0,
- gasket_dev->interrupt_data->interrupt_bar_index,
- location);
- }
-#undef MSIX_VECTOR_SIZE
-#undef MSIX_MASK_BIT_OFFSET
-#undef APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE
-}
-
-static ssize_t interrupt_sysfs_show(struct device *device,
- struct device_attribute *attr, char *buf)
-{
- int i, ret;
- ssize_t written = 0, total_written = 0;
- struct gasket_interrupt_data *interrupt_data;
- struct gasket_dev *gasket_dev;
- struct gasket_sysfs_attribute *gasket_attr;
- enum interrupt_sysfs_attribute_type sysfs_type;
-
- gasket_dev = gasket_sysfs_get_device_data(device);
- if (!gasket_dev) {
- dev_dbg(device, "No sysfs mapping found for device\n");
- return 0;
- }
-
- gasket_attr = gasket_sysfs_get_attr(device, attr);
- if (!gasket_attr) {
- dev_dbg(device, "No sysfs attr data found for device\n");
- gasket_sysfs_put_device_data(device, gasket_dev);
- return 0;
- }
-
- sysfs_type = (enum interrupt_sysfs_attribute_type)
- gasket_attr->data.attr_type;
- interrupt_data = gasket_dev->interrupt_data;
- switch (sysfs_type) {
- case ATTR_INTERRUPT_COUNTS:
- for (i = 0; i < interrupt_data->num_interrupts; ++i) {
- written =
- scnprintf(buf, PAGE_SIZE - total_written,
- "0x%02x: %ld\n", i,
- interrupt_data->interrupt_counts[i]);
- total_written += written;
- buf += written;
- }
- ret = total_written;
- break;
- default:
- dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n",
- attr->attr.name);
- ret = 0;
- break;
- }
-
- gasket_sysfs_put_attr(device, gasket_attr);
- gasket_sysfs_put_device_data(device, gasket_dev);
- return ret;
-}
-
-static struct gasket_sysfs_attribute interrupt_sysfs_attrs[] = {
- GASKET_SYSFS_RO(interrupt_counts, interrupt_sysfs_show,
- ATTR_INTERRUPT_COUNTS),
- GASKET_END_OF_ATTR_ARRAY,
-};
-
-int gasket_interrupt_init(struct gasket_dev *gasket_dev)
-{
- int ret;
- struct gasket_interrupt_data *interrupt_data;
- const struct gasket_driver_desc *driver_desc =
- gasket_get_driver_desc(gasket_dev);
-
- interrupt_data = kzalloc(sizeof(*interrupt_data), GFP_KERNEL);
- if (!interrupt_data)
- return -ENOMEM;
- gasket_dev->interrupt_data = interrupt_data;
- interrupt_data->name = driver_desc->name;
- interrupt_data->type = driver_desc->interrupt_type;
- interrupt_data->pci_dev = gasket_dev->pci_dev;
- interrupt_data->num_interrupts = driver_desc->num_interrupts;
- interrupt_data->interrupts = driver_desc->interrupts;
- interrupt_data->interrupt_bar_index = driver_desc->interrupt_bar_index;
- interrupt_data->pack_width = driver_desc->interrupt_pack_width;
- interrupt_data->num_configured = 0;
-
- interrupt_data->eventfd_ctxs =
- kcalloc(driver_desc->num_interrupts,
- sizeof(*interrupt_data->eventfd_ctxs), GFP_KERNEL);
- if (!interrupt_data->eventfd_ctxs) {
- kfree(interrupt_data);
- return -ENOMEM;
- }
-
- interrupt_data->interrupt_counts =
- kcalloc(driver_desc->num_interrupts,
- sizeof(*interrupt_data->interrupt_counts), GFP_KERNEL);
- if (!interrupt_data->interrupt_counts) {
- kfree(interrupt_data->eventfd_ctxs);
- kfree(interrupt_data);
- return -ENOMEM;
- }
-
- switch (interrupt_data->type) {
- case PCI_MSIX:
- ret = gasket_interrupt_msix_init(interrupt_data);
- if (ret)
- break;
- force_msix_interrupt_unmasking(gasket_dev);
- break;
-
- default:
- ret = -EINVAL;
- }
-
- if (ret) {
- /* Failing to setup interrupts will cause the device to report
- * GASKET_STATUS_LAMED. But it is not fatal.
- */
- dev_warn(gasket_dev->dev,
- "Couldn't initialize interrupts: %d\n", ret);
- return 0;
- }
-
- gasket_interrupt_setup(gasket_dev);
- gasket_sysfs_create_entries(gasket_dev->dev_info.device,
- interrupt_sysfs_attrs);
-
- return 0;
-}
-
-static void
-gasket_interrupt_msix_cleanup(struct gasket_interrupt_data *interrupt_data)
-{
- int i;
-
- for (i = 0; i < interrupt_data->num_configured; i++)
- free_irq(interrupt_data->msix_entries[i].vector,
- interrupt_data);
- interrupt_data->num_configured = 0;
-
- if (interrupt_data->msix_configured)
- pci_disable_msix(interrupt_data->pci_dev);
- interrupt_data->msix_configured = 0;
- kfree(interrupt_data->msix_entries);
-}
-
-int gasket_interrupt_reinit(struct gasket_dev *gasket_dev)
-{
- int ret;
-
- if (!gasket_dev->interrupt_data) {
- dev_dbg(gasket_dev->dev,
- "Attempted to reinit uninitialized interrupt data\n");
- return -EINVAL;
- }
-
- switch (gasket_dev->interrupt_data->type) {
- case PCI_MSIX:
- gasket_interrupt_msix_cleanup(gasket_dev->interrupt_data);
- ret = gasket_interrupt_msix_init(gasket_dev->interrupt_data);
- if (ret)
- break;
- force_msix_interrupt_unmasking(gasket_dev);
- break;
-
- default:
- ret = -EINVAL;
- }
-
- if (ret) {
- /* Failing to setup interrupts will cause the device
- * to report GASKET_STATUS_LAMED, but is not fatal.
- */
- dev_warn(gasket_dev->dev, "Couldn't reinit interrupts: %d\n",
- ret);
- return 0;
- }
-
- gasket_interrupt_setup(gasket_dev);
-
- return 0;
-}
-
-/* See gasket_interrupt.h for description. */
-int gasket_interrupt_reset_counts(struct gasket_dev *gasket_dev)
-{
- dev_dbg(gasket_dev->dev, "Clearing interrupt counts\n");
- memset(gasket_dev->interrupt_data->interrupt_counts, 0,
- gasket_dev->interrupt_data->num_interrupts *
- sizeof(*gasket_dev->interrupt_data->interrupt_counts));
- return 0;
-}
-
-/* See gasket_interrupt.h for description. */
-void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev)
-{
- struct gasket_interrupt_data *interrupt_data =
- gasket_dev->interrupt_data;
- /*
- * It is possible to get an error code from gasket_interrupt_init
- * before interrupt_data has been allocated, so check it.
- */
- if (!interrupt_data)
- return;
-
- switch (interrupt_data->type) {
- case PCI_MSIX:
- gasket_interrupt_msix_cleanup(interrupt_data);
- break;
-
- default:
- break;
- }
-
- kfree(interrupt_data->interrupt_counts);
- kfree(interrupt_data->eventfd_ctxs);
- kfree(interrupt_data);
- gasket_dev->interrupt_data = NULL;
-}
-
-int gasket_interrupt_system_status(struct gasket_dev *gasket_dev)
-{
- if (!gasket_dev->interrupt_data) {
- dev_dbg(gasket_dev->dev, "Interrupt data is null\n");
- return GASKET_STATUS_DEAD;
- }
-
- if (gasket_dev->interrupt_data->num_configured !=
- gasket_dev->interrupt_data->num_interrupts) {
- dev_dbg(gasket_dev->dev,
- "Not all interrupts were configured\n");
- return GASKET_STATUS_LAMED;
- }
-
- return GASKET_STATUS_ALIVE;
-}
-
-int gasket_interrupt_set_eventfd(struct gasket_interrupt_data *interrupt_data,
- int interrupt, int event_fd)
-{
- struct eventfd_ctx *ctx;
-
- if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts)
- return -EINVAL;
-
- ctx = eventfd_ctx_fdget(event_fd);
-
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- interrupt_data->eventfd_ctxs[interrupt] = ctx;
- return 0;
-}
-
-int gasket_interrupt_clear_eventfd(struct gasket_interrupt_data *interrupt_data,
- int interrupt)
-{
- if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts)
- return -EINVAL;
-
- if (interrupt_data->eventfd_ctxs[interrupt]) {
- eventfd_ctx_put(interrupt_data->eventfd_ctxs[interrupt]);
- interrupt_data->eventfd_ctxs[interrupt] = NULL;
- }
- return 0;
-}
diff --git a/drivers/staging/gasket/gasket_interrupt.h b/drivers/staging/gasket/gasket_interrupt.h
deleted file mode 100644
index 85526a1374a1..000000000000
--- a/drivers/staging/gasket/gasket_interrupt.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Gasket common interrupt module. Defines functions for enabling
- * eventfd-triggered interrupts between a Gasket device and a host process.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-#ifndef __GASKET_INTERRUPT_H__
-#define __GASKET_INTERRUPT_H__
-
-#include <linux/eventfd.h>
-#include <linux/pci.h>
-
-#include "gasket_core.h"
-
-/* Note that this currently assumes that device interrupts are a dense set,
- * numbered from 0 - (num_interrupts - 1). Should this have to change, these
- * APIs will have to be updated.
- */
-
-/* Opaque type used to hold interrupt subsystem data. */
-struct gasket_interrupt_data;
-
-/*
- * Initialize the interrupt module.
- * @gasket_dev: The Gasket device structure for the device to be initted.
- */
-int gasket_interrupt_init(struct gasket_dev *gasket_dev);
-
-/*
- * Clean up a device's interrupt structure.
- * @gasket_dev: The Gasket information structure for this device.
- *
- * Cleans up the device's interrupts and deallocates data.
- */
-void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev);
-
-/*
- * Clean up and re-initialize the MSI-x subsystem.
- * @gasket_dev: The Gasket information structure for this device.
- *
- * Performs a teardown of the MSI-x subsystem and re-initializes it. Does not
- * free the underlying data structures. Returns 0 on success and an error code
- * on error.
- */
-int gasket_interrupt_reinit(struct gasket_dev *gasket_dev);
-
-/*
- * Reset the counts stored in the interrupt subsystem.
- * @gasket_dev: The Gasket information structure for this device.
- *
- * Sets the counts of all interrupts in the subsystem to 0.
- */
-int gasket_interrupt_reset_counts(struct gasket_dev *gasket_dev);
-
-/*
- * Associates an eventfd with a device interrupt.
- * @data: Pointer to device interrupt data.
- * @interrupt: The device interrupt to configure.
- * @event_fd: The eventfd to associate with the interrupt.
- *
- * Prepares the host to receive notification of device interrupts by associating
- * event_fd with interrupt. Upon receipt of a device interrupt, event_fd will be
- * signaled, after successful configuration.
- *
- * Returns 0 on success, a negative error code otherwise.
- */
-int gasket_interrupt_set_eventfd(struct gasket_interrupt_data *interrupt_data,
- int interrupt, int event_fd);
-
-/*
- * Removes an interrupt-eventfd association.
- * @data: Pointer to device interrupt data.
- * @interrupt: The device interrupt to de-associate.
- *
- * Removes any eventfd associated with the specified interrupt, if any.
- */
-int gasket_interrupt_clear_eventfd(struct gasket_interrupt_data *interrupt_data,
- int interrupt);
-
-/*
- * The below functions exist for backwards compatibility.
- * No new uses should be written.
- */
-/*
- * Get the health of the interrupt subsystem.
- * @gasket_dev: The Gasket device struct.
- *
- * Returns DEAD if not set up, LAMED if initialization failed, and ALIVE
- * otherwise.
- */
-
-int gasket_interrupt_system_status(struct gasket_dev *gasket_dev);
-
-#endif
diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c
deleted file mode 100644
index aa65f4fbf860..000000000000
--- a/drivers/staging/gasket/gasket_ioctl.c
+++ /dev/null
@@ -1,388 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright (C) 2018 Google, Inc. */
-#include "gasket.h"
-#include "gasket_ioctl.h"
-#include "gasket_constants.h"
-#include "gasket_core.h"
-#include "gasket_interrupt.h"
-#include "gasket_page_table.h"
-#include <linux/compiler.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/uaccess.h>
-
-#ifdef GASKET_KERNEL_TRACE_SUPPORT
-#define CREATE_TRACE_POINTS
-#include <trace/events/gasket_ioctl.h>
-#else
-#define trace_gasket_ioctl_entry(x, ...)
-#define trace_gasket_ioctl_exit(x)
-#define trace_gasket_ioctl_integer_data(x)
-#define trace_gasket_ioctl_eventfd_data(x, ...)
-#define trace_gasket_ioctl_page_table_data(x, ...)
-#define trace_gasket_ioctl_config_coherent_allocator(x, ...)
-#endif
-
-/* Associate an eventfd with an interrupt. */
-static int gasket_set_event_fd(struct gasket_dev *gasket_dev,
- struct gasket_interrupt_eventfd __user *argp)
-{
- struct gasket_interrupt_eventfd die;
-
- if (copy_from_user(&die, argp, sizeof(struct gasket_interrupt_eventfd)))
- return -EFAULT;
-
- trace_gasket_ioctl_eventfd_data(die.interrupt, die.event_fd);
-
- return gasket_interrupt_set_eventfd(gasket_dev->interrupt_data,
- die.interrupt, die.event_fd);
-}
-
-/* Read the size of the page table. */
-static int gasket_read_page_table_size(struct gasket_dev *gasket_dev,
- struct gasket_page_table_ioctl __user *argp)
-{
- int ret = 0;
- struct gasket_page_table_ioctl ibuf;
- struct gasket_page_table *table;
-
- if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl)))
- return -EFAULT;
-
- if (ibuf.page_table_index >= gasket_dev->num_page_tables)
- return -EFAULT;
-
- table = gasket_dev->page_table[ibuf.page_table_index];
- ibuf.size = gasket_page_table_num_entries(table);
-
- trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
- ibuf.host_address,
- ibuf.device_address);
-
- if (copy_to_user(argp, &ibuf, sizeof(ibuf)))
- return -EFAULT;
-
- return ret;
-}
-
-/* Read the size of the simple page table. */
-static int gasket_read_simple_page_table_size(struct gasket_dev *gasket_dev,
- struct gasket_page_table_ioctl __user *argp)
-{
- int ret = 0;
- struct gasket_page_table_ioctl ibuf;
- struct gasket_page_table *table;
-
- if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl)))
- return -EFAULT;
-
- if (ibuf.page_table_index >= gasket_dev->num_page_tables)
- return -EFAULT;
-
- table = gasket_dev->page_table[ibuf.page_table_index];
- ibuf.size = gasket_page_table_num_simple_entries(table);
-
- trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
- ibuf.host_address,
- ibuf.device_address);
-
- if (copy_to_user(argp, &ibuf, sizeof(ibuf)))
- return -EFAULT;
-
- return ret;
-}
-
-/* Set the boundary between the simple and extended page tables. */
-static int gasket_partition_page_table(struct gasket_dev *gasket_dev,
- struct gasket_page_table_ioctl __user *argp)
-{
- int ret;
- struct gasket_page_table_ioctl ibuf;
- uint max_page_table_size;
- struct gasket_page_table *table;
-
- if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl)))
- return -EFAULT;
-
- trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
- ibuf.host_address,
- ibuf.device_address);
-
- if (ibuf.page_table_index >= gasket_dev->num_page_tables)
- return -EFAULT;
- table = gasket_dev->page_table[ibuf.page_table_index];
- max_page_table_size = gasket_page_table_max_size(table);
-
- if (ibuf.size > max_page_table_size) {
- dev_dbg(gasket_dev->dev,
- "Partition request 0x%llx too large, max is 0x%x\n",
- ibuf.size, max_page_table_size);
- return -EINVAL;
- }
-
- mutex_lock(&gasket_dev->mutex);
-
- ret = gasket_page_table_partition(table, ibuf.size);
- mutex_unlock(&gasket_dev->mutex);
-
- return ret;
-}
-
-/* Map a userspace buffer to a device virtual address. */
-static int gasket_map_buffers(struct gasket_dev *gasket_dev,
- struct gasket_page_table_ioctl __user *argp)
-{
- struct gasket_page_table_ioctl ibuf;
- struct gasket_page_table *table;
-
- if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl)))
- return -EFAULT;
-
- trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
- ibuf.host_address,
- ibuf.device_address);
-
- if (ibuf.page_table_index >= gasket_dev->num_page_tables)
- return -EFAULT;
-
- table = gasket_dev->page_table[ibuf.page_table_index];
- if (gasket_page_table_are_addrs_bad(table, ibuf.host_address,
- ibuf.device_address, ibuf.size))
- return -EINVAL;
-
- return gasket_page_table_map(table, ibuf.host_address, ibuf.device_address,
- ibuf.size / PAGE_SIZE);
-}
-
-/* Unmap a userspace buffer from a device virtual address. */
-static int gasket_unmap_buffers(struct gasket_dev *gasket_dev,
- struct gasket_page_table_ioctl __user *argp)
-{
- struct gasket_page_table_ioctl ibuf;
- struct gasket_page_table *table;
-
- if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl)))
- return -EFAULT;
-
- trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
- ibuf.host_address,
- ibuf.device_address);
-
- if (ibuf.page_table_index >= gasket_dev->num_page_tables)
- return -EFAULT;
-
- table = gasket_dev->page_table[ibuf.page_table_index];
- if (gasket_page_table_is_dev_addr_bad(table, ibuf.device_address, ibuf.size))
- return -EINVAL;
-
- gasket_page_table_unmap(table, ibuf.device_address, ibuf.size / PAGE_SIZE);
-
- return 0;
-}
-
-/*
- * Reserve structures for coherent allocation, and allocate or free the
- * corresponding memory.
- */
-static int gasket_config_coherent_allocator(struct gasket_dev *gasket_dev,
- struct gasket_coherent_alloc_config_ioctl __user *argp)
-{
- int ret;
- struct gasket_coherent_alloc_config_ioctl ibuf;
-
- if (copy_from_user(&ibuf, argp,
- sizeof(struct gasket_coherent_alloc_config_ioctl)))
- return -EFAULT;
-
- trace_gasket_ioctl_config_coherent_allocator(ibuf.enable, ibuf.size,
- ibuf.dma_address);
-
- if (ibuf.page_table_index >= gasket_dev->num_page_tables)
- return -EFAULT;
-
- if (ibuf.size > PAGE_SIZE * MAX_NUM_COHERENT_PAGES)
- return -ENOMEM;
-
- if (ibuf.enable == 0) {
- ret = gasket_free_coherent_memory(gasket_dev, ibuf.size,
- ibuf.dma_address,
- ibuf.page_table_index);
- } else {
- ret = gasket_alloc_coherent_memory(gasket_dev, ibuf.size,
- &ibuf.dma_address,
- ibuf.page_table_index);
- }
- if (ret)
- return ret;
- if (copy_to_user(argp, &ibuf, sizeof(ibuf)))
- return -EFAULT;
-
- return 0;
-}
-
-/* Check permissions for Gasket ioctls. */
-static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd)
-{
- bool alive;
- bool read, write;
- struct gasket_dev *gasket_dev = (struct gasket_dev *)filp->private_data;
-
- alive = (gasket_dev->status == GASKET_STATUS_ALIVE);
- if (!alive)
- dev_dbg(gasket_dev->dev, "%s alive %d status %d\n",
- __func__, alive, gasket_dev->status);
-
- read = !!(filp->f_mode & FMODE_READ);
- write = !!(filp->f_mode & FMODE_WRITE);
-
- switch (cmd) {
- case GASKET_IOCTL_RESET:
- case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS:
- return write;
-
- case GASKET_IOCTL_PAGE_TABLE_SIZE:
- case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE:
- case GASKET_IOCTL_NUMBER_PAGE_TABLES:
- return read;
-
- case GASKET_IOCTL_PARTITION_PAGE_TABLE:
- case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR:
- return alive && write;
-
- case GASKET_IOCTL_MAP_BUFFER:
- case GASKET_IOCTL_UNMAP_BUFFER:
- return alive && write;
-
- case GASKET_IOCTL_CLEAR_EVENTFD:
- case GASKET_IOCTL_SET_EVENTFD:
- return alive && write;
- }
-
- return false; /* unknown permissions */
-}
-
-/*
- * standard ioctl dispatch function.
- * @filp: File structure pointer describing this node usage session.
- * @cmd: ioctl number to handle.
- * @argp: ioctl-specific data pointer.
- *
- * Standard ioctl dispatcher; forwards operations to individual handlers.
- */
-long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp)
-{
- struct gasket_dev *gasket_dev;
- unsigned long arg = (unsigned long)argp;
- gasket_ioctl_permissions_cb_t ioctl_permissions_cb;
- int retval;
-
- gasket_dev = (struct gasket_dev *)filp->private_data;
- trace_gasket_ioctl_entry(gasket_dev->dev_info.name, cmd);
-
- ioctl_permissions_cb = gasket_get_ioctl_permissions_cb(gasket_dev);
- if (ioctl_permissions_cb) {
- retval = ioctl_permissions_cb(filp, cmd, argp);
- if (retval < 0) {
- trace_gasket_ioctl_exit(retval);
- return retval;
- } else if (retval == 0) {
- trace_gasket_ioctl_exit(-EPERM);
- return -EPERM;
- }
- } else if (!gasket_ioctl_check_permissions(filp, cmd)) {
- trace_gasket_ioctl_exit(-EPERM);
- dev_dbg(gasket_dev->dev, "ioctl cmd=%x noperm\n", cmd);
- return -EPERM;
- }
-
- /* Tracing happens in this switch statement for all ioctls with
- * an integer argrument, but ioctls with a struct argument
- * that needs copying and decoding, that tracing is done within
- * the handler call.
- */
- switch (cmd) {
- case GASKET_IOCTL_RESET:
- retval = gasket_reset(gasket_dev);
- break;
- case GASKET_IOCTL_SET_EVENTFD:
- retval = gasket_set_event_fd(gasket_dev, argp);
- break;
- case GASKET_IOCTL_CLEAR_EVENTFD:
- trace_gasket_ioctl_integer_data(arg);
- retval =
- gasket_interrupt_clear_eventfd(gasket_dev->interrupt_data,
- (int)arg);
- break;
- case GASKET_IOCTL_PARTITION_PAGE_TABLE:
- trace_gasket_ioctl_integer_data(arg);
- retval = gasket_partition_page_table(gasket_dev, argp);
- break;
- case GASKET_IOCTL_NUMBER_PAGE_TABLES:
- trace_gasket_ioctl_integer_data(gasket_dev->num_page_tables);
- if (copy_to_user(argp, &gasket_dev->num_page_tables,
- sizeof(uint64_t)))
- retval = -EFAULT;
- else
- retval = 0;
- break;
- case GASKET_IOCTL_PAGE_TABLE_SIZE:
- retval = gasket_read_page_table_size(gasket_dev, argp);
- break;
- case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE:
- retval = gasket_read_simple_page_table_size(gasket_dev, argp);
- break;
- case GASKET_IOCTL_MAP_BUFFER:
- retval = gasket_map_buffers(gasket_dev, argp);
- break;
- case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR:
- retval = gasket_config_coherent_allocator(gasket_dev, argp);
- break;
- case GASKET_IOCTL_UNMAP_BUFFER:
- retval = gasket_unmap_buffers(gasket_dev, argp);
- break;
- case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS:
- /* Clear interrupt counts doesn't take an arg, so use 0. */
- trace_gasket_ioctl_integer_data(0);
- retval = gasket_interrupt_reset_counts(gasket_dev);
- break;
- default:
- /* If we don't understand the ioctl, the best we can do is trace
- * the arg.
- */
- trace_gasket_ioctl_integer_data(arg);
- dev_dbg(gasket_dev->dev,
- "Unknown ioctl cmd=0x%x not caught by gasket_is_supported_ioctl\n",
- cmd);
- retval = -EINVAL;
- break;
- }
-
- trace_gasket_ioctl_exit(retval);
- return retval;
-}
-
-/*
- * Determines if an ioctl is part of the standard Gasket framework.
- * @cmd: The ioctl number to handle.
- *
- * Returns 1 if the ioctl is supported and 0 otherwise.
- */
-long gasket_is_supported_ioctl(uint cmd)
-{
- switch (cmd) {
- case GASKET_IOCTL_RESET:
- case GASKET_IOCTL_SET_EVENTFD:
- case GASKET_IOCTL_CLEAR_EVENTFD:
- case GASKET_IOCTL_PARTITION_PAGE_TABLE:
- case GASKET_IOCTL_NUMBER_PAGE_TABLES:
- case GASKET_IOCTL_PAGE_TABLE_SIZE:
- case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE:
- case GASKET_IOCTL_MAP_BUFFER:
- case GASKET_IOCTL_UNMAP_BUFFER:
- case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS:
- case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR:
- return 1;
- default:
- return 0;
- }
-}
diff --git a/drivers/staging/gasket/gasket_ioctl.h b/drivers/staging/gasket/gasket_ioctl.h
deleted file mode 100644
index 51f468c77f04..000000000000
--- a/drivers/staging/gasket/gasket_ioctl.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright (C) 2018 Google, Inc. */
-#ifndef __GASKET_IOCTL_H__
-#define __GASKET_IOCTL_H__
-
-#include "gasket_core.h"
-
-#include <linux/compiler.h>
-
-/*
- * Handle Gasket common ioctls.
- * @filp: Pointer to the ioctl's file.
- * @cmd: Ioctl command.
- * @arg: Ioctl argument pointer.
- *
- * Returns 0 on success and nonzero on failure.
- */
-long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp);
-
-/*
- * Determines if an ioctl is part of the standard Gasket framework.
- * @cmd: The ioctl number to handle.
- *
- * Returns 1 if the ioctl is supported and 0 otherwise.
- */
-long gasket_is_supported_ioctl(uint cmd);
-
-#endif
diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c
deleted file mode 100644
index 6f6273c83822..000000000000
--- a/drivers/staging/gasket/gasket_page_table.c
+++ /dev/null
@@ -1,1359 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Implementation of Gasket page table support.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-
-/*
- * Implementation of Gasket page table support.
- *
- * This file assumes 4kB pages throughout; can be factored out when necessary.
- *
- * There is a configurable number of page table entries, as well as a
- * configurable bit index for the extended address flag. Both of these are
- * specified in gasket_page_table_init through the page_table_config parameter.
- *
- * The following example assumes:
- * page_table_config->total_entries = 8192
- * page_table_config->extended_bit = 63
- *
- * Address format:
- * Simple addresses - those whose containing pages are directly placed in the
- * device's address translation registers - are laid out as:
- * [ 63 - 25: 0 | 24 - 12: page index | 11 - 0: page offset ]
- * page index: The index of the containing page in the device's address
- * translation registers.
- * page offset: The index of the address into the containing page.
- *
- * Extended address - those whose containing pages are contained in a second-
- * level page table whose address is present in the device's address translation
- * registers - are laid out as:
- * [ 63: flag | 62 - 34: 0 | 33 - 21: dev/level 0 index |
- * 20 - 12: host/level 1 index | 11 - 0: page offset ]
- * flag: Marker indicating that this is an extended address. Always 1.
- * dev index: The index of the first-level page in the device's extended
- * address translation registers.
- * host index: The index of the containing page in the [host-resident] second-
- * level page table.
- * page offset: The index of the address into the containing [second-level]
- * page.
- */
-#include "gasket_page_table.h"
-
-#include <linux/device.h>
-#include <linux/file.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/pagemap.h>
-#include <linux/vmalloc.h>
-
-#include "gasket_constants.h"
-#include "gasket_core.h"
-
-/* Constants & utility macros */
-/* The number of pages that can be mapped into each second-level page table. */
-#define GASKET_PAGES_PER_SUBTABLE 512
-
-/* The starting position of the page index in a simple virtual address. */
-#define GASKET_SIMPLE_PAGE_SHIFT 12
-
-/* Flag indicating that a [device] slot is valid for use. */
-#define GASKET_VALID_SLOT_FLAG 1
-
-/*
- * The starting position of the level 0 page index (i.e., the entry in the
- * device's extended address registers) in an extended address.
- * Also can be thought of as (log2(PAGE_SIZE) + log2(PAGES_PER_SUBTABLE)),
- * or (12 + 9).
- */
-#define GASKET_EXTENDED_LVL0_SHIFT 21
-
-/*
- * Number of first level pages that Gasket chips support. Equivalent to
- * log2(NUM_LVL0_PAGE_TABLES)
- *
- * At a maximum, allowing for a 34 bits address space (or 16GB)
- * = GASKET_EXTENDED_LVL0_WIDTH + (log2(PAGE_SIZE) + log2(PAGES_PER_SUBTABLE)
- * or, = 13 + 9 + 12
- */
-#define GASKET_EXTENDED_LVL0_WIDTH 13
-
-/*
- * The starting position of the level 1 page index (i.e., the entry in the
- * host second-level/sub- table) in an extended address.
- */
-#define GASKET_EXTENDED_LVL1_SHIFT 12
-
-/* Type declarations */
-/* Valid states for a struct gasket_page_table_entry. */
-enum pte_status {
- PTE_FREE,
- PTE_INUSE,
-};
-
-/*
- * Mapping metadata for a single page.
- *
- * In this file, host-side page table entries are referred to as that (or PTEs).
- * Where device vs. host entries are differentiated, device-side or -visible
- * entries are called "slots". A slot may be either an entry in the device's
- * address translation table registers or an entry in a second-level page
- * table ("subtable").
- *
- * The full data in this structure is visible on the host [of course]. Only
- * the address contained in dma_addr is communicated to the device; that points
- * to the actual page mapped and described by this structure.
- */
-struct gasket_page_table_entry {
- /* The status of this entry/slot: free or in use. */
- enum pte_status status;
-
- /*
- * Index for alignment into host vaddrs.
- * When a user specifies a host address for a mapping, that address may
- * not be page-aligned. Offset is the index into the containing page of
- * the host address (i.e., host_vaddr & (PAGE_SIZE - 1)).
- * This is necessary for translating between user-specified addresses
- * and page-aligned addresses.
- */
- int offset;
-
- /* Address of the page in DMA space. */
- dma_addr_t dma_addr;
-
- /* Linux page descriptor for the page described by this structure. */
- struct page *page;
-
- /*
- * If this is an extended and first-level entry, sublevel points
- * to the second-level entries underneath this entry.
- */
- struct gasket_page_table_entry *sublevel;
-};
-
-/*
- * Maintains virtual to physical address mapping for a coherent page that is
- * allocated by this module for a given device.
- * Note that coherent pages mappings virt mapping cannot be tracked by the
- * Linux kernel, and coherent pages don't have a struct page associated,
- * hence Linux kernel cannot perform a get_user_page_xx() on a phys address
- * that was allocated coherent.
- * This structure trivially implements this mechanism.
- */
-struct gasket_coherent_page_entry {
- /* Phys address, dma'able by the owner device */
- dma_addr_t paddr;
-
- /* Kernel virtual address */
- u64 user_virt;
-
- /* User virtual address that was mapped by the mmap kernel subsystem */
- u64 kernel_virt;
-
- /*
- * Whether this page has been mapped into a user land process virtual
- * space
- */
- u32 in_use;
-};
-
-/*
- * [Host-side] page table descriptor.
- *
- * This structure tracks the metadata necessary to manage both simple and
- * extended page tables.
- */
-struct gasket_page_table {
- /* The config used to create this page table. */
- struct gasket_page_table_config config;
-
- /* The number of simple (single-level) entries in the page table. */
- uint num_simple_entries;
-
- /* The number of extended (two-level) entries in the page table. */
- uint num_extended_entries;
-
- /* Array of [host-side] page table entries. */
- struct gasket_page_table_entry *entries;
-
- /* Number of actively mapped kernel pages in this table. */
- uint num_active_pages;
-
- /* Device register: base of/first slot in the page table. */
- u64 __iomem *base_slot;
-
- /* Device register: holds the offset indicating the start of the
- * extended address region of the device's address translation table.
- */
- u64 __iomem *extended_offset_reg;
-
- /* Device structure for the underlying device. Only used for logging. */
- struct device *device;
-
- /* PCI system descriptor for the underlying device. */
- struct pci_dev *pci_dev;
-
- /* Location of the extended address bit for this Gasket device. */
- u64 extended_flag;
-
- /* Mutex to protect page table internals. */
- struct mutex mutex;
-
- /* Number of coherent pages accessible thru by this page table */
- int num_coherent_pages;
-
- /*
- * List of coherent memory (physical) allocated for a device.
- *
- * This structure also remembers the user virtual mapping, this is
- * hacky, but we need to do this because the kernel doesn't keep track
- * of the user coherent pages (pfn pages), and virt to coherent page
- * mapping.
- * TODO: use find_vma() APIs to convert host address to vm_area, to
- * dma_addr_t instead of storing user virtu address in
- * gasket_coherent_page_entry
- *
- * Note that the user virtual mapping is created by the driver, in
- * gasket_mmap function, so user_virt belongs in the driver anyhow.
- */
- struct gasket_coherent_page_entry *coherent_pages;
-};
-
-/* See gasket_page_table.h for description. */
-int gasket_page_table_init(struct gasket_page_table **ppg_tbl,
- const struct gasket_bar_data *bar_data,
- const struct gasket_page_table_config *page_table_config,
- struct device *device, struct pci_dev *pci_dev)
-{
- ulong bytes;
- struct gasket_page_table *pg_tbl;
- ulong total_entries = page_table_config->total_entries;
-
- /*
- * TODO: Verify config->total_entries against value read from the
- * hardware register that contains the page table size.
- */
- if (total_entries == ULONG_MAX) {
- dev_dbg(device,
- "Error reading page table size. Initializing page table with size 0\n");
- total_entries = 0;
- }
-
- dev_dbg(device,
- "Attempting to initialize page table of size 0x%lx\n",
- total_entries);
-
- dev_dbg(device,
- "Table has base reg 0x%x, extended offset reg 0x%x\n",
- page_table_config->base_reg,
- page_table_config->extended_reg);
-
- *ppg_tbl = kzalloc(sizeof(**ppg_tbl), GFP_KERNEL);
- if (!*ppg_tbl) {
- dev_dbg(device, "No memory for page table\n");
- return -ENOMEM;
- }
-
- pg_tbl = *ppg_tbl;
- bytes = total_entries * sizeof(struct gasket_page_table_entry);
- if (bytes != 0) {
- pg_tbl->entries = vzalloc(bytes);
- if (!pg_tbl->entries) {
- dev_dbg(device,
- "No memory for address translation metadata\n");
- kfree(pg_tbl);
- *ppg_tbl = NULL;
- return -ENOMEM;
- }
- }
-
- mutex_init(&pg_tbl->mutex);
- memcpy(&pg_tbl->config, page_table_config, sizeof(*page_table_config));
- if (pg_tbl->config.mode == GASKET_PAGE_TABLE_MODE_NORMAL ||
- pg_tbl->config.mode == GASKET_PAGE_TABLE_MODE_SIMPLE) {
- pg_tbl->num_simple_entries = total_entries;
- pg_tbl->num_extended_entries = 0;
- pg_tbl->extended_flag = 1ull << page_table_config->extended_bit;
- } else {
- pg_tbl->num_simple_entries = 0;
- pg_tbl->num_extended_entries = total_entries;
- pg_tbl->extended_flag = 0;
- }
- pg_tbl->num_active_pages = 0;
- pg_tbl->base_slot =
- (u64 __iomem *)&bar_data->virt_base[page_table_config->base_reg];
- pg_tbl->extended_offset_reg =
- (u64 __iomem *)&bar_data->virt_base[page_table_config->extended_reg];
- pg_tbl->device = get_device(device);
- pg_tbl->pci_dev = pci_dev;
-
- dev_dbg(device, "Page table initialized successfully\n");
-
- return 0;
-}
-
-/*
- * Check if a range of PTEs is free.
- * The page table mutex must be held by the caller.
- */
-static bool gasket_is_pte_range_free(struct gasket_page_table_entry *ptes,
- uint num_entries)
-{
- int i;
-
- for (i = 0; i < num_entries; i++) {
- if (ptes[i].status != PTE_FREE)
- return false;
- }
-
- return true;
-}
-
-/*
- * Free a second level page [sub]table.
- * The page table mutex must be held before this call.
- */
-static void gasket_free_extended_subtable(struct gasket_page_table *pg_tbl,
- struct gasket_page_table_entry *pte,
- u64 __iomem *slot)
-{
- /* Release the page table from the driver */
- pte->status = PTE_FREE;
-
- /* Release the page table from the device */
- writeq(0, slot);
-
- if (pte->dma_addr)
- dma_unmap_page(pg_tbl->device, pte->dma_addr, PAGE_SIZE,
- DMA_TO_DEVICE);
-
- vfree(pte->sublevel);
-
- if (pte->page)
- free_page((ulong)page_address(pte->page));
-
- memset(pte, 0, sizeof(struct gasket_page_table_entry));
-}
-
-/*
- * Actually perform collection.
- * The page table mutex must be held by the caller.
- */
-static void
-gasket_page_table_garbage_collect_nolock(struct gasket_page_table *pg_tbl)
-{
- struct gasket_page_table_entry *pte;
- u64 __iomem *slot;
-
- /* XXX FIX ME XXX -- more efficient to keep a usage count */
- /* rather than scanning the second level page tables */
-
- for (pte = pg_tbl->entries + pg_tbl->num_simple_entries,
- slot = pg_tbl->base_slot + pg_tbl->num_simple_entries;
- pte < pg_tbl->entries + pg_tbl->config.total_entries;
- pte++, slot++) {
- if (pte->status == PTE_INUSE) {
- if (gasket_is_pte_range_free(pte->sublevel,
- GASKET_PAGES_PER_SUBTABLE))
- gasket_free_extended_subtable(pg_tbl, pte,
- slot);
- }
- }
-}
-
-/* See gasket_page_table.h for description. */
-void gasket_page_table_garbage_collect(struct gasket_page_table *pg_tbl)
-{
- mutex_lock(&pg_tbl->mutex);
- gasket_page_table_garbage_collect_nolock(pg_tbl);
- mutex_unlock(&pg_tbl->mutex);
-}
-
-/* See gasket_page_table.h for description. */
-void gasket_page_table_cleanup(struct gasket_page_table *pg_tbl)
-{
- /* Deallocate free second-level tables. */
- gasket_page_table_garbage_collect(pg_tbl);
-
- /* TODO: Check that all PTEs have been freed? */
-
- vfree(pg_tbl->entries);
- pg_tbl->entries = NULL;
-
- put_device(pg_tbl->device);
- kfree(pg_tbl);
-}
-
-/* See gasket_page_table.h for description. */
-int gasket_page_table_partition(struct gasket_page_table *pg_tbl,
- uint num_simple_entries)
-{
- int i, start;
-
- mutex_lock(&pg_tbl->mutex);
- if (num_simple_entries > pg_tbl->config.total_entries) {
- mutex_unlock(&pg_tbl->mutex);
- return -EINVAL;
- }
-
- gasket_page_table_garbage_collect_nolock(pg_tbl);
-
- start = min(pg_tbl->num_simple_entries, num_simple_entries);
-
- for (i = start; i < pg_tbl->config.total_entries; i++) {
- if (pg_tbl->entries[i].status != PTE_FREE) {
- dev_err(pg_tbl->device, "entry %d is not free\n", i);
- mutex_unlock(&pg_tbl->mutex);
- return -EBUSY;
- }
- }
-
- pg_tbl->num_simple_entries = num_simple_entries;
- pg_tbl->num_extended_entries =
- pg_tbl->config.total_entries - num_simple_entries;
- writeq(num_simple_entries, pg_tbl->extended_offset_reg);
-
- mutex_unlock(&pg_tbl->mutex);
- return 0;
-}
-EXPORT_SYMBOL(gasket_page_table_partition);
-
-/*
- * Return whether a host buffer was mapped as coherent memory.
- *
- * A Gasket page_table currently support one contiguous dma range, mapped to one
- * contiguous virtual memory range. Check if the host_addr is within that range.
- */
-static int is_coherent(struct gasket_page_table *pg_tbl, ulong host_addr)
-{
- u64 min, max;
-
- /* whether the host address is within user virt range */
- if (!pg_tbl->coherent_pages)
- return 0;
-
- min = (u64)pg_tbl->coherent_pages[0].user_virt;
- max = min + PAGE_SIZE * pg_tbl->num_coherent_pages;
-
- return min <= host_addr && host_addr < max;
-}
-
-/* Safely return a page to the OS. */
-static bool gasket_release_page(struct page *page)
-{
- if (!page)
- return false;
-
- if (!PageReserved(page))
- SetPageDirty(page);
- unpin_user_page(page);
-
- return true;
-}
-
-/*
- * Get and map last level page table buffers.
- *
- * slots is the location(s) to write device-mapped page address. If this is a
- * simple mapping, these will be address translation registers. If this is
- * an extended mapping, these will be within a second-level page table
- * allocated by the host and so must have their __iomem attribute casted away.
- */
-static int gasket_perform_mapping(struct gasket_page_table *pg_tbl,
- struct gasket_page_table_entry *ptes,
- u64 __iomem *slots, ulong host_addr,
- uint num_pages, int is_simple_mapping)
-{
- int ret;
- ulong offset;
- struct page *page;
- dma_addr_t dma_addr;
- ulong page_addr;
- int i;
-
- for (i = 0; i < num_pages; i++) {
- page_addr = host_addr + i * PAGE_SIZE;
- offset = page_addr & (PAGE_SIZE - 1);
- if (is_coherent(pg_tbl, host_addr)) {
- u64 off =
- (u64)host_addr -
- (u64)pg_tbl->coherent_pages[0].user_virt;
- ptes[i].page = NULL;
- ptes[i].offset = offset;
- ptes[i].dma_addr = pg_tbl->coherent_pages[0].paddr +
- off + i * PAGE_SIZE;
- } else {
- ret = pin_user_pages_fast(page_addr - offset, 1,
- FOLL_WRITE, &page);
-
- if (ret <= 0) {
- dev_err(pg_tbl->device,
- "pin user pages failed for addr=0x%lx, offset=0x%lx [ret=%d]\n",
- page_addr, offset, ret);
- return ret ? ret : -ENOMEM;
- }
- ++pg_tbl->num_active_pages;
-
- ptes[i].page = page;
- ptes[i].offset = offset;
-
- /* Map the page into DMA space. */
- ptes[i].dma_addr =
- dma_map_page(pg_tbl->device, page, 0, PAGE_SIZE,
- DMA_BIDIRECTIONAL);
-
- if (dma_mapping_error(pg_tbl->device,
- ptes[i].dma_addr)) {
- if (gasket_release_page(ptes[i].page))
- --pg_tbl->num_active_pages;
-
- memset(&ptes[i], 0,
- sizeof(struct gasket_page_table_entry));
- return -EINVAL;
- }
- }
-
- /* Make the DMA-space address available to the device. */
- dma_addr = (ptes[i].dma_addr + offset) | GASKET_VALID_SLOT_FLAG;
-
- if (is_simple_mapping) {
- writeq(dma_addr, &slots[i]);
- } else {
- ((u64 __force *)slots)[i] = dma_addr;
- /* Extended page table vectors are in DRAM,
- * and so need to be synced each time they are updated.
- */
- dma_map_single(pg_tbl->device,
- (void *)&((u64 __force *)slots)[i],
- sizeof(u64), DMA_TO_DEVICE);
- }
- ptes[i].status = PTE_INUSE;
- }
- return 0;
-}
-
-/*
- * Return the index of the page for the address in the simple table.
- * Does not perform validity checking.
- */
-static int gasket_simple_page_idx(struct gasket_page_table *pg_tbl,
- ulong dev_addr)
-{
- return (dev_addr >> GASKET_SIMPLE_PAGE_SHIFT) &
- (pg_tbl->config.total_entries - 1);
-}
-
-/*
- * Return the level 0 page index for the given address.
- * Does not perform validity checking.
- */
-static ulong gasket_extended_lvl0_page_idx(struct gasket_page_table *pg_tbl,
- ulong dev_addr)
-{
- return (dev_addr >> GASKET_EXTENDED_LVL0_SHIFT) &
- (pg_tbl->config.total_entries - 1);
-}
-
-/*
- * Return the level 1 page index for the given address.
- * Does not perform validity checking.
- */
-static ulong gasket_extended_lvl1_page_idx(struct gasket_page_table *pg_tbl,
- ulong dev_addr)
-{
- return (dev_addr >> GASKET_EXTENDED_LVL1_SHIFT) &
- (GASKET_PAGES_PER_SUBTABLE - 1);
-}
-
-/*
- * Allocate page table entries in a simple table.
- * The page table mutex must be held by the caller.
- */
-static int gasket_alloc_simple_entries(struct gasket_page_table *pg_tbl,
- ulong dev_addr, uint num_pages)
-{
- if (!gasket_is_pte_range_free(pg_tbl->entries +
- gasket_simple_page_idx(pg_tbl, dev_addr),
- num_pages))
- return -EBUSY;
-
- return 0;
-}
-
-/*
- * Unmap and release mapped pages.
- * The page table mutex must be held by the caller.
- */
-static void gasket_perform_unmapping(struct gasket_page_table *pg_tbl,
- struct gasket_page_table_entry *ptes,
- u64 __iomem *slots, uint num_pages,
- int is_simple_mapping)
-{
- int i;
- /*
- * For each page table entry and corresponding entry in the device's
- * address translation table:
- */
- for (i = 0; i < num_pages; i++) {
- /* release the address from the device, */
- if (is_simple_mapping || ptes[i].status == PTE_INUSE) {
- writeq(0, &slots[i]);
- } else {
- ((u64 __force *)slots)[i] = 0;
- /* sync above PTE update before updating mappings */
- wmb();
- }
-
- /* release the address from the driver, */
- if (ptes[i].status == PTE_INUSE) {
- if (ptes[i].page && ptes[i].dma_addr) {
- dma_unmap_page(pg_tbl->device, ptes[i].dma_addr,
- PAGE_SIZE, DMA_BIDIRECTIONAL);
- }
- if (gasket_release_page(ptes[i].page))
- --pg_tbl->num_active_pages;
- }
-
- /* and clear the PTE. */
- memset(&ptes[i], 0, sizeof(struct gasket_page_table_entry));
- }
-}
-
-/*
- * Unmap and release pages mapped to simple addresses.
- * The page table mutex must be held by the caller.
- */
-static void gasket_unmap_simple_pages(struct gasket_page_table *pg_tbl,
- ulong dev_addr, uint num_pages)
-{
- uint slot = gasket_simple_page_idx(pg_tbl, dev_addr);
-
- gasket_perform_unmapping(pg_tbl, pg_tbl->entries + slot,
- pg_tbl->base_slot + slot, num_pages, 1);
-}
-
-/*
- * Unmap and release buffers to extended addresses.
- * The page table mutex must be held by the caller.
- */
-static void gasket_unmap_extended_pages(struct gasket_page_table *pg_tbl,
- ulong dev_addr, uint num_pages)
-{
- uint slot_idx, remain, len;
- struct gasket_page_table_entry *pte;
- u64 __iomem *slot_base;
-
- remain = num_pages;
- slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr);
- pte = pg_tbl->entries + pg_tbl->num_simple_entries +
- gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
-
- while (remain > 0) {
- /* TODO: Add check to ensure pte remains valid? */
- len = min(remain, GASKET_PAGES_PER_SUBTABLE - slot_idx);
-
- if (pte->status == PTE_INUSE) {
- slot_base = (u64 __iomem *)(page_address(pte->page) +
- pte->offset);
- gasket_perform_unmapping(pg_tbl,
- pte->sublevel + slot_idx,
- slot_base + slot_idx, len, 0);
- }
-
- remain -= len;
- slot_idx = 0;
- pte++;
- }
-}
-
-/* Evaluates to nonzero if the specified virtual address is simple. */
-static inline bool gasket_addr_is_simple(struct gasket_page_table *pg_tbl,
- ulong addr)
-{
- return !((addr) & (pg_tbl)->extended_flag);
-}
-
-/*
- * Convert (simple, page, offset) into a device address.
- * Examples:
- * Simple page 0, offset 32:
- * Input (1, 0, 32), Output 0x20
- * Simple page 1000, offset 511:
- * Input (1, 1000, 511), Output 0x3E81FF
- * Extended page 0, offset 32:
- * Input (0, 0, 32), Output 0x8000000020
- * Extended page 1000, offset 511:
- * Input (0, 1000, 511), Output 0x8003E81FF
- */
-static ulong gasket_components_to_dev_address(struct gasket_page_table *pg_tbl,
- int is_simple, uint page_index,
- uint offset)
-{
- ulong dev_addr = (page_index << GASKET_SIMPLE_PAGE_SHIFT) | offset;
-
- return is_simple ? dev_addr : (pg_tbl->extended_flag | dev_addr);
-}
-
-/*
- * Validity checking for simple addresses.
- *
- * Verify that address translation commutes (from address to/from page + offset)
- * and that the requested page range starts and ends within the set of
- * currently-partitioned simple pages.
- */
-static bool gasket_is_simple_dev_addr_bad(struct gasket_page_table *pg_tbl,
- ulong dev_addr, uint num_pages)
-{
- ulong page_offset = dev_addr & (PAGE_SIZE - 1);
- ulong page_index =
- (dev_addr / PAGE_SIZE) & (pg_tbl->config.total_entries - 1);
-
- if (gasket_components_to_dev_address(pg_tbl, 1, page_index,
- page_offset) != dev_addr) {
- dev_err(pg_tbl->device, "address is invalid, 0x%lX\n",
- dev_addr);
- return true;
- }
-
- if (page_index >= pg_tbl->num_simple_entries) {
- dev_err(pg_tbl->device,
- "starting slot at %lu is too large, max is < %u\n",
- page_index, pg_tbl->num_simple_entries);
- return true;
- }
-
- if (page_index + num_pages > pg_tbl->num_simple_entries) {
- dev_err(pg_tbl->device,
- "ending slot at %lu is too large, max is <= %u\n",
- page_index + num_pages, pg_tbl->num_simple_entries);
- return true;
- }
-
- return false;
-}
-
-/*
- * Validity checking for extended addresses.
- *
- * Verify that address translation commutes (from address to/from page +
- * offset) and that the requested page range starts and ends within the set of
- * currently-partitioned extended pages.
- */
-static bool gasket_is_extended_dev_addr_bad(struct gasket_page_table *pg_tbl,
- ulong dev_addr, uint num_pages)
-{
- /* Starting byte index of dev_addr into the first mapped page */
- ulong page_offset = dev_addr & (PAGE_SIZE - 1);
- ulong page_global_idx, page_lvl0_idx;
- ulong num_lvl0_pages;
- ulong addr;
-
- /* check if the device address is out of bound */
- addr = dev_addr & ~((pg_tbl)->extended_flag);
- if (addr >> (GASKET_EXTENDED_LVL0_WIDTH + GASKET_EXTENDED_LVL0_SHIFT)) {
- dev_err(pg_tbl->device, "device address out of bounds: 0x%lx\n",
- dev_addr);
- return true;
- }
-
- /* Find the starting sub-page index in the space of all sub-pages. */
- page_global_idx = (dev_addr / PAGE_SIZE) &
- (pg_tbl->config.total_entries * GASKET_PAGES_PER_SUBTABLE - 1);
-
- /* Find the starting level 0 index. */
- page_lvl0_idx = gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
-
- /* Get the count of affected level 0 pages. */
- num_lvl0_pages = DIV_ROUND_UP(num_pages, GASKET_PAGES_PER_SUBTABLE);
-
- if (gasket_components_to_dev_address(pg_tbl, 0, page_global_idx,
- page_offset) != dev_addr) {
- dev_err(pg_tbl->device, "address is invalid: 0x%lx\n",
- dev_addr);
- return true;
- }
-
- if (page_lvl0_idx >= pg_tbl->num_extended_entries) {
- dev_err(pg_tbl->device,
- "starting level 0 slot at %lu is too large, max is < %u\n",
- page_lvl0_idx, pg_tbl->num_extended_entries);
- return true;
- }
-
- if (page_lvl0_idx + num_lvl0_pages > pg_tbl->num_extended_entries) {
- dev_err(pg_tbl->device,
- "ending level 0 slot at %lu is too large, max is <= %u\n",
- page_lvl0_idx + num_lvl0_pages,
- pg_tbl->num_extended_entries);
- return true;
- }
-
- return false;
-}
-
-/*
- * Non-locking entry to unmapping routines.
- * The page table mutex must be held by the caller.
- */
-static void gasket_page_table_unmap_nolock(struct gasket_page_table *pg_tbl,
- ulong dev_addr, uint num_pages)
-{
- if (!num_pages)
- return;
-
- if (gasket_addr_is_simple(pg_tbl, dev_addr))
- gasket_unmap_simple_pages(pg_tbl, dev_addr, num_pages);
- else
- gasket_unmap_extended_pages(pg_tbl, dev_addr, num_pages);
-}
-
-/*
- * Allocate and map pages to simple addresses.
- * If there is an error, no pages are mapped.
- */
-static int gasket_map_simple_pages(struct gasket_page_table *pg_tbl,
- ulong host_addr, ulong dev_addr,
- uint num_pages)
-{
- int ret;
- uint slot_idx = gasket_simple_page_idx(pg_tbl, dev_addr);
-
- ret = gasket_alloc_simple_entries(pg_tbl, dev_addr, num_pages);
- if (ret) {
- dev_err(pg_tbl->device,
- "page table slots %u (@ 0x%lx) to %u are not available\n",
- slot_idx, dev_addr, slot_idx + num_pages - 1);
- return ret;
- }
-
- ret = gasket_perform_mapping(pg_tbl, pg_tbl->entries + slot_idx,
- pg_tbl->base_slot + slot_idx, host_addr,
- num_pages, 1);
-
- if (ret) {
- gasket_page_table_unmap_nolock(pg_tbl, dev_addr, num_pages);
- dev_err(pg_tbl->device, "gasket_perform_mapping %d\n", ret);
- }
- return ret;
-}
-
-/*
- * Allocate a second level page table.
- * The page table mutex must be held by the caller.
- */
-static int gasket_alloc_extended_subtable(struct gasket_page_table *pg_tbl,
- struct gasket_page_table_entry *pte,
- u64 __iomem *slot)
-{
- ulong page_addr, subtable_bytes;
- dma_addr_t dma_addr;
-
- /* XXX FIX ME XXX this is inefficient for non-4K page sizes */
-
- /* GFP_DMA flag must be passed to architectures for which
- * part of the memory range is not considered DMA'able.
- * This seems to be the case for Juno board with 4.5.0 Linaro kernel
- */
- page_addr = get_zeroed_page(GFP_KERNEL | GFP_DMA);
- if (!page_addr)
- return -ENOMEM;
- pte->page = virt_to_page((void *)page_addr);
- pte->offset = 0;
-
- subtable_bytes = sizeof(struct gasket_page_table_entry) *
- GASKET_PAGES_PER_SUBTABLE;
- pte->sublevel = vzalloc(subtable_bytes);
- if (!pte->sublevel) {
- free_page(page_addr);
- memset(pte, 0, sizeof(struct gasket_page_table_entry));
- return -ENOMEM;
- }
-
- /* Map the page into DMA space. */
- pte->dma_addr = dma_map_page(pg_tbl->device, pte->page, 0, PAGE_SIZE,
- DMA_TO_DEVICE);
- if (dma_mapping_error(pg_tbl->device, pte->dma_addr)) {
- free_page(page_addr);
- vfree(pte->sublevel);
- memset(pte, 0, sizeof(struct gasket_page_table_entry));
- return -ENOMEM;
- }
-
- /* make the addresses available to the device */
- dma_addr = (pte->dma_addr + pte->offset) | GASKET_VALID_SLOT_FLAG;
- writeq(dma_addr, slot);
-
- pte->status = PTE_INUSE;
-
- return 0;
-}
-
-/*
- * Allocate slots in an extended page table. Check to see if a range of page
- * table slots are available. If necessary, memory is allocated for second level
- * page tables.
- *
- * Note that memory for second level page tables is allocated as needed, but
- * that memory is only freed on the final close of the device file, when the
- * page tables are repartitioned, or the device is removed. If there is an
- * error or if the full range of slots is not available, any memory
- * allocated for second level page tables remains allocated until final close,
- * repartition, or device removal.
- *
- * The page table mutex must be held by the caller.
- */
-static int gasket_alloc_extended_entries(struct gasket_page_table *pg_tbl,
- ulong dev_addr, uint num_entries)
-{
- int ret = 0;
- uint remain, subtable_slot_idx, len;
- struct gasket_page_table_entry *pte;
- u64 __iomem *slot;
-
- remain = num_entries;
- subtable_slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr);
- pte = pg_tbl->entries + pg_tbl->num_simple_entries +
- gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
- slot = pg_tbl->base_slot + pg_tbl->num_simple_entries +
- gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
-
- while (remain > 0) {
- len = min(remain,
- GASKET_PAGES_PER_SUBTABLE - subtable_slot_idx);
-
- if (pte->status == PTE_FREE) {
- ret = gasket_alloc_extended_subtable(pg_tbl, pte, slot);
- if (ret) {
- dev_err(pg_tbl->device,
- "no memory for extended addr subtable\n");
- return ret;
- }
- } else {
- if (!gasket_is_pte_range_free(pte->sublevel +
- subtable_slot_idx, len))
- return -EBUSY;
- }
-
- remain -= len;
- subtable_slot_idx = 0;
- pte++;
- slot++;
- }
-
- return 0;
-}
-
-/*
- * gasket_map_extended_pages - Get and map buffers to extended addresses.
- * If there is an error, no pages are mapped.
- */
-static int gasket_map_extended_pages(struct gasket_page_table *pg_tbl,
- ulong host_addr, ulong dev_addr,
- uint num_pages)
-{
- int ret;
- ulong dev_addr_end;
- uint slot_idx, remain, len;
- struct gasket_page_table_entry *pte;
- u64 __iomem *slot_base;
-
- ret = gasket_alloc_extended_entries(pg_tbl, dev_addr, num_pages);
- if (ret) {
- dev_addr_end = dev_addr + (num_pages / PAGE_SIZE) - 1;
- dev_err(pg_tbl->device,
- "page table slots (%lu,%lu) (@ 0x%lx) to (%lu,%lu) are not available\n",
- gasket_extended_lvl0_page_idx(pg_tbl, dev_addr),
- dev_addr,
- gasket_extended_lvl1_page_idx(pg_tbl, dev_addr),
- gasket_extended_lvl0_page_idx(pg_tbl, dev_addr_end),
- gasket_extended_lvl1_page_idx(pg_tbl, dev_addr_end));
- return ret;
- }
-
- remain = num_pages;
- slot_idx = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr);
- pte = pg_tbl->entries + pg_tbl->num_simple_entries +
- gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
-
- while (remain > 0) {
- len = min(remain, GASKET_PAGES_PER_SUBTABLE - slot_idx);
-
- slot_base =
- (u64 __iomem *)(page_address(pte->page) + pte->offset);
- ret = gasket_perform_mapping(pg_tbl, pte->sublevel + slot_idx,
- slot_base + slot_idx, host_addr,
- len, 0);
- if (ret) {
- gasket_page_table_unmap_nolock(pg_tbl, dev_addr,
- num_pages);
- return ret;
- }
-
- remain -= len;
- slot_idx = 0;
- pte++;
- host_addr += len * PAGE_SIZE;
- }
-
- return 0;
-}
-
-/*
- * See gasket_page_table.h for general description.
- *
- * gasket_page_table_map calls either gasket_map_simple_pages() or
- * gasket_map_extended_pages() to actually perform the mapping.
- *
- * The page table mutex is held for the entire operation.
- */
-int gasket_page_table_map(struct gasket_page_table *pg_tbl, ulong host_addr,
- ulong dev_addr, uint num_pages)
-{
- int ret;
-
- if (!num_pages)
- return 0;
-
- mutex_lock(&pg_tbl->mutex);
-
- if (gasket_addr_is_simple(pg_tbl, dev_addr)) {
- ret = gasket_map_simple_pages(pg_tbl, host_addr, dev_addr,
- num_pages);
- } else {
- ret = gasket_map_extended_pages(pg_tbl, host_addr, dev_addr,
- num_pages);
- }
-
- mutex_unlock(&pg_tbl->mutex);
- return ret;
-}
-EXPORT_SYMBOL(gasket_page_table_map);
-
-/*
- * See gasket_page_table.h for general description.
- *
- * gasket_page_table_unmap takes the page table lock and calls either
- * gasket_unmap_simple_pages() or gasket_unmap_extended_pages() to
- * actually unmap the pages from device space.
- *
- * The page table mutex is held for the entire operation.
- */
-void gasket_page_table_unmap(struct gasket_page_table *pg_tbl, ulong dev_addr,
- uint num_pages)
-{
- if (!num_pages)
- return;
-
- mutex_lock(&pg_tbl->mutex);
- gasket_page_table_unmap_nolock(pg_tbl, dev_addr, num_pages);
- mutex_unlock(&pg_tbl->mutex);
-}
-EXPORT_SYMBOL(gasket_page_table_unmap);
-
-static void gasket_page_table_unmap_all_nolock(struct gasket_page_table *pg_tbl)
-{
- gasket_unmap_simple_pages(pg_tbl,
- gasket_components_to_dev_address(pg_tbl, 1, 0,
- 0),
- pg_tbl->num_simple_entries);
- gasket_unmap_extended_pages(pg_tbl,
- gasket_components_to_dev_address(pg_tbl, 0,
- 0, 0),
- pg_tbl->num_extended_entries *
- GASKET_PAGES_PER_SUBTABLE);
-}
-
-/* See gasket_page_table.h for description. */
-void gasket_page_table_unmap_all(struct gasket_page_table *pg_tbl)
-{
- mutex_lock(&pg_tbl->mutex);
- gasket_page_table_unmap_all_nolock(pg_tbl);
- mutex_unlock(&pg_tbl->mutex);
-}
-EXPORT_SYMBOL(gasket_page_table_unmap_all);
-
-/* See gasket_page_table.h for description. */
-void gasket_page_table_reset(struct gasket_page_table *pg_tbl)
-{
- mutex_lock(&pg_tbl->mutex);
- gasket_page_table_unmap_all_nolock(pg_tbl);
- writeq(pg_tbl->config.total_entries, pg_tbl->extended_offset_reg);
- mutex_unlock(&pg_tbl->mutex);
-}
-
-/* See gasket_page_table.h for description. */
-int gasket_page_table_lookup_page(struct gasket_page_table *pg_tbl,
- ulong dev_addr, struct page **ppage,
- ulong *poffset)
-{
- uint page_num;
- struct gasket_page_table_entry *pte;
-
- mutex_lock(&pg_tbl->mutex);
- if (gasket_addr_is_simple(pg_tbl, dev_addr)) {
- page_num = gasket_simple_page_idx(pg_tbl, dev_addr);
- if (page_num >= pg_tbl->num_simple_entries)
- goto fail;
-
- pte = pg_tbl->entries + page_num;
- if (pte->status != PTE_INUSE)
- goto fail;
- } else {
- /* Find the level 0 entry, */
- page_num = gasket_extended_lvl0_page_idx(pg_tbl, dev_addr);
- if (page_num >= pg_tbl->num_extended_entries)
- goto fail;
-
- pte = pg_tbl->entries + pg_tbl->num_simple_entries + page_num;
- if (pte->status != PTE_INUSE)
- goto fail;
-
- /* and its contained level 1 entry. */
- page_num = gasket_extended_lvl1_page_idx(pg_tbl, dev_addr);
- pte = pte->sublevel + page_num;
- if (pte->status != PTE_INUSE)
- goto fail;
- }
-
- *ppage = pte->page;
- *poffset = pte->offset;
- mutex_unlock(&pg_tbl->mutex);
- return 0;
-
-fail:
- *ppage = NULL;
- *poffset = 0;
- mutex_unlock(&pg_tbl->mutex);
- return -EINVAL;
-}
-
-/* See gasket_page_table.h for description. */
-bool gasket_page_table_are_addrs_bad(struct gasket_page_table *pg_tbl,
- ulong host_addr, ulong dev_addr,
- ulong bytes)
-{
- if (host_addr & (PAGE_SIZE - 1)) {
- dev_err(pg_tbl->device,
- "host mapping address 0x%lx must be page aligned\n",
- host_addr);
- return true;
- }
-
- return gasket_page_table_is_dev_addr_bad(pg_tbl, dev_addr, bytes);
-}
-EXPORT_SYMBOL(gasket_page_table_are_addrs_bad);
-
-/* See gasket_page_table.h for description. */
-bool gasket_page_table_is_dev_addr_bad(struct gasket_page_table *pg_tbl,
- ulong dev_addr, ulong bytes)
-{
- uint num_pages = bytes / PAGE_SIZE;
-
- if (bytes & (PAGE_SIZE - 1)) {
- dev_err(pg_tbl->device,
- "mapping size 0x%lX must be page aligned\n", bytes);
- return true;
- }
-
- if (num_pages == 0) {
- dev_err(pg_tbl->device,
- "requested mapping is less than one page: %lu / %lu\n",
- bytes, PAGE_SIZE);
- return true;
- }
-
- if (gasket_addr_is_simple(pg_tbl, dev_addr))
- return gasket_is_simple_dev_addr_bad(pg_tbl, dev_addr,
- num_pages);
- return gasket_is_extended_dev_addr_bad(pg_tbl, dev_addr, num_pages);
-}
-EXPORT_SYMBOL(gasket_page_table_is_dev_addr_bad);
-
-/* See gasket_page_table.h for description. */
-uint gasket_page_table_max_size(struct gasket_page_table *page_table)
-{
- if (!page_table)
- return 0;
- return page_table->config.total_entries;
-}
-EXPORT_SYMBOL(gasket_page_table_max_size);
-
-/* See gasket_page_table.h for description. */
-uint gasket_page_table_num_entries(struct gasket_page_table *pg_tbl)
-{
- if (!pg_tbl)
- return 0;
- return pg_tbl->num_simple_entries + pg_tbl->num_extended_entries;
-}
-EXPORT_SYMBOL(gasket_page_table_num_entries);
-
-/* See gasket_page_table.h for description. */
-uint gasket_page_table_num_simple_entries(struct gasket_page_table *pg_tbl)
-{
- if (!pg_tbl)
- return 0;
- return pg_tbl->num_simple_entries;
-}
-EXPORT_SYMBOL(gasket_page_table_num_simple_entries);
-
-/* See gasket_page_table.h for description. */
-uint gasket_page_table_num_active_pages(struct gasket_page_table *pg_tbl)
-{
- if (!pg_tbl)
- return 0;
- return pg_tbl->num_active_pages;
-}
-EXPORT_SYMBOL(gasket_page_table_num_active_pages);
-
-/* See gasket_page_table.h */
-int gasket_page_table_system_status(struct gasket_page_table *page_table)
-{
- if (!page_table)
- return GASKET_STATUS_LAMED;
-
- if (gasket_page_table_num_entries(page_table) == 0) {
- dev_dbg(page_table->device, "Page table size is 0\n");
- return GASKET_STATUS_LAMED;
- }
-
- return GASKET_STATUS_ALIVE;
-}
-
-/* Record the host_addr to coherent dma memory mapping. */
-int gasket_set_user_virt(struct gasket_dev *gasket_dev, u64 size,
- dma_addr_t dma_address, ulong vma)
-{
- int j;
- struct gasket_page_table *pg_tbl;
-
- unsigned int num_pages = size / PAGE_SIZE;
-
- /*
- * TODO: for future chipset, better handling of the case where multiple
- * page tables are supported on a given device
- */
- pg_tbl = gasket_dev->page_table[0];
- if (!pg_tbl) {
- dev_dbg(gasket_dev->dev, "%s: invalid page table index\n",
- __func__);
- return 0;
- }
- for (j = 0; j < num_pages; j++) {
- pg_tbl->coherent_pages[j].user_virt =
- (u64)vma + j * PAGE_SIZE;
- }
- return 0;
-}
-
-/* Allocate a block of coherent memory. */
-int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size,
- dma_addr_t *dma_address, u64 index)
-{
- dma_addr_t handle;
- void *mem;
- int j;
- unsigned int num_pages = DIV_ROUND_UP(size, PAGE_SIZE);
- const struct gasket_driver_desc *driver_desc =
- gasket_get_driver_desc(gasket_dev);
-
- if (!gasket_dev->page_table[index])
- return -EFAULT;
-
- if (num_pages == 0)
- return -EINVAL;
-
- mem = dma_alloc_coherent(gasket_get_device(gasket_dev),
- num_pages * PAGE_SIZE, &handle, GFP_KERNEL);
- if (!mem)
- goto nomem;
-
- gasket_dev->page_table[index]->num_coherent_pages = num_pages;
-
- /* allocate the physical memory block */
- gasket_dev->page_table[index]->coherent_pages =
- kcalloc(num_pages,
- sizeof(*gasket_dev->page_table[index]->coherent_pages),
- GFP_KERNEL);
- if (!gasket_dev->page_table[index]->coherent_pages)
- goto nomem;
-
- gasket_dev->coherent_buffer.length_bytes =
- PAGE_SIZE * (num_pages);
- gasket_dev->coherent_buffer.phys_base = handle;
- gasket_dev->coherent_buffer.virt_base = mem;
-
- *dma_address = driver_desc->coherent_buffer_description.base;
- for (j = 0; j < num_pages; j++) {
- gasket_dev->page_table[index]->coherent_pages[j].paddr =
- handle + j * PAGE_SIZE;
- gasket_dev->page_table[index]->coherent_pages[j].kernel_virt =
- (u64)mem + j * PAGE_SIZE;
- }
-
- return 0;
-
-nomem:
- if (mem) {
- dma_free_coherent(gasket_get_device(gasket_dev),
- num_pages * PAGE_SIZE, mem, handle);
- gasket_dev->coherent_buffer.length_bytes = 0;
- gasket_dev->coherent_buffer.virt_base = NULL;
- gasket_dev->coherent_buffer.phys_base = 0;
- }
-
- kfree(gasket_dev->page_table[index]->coherent_pages);
- gasket_dev->page_table[index]->coherent_pages = NULL;
- gasket_dev->page_table[index]->num_coherent_pages = 0;
- return -ENOMEM;
-}
-
-/* Free a block of coherent memory. */
-int gasket_free_coherent_memory(struct gasket_dev *gasket_dev, u64 size,
- dma_addr_t dma_address, u64 index)
-{
- const struct gasket_driver_desc *driver_desc;
-
- if (!gasket_dev->page_table[index])
- return -EFAULT;
-
- driver_desc = gasket_get_driver_desc(gasket_dev);
-
- if (driver_desc->coherent_buffer_description.base != dma_address)
- return -EADDRNOTAVAIL;
-
- if (gasket_dev->coherent_buffer.length_bytes) {
- dma_free_coherent(gasket_get_device(gasket_dev),
- gasket_dev->coherent_buffer.length_bytes,
- gasket_dev->coherent_buffer.virt_base,
- gasket_dev->coherent_buffer.phys_base);
- gasket_dev->coherent_buffer.length_bytes = 0;
- gasket_dev->coherent_buffer.virt_base = NULL;
- gasket_dev->coherent_buffer.phys_base = 0;
- }
-
- kfree(gasket_dev->page_table[index]->coherent_pages);
- gasket_dev->page_table[index]->coherent_pages = NULL;
- gasket_dev->page_table[index]->num_coherent_pages = 0;
-
- return 0;
-}
-
-/* Release all coherent memory. */
-void gasket_free_coherent_memory_all(struct gasket_dev *gasket_dev, u64 index)
-{
- if (!gasket_dev->page_table[index])
- return;
-
- if (gasket_dev->coherent_buffer.length_bytes) {
- dma_free_coherent(gasket_get_device(gasket_dev),
- gasket_dev->coherent_buffer.length_bytes,
- gasket_dev->coherent_buffer.virt_base,
- gasket_dev->coherent_buffer.phys_base);
- gasket_dev->coherent_buffer.length_bytes = 0;
- gasket_dev->coherent_buffer.virt_base = NULL;
- gasket_dev->coherent_buffer.phys_base = 0;
- }
-}
diff --git a/drivers/staging/gasket/gasket_page_table.h b/drivers/staging/gasket/gasket_page_table.h
deleted file mode 100644
index 7b01b73ea3e7..000000000000
--- a/drivers/staging/gasket/gasket_page_table.h
+++ /dev/null
@@ -1,249 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Gasket Page Table functionality. This file describes the address
- * translation/paging functionality supported by the Gasket driver framework.
- * As much as possible, internal details are hidden to simplify use -
- * all calls are thread-safe (protected by an internal mutex) except where
- * indicated otherwise.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-
-#ifndef __GASKET_PAGE_TABLE_H__
-#define __GASKET_PAGE_TABLE_H__
-
-#include <linux/pci.h>
-#include <linux/types.h>
-
-#include "gasket_constants.h"
-#include "gasket_core.h"
-
-/*
- * Structure used for managing address translation on a device. All details are
- * internal to the implementation.
- */
-struct gasket_page_table;
-
-/*
- * Allocate and init address translation data.
- * @ppage_table: Pointer to Gasket page table pointer. Set by this call.
- * @att_base_reg: [Mapped] pointer to the first entry in the device's address
- * translation table.
- * @extended_offset_reg: [Mapped] pointer to the device's register containing
- * the starting index of the extended translation table.
- * @extended_bit_location: The index of the bit indicating whether an address
- * is extended.
- * @total_entries: The total number of entries in the device's address
- * translation table.
- * @device: Device structure for the underlying device. Only used for logging.
- * @pci_dev: PCI system descriptor for the underlying device.
- * whether the driver will supply its own.
- *
- * Description: Allocates and initializes data to track address translation -
- * simple and extended page table metadata. Initially, the page table is
- * partitioned such that all addresses are "simple" (single-level lookup).
- * gasket_partition_page_table can be called to change this paritioning.
- *
- * Returns 0 on success, a negative error code otherwise.
- */
-int gasket_page_table_init(struct gasket_page_table **ppg_tbl,
- const struct gasket_bar_data *bar_data,
- const struct gasket_page_table_config *page_table_config,
- struct device *device, struct pci_dev *pci_dev);
-
-/*
- * Deallocate and cleanup page table data.
- * @page_table: Gasket page table pointer.
- *
- * Description: The inverse of gasket_init; frees page_table and its contained
- * elements.
- *
- * Because this call destroys the page table, it cannot be
- * thread-safe (mutex-protected)!
- */
-void gasket_page_table_cleanup(struct gasket_page_table *page_table);
-
-/*
- * Sets the size of the simple page table.
- * @page_table: Gasket page table pointer.
- * @num_simple_entries: Desired size of the simple page table (in entries).
- *
- * Description: gasket_partition_page_table checks to see if the simple page
- * size can be changed (i.e., if there are no active extended
- * mappings in the new simple size range), and, if so,
- * sets the new simple and extended page table sizes.
- *
- * Returns 0 if successful, or non-zero if the page table entries
- * are not free.
- */
-int gasket_page_table_partition(struct gasket_page_table *page_table,
- uint num_simple_entries);
-
-/*
- * Get and map [host] user space pages into device memory.
- * @page_table: Gasket page table pointer.
- * @host_addr: Starting host virtual memory address of the pages.
- * @dev_addr: Starting device address of the pages.
- * @num_pages: Number of [4kB] pages to map.
- *
- * Description: Maps the "num_pages" pages of host memory pointed to by
- * host_addr to the address "dev_addr" in device memory.
- *
- * The caller is responsible for checking the addresses ranges.
- *
- * Returns 0 if successful or a non-zero error number otherwise.
- * If there is an error, no pages are mapped.
- */
-int gasket_page_table_map(struct gasket_page_table *page_table, ulong host_addr,
- ulong dev_addr, uint num_pages);
-
-/*
- * Un-map host pages from device memory.
- * @page_table: Gasket page table pointer.
- * @dev_addr: Starting device address of the pages to unmap.
- * @num_pages: The number of [4kB] pages to unmap.
- *
- * Description: The inverse of gasket_map_pages. Unmaps pages from the device.
- */
-void gasket_page_table_unmap(struct gasket_page_table *page_table,
- ulong dev_addr, uint num_pages);
-
-/*
- * Unmap ALL host pages from device memory.
- * @page_table: Gasket page table pointer.
- */
-void gasket_page_table_unmap_all(struct gasket_page_table *page_table);
-
-/*
- * Unmap all host pages from device memory and reset the table to fully simple
- * addressing.
- * @page_table: Gasket page table pointer.
- */
-void gasket_page_table_reset(struct gasket_page_table *page_table);
-
-/*
- * Reclaims unused page table memory.
- * @page_table: Gasket page table pointer.
- *
- * Description: Examines the page table and frees any currently-unused
- * allocations. Called internally on gasket_cleanup().
- */
-void gasket_page_table_garbage_collect(struct gasket_page_table *page_table);
-
-/*
- * Retrieve the backing page for a device address.
- * @page_table: Gasket page table pointer.
- * @dev_addr: Gasket device address.
- * @ppage: Pointer to a page pointer for the returned page.
- * @poffset: Pointer to an unsigned long for the returned offset.
- *
- * Description: Interprets the address and looks up the corresponding page
- * in the page table and the offset in that page. (We need an
- * offset because the host page may be larger than the Gasket chip
- * page it contains.)
- *
- * Returns 0 if successful, -1 for an error. The page pointer
- * and offset are returned through the pointers, if successful.
- */
-int gasket_page_table_lookup_page(struct gasket_page_table *page_table,
- ulong dev_addr, struct page **page,
- ulong *poffset);
-
-/*
- * Checks validity for input addrs and size.
- * @page_table: Gasket page table pointer.
- * @host_addr: Host address to check.
- * @dev_addr: Gasket device address.
- * @bytes: Size of the range to check (in bytes).
- *
- * Description: This call performs a number of checks to verify that the ranges
- * specified by both addresses and the size are valid for mapping pages into
- * device memory.
- *
- * Returns true if the mapping is bad, false otherwise.
- */
-bool gasket_page_table_are_addrs_bad(struct gasket_page_table *page_table,
- ulong host_addr, ulong dev_addr,
- ulong bytes);
-
-/*
- * Checks validity for input dev addr and size.
- * @page_table: Gasket page table pointer.
- * @dev_addr: Gasket device address.
- * @bytes: Size of the range to check (in bytes).
- *
- * Description: This call performs a number of checks to verify that the range
- * specified by the device address and the size is valid for mapping pages into
- * device memory.
- *
- * Returns true if the address is bad, false otherwise.
- */
-bool gasket_page_table_is_dev_addr_bad(struct gasket_page_table *page_table,
- ulong dev_addr, ulong bytes);
-
-/*
- * Gets maximum size for the given page table.
- * @page_table: Gasket page table pointer.
- */
-uint gasket_page_table_max_size(struct gasket_page_table *page_table);
-
-/*
- * Gets the total number of entries in the arg.
- * @page_table: Gasket page table pointer.
- */
-uint gasket_page_table_num_entries(struct gasket_page_table *page_table);
-
-/*
- * Gets the number of simple entries.
- * @page_table: Gasket page table pointer.
- */
-uint gasket_page_table_num_simple_entries(struct gasket_page_table *page_table);
-
-/*
- * Gets the number of actively pinned pages.
- * @page_table: Gasket page table pointer.
- */
-uint gasket_page_table_num_active_pages(struct gasket_page_table *page_table);
-
-/*
- * Get status of page table managed by @page_table.
- * @page_table: Gasket page table pointer.
- */
-int gasket_page_table_system_status(struct gasket_page_table *page_table);
-
-/*
- * Allocate a block of coherent memory.
- * @gasket_dev: Gasket Device.
- * @size: Size of the memory block.
- * @dma_address: Dma address allocated by the kernel.
- * @index: Index of the gasket_page_table within this Gasket device
- *
- * Description: Allocate a contiguous coherent memory block, DMA'ble
- * by this device.
- */
-int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, uint64_t size,
- dma_addr_t *dma_address, uint64_t index);
-/* Release a block of contiguous coherent memory, in use by a device. */
-int gasket_free_coherent_memory(struct gasket_dev *gasket_dev, uint64_t size,
- dma_addr_t dma_address, uint64_t index);
-
-/* Release all coherent memory. */
-void gasket_free_coherent_memory_all(struct gasket_dev *gasket_dev,
- uint64_t index);
-
-/*
- * Records the host_addr to coherent dma memory mapping.
- * @gasket_dev: Gasket Device.
- * @size: Size of the virtual address range to map.
- * @dma_address: Dma address within the coherent memory range.
- * @vma: Virtual address we wish to map to coherent memory.
- *
- * Description: For each page in the virtual address range, record the
- * coherent page mapping.
- *
- * Does not perform validity checking.
- */
-int gasket_set_user_virt(struct gasket_dev *gasket_dev, uint64_t size,
- dma_addr_t dma_address, ulong vma);
-
-#endif /* __GASKET_PAGE_TABLE_H__ */
diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c
deleted file mode 100644
index af26bc9f184a..000000000000
--- a/drivers/staging/gasket/gasket_sysfs.c
+++ /dev/null
@@ -1,398 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright (C) 2018 Google, Inc. */
-#include "gasket_sysfs.h"
-
-#include "gasket_core.h"
-
-#include <linux/device.h>
-#include <linux/printk.h>
-
-/*
- * Pair of kernel device and user-specified pointer. Used in lookups in sysfs
- * "show" functions to return user data.
- */
-
-struct gasket_sysfs_mapping {
- /*
- * The device bound to this mapping. If this is NULL, then this mapping
- * is free.
- */
- struct device *device;
-
- /* The Gasket descriptor for this device. */
- struct gasket_dev *gasket_dev;
-
- /* This device's set of sysfs attributes/nodes. */
- struct gasket_sysfs_attribute *attributes;
-
- /* The number of live elements in "attributes". */
- int attribute_count;
-
- /* Protects structure from simultaneous access. */
- struct mutex mutex;
-
- /* Tracks active users of this mapping. */
- struct kref refcount;
-};
-
-/*
- * Data needed to manage users of this sysfs utility.
- * Currently has a fixed size; if space is a concern, this can be dynamically
- * allocated.
- */
-/*
- * 'Global' (file-scoped) list of mappings between devices and gasket_data
- * pointers. This removes the requirement to have a gasket_sysfs_data
- * handle in all files.
- */
-static struct gasket_sysfs_mapping dev_mappings[GASKET_SYSFS_NUM_MAPPINGS];
-
-/* Callback when a mapping's refcount goes to zero. */
-static void release_entry(struct kref *ref)
-{
- /* All work is done after the return from kref_put. */
-}
-
-/* Look up mapping information for the given device. */
-static struct gasket_sysfs_mapping *get_mapping(struct device *device)
-{
- int i;
-
- for (i = 0; i < GASKET_SYSFS_NUM_MAPPINGS; i++) {
- mutex_lock(&dev_mappings[i].mutex);
- if (dev_mappings[i].device == device) {
- kref_get(&dev_mappings[i].refcount);
- mutex_unlock(&dev_mappings[i].mutex);
- return &dev_mappings[i];
- }
- mutex_unlock(&dev_mappings[i].mutex);
- }
-
- dev_dbg(device, "%s: Mapping to device %s not found\n",
- __func__, device->kobj.name);
- return NULL;
-}
-
-/* Put a reference to a mapping. */
-static void put_mapping(struct gasket_sysfs_mapping *mapping)
-{
- int i;
- int num_files_to_remove = 0;
- struct device_attribute *files_to_remove;
- struct device *device;
-
- if (!mapping) {
- pr_debug("%s: Mapping should not be NULL\n", __func__);
- return;
- }
-
- mutex_lock(&mapping->mutex);
- if (kref_put(&mapping->refcount, release_entry)) {
- dev_dbg(mapping->device, "Removing Gasket sysfs mapping\n");
- /*
- * We can't remove the sysfs nodes in the kref callback, since
- * device_remove_file() blocks until the node is free.
- * Readers/writers of sysfs nodes, though, will be blocked on
- * the mapping mutex, resulting in deadlock. To fix this, the
- * sysfs nodes are removed outside the lock.
- */
- device = mapping->device;
- num_files_to_remove = mapping->attribute_count;
- files_to_remove = kcalloc(num_files_to_remove,
- sizeof(*files_to_remove),
- GFP_KERNEL);
- if (files_to_remove)
- for (i = 0; i < num_files_to_remove; i++)
- files_to_remove[i] =
- mapping->attributes[i].attr;
- else
- num_files_to_remove = 0;
-
- kfree(mapping->attributes);
- mapping->attributes = NULL;
- mapping->attribute_count = 0;
- put_device(mapping->device);
- mapping->device = NULL;
- mapping->gasket_dev = NULL;
- }
- mutex_unlock(&mapping->mutex);
-
- if (num_files_to_remove != 0) {
- for (i = 0; i < num_files_to_remove; ++i)
- device_remove_file(device, &files_to_remove[i]);
- kfree(files_to_remove);
- }
-}
-
-/*
- * Put a reference to a mapping N times.
- *
- * In higher-level resource acquire/release function pairs, the release function
- * will need to release a mapping 2x - once for the refcount taken in the
- * release function itself, and once for the count taken in the acquire call.
- */
-static void put_mapping_n(struct gasket_sysfs_mapping *mapping, int times)
-{
- int i;
-
- for (i = 0; i < times; i++)
- put_mapping(mapping);
-}
-
-void gasket_sysfs_init(void)
-{
- int i;
-
- for (i = 0; i < GASKET_SYSFS_NUM_MAPPINGS; i++) {
- dev_mappings[i].device = NULL;
- mutex_init(&dev_mappings[i].mutex);
- }
-}
-
-int gasket_sysfs_create_mapping(struct device *device,
- struct gasket_dev *gasket_dev)
-{
- struct gasket_sysfs_mapping *mapping;
- int map_idx = -1;
-
- /*
- * We need a function-level mutex to protect against the same device
- * being added [multiple times] simultaneously.
- */
- static DEFINE_MUTEX(function_mutex);
-
- mutex_lock(&function_mutex);
- dev_dbg(device, "Creating sysfs entries for device\n");
-
- /* Check that the device we're adding hasn't already been added. */
- mapping = get_mapping(device);
- if (mapping) {
- dev_err(device,
- "Attempting to re-initialize sysfs mapping for device\n");
- put_mapping(mapping);
- mutex_unlock(&function_mutex);
- return -EBUSY;
- }
-
- /* Find the first empty entry in the array. */
- for (map_idx = 0; map_idx < GASKET_SYSFS_NUM_MAPPINGS; ++map_idx) {
- mutex_lock(&dev_mappings[map_idx].mutex);
- if (!dev_mappings[map_idx].device)
- /* Break with the mutex held! */
- break;
- mutex_unlock(&dev_mappings[map_idx].mutex);
- }
-
- if (map_idx == GASKET_SYSFS_NUM_MAPPINGS) {
- dev_err(device, "All mappings have been exhausted\n");
- mutex_unlock(&function_mutex);
- return -ENOMEM;
- }
-
- dev_dbg(device, "Creating sysfs mapping for device %s\n",
- device->kobj.name);
-
- mapping = &dev_mappings[map_idx];
- mapping->attributes = kcalloc(GASKET_SYSFS_MAX_NODES,
- sizeof(*mapping->attributes),
- GFP_KERNEL);
- if (!mapping->attributes) {
- dev_dbg(device, "Unable to allocate sysfs attribute array\n");
- mutex_unlock(&mapping->mutex);
- mutex_unlock(&function_mutex);
- return -ENOMEM;
- }
-
- kref_init(&mapping->refcount);
- mapping->device = get_device(device);
- mapping->gasket_dev = gasket_dev;
- mapping->attribute_count = 0;
- mutex_unlock(&mapping->mutex);
- mutex_unlock(&function_mutex);
-
- /* Don't decrement the refcount here! One open count keeps it alive! */
- return 0;
-}
-
-int gasket_sysfs_create_entries(struct device *device,
- const struct gasket_sysfs_attribute *attrs)
-{
- int i;
- int ret;
- struct gasket_sysfs_mapping *mapping = get_mapping(device);
-
- if (!mapping) {
- dev_dbg(device,
- "Creating entries for device without first initializing mapping\n");
- return -EINVAL;
- }
-
- mutex_lock(&mapping->mutex);
- for (i = 0; attrs[i].attr.attr.name != NULL; i++) {
- if (mapping->attribute_count == GASKET_SYSFS_MAX_NODES) {
- dev_err(device,
- "Maximum number of sysfs nodes reached for device\n");
- mutex_unlock(&mapping->mutex);
- put_mapping(mapping);
- return -ENOMEM;
- }
-
- ret = device_create_file(device, &attrs[i].attr);
- if (ret) {
- dev_dbg(device, "Unable to create device entries\n");
- mutex_unlock(&mapping->mutex);
- put_mapping(mapping);
- return ret;
- }
-
- mapping->attributes[mapping->attribute_count] = attrs[i];
- ++mapping->attribute_count;
- }
-
- mutex_unlock(&mapping->mutex);
- put_mapping(mapping);
- return 0;
-}
-EXPORT_SYMBOL(gasket_sysfs_create_entries);
-
-void gasket_sysfs_remove_mapping(struct device *device)
-{
- struct gasket_sysfs_mapping *mapping = get_mapping(device);
-
- if (!mapping) {
- dev_err(device,
- "Attempted to remove non-existent sysfs mapping to device\n");
- return;
- }
-
- put_mapping_n(mapping, 2);
-}
-
-struct gasket_dev *gasket_sysfs_get_device_data(struct device *device)
-{
- struct gasket_sysfs_mapping *mapping = get_mapping(device);
-
- if (!mapping) {
- dev_err(device, "device not registered\n");
- return NULL;
- }
-
- return mapping->gasket_dev;
-}
-EXPORT_SYMBOL(gasket_sysfs_get_device_data);
-
-void gasket_sysfs_put_device_data(struct device *device, struct gasket_dev *dev)
-{
- struct gasket_sysfs_mapping *mapping = get_mapping(device);
-
- if (!mapping)
- return;
-
- /* See comment of put_mapping_n() for why the '2' is necessary. */
- put_mapping_n(mapping, 2);
-}
-EXPORT_SYMBOL(gasket_sysfs_put_device_data);
-
-struct gasket_sysfs_attribute *
-gasket_sysfs_get_attr(struct device *device, struct device_attribute *attr)
-{
- int i;
- int num_attrs;
- struct gasket_sysfs_mapping *mapping = get_mapping(device);
- struct gasket_sysfs_attribute *attrs = NULL;
-
- if (!mapping)
- return NULL;
-
- attrs = mapping->attributes;
- num_attrs = mapping->attribute_count;
- for (i = 0; i < num_attrs; ++i) {
- if (!strcmp(attrs[i].attr.attr.name, attr->attr.name))
- return &attrs[i];
- }
-
- dev_err(device, "Unable to find match for device_attribute %s\n",
- attr->attr.name);
- return NULL;
-}
-EXPORT_SYMBOL(gasket_sysfs_get_attr);
-
-void gasket_sysfs_put_attr(struct device *device,
- struct gasket_sysfs_attribute *attr)
-{
- int i;
- int num_attrs;
- struct gasket_sysfs_mapping *mapping = get_mapping(device);
- struct gasket_sysfs_attribute *attrs = NULL;
-
- if (!mapping)
- return;
-
- attrs = mapping->attributes;
- num_attrs = mapping->attribute_count;
- for (i = 0; i < num_attrs; ++i) {
- if (&attrs[i] == attr) {
- put_mapping_n(mapping, 2);
- return;
- }
- }
-
- dev_err(device, "Unable to put unknown attribute: %s\n",
- attr->attr.attr.name);
- put_mapping(mapping);
-}
-EXPORT_SYMBOL(gasket_sysfs_put_attr);
-
-ssize_t gasket_sysfs_register_store(struct device *device,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- ulong parsed_value = 0;
- struct gasket_sysfs_mapping *mapping;
- struct gasket_dev *gasket_dev;
- struct gasket_sysfs_attribute *gasket_attr;
-
- if (count < 3 || buf[0] != '0' || buf[1] != 'x') {
- dev_err(device,
- "sysfs register write format: \"0x<hex value>\"\n");
- return -EINVAL;
- }
-
- if (kstrtoul(buf, 16, &parsed_value) != 0) {
- dev_err(device,
- "Unable to parse input as 64-bit hex value: %s\n", buf);
- return -EINVAL;
- }
-
- mapping = get_mapping(device);
- if (!mapping) {
- dev_err(device, "Device driver may have been removed\n");
- return 0;
- }
-
- gasket_dev = mapping->gasket_dev;
- if (!gasket_dev) {
- dev_err(device, "Device driver may have been removed\n");
- put_mapping(mapping);
- return 0;
- }
-
- gasket_attr = gasket_sysfs_get_attr(device, attr);
- if (!gasket_attr) {
- put_mapping(mapping);
- return count;
- }
-
- gasket_dev_write_64(gasket_dev, parsed_value,
- gasket_attr->data.bar_address.bar,
- gasket_attr->data.bar_address.offset);
-
- if (gasket_attr->write_callback)
- gasket_attr->write_callback(gasket_dev, gasket_attr,
- parsed_value);
-
- gasket_sysfs_put_attr(device, gasket_attr);
- put_mapping(mapping);
- return count;
-}
-EXPORT_SYMBOL(gasket_sysfs_register_store);
diff --git a/drivers/staging/gasket/gasket_sysfs.h b/drivers/staging/gasket/gasket_sysfs.h
deleted file mode 100644
index d5e167dfbe76..000000000000
--- a/drivers/staging/gasket/gasket_sysfs.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Set of common sysfs utilities.
- *
- * Copyright (C) 2018 Google, Inc.
- */
-
-/* The functions described here are a set of utilities to allow each file in the
- * Gasket driver framework to manage their own set of sysfs entries, instead of
- * centralizing all that work in one file.
- *
- * The goal of these utilities is to allow for sysfs entries to be easily
- * created without causing a proliferation of sysfs "show" functions. This
- * requires O(N) string lookups during show function execution, but as reading
- * sysfs entries is rarely performance-critical, this is likely acceptible.
- */
-#ifndef __GASKET_SYSFS_H__
-#define __GASKET_SYSFS_H__
-
-#include "gasket_constants.h"
-#include "gasket_core.h"
-#include <linux/device.h>
-#include <linux/stringify.h>
-#include <linux/sysfs.h>
-
-/* The maximum number of mappings/devices a driver needs to support. */
-#define GASKET_SYSFS_NUM_MAPPINGS (GASKET_FRAMEWORK_DESC_MAX * GASKET_DEV_MAX)
-
-/* The maximum number of sysfs nodes in a directory.
- */
-#define GASKET_SYSFS_MAX_NODES 196
-
-/*
- * Terminator struct for a gasket_sysfs_attr array. Must be at the end of
- * all gasket_sysfs_attribute arrays.
- */
-#define GASKET_END_OF_ATTR_ARRAY \
- { \
- .attr = __ATTR_NULL, \
- .data.attr_type = 0, \
- }
-
-/*
- * Pairing of sysfs attribute and user data.
- * Used in lookups in sysfs "show" functions to return attribute metadata.
- */
-struct gasket_sysfs_attribute {
- /* The underlying sysfs device attribute associated with this data. */
- struct device_attribute attr;
-
- /* User-specified data to associate with the attribute. */
- union {
- struct bar_address_ {
- ulong bar;
- ulong offset;
- } bar_address;
- uint attr_type;
- } data;
-
- /*
- * Function pointer to a callback to be invoked when this attribute is
- * written (if so configured). The arguments are to the Gasket device
- * pointer, the enclosing gasket_attr structure, and the value written.
- * The callback should perform any logging necessary, as errors cannot
- * be returned from the callback.
- */
- void (*write_callback)(struct gasket_dev *dev,
- struct gasket_sysfs_attribute *attr,
- ulong value);
-};
-
-#define GASKET_SYSFS_RO(_name, _show_function, _attr_type) \
- { \
- .attr = __ATTR(_name, 0444, _show_function, NULL), \
- .data.attr_type = _attr_type \
- }
-
-/* Initializes the Gasket sysfs subsystem.
- *
- * Description: Performs one-time initialization. Must be called before usage
- * at [Gasket] module load time.
- */
-void gasket_sysfs_init(void);
-
-/*
- * Create an entry in mapping_data between a device and a Gasket device.
- * @device: Device struct to map to.
- * @gasket_dev: The dev struct associated with the driver controlling @device.
- *
- * Description: This function maps a gasket_dev* to a device*. This mapping can
- * be used in sysfs_show functions to get a handle to the gasket_dev struct
- * controlling the device node.
- *
- * If this function is not called before gasket_sysfs_create_entries, a warning
- * will be logged.
- */
-int gasket_sysfs_create_mapping(struct device *device,
- struct gasket_dev *gasket_dev);
-
-/*
- * Creates bulk entries in sysfs.
- * @device: Kernel device structure.
- * @attrs: List of attributes/sysfs entries to create.
- *
- * Description: Creates each sysfs entry described in "attrs". Can be called
- * multiple times for a given @device. If the gasket_dev specified in
- * gasket_sysfs_create_mapping had a legacy device, the entries will be created
- * for it, as well.
- */
-int gasket_sysfs_create_entries(struct device *device,
- const struct gasket_sysfs_attribute *attrs);
-
-/*
- * Removes a device mapping from the global table.
- * @device: Device to unmap.
- *
- * Description: Removes the device->Gasket device mapping from the internal
- * table.
- */
-void gasket_sysfs_remove_mapping(struct device *device);
-
-/*
- * User data lookup based on kernel device structure.
- * @device: Kernel device structure.
- *
- * Description: Returns the user data associated with "device" in a prior call
- * to gasket_sysfs_create_entries. Returns NULL if no mapping can be found.
- * Upon success, this call take a reference to internal sysfs data that must be
- * released with gasket_sysfs_put_device_data. While this reference is held, the
- * underlying device sysfs information/structure will remain valid/will not be
- * deleted.
- */
-struct gasket_dev *gasket_sysfs_get_device_data(struct device *device);
-
-/*
- * Releases a references to internal data.
- * @device: Kernel device structure.
- * @dev: Gasket device descriptor (returned by gasket_sysfs_get_device_data).
- */
-void gasket_sysfs_put_device_data(struct device *device,
- struct gasket_dev *gasket_dev);
-
-/*
- * Gasket-specific attribute lookup.
- * @device: Kernel device structure.
- * @attr: Device attribute to look up.
- *
- * Returns the Gasket sysfs attribute associated with the kernel device
- * attribute and device structure itself. Upon success, this call will take a
- * reference to internal sysfs data that must be released with a call to
- * gasket_sysfs_put_attr. While this reference is held, the underlying device
- * sysfs information/structure will remain valid/will not be deleted.
- */
-struct gasket_sysfs_attribute *
-gasket_sysfs_get_attr(struct device *device, struct device_attribute *attr);
-
-/*
- * Releases a references to internal data.
- * @device: Kernel device structure.
- * @attr: Gasket sysfs attribute descriptor (returned by
- * gasket_sysfs_get_attr).
- */
-void gasket_sysfs_put_attr(struct device *device,
- struct gasket_sysfs_attribute *attr);
-
-/*
- * Write to a register sysfs node.
- * @buf: NULL-terminated data being written.
- * @count: number of bytes in the "buf" argument.
- */
-ssize_t gasket_sysfs_register_store(struct device *device,
- struct device_attribute *attr,
- const char *buf, size_t count);
-
-#endif /* __GASKET_SYSFS_H__ */
diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
index eebf0deb39f5..e374dfc0c92f 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -77,9 +77,8 @@ static void arche_platform_set_state(struct arche_platform_drvdata *arche_pdata,
}
/* Requires arche_pdata->wake_lock is held by calling context */
-static void arche_platform_set_wake_detect_state(
- struct arche_platform_drvdata *arche_pdata,
- enum svc_wakedetect_state state)
+static void arche_platform_set_wake_detect_state(struct arche_platform_drvdata *arche_pdata,
+ enum svc_wakedetect_state state)
{
arche_pdata->wake_detect_state = state;
}
@@ -181,9 +180,8 @@ static irqreturn_t arche_platform_wd_irq(int irq, void *devid)
WD_STATE_COLDBOOT_START) {
arche_platform_set_wake_detect_state(arche_pdata,
WD_STATE_COLDBOOT_TRIG);
- spin_unlock_irqrestore(
- &arche_pdata->wake_lock,
- flags);
+ spin_unlock_irqrestore(&arche_pdata->wake_lock,
+ flags);
return IRQ_WAKE_THREAD;
}
}
diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greybus/audio_module.c
index 0f9fdc077b4c..12c376c477b3 100644
--- a/drivers/staging/greybus/audio_module.c
+++ b/drivers/staging/greybus/audio_module.c
@@ -260,7 +260,7 @@ static int gb_audio_probe(struct gb_bundle *bundle,
INIT_LIST_HEAD(&gbmodule->widget_ctl_list);
INIT_LIST_HEAD(&gbmodule->jack_list);
gbmodule->dev = dev;
- snprintf(gbmodule->name, NAME_SIZE, "%s.%s", dev->driver->name,
+ snprintf(gbmodule->name, sizeof(gbmodule->name), "%s.%s", dev->driver->name,
dev_name(dev));
greybus_set_drvdata(bundle, gbmodule);
@@ -342,7 +342,7 @@ static int gb_audio_probe(struct gb_bundle *bundle,
/* inform above layer for uevent */
dev_dbg(dev, "Inform set_event:%d to above layer\n", 1);
/* prepare for the audio manager */
- strscpy(desc.name, gbmodule->name, GB_AUDIO_MANAGER_MODULE_NAME_LEN);
+ strscpy(desc.name, gbmodule->name, sizeof(desc.name));
desc.vid = 2; /* todo */
desc.pid = 3; /* todo */
desc.intf_id = gbmodule->dev_id;
diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
index e816e4db555e..1fc7727ab7be 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -200,7 +200,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,
return -EINVAL;
name = gbaudio_map_controlid(module, data->ctl_id,
uinfo->value.enumerated.item);
- strscpy(uinfo->value.enumerated.name, name, NAME_SIZE);
+ strscpy(uinfo->value.enumerated.name, name, sizeof(uinfo->value.enumerated.name));
break;
default:
dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n",
@@ -363,7 +363,7 @@ static int gbcodec_mixer_dapm_ctl_info(struct snd_kcontrol *kcontrol,
platform_min = le32_to_cpu(info->value.integer.min);
if (platform_max == 1 &&
- !strnstr(kcontrol->id.name, " Volume", NAME_SIZE))
+ !strnstr(kcontrol->id.name, " Volume", sizeof(kcontrol->id.name)))
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
else
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -1047,8 +1047,8 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
}
/* Prefix dev_id to widget control_name */
- strscpy(temp_name, w->name, NAME_SIZE);
- snprintf(w->name, NAME_SIZE, "GB %d %s", module->dev_id, temp_name);
+ strscpy(temp_name, w->name, sizeof(temp_name));
+ snprintf(w->name, sizeof(w->name), "GB %d %s", module->dev_id, temp_name);
switch (w->type) {
case snd_soc_dapm_spk:
@@ -1169,8 +1169,8 @@ static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module,
}
control->id = curr->id;
/* Prefix dev_id to widget_name */
- strscpy(temp_name, curr->name, NAME_SIZE);
- snprintf(curr->name, NAME_SIZE, "GB %d %s", module->dev_id,
+ strscpy(temp_name, curr->name, sizeof(temp_name));
+ snprintf(curr->name, sizeof(curr->name), "GB %d %s", module->dev_id,
temp_name);
control->name = curr->name;
if (curr->info.type == GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED) {
diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c
index b570e13394ac..cdbb42cd413b 100644
--- a/drivers/staging/greybus/camera.c
+++ b/drivers/staging/greybus/camera.c
@@ -1120,16 +1120,9 @@ static ssize_t gb_camera_debugfs_write(struct file *file,
if (len > 1024)
return -EINVAL;
- kbuf = kmalloc(len + 1, GFP_KERNEL);
- if (!kbuf)
- return -ENOMEM;
-
- if (copy_from_user(kbuf, buf, len)) {
- ret = -EFAULT;
- goto done;
- }
-
- kbuf[len] = '\0';
+ kbuf = memdup_user_nul(buf, len);
+ if (IS_ERR(kbuf))
+ return PTR_ERR(kbuf);
ret = op->execute(gcam, kbuf, len);
diff --git a/drivers/staging/greybus/sdio.c b/drivers/staging/greybus/sdio.c
index 0939f4a4c963..37bf04c22dbc 100644
--- a/drivers/staging/greybus/sdio.c
+++ b/drivers/staging/greybus/sdio.c
@@ -33,7 +33,6 @@ struct gb_sdio_host {
bool read_only;
};
-
#define GB_SDIO_RSP_R1_R5_R6_R7 (GB_SDIO_RSP_PRESENT | GB_SDIO_RSP_CRC | \
GB_SDIO_RSP_OPCODE)
#define GB_SDIO_RSP_R3_R4 (GB_SDIO_RSP_PRESENT)
diff --git a/drivers/staging/hikey9xx/Kconfig b/drivers/staging/hikey9xx/Kconfig
index 82bb4a22b286..c4dc1016edf2 100644
--- a/drivers/staging/hikey9xx/Kconfig
+++ b/drivers/staging/hikey9xx/Kconfig
@@ -39,14 +39,3 @@ config MFD_HI6421_SPMI
individual components like voltage regulators under corresponding
menus in order to enable them.
We communicate with the Hi6421v600 via a SPMI bus.
-
-# to be placed at drivers/regulator
-config REGULATOR_HI6421V600
- tristate "HiSilicon Hi6421v600 PMIC voltage regulator support"
- depends on MFD_HI6421_SPMI && OF
- depends on REGULATOR
- select REGMAP
- help
- This driver provides support for the voltage regulators on
- HiSilicon Hi6421v600 PMU / Codec IC.
- This is used on Kirin 3670 boards, like HiKey 970.
diff --git a/drivers/staging/hikey9xx/Makefile b/drivers/staging/hikey9xx/Makefile
index 1924fadac952..9103735d8377 100644
--- a/drivers/staging/hikey9xx/Makefile
+++ b/drivers/staging/hikey9xx/Makefile
@@ -4,4 +4,3 @@ obj-$(CONFIG_PHY_HI3670_USB) += phy-hi3670-usb3.o
obj-$(CONFIG_SPMI_HISI3670) += hisi-spmi-controller.o
obj-$(CONFIG_MFD_HI6421_SPMI) += hi6421-spmi-pmic.o
-obj-$(CONFIG_REGULATOR_HI6421V600) += hi6421v600-regulator.o
diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
index 4ebcfea9f3bf..626140cb96f2 100644
--- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
+++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c
@@ -48,9 +48,9 @@ enum hi6421_spmi_pmic_irq_list {
/*
* The IRQs are mapped as:
*
- * ====================== ============= ============ =====
- * IRQ MASK REGISTER IRQ REGISTER BIT
- * ====================== ============= ============ =====
+ * ====================== ============= ============ =====
+ * IRQ MASK REGISTER IRQ REGISTER BIT
+ * ====================== ============= ============ =====
* OTMP 0x0202 0x212 bit 0
* VBUS_CONNECT 0x0202 0x212 bit 1
* VBUS_DISCONNECT 0x0202 0x212 bit 2
@@ -66,7 +66,7 @@ enum hi6421_spmi_pmic_irq_list {
* SIM0_HPD_F 0x0203 0x213 bit 3
* SIM1_HPD_R 0x0203 0x213 bit 4
* SIM1_HPD_F 0x0203 0x213 bit 5
- * ====================== ============= ============ =====
+ * ====================== ============= ============ =====
*/
#define SOC_PMIC_IRQ_MASK_0_ADDR 0x0202
#define SOC_PMIC_IRQ0_ADDR 0x0212
diff --git a/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml b/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml
index 21f68a9c2df1..6b755039a74c 100644
--- a/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml
+++ b/drivers/staging/hikey9xx/hisilicon,hisi-spmi-controller.yaml
@@ -16,7 +16,11 @@ description: |
The PMIC part is provided by
drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml.
+allOf:
+ - $ref: spmi.yaml#
+
properties:
+
$nodename:
pattern: "spmi@[0-9a-f]"
@@ -26,13 +30,8 @@ properties:
reg:
maxItems: 1
- "#address-cells":
- const: 2
-
- "#size-cells":
- const: 0
-
spmi-channel:
+ $ref: /schemas/types.yaml#/definitions/uint32
description: |
number of the Kirin 970 SPMI channel where the SPMI devices are connected.
@@ -40,18 +39,16 @@ required:
- compatible
- reg
- spmi-channel
- - "#address-cells"
- - "#size-cells"
patternProperties:
- "^pmic@[0-9a-f]$":
+ "@[0-9a-f]$":
description: |
PMIC properties, which are specific to the used SPMI PMIC device(s).
When used in combination with HiSilicon 6421v600, the properties
are documented at
drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml.
-additionalProperties: false
+unevaluatedProperties: false
examples:
- |
@@ -63,7 +60,6 @@ examples:
compatible = "hisilicon,kirin970-spmi-controller";
#address-cells = <2>;
#size-cells = <0>;
- status = "ok";
reg = <0x0 0xfff24000 0x0 0x1000>;
spmi-channel = <2>;
diff --git a/drivers/staging/iio/TODO b/drivers/staging/iio/TODO
index 4d469016a13a..0fa6a5500bdb 100644
--- a/drivers/staging/iio/TODO
+++ b/drivers/staging/iio/TODO
@@ -1,9 +1,5 @@
2020-02-25
-ADI Drivers:
-CC the device-drivers-devel@blackfin.uclinux.org mailing list when
-e-mailing the normal IIO list (see below).
-
Contact: Jonathan Cameron <jic23@kernel.org>.
Mailing list: linux-iio@vger.kernel.org
diff --git a/drivers/staging/iio/cdc/Kconfig b/drivers/staging/iio/cdc/Kconfig
index e0a5ce66a984..a7386bbbcb79 100644
--- a/drivers/staging/iio/cdc/Kconfig
+++ b/drivers/staging/iio/cdc/Kconfig
@@ -4,16 +4,6 @@
#
menu "Capacitance to digital converters"
-config AD7150
- tristate "Analog Devices ad7150/1/6 capacitive sensor driver"
- depends on I2C
- help
- Say yes here to build support for Analog Devices capacitive sensors.
- (ad7150, ad7151, ad7156) Provides direct access via sysfs.
-
- To compile this driver as a module, choose M here: the
- module will be called ad7150.
-
config AD7746
tristate "Analog Devices AD7745, AD7746 AD7747 capacitive sensor driver"
depends on I2C
diff --git a/drivers/staging/iio/cdc/Makefile b/drivers/staging/iio/cdc/Makefile
index ab8222579e7e..afb7499a7090 100644
--- a/drivers/staging/iio/cdc/Makefile
+++ b/drivers/staging/iio/cdc/Makefile
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
#
-# Makefile for industrial I/O DAC drivers
+# Makefile for industrial I/O CDC drivers
#
-obj-$(CONFIG_AD7150) += ad7150.o
obj-$(CONFIG_AD7746) += ad7746.o
diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c
deleted file mode 100644
index 48132ab157ef..000000000000
--- a/drivers/staging/iio/cdc/ad7150.c
+++ /dev/null
@@ -1,655 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * AD7150 capacitive sensor driver supporting AD7150/1/6
- *
- * Copyright 2010-2011 Analog Devices Inc.
- */
-
-#include <linux/bitfield.h>
-#include <linux/interrupt.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/i2c.h>
-#include <linux/module.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include <linux/iio/events.h>
-/*
- * AD7150 registers definition
- */
-
-#define AD7150_STATUS 0
-#define AD7150_STATUS_OUT1 BIT(3)
-#define AD7150_STATUS_OUT2 BIT(5)
-#define AD7150_CH1_DATA_HIGH 1
-#define AD7150_CH2_DATA_HIGH 3
-#define AD7150_CH1_AVG_HIGH 5
-#define AD7150_CH2_AVG_HIGH 7
-#define AD7150_CH1_SENSITIVITY 9
-#define AD7150_CH1_THR_HOLD_H 9
-#define AD7150_CH1_TIMEOUT 10
-#define AD7150_CH1_SETUP 11
-#define AD7150_CH2_SENSITIVITY 12
-#define AD7150_CH2_THR_HOLD_H 12
-#define AD7150_CH2_TIMEOUT 13
-#define AD7150_CH2_SETUP 14
-#define AD7150_CFG 15
-#define AD7150_CFG_FIX BIT(7)
-#define AD7150_PD_TIMER 16
-#define AD7150_CH1_CAPDAC 17
-#define AD7150_CH2_CAPDAC 18
-#define AD7150_SN3 19
-#define AD7150_SN2 20
-#define AD7150_SN1 21
-#define AD7150_SN0 22
-#define AD7150_ID 23
-
-/* AD7150 masks */
-#define AD7150_THRESHTYPE_MSK GENMASK(6, 5)
-
-/**
- * struct ad7150_chip_info - instance specific chip data
- * @client: i2c client for this device
- * @current_event: device always has one type of event enabled.
- * This element stores the event code of the current one.
- * @threshold: thresholds for simple capacitance value events
- * @thresh_sensitivity: threshold for simple capacitance offset
- * from 'average' value.
- * @mag_sensitity: threshold for magnitude of capacitance offset from
- * from 'average' value.
- * @thresh_timeout: a timeout, in samples from the moment an
- * adaptive threshold event occurs to when the average
- * value jumps to current value.
- * @mag_timeout: a timeout, in sample from the moment an
- * adaptive magnitude event occurs to when the average
- * value jumps to the current value.
- * @old_state: store state from previous event, allowing confirmation
- * of new condition.
- * @conversion_mode: the current conversion mode.
- * @state_lock: ensure consistent state of this structure wrt the
- * hardware.
- */
-struct ad7150_chip_info {
- struct i2c_client *client;
- u64 current_event;
- u16 threshold[2][2];
- u8 thresh_sensitivity[2][2];
- u8 mag_sensitivity[2][2];
- u8 thresh_timeout[2][2];
- u8 mag_timeout[2][2];
- int old_state;
- char *conversion_mode;
- struct mutex state_lock;
-};
-
-/*
- * sysfs nodes
- */
-
-static const u8 ad7150_addresses[][6] = {
- { AD7150_CH1_DATA_HIGH, AD7150_CH1_AVG_HIGH,
- AD7150_CH1_SETUP, AD7150_CH1_THR_HOLD_H,
- AD7150_CH1_SENSITIVITY, AD7150_CH1_TIMEOUT },
- { AD7150_CH2_DATA_HIGH, AD7150_CH2_AVG_HIGH,
- AD7150_CH2_SETUP, AD7150_CH2_THR_HOLD_H,
- AD7150_CH2_SENSITIVITY, AD7150_CH2_TIMEOUT },
-};
-
-static int ad7150_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long mask)
-{
- int ret;
- struct ad7150_chip_info *chip = iio_priv(indio_dev);
- int channel = chan->channel;
-
- switch (mask) {
- case IIO_CHAN_INFO_RAW:
- ret = i2c_smbus_read_word_data(chip->client,
- ad7150_addresses[channel][0]);
- if (ret < 0)
- return ret;
- *val = swab16(ret);
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_AVERAGE_RAW:
- ret = i2c_smbus_read_word_data(chip->client,
- ad7150_addresses[channel][1]);
- if (ret < 0)
- return ret;
- *val = swab16(ret);
- return IIO_VAL_INT;
- default:
- return -EINVAL;
- }
-}
-
-static int ad7150_read_event_config(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan,
- enum iio_event_type type,
- enum iio_event_direction dir)
-{
- int ret;
- u8 threshtype;
- bool thrfixed;
- struct ad7150_chip_info *chip = iio_priv(indio_dev);
-
- ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG);
- if (ret < 0)
- return ret;
-
- threshtype = FIELD_GET(AD7150_THRESHTYPE_MSK, ret);
-
- /*check if threshold mode is fixed or adaptive*/
- thrfixed = FIELD_GET(AD7150_CFG_FIX, ret);
-
- switch (type) {
- case IIO_EV_TYPE_MAG_ADAPTIVE:
- if (dir == IIO_EV_DIR_RISING)
- return !thrfixed && (threshtype == 0x1);
- return !thrfixed && (threshtype == 0x0);
- case IIO_EV_TYPE_THRESH_ADAPTIVE:
- if (dir == IIO_EV_DIR_RISING)
- return !thrfixed && (threshtype == 0x3);
- return !thrfixed && (threshtype == 0x2);
- case IIO_EV_TYPE_THRESH:
- if (dir == IIO_EV_DIR_RISING)
- return thrfixed && (threshtype == 0x1);
- return thrfixed && (threshtype == 0x0);
- default:
- break;
- }
- return -EINVAL;
-}
-
-/* state_lock should be held to ensure consistent state*/
-
-static int ad7150_write_event_params(struct iio_dev *indio_dev,
- unsigned int chan,
- enum iio_event_type type,
- enum iio_event_direction dir)
-{
- int ret;
- u16 value;
- u8 sens, timeout;
- struct ad7150_chip_info *chip = iio_priv(indio_dev);
- int rising = (dir == IIO_EV_DIR_RISING);
- u64 event_code;
-
- event_code = IIO_UNMOD_EVENT_CODE(IIO_CAPACITANCE, chan, type, dir);
-
- if (event_code != chip->current_event)
- return 0;
-
- switch (type) {
- /* Note completely different from the adaptive versions */
- case IIO_EV_TYPE_THRESH:
- value = chip->threshold[rising][chan];
- return i2c_smbus_write_word_data(chip->client,
- ad7150_addresses[chan][3],
- swab16(value));
- case IIO_EV_TYPE_MAG_ADAPTIVE:
- sens = chip->mag_sensitivity[rising][chan];
- timeout = chip->mag_timeout[rising][chan];
- break;
- case IIO_EV_TYPE_THRESH_ADAPTIVE:
- sens = chip->thresh_sensitivity[rising][chan];
- timeout = chip->thresh_timeout[rising][chan];
- break;
- default:
- return -EINVAL;
- }
- ret = i2c_smbus_write_byte_data(chip->client,
- ad7150_addresses[chan][4],
- sens);
- if (ret)
- return ret;
- return i2c_smbus_write_byte_data(chip->client,
- ad7150_addresses[chan][5],
- timeout);
-}
-
-static int ad7150_write_event_config(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan,
- enum iio_event_type type,
- enum iio_event_direction dir, int state)
-{
- u8 thresh_type, cfg, adaptive;
- int ret;
- struct ad7150_chip_info *chip = iio_priv(indio_dev);
- int rising = (dir == IIO_EV_DIR_RISING);
- u64 event_code;
-
- /* Something must always be turned on */
- if (!state)
- return -EINVAL;
-
- event_code = IIO_UNMOD_EVENT_CODE(chan->type, chan->channel, type, dir);
- if (event_code == chip->current_event)
- return 0;
- mutex_lock(&chip->state_lock);
- ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG);
- if (ret < 0)
- goto error_ret;
-
- cfg = ret & ~((0x03 << 5) | BIT(7));
-
- switch (type) {
- case IIO_EV_TYPE_MAG_ADAPTIVE:
- adaptive = 1;
- if (rising)
- thresh_type = 0x1;
- else
- thresh_type = 0x0;
- break;
- case IIO_EV_TYPE_THRESH_ADAPTIVE:
- adaptive = 1;
- if (rising)
- thresh_type = 0x3;
- else
- thresh_type = 0x2;
- break;
- case IIO_EV_TYPE_THRESH:
- adaptive = 0;
- if (rising)
- thresh_type = 0x1;
- else
- thresh_type = 0x0;
- break;
- default:
- ret = -EINVAL;
- goto error_ret;
- }
-
- cfg |= (!adaptive << 7) | (thresh_type << 5);
-
- ret = i2c_smbus_write_byte_data(chip->client, AD7150_CFG, cfg);
- if (ret < 0)
- goto error_ret;
-
- chip->current_event = event_code;
-
- /* update control attributes */
- ret = ad7150_write_event_params(indio_dev, chan->channel, type, dir);
-error_ret:
- mutex_unlock(&chip->state_lock);
-
- return ret;
-}
-
-static int ad7150_read_event_value(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan,
- enum iio_event_type type,
- enum iio_event_direction dir,
- enum iio_event_info info,
- int *val, int *val2)
-{
- struct ad7150_chip_info *chip = iio_priv(indio_dev);
- int rising = (dir == IIO_EV_DIR_RISING);
-
- /* Complex register sharing going on here */
- switch (type) {
- case IIO_EV_TYPE_MAG_ADAPTIVE:
- *val = chip->mag_sensitivity[rising][chan->channel];
- return IIO_VAL_INT;
- case IIO_EV_TYPE_THRESH_ADAPTIVE:
- *val = chip->thresh_sensitivity[rising][chan->channel];
- return IIO_VAL_INT;
- case IIO_EV_TYPE_THRESH:
- *val = chip->threshold[rising][chan->channel];
- return IIO_VAL_INT;
- default:
- return -EINVAL;
- }
-}
-
-static int ad7150_write_event_value(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan,
- enum iio_event_type type,
- enum iio_event_direction dir,
- enum iio_event_info info,
- int val, int val2)
-{
- int ret;
- struct ad7150_chip_info *chip = iio_priv(indio_dev);
- int rising = (dir == IIO_EV_DIR_RISING);
-
- mutex_lock(&chip->state_lock);
- switch (type) {
- case IIO_EV_TYPE_MAG_ADAPTIVE:
- chip->mag_sensitivity[rising][chan->channel] = val;
- break;
- case IIO_EV_TYPE_THRESH_ADAPTIVE:
- chip->thresh_sensitivity[rising][chan->channel] = val;
- break;
- case IIO_EV_TYPE_THRESH:
- chip->threshold[rising][chan->channel] = val;
- break;
- default:
- ret = -EINVAL;
- goto error_ret;
- }
-
- /* write back if active */
- ret = ad7150_write_event_params(indio_dev, chan->channel, type, dir);
-
-error_ret:
- mutex_unlock(&chip->state_lock);
- return ret;
-}
-
-static ssize_t ad7150_show_timeout(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ad7150_chip_info *chip = iio_priv(indio_dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- u8 value;
-
- /* use the event code for consistency reasons */
- int chan = IIO_EVENT_CODE_EXTRACT_CHAN(this_attr->address);
- int rising = (IIO_EVENT_CODE_EXTRACT_DIR(this_attr->address)
- == IIO_EV_DIR_RISING) ? 1 : 0;
-
- switch (IIO_EVENT_CODE_EXTRACT_TYPE(this_attr->address)) {
- case IIO_EV_TYPE_MAG_ADAPTIVE:
- value = chip->mag_timeout[rising][chan];
- break;
- case IIO_EV_TYPE_THRESH_ADAPTIVE:
- value = chip->thresh_timeout[rising][chan];
- break;
- default:
- return -EINVAL;
- }
-
- return sprintf(buf, "%d\n", value);
-}
-
-static ssize_t ad7150_store_timeout(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct ad7150_chip_info *chip = iio_priv(indio_dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int chan = IIO_EVENT_CODE_EXTRACT_CHAN(this_attr->address);
- enum iio_event_direction dir;
- enum iio_event_type type;
- int rising;
- u8 data;
- int ret;
-
- type = IIO_EVENT_CODE_EXTRACT_TYPE(this_attr->address);
- dir = IIO_EVENT_CODE_EXTRACT_DIR(this_attr->address);
- rising = (dir == IIO_EV_DIR_RISING);
-
- ret = kstrtou8(buf, 10, &data);
- if (ret < 0)
- return ret;
-
- mutex_lock(&chip->state_lock);
- switch (type) {
- case IIO_EV_TYPE_MAG_ADAPTIVE:
- chip->mag_timeout[rising][chan] = data;
- break;
- case IIO_EV_TYPE_THRESH_ADAPTIVE:
- chip->thresh_timeout[rising][chan] = data;
- break;
- default:
- ret = -EINVAL;
- goto error_ret;
- }
-
- ret = ad7150_write_event_params(indio_dev, chan, type, dir);
-error_ret:
- mutex_unlock(&chip->state_lock);
-
- if (ret < 0)
- return ret;
-
- return len;
-}
-
-#define AD7150_TIMEOUT(chan, type, dir, ev_type, ev_dir) \
- IIO_DEVICE_ATTR(in_capacitance##chan##_##type##_##dir##_timeout, \
- 0644, \
- &ad7150_show_timeout, \
- &ad7150_store_timeout, \
- IIO_UNMOD_EVENT_CODE(IIO_CAPACITANCE, \
- chan, \
- IIO_EV_TYPE_##ev_type, \
- IIO_EV_DIR_##ev_dir))
-static AD7150_TIMEOUT(0, mag_adaptive, rising, MAG_ADAPTIVE, RISING);
-static AD7150_TIMEOUT(0, mag_adaptive, falling, MAG_ADAPTIVE, FALLING);
-static AD7150_TIMEOUT(1, mag_adaptive, rising, MAG_ADAPTIVE, RISING);
-static AD7150_TIMEOUT(1, mag_adaptive, falling, MAG_ADAPTIVE, FALLING);
-static AD7150_TIMEOUT(0, thresh_adaptive, rising, THRESH_ADAPTIVE, RISING);
-static AD7150_TIMEOUT(0, thresh_adaptive, falling, THRESH_ADAPTIVE, FALLING);
-static AD7150_TIMEOUT(1, thresh_adaptive, rising, THRESH_ADAPTIVE, RISING);
-static AD7150_TIMEOUT(1, thresh_adaptive, falling, THRESH_ADAPTIVE, FALLING);
-
-static const struct iio_event_spec ad7150_events[] = {
- {
- .type = IIO_EV_TYPE_THRESH,
- .dir = IIO_EV_DIR_RISING,
- .mask_separate = BIT(IIO_EV_INFO_VALUE) |
- BIT(IIO_EV_INFO_ENABLE),
- }, {
- .type = IIO_EV_TYPE_THRESH,
- .dir = IIO_EV_DIR_FALLING,
- .mask_separate = BIT(IIO_EV_INFO_VALUE) |
- BIT(IIO_EV_INFO_ENABLE),
- }, {
- .type = IIO_EV_TYPE_THRESH_ADAPTIVE,
- .dir = IIO_EV_DIR_RISING,
- .mask_separate = BIT(IIO_EV_INFO_VALUE) |
- BIT(IIO_EV_INFO_ENABLE),
- }, {
- .type = IIO_EV_TYPE_THRESH_ADAPTIVE,
- .dir = IIO_EV_DIR_FALLING,
- .mask_separate = BIT(IIO_EV_INFO_VALUE) |
- BIT(IIO_EV_INFO_ENABLE),
- }, {
- .type = IIO_EV_TYPE_MAG_ADAPTIVE,
- .dir = IIO_EV_DIR_RISING,
- .mask_separate = BIT(IIO_EV_INFO_VALUE) |
- BIT(IIO_EV_INFO_ENABLE),
- }, {
- .type = IIO_EV_TYPE_MAG_ADAPTIVE,
- .dir = IIO_EV_DIR_FALLING,
- .mask_separate = BIT(IIO_EV_INFO_VALUE) |
- BIT(IIO_EV_INFO_ENABLE),
- },
-};
-
-#define AD7150_CAPACITANCE_CHAN(_chan) { \
- .type = IIO_CAPACITANCE, \
- .indexed = 1, \
- .channel = _chan, \
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
- BIT(IIO_CHAN_INFO_AVERAGE_RAW), \
- .event_spec = ad7150_events, \
- .num_event_specs = ARRAY_SIZE(ad7150_events), \
- }
-
-static const struct iio_chan_spec ad7150_channels[] = {
- AD7150_CAPACITANCE_CHAN(0),
- AD7150_CAPACITANCE_CHAN(1)
-};
-
-static irqreturn_t ad7150_event_handler(int irq, void *private)
-{
- struct iio_dev *indio_dev = private;
- struct ad7150_chip_info *chip = iio_priv(indio_dev);
- u8 int_status;
- s64 timestamp = iio_get_time_ns(indio_dev);
- int ret;
-
- ret = i2c_smbus_read_byte_data(chip->client, AD7150_STATUS);
- if (ret < 0)
- return IRQ_HANDLED;
-
- int_status = ret;
-
- if ((int_status & AD7150_STATUS_OUT1) &&
- !(chip->old_state & AD7150_STATUS_OUT1))
- iio_push_event(indio_dev,
- IIO_UNMOD_EVENT_CODE(IIO_CAPACITANCE,
- 0,
- IIO_EV_TYPE_THRESH,
- IIO_EV_DIR_RISING),
- timestamp);
- else if ((!(int_status & AD7150_STATUS_OUT1)) &&
- (chip->old_state & AD7150_STATUS_OUT1))
- iio_push_event(indio_dev,
- IIO_UNMOD_EVENT_CODE(IIO_CAPACITANCE,
- 0,
- IIO_EV_TYPE_THRESH,
- IIO_EV_DIR_FALLING),
- timestamp);
-
- if ((int_status & AD7150_STATUS_OUT2) &&
- !(chip->old_state & AD7150_STATUS_OUT2))
- iio_push_event(indio_dev,
- IIO_UNMOD_EVENT_CODE(IIO_CAPACITANCE,
- 1,
- IIO_EV_TYPE_THRESH,
- IIO_EV_DIR_RISING),
- timestamp);
- else if ((!(int_status & AD7150_STATUS_OUT2)) &&
- (chip->old_state & AD7150_STATUS_OUT2))
- iio_push_event(indio_dev,
- IIO_UNMOD_EVENT_CODE(IIO_CAPACITANCE,
- 1,
- IIO_EV_TYPE_THRESH,
- IIO_EV_DIR_FALLING),
- timestamp);
- /* store the status to avoid repushing same events */
- chip->old_state = int_status;
-
- return IRQ_HANDLED;
-}
-
-/* Timeouts not currently handled by core */
-static struct attribute *ad7150_event_attributes[] = {
- &iio_dev_attr_in_capacitance0_mag_adaptive_rising_timeout
- .dev_attr.attr,
- &iio_dev_attr_in_capacitance0_mag_adaptive_falling_timeout
- .dev_attr.attr,
- &iio_dev_attr_in_capacitance1_mag_adaptive_rising_timeout
- .dev_attr.attr,
- &iio_dev_attr_in_capacitance1_mag_adaptive_falling_timeout
- .dev_attr.attr,
- &iio_dev_attr_in_capacitance0_thresh_adaptive_rising_timeout
- .dev_attr.attr,
- &iio_dev_attr_in_capacitance0_thresh_adaptive_falling_timeout
- .dev_attr.attr,
- &iio_dev_attr_in_capacitance1_thresh_adaptive_rising_timeout
- .dev_attr.attr,
- &iio_dev_attr_in_capacitance1_thresh_adaptive_falling_timeout
- .dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ad7150_event_attribute_group = {
- .attrs = ad7150_event_attributes,
- .name = "events",
-};
-
-static const struct iio_info ad7150_info = {
- .event_attrs = &ad7150_event_attribute_group,
- .read_raw = &ad7150_read_raw,
- .read_event_config = &ad7150_read_event_config,
- .write_event_config = &ad7150_write_event_config,
- .read_event_value = &ad7150_read_event_value,
- .write_event_value = &ad7150_write_event_value,
-};
-
-static int ad7150_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
-{
- int ret;
- struct ad7150_chip_info *chip;
- struct iio_dev *indio_dev;
-
- indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
- if (!indio_dev)
- return -ENOMEM;
- chip = iio_priv(indio_dev);
- mutex_init(&chip->state_lock);
- /* this is only used for device removal purposes */
- i2c_set_clientdata(client, indio_dev);
-
- chip->client = client;
-
- indio_dev->name = id->name;
- indio_dev->channels = ad7150_channels;
- indio_dev->num_channels = ARRAY_SIZE(ad7150_channels);
-
- indio_dev->info = &ad7150_info;
-
- indio_dev->modes = INDIO_DIRECT_MODE;
-
- if (client->irq) {
- ret = devm_request_threaded_irq(&client->dev, client->irq,
- NULL,
- &ad7150_event_handler,
- IRQF_TRIGGER_RISING |
- IRQF_TRIGGER_FALLING |
- IRQF_ONESHOT,
- "ad7150_irq1",
- indio_dev);
- if (ret)
- return ret;
- }
-
- if (client->dev.platform_data) {
- ret = devm_request_threaded_irq(&client->dev, *(unsigned int *)
- client->dev.platform_data,
- NULL,
- &ad7150_event_handler,
- IRQF_TRIGGER_RISING |
- IRQF_TRIGGER_FALLING |
- IRQF_ONESHOT,
- "ad7150_irq2",
- indio_dev);
- if (ret)
- return ret;
- }
-
- ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev);
- if (ret)
- return ret;
-
- dev_info(&client->dev, "%s capacitive sensor registered,irq: %d\n",
- id->name, client->irq);
-
- return 0;
-}
-
-static const struct i2c_device_id ad7150_id[] = {
- { "ad7150", 0 },
- { "ad7151", 0 },
- { "ad7156", 0 },
- {}
-};
-
-MODULE_DEVICE_TABLE(i2c, ad7150_id);
-
-static struct i2c_driver ad7150_driver = {
- .driver = {
- .name = "ad7150",
- },
- .probe = ad7150_probe,
- .id_table = ad7150_id,
-};
-module_i2c_driver(ad7150_driver);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices AD7150/1/6 capacitive sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
index 447937e04ebd..3f1981e287f5 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -86,7 +86,7 @@
* @freq_msg: tuning word spi message
* @phase_xfer: tuning word spi transfer
* @phase_msg: tuning word spi message
- * @lock protect sensor state
+ * @lock: protect sensor state
* @data: spi transmit buffer
* @phase_data: tuning word spi transmit buffer
* @freq_data: tuning word spi transmit buffer
@@ -248,7 +248,7 @@ error_ret:
return ret ? ret : len;
}
-/**
+/*
* see dds.h for further information
*/
diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
index 262c3590e64e..60a3ae5587b9 100644
--- a/drivers/staging/iio/frequency/ad9834.c
+++ b/drivers/staging/iio/frequency/ad9834.c
@@ -56,7 +56,6 @@
/**
* struct ad9834_state - driver instance specific data
* @spi: spi_device
- * @reg: supply regulator
* @mclk: external master clock
* @control: cached control word
* @xfer: default spi transfer
@@ -70,7 +69,6 @@
struct ad9834_state {
struct spi_device *spi;
- struct regulator *reg;
struct clk *mclk;
unsigned short control;
unsigned short devid;
@@ -390,6 +388,20 @@ static const struct iio_info ad9833_info = {
.attrs = &ad9833_attribute_group,
};
+static void ad9834_disable_reg(void *data)
+{
+ struct regulator *reg = data;
+
+ regulator_disable(reg);
+}
+
+static void ad9834_disable_clk(void *data)
+{
+ struct clk *clk = data;
+
+ clk_disable_unprepare(clk);
+}
+
static int ad9834_probe(struct spi_device *spi)
{
struct ad9834_state *st;
@@ -407,29 +419,35 @@ static int ad9834_probe(struct spi_device *spi)
return ret;
}
+ ret = devm_add_action_or_reset(&spi->dev, ad9834_disable_reg, reg);
+ if (ret)
+ return ret;
+
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (!indio_dev) {
ret = -ENOMEM;
- goto error_disable_reg;
+ return ret;
}
- spi_set_drvdata(spi, indio_dev);
st = iio_priv(indio_dev);
mutex_init(&st->lock);
st->mclk = devm_clk_get(&spi->dev, NULL);
if (IS_ERR(st->mclk)) {
ret = PTR_ERR(st->mclk);
- goto error_disable_reg;
+ return ret;
}
ret = clk_prepare_enable(st->mclk);
if (ret) {
dev_err(&spi->dev, "Failed to enable master clock\n");
- goto error_disable_reg;
+ return ret;
}
+ ret = devm_add_action_or_reset(&spi->dev, ad9834_disable_clk, st->mclk);
+ if (ret)
+ return ret;
+
st->spi = spi;
st->devid = spi_get_device_id(spi)->driver_data;
- st->reg = reg;
indio_dev->name = spi_get_device_id(spi)->name;
switch (st->devid) {
case ID_AD9833:
@@ -470,48 +488,26 @@ static int ad9834_probe(struct spi_device *spi)
ret = spi_sync(st->spi, &st->msg);
if (ret) {
dev_err(&spi->dev, "device init failed\n");
- goto error_clock_unprepare;
+ return ret;
}
ret = ad9834_write_frequency(st, AD9834_REG_FREQ0, 1000000);
if (ret)
- goto error_clock_unprepare;
+ return ret;
ret = ad9834_write_frequency(st, AD9834_REG_FREQ1, 5000000);
if (ret)
- goto error_clock_unprepare;
+ return ret;
ret = ad9834_write_phase(st, AD9834_REG_PHASE0, 512);
if (ret)
- goto error_clock_unprepare;
+ return ret;
ret = ad9834_write_phase(st, AD9834_REG_PHASE1, 1024);
if (ret)
- goto error_clock_unprepare;
-
- ret = iio_device_register(indio_dev);
- if (ret)
- goto error_clock_unprepare;
-
- return 0;
-error_clock_unprepare:
- clk_disable_unprepare(st->mclk);
-error_disable_reg:
- regulator_disable(reg);
-
- return ret;
-}
-
-static int ad9834_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ad9834_state *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
- clk_disable_unprepare(st->mclk);
- regulator_disable(st->reg);
+ return ret;
- return 0;
+ return devm_iio_device_register(&spi->dev, indio_dev);
}
static const struct spi_device_id ad9834_id[] = {
@@ -539,7 +535,6 @@ static struct spi_driver ad9834_driver = {
.of_match_table = ad9834_of_match
},
.probe = ad9834_probe,
- .remove = ad9834_remove,
.id_table = ad9834_id,
};
module_spi_driver(ad9834_driver);
diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
index dba78896ea8f..793918e1c45f 100644
--- a/drivers/staging/iio/impedance-analyzer/ad5933.c
+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
@@ -602,23 +602,6 @@ static const struct iio_buffer_setup_ops ad5933_ring_setup_ops = {
.postdisable = ad5933_ring_postdisable,
};
-static int ad5933_register_ring_funcs_and_init(struct device *dev,
- struct iio_dev *indio_dev)
-{
- struct iio_buffer *buffer;
-
- buffer = devm_iio_kfifo_allocate(dev);
- if (!buffer)
- return -ENOMEM;
-
- iio_device_attach_buffer(indio_dev, buffer);
-
- /* Ring buffer functions - here trigger setup related */
- indio_dev->setup_ops = &ad5933_ring_setup_ops;
-
- return 0;
-}
-
static void ad5933_work(struct work_struct *work)
{
struct ad5933_state *st = container_of(work,
@@ -761,11 +744,13 @@ static int ad5933_probe(struct i2c_client *client,
indio_dev->info = &ad5933_info;
indio_dev->name = id->name;
- indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE);
+ indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = ad5933_channels;
indio_dev->num_channels = ARRAY_SIZE(ad5933_channels);
- ret = ad5933_register_ring_funcs_and_init(&client->dev, indio_dev);
+ ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
+ INDIO_BUFFER_SOFTWARE,
+ &ad5933_ring_setup_ops);
if (ret)
return ret;
diff --git a/drivers/staging/kpc2000/kpc2000/pcie.h b/drivers/staging/kpc2000/kpc2000/pcie.h
index cb815c30faa4..f1fc91b4c704 100644
--- a/drivers/staging/kpc2000/kpc2000/pcie.h
+++ b/drivers/staging/kpc2000/kpc2000/pcie.h
@@ -6,7 +6,6 @@
#include "../kpc.h"
#include "dma_common_defs.h"
-
/* System Register Map (BAR 1, Start Addr 0)
*
* BAR Size:
diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c
index 25bb5c97dd21..14f7940fa4fb 100644
--- a/drivers/staging/kpc2000/kpc2000_i2c.c
+++ b/drivers/staging/kpc2000/kpc2000_i2c.c
@@ -200,7 +200,9 @@ static int i801_check_post(struct kpc_i2c *priv, int status, int timeout)
outb_p(status & STATUS_FLAGS, SMBHSTSTS(priv));
status = inb_p(SMBHSTSTS(priv)) & STATUS_FLAGS;
if (status)
- dev_warn(&priv->adapter.dev, "Failed clearing status flags at end of transaction (%02x)\n", status);
+ dev_warn(&priv->adapter.dev,
+ "Failed clearing status flags at end of transaction (%02x)\n",
+ status);
}
return result;
@@ -269,7 +271,7 @@ static int i801_block_transaction_by_block(struct kpc_i2c *priv,
}
status = i801_transaction(priv,
- I801_BLOCK_DATA | ENABLE_INT9 | I801_PEC_EN * hwpec);
+ I801_BLOCK_DATA | ENABLE_INT9 | I801_PEC_EN * hwpec);
if (status)
return status;
diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index 44017d523da5..16ca18b8aa15 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -465,7 +465,7 @@ kp_spi_probe(struct platform_device *pldev)
}
kpspi->base = devm_ioremap(&pldev->dev, r->start,
- resource_size(r));
+ resource_size(r));
status = spi_register_master(master);
if (status < 0) {
diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig
index 535e6dec3504..6f420cbcdcff 100644
--- a/drivers/staging/most/Kconfig
+++ b/drivers/staging/most/Kconfig
@@ -20,8 +20,6 @@ if MOST_COMPONENTS
source "drivers/staging/most/net/Kconfig"
-source "drivers/staging/most/sound/Kconfig"
-
source "drivers/staging/most/video/Kconfig"
source "drivers/staging/most/dim2/Kconfig"
diff --git a/drivers/staging/most/Makefile b/drivers/staging/most/Makefile
index be94673209f5..8b3fc5a7af51 100644
--- a/drivers/staging/most/Makefile
+++ b/drivers/staging/most/Makefile
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_MOST_NET) += net/
-obj-$(CONFIG_MOST_SOUND) += sound/
obj-$(CONFIG_MOST_VIDEO) += video/
obj-$(CONFIG_MOST_DIM2) += dim2/
obj-$(CONFIG_MOST_I2C) += i2c/
diff --git a/drivers/staging/most/sound/Kconfig b/drivers/staging/most/sound/Kconfig
deleted file mode 100644
index ad9f7821af7d..000000000000
--- a/drivers/staging/most/sound/Kconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# MOST ALSA configuration
-#
-
-config MOST_SOUND
- tristate "Sound"
- depends on SND
- select SND_PCM
- help
- Say Y here if you want to commumicate via ALSA/sound devices.
-
- To compile this driver as a module, choose M here: the
- module will be called most_sound.
diff --git a/drivers/staging/most/sound/Makefile b/drivers/staging/most/sound/Makefile
deleted file mode 100644
index f0cd9d8d213e..000000000000
--- a/drivers/staging/most/sound/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_MOST_SOUND) += most_sound.o
-
-most_sound-objs := sound.o
diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c
index c3532bc138fb..115250115f10 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -301,18 +301,19 @@ static int mt7621_pci_parse_request_of_pci_ranges(struct pci_host_bridge *host)
/*
* IO_SPACE_LIMIT for MIPS is 0xffff but this platform uses IO at
- * upper address 0x001e160000 so we have to get the resource from
- * the DT because when it has been requested it failed and has been
- * removed from bridge->dma_ranges and bridge->windows. So parse it
- * and remap it manually to make things work.
+ * upper address 0x001e160000. of_pci_range_to_resource does not work
+ * well for MIPS platforms that don't define PCI_IOBASE, so set the IO
+ * resource manually instead.
*/
+ pcie->io.name = node->full_name;
+ pcie->io.parent = pcie->io.child = pcie->io.sibling = NULL;
for_each_of_pci_range(&parser, &range) {
switch (range.flags & IORESOURCE_TYPE_BITS) {
case IORESOURCE_IO:
pcie->io_map_base =
(unsigned long)ioremap(range.cpu_addr,
range.size);
- of_pci_range_to_resource(&range, node, &pcie->io);
+ pcie->io.flags = range.flags;
pcie->io.start = range.cpu_addr;
pcie->io.end = range.cpu_addr + range.size - 1;
set_io_port_base(pcie->io_map_base);
@@ -521,7 +522,6 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie)
if (slot == 1 && tmp && !tmp->enabled)
phy_power_off(tmp->phy);
-
}
}
}
diff --git a/drivers/staging/netlogic/Kconfig b/drivers/staging/netlogic/Kconfig
index b2a4d4586697..e1712606ee3c 100644
--- a/drivers/staging/netlogic/Kconfig
+++ b/drivers/staging/netlogic/Kconfig
@@ -2,6 +2,7 @@
config NETLOGIC_XLR_NET
tristate "Netlogic XLR/XLS network device"
depends on CPU_XLR
+ depends on NETDEVICES
select PHYLIB
help
This driver support Netlogic XLR/XLS on chip gigabit
diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c
index 157009015c3b..06041c7f7d4f 100644
--- a/drivers/staging/nvec/nvec_ps2.c
+++ b/drivers/staging/nvec/nvec_ps2.c
@@ -28,7 +28,7 @@
print_hex_dump(KERN_DEBUG, str, DUMP_PREFIX_NONE, \
16, 1, buf, len, false)
#else
-#define NVEC_PHD(str, buf, len)
+#define NVEC_PHD(str, buf, len) do { } while (0)
#endif
enum ps2_subcmds {
diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c
index e2f8b6b67f75..f27f20a4aa2d 100644
--- a/drivers/staging/octeon-usb/octeon-hcd.c
+++ b/drivers/staging/octeon-usb/octeon-hcd.c
@@ -1258,7 +1258,7 @@ static void cvmx_usb_poll_tx_fifo(struct octeon_hcd *usb)
union cvmx_usbcx_hptxsts tx_status;
tx_status.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_HPTXSTS(usb->index));
+ 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),
@@ -1272,7 +1272,7 @@ static void cvmx_usb_poll_tx_fifo(struct octeon_hcd *usb)
union cvmx_usbcx_gnptxsts tx_status;
tx_status.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_GNPTXSTS(usb->index));
+ 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),
@@ -1298,13 +1298,13 @@ static void cvmx_usb_fill_tx_fifo(struct octeon_hcd *usb, int channel)
/* We only need to fill data on outbound channels */
hcchar.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_HCCHARX(channel, usb->index));
+ 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));
+ CVMX_USBCX_HCSPLTX(channel, usb->index));
if (usbc_hcsplt.s.spltena && usbc_hcsplt.s.compsplt)
return;
@@ -1313,7 +1313,7 @@ static void cvmx_usb_fill_tx_fifo(struct octeon_hcd *usb, int channel)
* words.
*/
usbc_hctsiz.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_HCTSIZX(channel, usb->index));
+ CVMX_USBCX_HCTSIZX(channel, usb->index));
if (!usbc_hctsiz.s.xfersize)
return;
@@ -1360,7 +1360,7 @@ static void cvmx_usb_start_channel_control(struct octeon_hcd *usb,
union cvmx_usbcx_hctsizx usbc_hctsiz;
usbc_hctsiz.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_HCTSIZX(channel, usb->index));
+ CVMX_USBCX_HCTSIZX(channel, usb->index));
switch (transaction->stage) {
case CVMX_USB_STAGE_NON_CONTROL:
@@ -1517,7 +1517,7 @@ static void cvmx_usb_start_channel(struct octeon_hcd *usb, int channel,
/* Clear all channel status bits */
usbc_hcint.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_HCINTX(channel, usb->index));
+ CVMX_USBCX_HCINTX(channel, usb->index));
cvmx_usb_write_csr32(usb,
CVMX_USBCX_HCINTX(channel, usb->index),
@@ -1552,7 +1552,7 @@ static void cvmx_usb_start_channel(struct octeon_hcd *usb, int channel,
/* Enable the channel interrupt to propagate */
usbc_haintmsk.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_HAINTMSK(usb->index));
+ CVMX_USBCX_HAINTMSK(usb->index));
usbc_haintmsk.s.haintmsk |= 1 << channel;
cvmx_usb_write_csr32(usb, CVMX_USBCX_HAINTMSK(usb->index),
usbc_haintmsk.u32);
@@ -1836,7 +1836,7 @@ static void cvmx_usb_start_channel(struct octeon_hcd *usb, int channel,
* Returns: Pipe or NULL if none are ready
*/
static struct cvmx_usb_pipe *cvmx_usb_find_ready_pipe(struct octeon_hcd *usb,
- enum cvmx_usb_transfer xfer_type)
+ enum cvmx_usb_transfer xfer_type)
{
struct list_head *list = usb->active_pipes + xfer_type;
u64 current_frame = usb->frame_number;
@@ -2309,7 +2309,8 @@ static int cvmx_usb_cancel(struct octeon_hcd *usb,
CVMX_SYNCW;
usbc_hcchar.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_HCCHARX(pipe->channel, usb->index));
+ CVMX_USBCX_HCCHARX(pipe->channel,
+ usb->index));
/*
* If the channel isn't enabled then the transaction already
* completed.
@@ -2605,11 +2606,12 @@ static int cvmx_usb_poll_channel(struct octeon_hcd *usb, int channel)
/* Read the interrupt status bits for the channel */
usbc_hcint.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_HCINTX(channel, usb->index));
+ CVMX_USBCX_HCINTX(channel, usb->index));
if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) {
usbc_hcchar.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_HCCHARX(channel, usb->index));
+ CVMX_USBCX_HCCHARX(channel,
+ usb->index));
if (usbc_hcchar.s.chena && usbc_hcchar.s.chdis) {
/*
@@ -2688,9 +2690,9 @@ static int cvmx_usb_poll_channel(struct octeon_hcd *usb, int channel)
* transferred
*/
usbc_hcchar.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_HCCHARX(channel, usb->index));
+ CVMX_USBCX_HCCHARX(channel, usb->index));
usbc_hctsiz.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_HCTSIZX(channel, usb->index));
+ CVMX_USBCX_HCTSIZX(channel, usb->index));
/*
* Calculating the number of bytes successfully transferred is dependent
@@ -3010,7 +3012,7 @@ static int cvmx_usb_poll(struct octeon_hcd *usb)
union cvmx_usbcx_haint usbc_haint;
usbc_haint.u32 = cvmx_usb_read_csr32(usb,
- CVMX_USBCX_HAINT(usb->index));
+ CVMX_USBCX_HAINT(usb->index));
while (usbc_haint.u32) {
int channel;
diff --git a/drivers/staging/octeon/ethernet-spi.c b/drivers/staging/octeon/ethernet-spi.c
index c582403e6a1f..699c98c5ec13 100644
--- a/drivers/staging/octeon/ethernet-spi.c
+++ b/drivers/staging/octeon/ethernet-spi.c
@@ -202,7 +202,7 @@ int cvm_oct_spi_init(struct net_device *dev)
}
number_spi_ports++;
- if ((priv->port == 0) || (priv->port == 16)) {
+ if (priv->port == 0 || priv->port == 16) {
cvm_oct_spi_enable_error_reporting(INTERFACE(priv->port));
priv->poll = cvm_oct_spi_poll;
}
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index 5dea6e96ec90..7c60b0cd8bf7 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -614,14 +614,11 @@ static const struct net_device_ops cvm_oct_pow_netdev_ops = {
static struct device_node *cvm_oct_of_get_child
(const struct device_node *parent, int reg_val)
{
- struct device_node *node = NULL;
- int size;
+ struct device_node *node;
const __be32 *addr;
+ int size;
- for (;;) {
- node = of_get_next_child(parent, node);
- if (!node)
- break;
+ for_each_child_of_node(parent, node) {
addr = of_get_property(node, "reg", &size);
if (addr && (be32_to_cpu(*addr) == reg_val))
break;
diff --git a/drivers/staging/qlge/qlge_devlink.c b/drivers/staging/qlge/qlge_devlink.c
index 86834d96cebf..0ab02d6d3817 100644
--- a/drivers/staging/qlge/qlge_devlink.c
+++ b/drivers/staging/qlge/qlge_devlink.c
@@ -148,16 +148,20 @@ static const struct devlink_health_reporter_ops qlge_reporter_ops = {
.dump = qlge_reporter_coredump,
};
-void qlge_health_create_reporters(struct qlge_adapter *priv)
+long qlge_health_create_reporters(struct qlge_adapter *priv)
{
struct devlink *devlink;
+ long err = 0;
devlink = priv_to_devlink(priv);
priv->reporter =
devlink_health_reporter_create(devlink, &qlge_reporter_ops,
0, priv);
- if (IS_ERR(priv->reporter))
+ if (IS_ERR(priv->reporter)) {
+ err = PTR_ERR(priv->reporter);
netdev_warn(priv->ndev,
"Failed to create reporter, err = %ld\n",
- PTR_ERR(priv->reporter));
+ err);
+ }
+ return err;
}
diff --git a/drivers/staging/qlge/qlge_devlink.h b/drivers/staging/qlge/qlge_devlink.h
index 19078e1ac694..94538e923f2f 100644
--- a/drivers/staging/qlge/qlge_devlink.h
+++ b/drivers/staging/qlge/qlge_devlink.h
@@ -4,6 +4,6 @@
#include <net/devlink.h>
-void qlge_health_create_reporters(struct qlge_adapter *priv);
+long qlge_health_create_reporters(struct qlge_adapter *priv);
#endif /* QLGE_DEVLINK_H */
diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
index 5516be3af898..c9dc6a852af4 100644
--- a/drivers/staging/qlge/qlge_main.c
+++ b/drivers/staging/qlge/qlge_main.c
@@ -3815,8 +3815,7 @@ static int qlge_adapter_down(struct qlge_adapter *qdev)
qlge_tx_ring_clean(qdev);
- /* Call netif_napi_del() from common point.
- */
+ /* Call netif_napi_del() from common point. */
for (i = 0; i < qdev->rss_ring_count; i++)
netif_napi_del(&qdev->rx_ring[i].napi);
@@ -4550,7 +4549,7 @@ static int qlge_probe(struct pci_dev *pdev,
struct net_device *ndev = NULL;
struct devlink *devlink;
static int cards_found;
- int err = 0;
+ int err;
devlink = devlink_alloc(&qlge_devlink_ops, sizeof(struct qlge_adapter));
if (!devlink)
@@ -4561,8 +4560,10 @@ static int qlge_probe(struct pci_dev *pdev,
ndev = alloc_etherdev_mq(sizeof(struct qlge_netdev_priv),
min(MAX_CPUS,
netif_get_num_default_rss_queues()));
- if (!ndev)
+ if (!ndev) {
+ err = -ENOMEM;
goto devlink_free;
+ }
ndev_priv = netdev_priv(ndev);
ndev_priv->qdev = qdev;
@@ -4620,7 +4621,11 @@ static int qlge_probe(struct pci_dev *pdev,
if (err)
goto netdev_free;
- qlge_health_create_reporters(qdev);
+ err = qlge_health_create_reporters(qdev);
+
+ if (err)
+ goto devlink_unregister;
+
/* Start up the timer to trigger EEH if
* the bus goes dead
*/
@@ -4632,6 +4637,8 @@ static int qlge_probe(struct pci_dev *pdev,
cards_found++;
return 0;
+devlink_unregister:
+ devlink_unregister(devlink);
netdev_free:
free_netdev(ndev);
devlink_free:
diff --git a/drivers/staging/ralink-gdma/ralink-gdma.c b/drivers/staging/ralink-gdma/ralink-gdma.c
index 655df317d0ee..33e28ccf4d85 100644
--- a/drivers/staging/ralink-gdma/ralink-gdma.c
+++ b/drivers/staging/ralink-gdma/ralink-gdma.c
@@ -788,6 +788,7 @@ static const struct of_device_id gdma_of_match_table[] = {
{ .compatible = "ralink,rt3883-gdma", .data = &rt3883_gdma_data },
{ },
};
+MODULE_DEVICE_TABLE(of, gdma_of_match_table);
static int gdma_dma_probe(struct platform_device *pdev)
{
@@ -833,7 +834,9 @@ static int gdma_dma_probe(struct platform_device *pdev)
return ret;
}
- device_reset(&pdev->dev);
+ ret = device_reset(&pdev->dev);
+ if (ret)
+ dev_err(&pdev->dev, "failed to reset: %d\n", ret);
dd = &dma_dev->ddev;
dma_cap_set(DMA_MEMCPY, dd->cap_mask);
diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 182bb944c9b3..008b60e72758 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -507,7 +507,6 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta)
struct ht_priv *phtpriv_sta = &psta->htpriv;
psta->mac_id = psta->aid + 1;
- DBG_88E("%s\n", __func__);
/* ap mode */
rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true);
@@ -571,8 +570,6 @@ static void update_hw_ht_param(struct adapter *padapter)
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
- DBG_88E("%s\n", __func__);
-
/* handle A-MPDU parameter field
* ampdu_params_info [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k
* ampdu_params_info [4:2]:Min MPDU Start Spacing
@@ -1166,8 +1163,6 @@ static void update_bcn_wps_ie(struct adapter *padapter)
unsigned char *ie = pnetwork->ies;
u32 ielen = pnetwork->ie_length;
- DBG_88E("%s\n", __func__);
-
pwps_ie_src = pmlmepriv->wps_beacon_ie;
if (!pwps_ie_src)
return;
@@ -1207,7 +1202,6 @@ static void update_bcn_wps_ie(struct adapter *padapter)
static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui)
{
- DBG_88E("%s\n", __func__);
if (!memcmp(WPS_OUI, oui, 4))
update_bcn_wps_ie(padapter);
diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index 1724dfd7edbc..6728391d39e3 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -4,7 +4,6 @@
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
******************************************************************************/
-#define _RTW_CMD_C_
#include <osdep_service.h>
#include <drv_types.h>
@@ -12,6 +11,42 @@
#include <mlme_osdep.h>
#include <rtw_mlme_ext.h>
+static struct cmd_hdl wlancmds[] = {
+ {sizeof(struct wlan_bssid_ex), join_cmd_hdl},
+ {sizeof(struct disconnect_parm), disconnect_hdl},
+ {sizeof(struct wlan_bssid_ex), createbss_hdl},
+ {sizeof(struct setopmode_parm), setopmode_hdl},
+ {sizeof(struct sitesurvey_parm), sitesurvey_cmd_hdl},
+ {sizeof(struct setauth_parm), setauth_hdl},
+ {sizeof(struct setkey_parm), setkey_hdl},
+ {sizeof(struct set_stakey_parm), set_stakey_hdl},
+ {sizeof(struct set_assocsta_parm), NULL},
+ {sizeof(struct addBaReq_parm), add_ba_hdl},
+ {sizeof(struct set_ch_parm), set_ch_hdl},
+ {sizeof(struct wlan_bssid_ex), tx_beacon_hdl},
+ {0, mlme_evt_hdl},
+ {0, rtw_drvextra_cmd_hdl},
+ {sizeof(struct SetChannelPlan_param), set_chplan_hdl}
+};
+
+static struct _cmd_callback rtw_cmd_callback[] = {
+ {_JoinBss_CMD_, &rtw_joinbss_cmd_callback},
+ {_DisConnect_CMD_, &rtw_disassoc_cmd_callback},
+ {_CreateBss_CMD_, &rtw_createbss_cmd_callback},
+ {_SetOpMode_CMD_, NULL},
+ {_SiteSurvey_CMD_, &rtw_survey_cmd_callback},
+ {_SetAuth_CMD_, NULL},
+ {_SetKey_CMD_, NULL},
+ {_SetStaKey_CMD_, &rtw_setstaKey_cmdrsp_callback},
+ {_SetAssocSta_CMD_, &rtw_setassocsta_cmdrsp_callback},
+ {_AddBAReq_CMD_, NULL},
+ {_SetChannel_CMD_, NULL},
+ {_TX_Beacon_CMD_, NULL},
+ {_Set_MLME_EVT_CMD_, NULL},
+ {_Set_Drv_Extra_CMD_, NULL},
+ {_SetChannelPlan_CMD_, NULL},
+};
+
/*
* Caller and the rtw_cmd_thread can protect cmd_q by spin_lock.
* No irqsave is necessary.
@@ -153,17 +188,6 @@ int rtw_cmd_thread(void *context)
("start r871x %s !!!!\n", __func__));
while (1) {
- if (wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp))
- break;
-
- if (padapter->bDriverStopped ||
- padapter->bSurpriseRemoved) {
- DBG_88E("%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
- __func__, padapter->bDriverStopped,
- padapter->bSurpriseRemoved, __LINE__);
- break;
- }
-_next:
if (padapter->bDriverStopped ||
padapter->bSurpriseRemoved) {
DBG_88E("%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
@@ -173,8 +197,13 @@ _next:
}
pcmd = rtw_dequeue_cmd(&pcmdpriv->cmd_queue);
- if (!pcmd)
+ if (!pcmd) {
+ /* The queue is empty. Wait until someone enqueues a command. */
+ if (wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp))
+ break;
+
continue;
+ }
if (rtw_cmd_filter(pcmdpriv, pcmd) == _FAIL) {
pcmd->res = H2C_DROPPED;
@@ -189,8 +218,6 @@ _next:
} else {
pcmd->res = H2C_PARAMETERS_ERROR;
}
-
- cmd_hdl = NULL;
}
/* call callback function for post-processed */
@@ -200,22 +227,19 @@ _next:
RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
("mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n",
pcmd_callback, pcmd->cmdcode));
- rtw_free_cmd_obj(pcmd);
} else {
/* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */
- pcmd_callback(pcmd->padapter, pcmd);/* need consider that free cmd_obj in rtw_cmd_callback */
+ pcmd_callback(pcmd->padapter, pcmd);
}
} else {
RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
("%s: cmdcode = 0x%x callback not defined!\n",
__func__, pcmd->cmdcode));
- rtw_free_cmd_obj(pcmd);
}
+ rtw_free_cmd_obj(pcmd);
if (signal_pending(current))
flush_signals(current);
-
- goto _next;
}
pcmdpriv->cmdthd_running = false;
@@ -1151,9 +1175,6 @@ void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
("\n ********Error: MgntActrtw_set_802_11_bssid_LIST_SCAN Fail ************\n\n."));
}
-
- /* free cmd */
- rtw_free_cmd_obj(pcmd);
}
void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
@@ -1167,11 +1188,7 @@ void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
("\n ***Error: disconnect_cmd_callback Fail ***\n."));
- return;
}
-
- /* free cmd */
- rtw_free_cmd_obj(pcmd);
}
void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
@@ -1189,8 +1206,6 @@ void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
mod_timer(&pmlmepriv->assoc_timer,
jiffies + msecs_to_jiffies(1));
}
-
- rtw_free_cmd_obj(pcmd);
}
void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
@@ -1257,8 +1272,6 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
createbss_cmd_fail:
spin_unlock_bh(&pmlmepriv->lock);
-
- rtw_free_cmd_obj(pcmd);
}
void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd)
@@ -1270,10 +1283,7 @@ void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pc
if (!psta) {
RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
("\nERROR: %s => can't get sta_info\n\n", __func__));
- goto exit;
}
-exit:
- rtw_free_cmd_obj(pcmd);
}
void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd)
@@ -1287,7 +1297,7 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *
if (!psta) {
RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
("\nERROR: %s => can't get sta_info\n\n", __func__));
- goto exit;
+ return;
}
psta->aid = passocsta_rsp->cam_id;
@@ -1297,7 +1307,4 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *
set_fwstate(pmlmepriv, _FW_LINKED);
spin_unlock_bh(&pmlmepriv->lock);
-
-exit:
- rtw_free_cmd_obj(pcmd);
}
diff --git a/drivers/staging/rtl8188eu/core/rtw_debug.c b/drivers/staging/rtl8188eu/core/rtw_debug.c
index 11198d43a371..1060837fe463 100644
--- a/drivers/staging/rtl8188eu/core/rtw_debug.c
+++ b/drivers/staging/rtl8188eu/core/rtw_debug.c
@@ -33,7 +33,7 @@ int proc_set_write_reg(struct file *file, const char __user *buffer,
unsigned long count, void *data)
{
struct net_device *dev = data;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
char tmp[32];
u32 addr, val, len;
@@ -75,7 +75,7 @@ int proc_get_read_reg(char *page, char **start,
int *eof, void *data)
{
struct net_device *dev = data;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
int len = 0;
@@ -139,7 +139,7 @@ int proc_get_adapter_state(char *page, char **start,
int *eof, void *data)
{
struct net_device *dev = data;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
int len = 0;
len += scnprintf(page + len, count - len, "bSurpriseRemoved=%d, bDriverStopped=%d\n",
@@ -155,7 +155,7 @@ int proc_get_best_channel(char *page, char **start,
int *eof, void *data)
{
struct net_device *dev = data;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
int len = 0;
u32 i, best_channel_24G = 1, index_24G = 0;
diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
index ec5b8be14c2b..7a706fe11750 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
@@ -223,13 +223,13 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv)
/* capability info */
*(u16 *)ie = 0;
- *(__le16 *)ie |= cpu_to_le16(cap_IBSS);
+ *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_IBSS);
if (pregistrypriv->preamble == PREAMBLE_SHORT)
- *(__le16 *)ie |= cpu_to_le16(cap_ShortPremble);
+ *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
if (pdev_network->Privacy)
- *(__le16 *)ie |= cpu_to_le16(cap_Privacy);
+ *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
sz += 2;
ie += 2;
diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c
index 1ef32ff900a9..17b999f45132 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c
@@ -11,6 +11,14 @@
#include <rtw_ioctl_set.h>
#include <hal_intf.h>
+static const struct {
+ int channel_plan;
+ char *name;
+} channel_table[] = { { RT_CHANNEL_DOMAIN_FCC, "US" },
+ { RT_CHANNEL_DOMAIN_ETSI, "EU" },
+ { RT_CHANNEL_DOMAIN_MKK, "JP" },
+ { RT_CHANNEL_DOMAIN_CHINA, "CN"} };
+
extern void indicate_wx_scan_complete_event(struct adapter *padapter);
u8 rtw_do_join(struct adapter *padapter)
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index f87dd71934c3..b6ac5b8915b1 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -37,7 +37,7 @@ int rtw_init_mlme_priv(struct adapter *padapter)
pmlmepriv->pscanned = NULL;
pmlmepriv->fw_state = 0;
pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown;
- pmlmepriv->scan_mode = SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */
+ pmlmepriv->scan_mode = SCAN_ACTIVE;/* 1: active, 0: passive. Maybe someday we should rename this variable to "active_mode" (Jeff) */
spin_lock_init(&pmlmepriv->lock);
_rtw_init_queue(&pmlmepriv->free_bss_pool);
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index ebd9b96a8211..50d3c3631be0 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -2188,7 +2188,7 @@ static void start_create_ibss(struct adapter *padapter)
/* update capability */
caps = rtw_get_capability(pnetwork);
update_capinfo(padapter, caps);
- if (caps & cap_IBSS) {/* adhoc master */
+ if (caps & WLAN_CAPABILITY_IBSS) {/* adhoc master */
val8 = 0xcf;
rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8));
@@ -2240,7 +2240,7 @@ static void start_clnt_join(struct adapter *padapter)
/* update capability */
caps = rtw_get_capability(pnetwork);
update_capinfo(padapter, caps);
- if (caps & cap_ESS) {
+ if (caps & WLAN_CAPABILITY_ESS) {
Set_MSR(padapter, WIFI_FW_STATION_STATE);
val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf;
@@ -2258,7 +2258,7 @@ static void start_clnt_join(struct adapter *padapter)
msecs_to_jiffies((REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO * REASSOC_LIMIT) + beacon_timeout));
pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE;
- } else if (caps & cap_IBSS) { /* adhoc client */
+ } else if (caps & WLAN_CAPABILITY_IBSS) { /* adhoc client */
Set_MSR(padapter, WIFI_FW_ADHOC_STATE);
val8 = 0xcf;
@@ -2526,7 +2526,7 @@ static unsigned int OnProbeReq(struct adapter *padapter,
if (check_fwstate(pmlmepriv, _FW_LINKED) &&
pmlmepriv->cur_network.join_res)
- issue_probersp(padapter, get_sa(pframe));
+ issue_probersp(padapter, ieee80211_get_SA((struct ieee80211_hdr *)pframe));
}
return _SUCCESS;
}
@@ -2819,7 +2819,7 @@ static unsigned int OnAuthClient(struct adapter *padapter,
DBG_88E("%s\n", __func__);
/* check A1 matches or not */
- if (memcmp(myid(&padapter->eeprompriv), get_da(pframe), ETH_ALEN))
+ if (memcmp(myid(&padapter->eeprompriv), ieee80211_get_DA((struct ieee80211_hdr *)pframe), ETH_ALEN))
return _SUCCESS;
if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE))
@@ -3332,7 +3332,7 @@ static unsigned int OnAssocRsp(struct adapter *padapter,
DBG_88E("%s\n", __func__);
/* check A1 matches or not */
- if (memcmp(myid(&padapter->eeprompriv), get_da(pframe), ETH_ALEN))
+ if (memcmp(myid(&padapter->eeprompriv), ieee80211_get_DA((struct ieee80211_hdr *)pframe), ETH_ALEN))
return _SUCCESS;
if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE)))
diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
index 3848e695ac84..4d507d9faec2 100644
--- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
@@ -84,7 +84,7 @@ static int rtw_hw_resume(struct adapter *padapter)
pwrpriv->bips_processing = true;
rtw_reset_drv_sw(padapter);
- if (ips_netdrv_open(rtw_netdev_priv(pnetdev)) != _SUCCESS) {
+ if (ips_netdrv_open(netdev_priv(pnetdev)) != _SUCCESS) {
mutex_unlock(&pwrpriv->mutex_lock);
goto error_exit;
}
@@ -480,10 +480,9 @@ void LPS_Leave(struct adapter *padapter)
void LeaveAllPowerSaveMode(struct adapter *Adapter)
{
struct mlme_priv *pmlmepriv = &Adapter->mlmepriv;
- u8 enqueue = 0;
if (check_fwstate(pmlmepriv, _FW_LINKED))
- rtw_lps_ctrl_wk_cmd(Adapter, LPS_CTRL_LEAVE, enqueue);
+ rtw_lps_ctrl_wk_cmd(Adapter, LPS_CTRL_LEAVE, 0);
}
void rtw_init_pwrctrl_priv(struct adapter *padapter)
diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c
index 36bcbe635cf4..b2fe448d999d 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -1029,8 +1029,8 @@ static int validate_recv_data_frame(struct adapter *adapter,
int ret = _SUCCESS;
bretry = GetRetry(ptr);
- pda = get_da(ptr);
- psa = get_sa(ptr);
+ pda = ieee80211_get_DA((struct ieee80211_hdr *)ptr);
+ psa = ieee80211_get_SA((struct ieee80211_hdr *)ptr);
pbssid = get_hdr_bssid(ptr);
if (!pbssid) {
@@ -1962,27 +1962,18 @@ exit:
return ret;
}
-s32 rtw_recv_entry(struct recv_frame *precvframe)
+int rtw_recv_entry(struct recv_frame *precvframe)
{
- struct adapter *padapter;
- struct recv_priv *precvpriv;
- s32 ret = _SUCCESS;
-
- padapter = precvframe->adapter;
-
- precvpriv = &padapter->recvpriv;
+ struct adapter *padapter = precvframe->adapter;
+ struct recv_priv *precvpriv = &padapter->recvpriv;
+ int ret;
ret = recv_func(padapter, precvframe);
- if (ret == _FAIL) {
+ if (ret == _SUCCESS)
+ precvpriv->rx_pkts++;
+ else
RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("%s: recv_func return fail!!!\n", __func__));
- goto _recv_entry_drop;
- }
-
- precvpriv->rx_pkts++;
-
- return ret;
-_recv_entry_drop:
return ret;
}
diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c
index 46ba55a8952a..617f89842c81 100644
--- a/drivers/staging/rtl8188eu/core/rtw_security.c
+++ b/drivers/staging/rtl8188eu/core/rtw_security.c
@@ -126,9 +126,7 @@ static __le32 getcrc32(u8 *buf, int len)
return cpu_to_le32(~crc); /* transmit complement, per CRC-32 spec */
}
-/*
- Need to consider the fragment situation
-*/
+/* Need to consider the fragment situation */
void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
{
int curfragnum, length;
@@ -427,9 +425,9 @@ static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in ROM)
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! */
+ { /* 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,
@@ -462,26 +460,20 @@ static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in ROM)
0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5,
0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0,
0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C,
- }
+ }
};
- /*
-**********************************************************************
-* Routine: Phase 1 -- generate P1K, given TA, TK, IV32
-*
-* Inputs:
-* tk[] = temporal key [128 bits]
-* ta[] = transmitter's MAC address [ 48 bits]
-* iv32 = upper 32 bits of IV [ 32 bits]
-* Output:
-* p1k[] = Phase 1 key [ 80 bits]
-*
-* Note:
-* This function only needs to be called every 2**16 packets,
-* although in theory it could be called every packet.
-*
-**********************************************************************
-*/
+/**
+ * phase1() - generate P1K, given TA, TK, IV32
+ * @tk[]: temporal key [128 bits]
+ * @ta[]: transmitter's MAC address [ 48 bits]
+ * @iv32: upper 32 bits of IV [ 32 bits]
+ *
+ * This function only needs to be called every 2**16 packets,
+ * although in theory it could be called every packet.
+ *
+ * Return: p1k[] - Phase 1 key [ 80 bits]
+ */
static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32)
{
int i;
@@ -504,29 +496,23 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32)
}
}
-/*
-**********************************************************************
-* Routine: Phase 2 -- generate RC4KEY, given TK, P1K, IV16
-*
-* Inputs:
-* tk[] = Temporal key [128 bits]
-* p1k[] = Phase 1 output key [ 80 bits]
-* iv16 = low 16 bits of IV counter [ 16 bits]
-* Output:
-* rc4key[] = the key used to encrypt the packet [128 bits]
-*
-* Note:
-* The value {TA, IV32, IV16} for Phase1/Phase2 must be unique
-* across all packets using the same key TK value. Then, for a
-* given value of TK[], this TKIP48 construction guarantees that
-* the final RC4KEY value is unique across all packets.
-*
-* Suggested implementation optimization: if PPK[] is "overlaid"
-* appropriately on RC4KEY[], there is no need for the final
-* for loop below that copies the PPK[] result into RC4KEY[].
-*
-**********************************************************************
-*/
+/**
+ * phase2() - generate RC4KEY, given TK, P1K, IV16
+ * @tk[]: Temporal key [128 bits]
+ * @p1k[]: Phase 1 output key [ 80 bits]
+ * @iv16: low 16 bits of IV counter [ 16 bits]
+ *
+ * The value {TA, IV32, IV16} for Phase1/Phase2 must be unique
+ * across all packets using the same key TK value. Then, for a
+ * given value of TK[], this TKIP48 construction guarantees that
+ * the final RC4KEY value is unique across all packets.
+ *
+ * Suggested implementation optimization: if PPK[] is "overlaid"
+ * appropriately on RC4KEY[], there is no need for the final
+ * for loop below that copies the PPK[] result into RC4KEY[].
+ *
+ * Return: rc4key[] - the key used to encrypt the packet [128 bits]
+ */
static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16)
{
int i;
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 317355f830cb..99e44b2c6f36 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -44,7 +44,10 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ;
u32 num_xmit_extbuf = NR_XMIT_EXTBUFF;
- /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
+ /*
+ * We don't need to memset padapter->XXX to zero because adapter is
+ * allocated by alloc_etherdev_mq, which eventually calls kvzalloc.
+ */
spin_lock_init(&pxmitpriv->lock);
@@ -1240,7 +1243,7 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
* If we turn on USE_RXTHREAD, then, no need for critical section.
* Otherwise, we must use _enter/_exit critical to protect free_xmit_queue...
*
- * Must be very very cautious...
+ * Must be very, very cautious...
*
*/
diff --git a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c
index 65a346ae3cb0..684b6cec0f09 100644
--- a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c
+++ b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c
@@ -385,14 +385,13 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm,
}
/* Endianness before calling this API */
-void ODM_PhyStatusQuery(struct odm_dm_struct *dm_odm,
- struct odm_phy_status_info *pPhyInfo,
- u8 *pPhyStatus, struct odm_per_pkt_info *pPktinfo)
+void odm_phy_status_query(struct odm_dm_struct *dm_odm,
+ struct odm_phy_status_info *phy_info,
+ u8 *phy_status, struct odm_per_pkt_info *pkt_info)
{
- odm_RxPhyStatus92CSeries_Parsing(dm_odm, pPhyInfo, pPhyStatus,
- pPktinfo);
+ odm_RxPhyStatus92CSeries_Parsing(dm_odm, phy_info, phy_status, pkt_info);
if (dm_odm->RSSI_test)
;/* Select the packets to do RSSI checking for antenna switching. */
else
- odm_Process_RSSIForDM(dm_odm, pPhyInfo, pPktinfo);
+ odm_Process_RSSIForDM(dm_odm, phy_info, pkt_info);
}
diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c
index 7d0135fde795..8669bf097479 100644
--- a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c
+++ b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c
@@ -133,6 +133,8 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe,
struct rx_pkt_attrib *pattrib = &precvframe->attrib;
struct odm_phy_status_info *pPHYInfo = (struct odm_phy_status_info *)(&pattrib->phy_info);
u8 *wlanhdr;
+ struct ieee80211_hdr *hdr =
+ (struct ieee80211_hdr *)precvframe->pkt->data;
struct odm_per_pkt_info pkt_info;
u8 *sa = NULL;
struct sta_priv *pstapriv;
@@ -144,13 +146,13 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe,
wlanhdr = precvframe->pkt->data;
- pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) &&
+ pkt_info.bPacketMatchBSSID = (!ieee80211_is_ctl(hdr->frame_control) &&
!pattrib->icv_err && !pattrib->crc_err &&
!memcmp(get_hdr_bssid(wlanhdr),
get_bssid(&padapter->mlmepriv), ETH_ALEN));
pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID &&
- (!memcmp(get_da(wlanhdr),
+ (!memcmp(ieee80211_get_DA(hdr),
myid(&padapter->eeprompriv), ETH_ALEN));
pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID &&
@@ -161,7 +163,7 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe,
sa = padapter->mlmepriv.cur_network.network.MacAddress;
/* to do Ad-hoc */
} else {
- sa = get_sa(wlanhdr);
+ sa = ieee80211_get_SA(hdr);
}
pstapriv = &padapter->stapriv;
@@ -171,8 +173,8 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe,
pkt_info.StationID = psta->mac_id;
pkt_info.Rate = pattrib->mcs_rate;
- ODM_PhyStatusQuery(&padapter->HalData->odmpriv, pPHYInfo,
- (u8 *)pphy_status, &(pkt_info));
+ odm_phy_status_query(&padapter->HalData->odmpriv, pPHYInfo,
+ (u8 *)pphy_status, &(pkt_info));
precvframe->psta = NULL;
if (pkt_info.bPacketMatchBSSID &&
diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c
index 25f46b2f4920..09bc915994db 100644
--- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c
+++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c
@@ -38,7 +38,7 @@ int rtw_hal_init_recv_priv(struct adapter *padapter)
precvbuf = precvpriv->precv_buf;
for (i = 0; i < NR_RECVBUFF; i++) {
- res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf);
+ res = rtw_os_recvbuf_resource_alloc(precvbuf);
if (res == _FAIL)
break;
precvbuf->adapter = padapter;
diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c
index abe58cf2de16..80cdcf6f7879 100644
--- a/drivers/staging/rtl8188eu/hal/usb_halinit.c
+++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c
@@ -574,8 +574,7 @@ static void _InitBeaconParameters(struct adapter *Adapter)
haldata->RegCR_1 = usb_read8(Adapter, REG_CR + 1);
}
-static void _BeaconFunctionEnable(struct adapter *Adapter,
- bool Enable, bool Linked)
+static void _BeaconFunctionEnable(struct adapter *Adapter)
{
usb_write8(Adapter, REG_BCN_CTRL, (BIT(4) | BIT(3) | BIT(1)));
@@ -1961,7 +1960,7 @@ void beacon_timing_control(struct adapter *adapt)
usb_write8(adapt, REG_RXTSF_OFFSET_CCK, 0x50);
usb_write8(adapt, REG_RXTSF_OFFSET_OFDM, 0x50);
- _BeaconFunctionEnable(adapt, true, true);
+ _BeaconFunctionEnable(adapt);
ResumeTxBeacon(adapt);
diff --git a/drivers/staging/rtl8188eu/include/drv_types.h b/drivers/staging/rtl8188eu/include/drv_types.h
index 0a3acb378d6d..4116051a9a65 100644
--- a/drivers/staging/rtl8188eu/include/drv_types.h
+++ b/drivers/staging/rtl8188eu/include/drv_types.h
@@ -150,7 +150,7 @@ struct adapter {
u8 hw_init_completed;
- void *cmdThread;
+ struct task_struct *cmdThread;
struct net_device *pnetdev;
struct net_device *pmondev;
diff --git a/drivers/staging/rtl8188eu/include/odm_hwconfig.h b/drivers/staging/rtl8188eu/include/odm_hwconfig.h
index 2cd8a47a3673..4f4d3cfb6c77 100644
--- a/drivers/staging/rtl8188eu/include/odm_hwconfig.h
+++ b/drivers/staging/rtl8188eu/include/odm_hwconfig.h
@@ -93,9 +93,9 @@ struct phy_status_rpt {
#endif
};
-void ODM_PhyStatusQuery(struct odm_dm_struct *pDM_Odm,
- struct odm_phy_status_info *pPhyInfo,
- u8 *pPhyStatus,
- struct odm_per_pkt_info *pPktinfo);
+void odm_phy_status_query(struct odm_dm_struct *dm_odm,
+ struct odm_phy_status_info *phy_info,
+ u8 *phy_status,
+ struct odm_per_pkt_info *pkt_info);
#endif
diff --git a/drivers/staging/rtl8188eu/include/osdep_intf.h b/drivers/staging/rtl8188eu/include/osdep_intf.h
index 5ee4ed995025..5012b9176526 100644
--- a/drivers/staging/rtl8188eu/include/osdep_intf.h
+++ b/drivers/staging/rtl8188eu/include/osdep_intf.h
@@ -23,7 +23,7 @@ void rtw_cancel_all_timer(struct adapter *padapter);
int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-struct net_device *rtw_init_netdev(struct adapter *padapter);
+struct net_device *rtw_init_netdev(void);
u16 rtw_recv_select_queue(struct sk_buff *skb);
int netdev_open(struct net_device *pnetdev);
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
index 56e937b26407..efd0833e28c8 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -66,19 +66,6 @@ u8 *_rtw_malloc(u32 sz);
void _rtw_init_queue(struct __queue *pqueue);
-struct rtw_netdev_priv_indicator {
- void *priv;
-};
-
-struct net_device *rtw_alloc_etherdev_with_old_priv(void *old_priv);
-
-static inline struct adapter *rtw_netdev_priv(struct net_device *netdev)
-{
- return ((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv;
-}
-
-void rtw_free_netdev(struct net_device *netdev);
-
#define FUNC_NDEV_FMT "%s(%s)"
#define FUNC_NDEV_ARG(ndev) __func__, ndev->name
#define FUNC_ADPT_FMT "%s(%s)"
diff --git a/drivers/staging/rtl8188eu/include/recv_osdep.h b/drivers/staging/rtl8188eu/include/recv_osdep.h
index 3b771702810d..614245d4b179 100644
--- a/drivers/staging/rtl8188eu/include/recv_osdep.h
+++ b/drivers/staging/rtl8188eu/include/recv_osdep.h
@@ -19,7 +19,7 @@ int rtw_recv_indicatepkt(struct adapter *adapter,
void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup);
-int rtw_os_recvbuf_resource_alloc(struct adapter *adapt, struct recv_buf *buf);
+int rtw_os_recvbuf_resource_alloc(struct recv_buf *precvbuf);
void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl);
diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
index 6035c12ec578..0c4c23be1dd5 100644
--- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
@@ -211,10 +211,6 @@ struct hal_data_8188e {
u8 bAPKThermalMeterIgnore;
bool EepromOrEfuse;
- /* 92C:256bytes, 88E:512bytes, we use union set (512bytes) */
- u8 EfuseMap[2][HWSET_MAX_SIZE_512];
- u8 EfuseUsedPercentage;
- struct efuse_hal EfuseHal;
u8 Index24G_CCK_Base[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
u8 Index24G_BW40_Base[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h
index 002a797c6d0a..68b8ad1a412f 100644
--- a/drivers/staging/rtl8188eu/include/rtw_cmd.h
+++ b/drivers/staging/rtl8188eu/include/rtw_cmd.h
@@ -361,24 +361,4 @@ enum rtw_h2c_cmd {
MAX_H2CCMD
};
-#ifdef _RTW_CMD_C_
-static struct _cmd_callback rtw_cmd_callback[] = {
- {_JoinBss_CMD_, &rtw_joinbss_cmd_callback},
- {_DisConnect_CMD_, &rtw_disassoc_cmd_callback},
- {_CreateBss_CMD_, &rtw_createbss_cmd_callback},
- {_SetOpMode_CMD_, NULL},
- {_SiteSurvey_CMD_, &rtw_survey_cmd_callback},
- {_SetAuth_CMD_, NULL},
- {_SetKey_CMD_, NULL},
- {_SetStaKey_CMD_, &rtw_setstaKey_cmdrsp_callback},
- {_SetAssocSta_CMD_, &rtw_setassocsta_cmdrsp_callback},
- {_AddBAReq_CMD_, NULL},
- {_SetChannel_CMD_, NULL},
- {_TX_Beacon_CMD_, NULL},
- {_Set_MLME_EVT_CMD_, NULL},
- {_Set_Drv_Extra_CMD_, NULL},
- {_SetChannelPlan_CMD_, NULL},
-};
-#endif
-
#endif /* _CMD_H_ */
diff --git a/drivers/staging/rtl8188eu/include/rtw_efuse.h b/drivers/staging/rtl8188eu/include/rtw_efuse.h
index 5926fc9b5e6b..74182c32c4ec 100644
--- a/drivers/staging/rtl8188eu/include/rtw_efuse.h
+++ b/drivers/staging/rtl8188eu/include/rtw_efuse.h
@@ -56,26 +56,6 @@ struct pgpkt {
u8 word_cnts;
};
-/*------------------------------Define structure----------------------------*/
-struct efuse_hal {
- u8 fakeEfuseBank;
- u32 fakeEfuseUsedBytes;
- u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE];
- u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN];
- u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN];
-
- u16 BTEfuseUsedBytes;
- u8 BTEfuseUsedPercentage;
- u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
- u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN];
- u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN];
-
- u16 fakeBTEfuseUsedBytes;
- u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
- u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN];
- u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN];
-};
-
u8 Efuse_CalculateWordCnts(u8 word_en);
u8 efuse_OneByteRead(struct adapter *adapter, u16 addr, u8 *data);
u8 efuse_OneByteWrite(struct adapter *adapter, u16 addr, u8 data);
diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h
index b11a6886a083..03d55eb7dc16 100644
--- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h
@@ -171,14 +171,6 @@ struct rt_channel_plan_map {
unsigned char Index2G;
};
-static const struct {
- int channel_plan;
- char *name;
-} channel_table[] = { { RT_CHANNEL_DOMAIN_FCC, "US" },
- { RT_CHANNEL_DOMAIN_ETSI, "EU" },
- { RT_CHANNEL_DOMAIN_MKK, "JP" },
- { RT_CHANNEL_DOMAIN_CHINA, "CN"} };
-
enum Associated_AP {
atherosAP = 0,
broadcomAP = 1,
@@ -606,28 +598,6 @@ u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf);
u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf);
u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf);
-#ifdef _RTW_CMD_C_
-
-static struct cmd_hdl wlancmds[] = {
- {sizeof(struct wlan_bssid_ex), join_cmd_hdl},
- {sizeof(struct disconnect_parm), disconnect_hdl},
- {sizeof(struct wlan_bssid_ex), createbss_hdl},
- {sizeof(struct setopmode_parm), setopmode_hdl},
- {sizeof(struct sitesurvey_parm), sitesurvey_cmd_hdl},
- {sizeof(struct setauth_parm), setauth_hdl},
- {sizeof(struct setkey_parm), setkey_hdl},
- {sizeof(struct set_stakey_parm), set_stakey_hdl},
- {sizeof(struct set_assocsta_parm), NULL},
- {sizeof(struct addBaReq_parm), add_ba_hdl},
- {sizeof(struct set_ch_parm), set_ch_hdl},
- {sizeof(struct wlan_bssid_ex), tx_beacon_hdl},
- {0, mlme_evt_hdl},
- {0, rtw_drvextra_cmd_hdl},
- {sizeof(struct SetChannelPlan_param), set_chplan_hdl}
-};
-
-#endif
-
struct C2HEvent_Header {
#ifdef __LITTLE_ENDIAN
unsigned int len:16;
diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
index 06062643c868..4345dc0c7cf9 100644
--- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
+++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
@@ -171,7 +171,7 @@ struct pwrctrl_priv {
unsigned long ips_deny_time; /* will deny IPS when system time less than this */
u8 ps_processing; /* temp used to mark whether in rtw_ps_processor */
- u8 bLeisurePs;
+ bool bLeisurePs;
u8 LpsIdleCount;
u8 power_mgnt;
u8 bFwCurrentInPSMode;
diff --git a/drivers/staging/rtl8188eu/include/usb_ops_linux.h b/drivers/staging/rtl8188eu/include/usb_ops_linux.h
index 70d729742839..19c6e76d747e 100644
--- a/drivers/staging/rtl8188eu/include/usb_ops_linux.h
+++ b/drivers/staging/rtl8188eu/include/usb_ops_linux.h
@@ -7,46 +7,14 @@
#ifndef __USB_OPS_LINUX_H__
#define __USB_OPS_LINUX_H__
-#define VENDOR_CMD_MAX_DATA_LEN 254
-
-#define RTW_USB_CONTROL_MSG_TIMEOUT_TEST 10/* ms */
-#define RTW_USB_CONTROL_MSG_TIMEOUT 500/* ms */
-
-#define MAX_USBCTRL_VENDORREQ_TIMES 10
-
-#define RTW_USB_BULKOUT_TIME 5000/* ms */
-
-#define REALTEK_USB_VENQT_READ 0xC0
-#define REALTEK_USB_VENQT_WRITE 0x40
-
-#define ALIGNMENT_UNIT 16
-#define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */
-#define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT)
-
#define USB_HIGH_SPEED_BULK_SIZE 512
#define USB_FULL_SPEED_BULK_SIZE 64
-#define _usbctrl_vendorreq_async_callback(urb, regs) \
- _usbctrl_vendorreq_async_callback(urb)
-#define usb_bulkout_zero_complete(purb, regs) \
- usb_bulkout_zero_complete(purb)
-#define usb_write_mem_complete(purb, regs) \
- usb_write_mem_complete(purb)
-#define usb_write_port_complete(purb, regs) \
- usb_write_port_complete(purb)
-#define usb_read_port_complete(purb, regs) \
- usb_read_port_complete(purb)
-#define usb_read_interrupt_complete(purb, regs) \
- usb_read_interrupt_complete(purb)
-
-unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr);
-
u8 usb_read8(struct adapter *adapter, u32 addr);
u16 usb_read16(struct adapter *adapter, u32 addr);
u32 usb_read32(struct adapter *adapter, u32 addr);
u32 usb_read_port(struct adapter *adapter, u32 addr, struct recv_buf *precvbuf);
-void usb_read_port_cancel(struct adapter *adapter);
int usb_write8(struct adapter *adapter, u32 addr, u8 val);
int usb_write16(struct adapter *adapter, u32 addr, u16 val);
diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h
index 1b9006879a11..84e17330628e 100644
--- a/drivers/staging/rtl8188eu/include/wifi.h
+++ b/drivers/staging/rtl8188eu/include/wifi.h
@@ -7,21 +7,8 @@
#ifndef _WIFI_H_
#define _WIFI_H_
-#define WLAN_IEEE_OUI_LEN 3
-#define WLAN_CRC_LEN 4
-#define WLAN_BSSID_LEN 6
-#define WLAN_BSS_TS_LEN 8
#define WLAN_HDR_A3_LEN 24
-#define WLAN_HDR_A4_LEN 30
#define WLAN_HDR_A3_QOS_LEN 26
-#define WLAN_HDR_A4_QOS_LEN 32
-#define WLAN_DATA_MAXLEN 2312
-
-#define WLAN_A3_PN_OFFSET 24
-#define WLAN_A4_PN_OFFSET 30
-
-#define WLAN_MIN_ETHFRM_LEN 60
-#define WLAN_MAX_ETHFRM_LEN 1514
#define P80211CAPTURE_VERSION 0x80211001
@@ -74,20 +61,6 @@ enum WIFI_FRAME_SUBTYPE {
WIFI_QOS_DATA_NULL = (BIT(6) | WIFI_QOS_DATA_TYPE),
};
-enum WIFI_REG_DOMAIN {
- DOMAIN_FCC = 1,
- DOMAIN_IC = 2,
- DOMAIN_ETSI = 3,
- DOMAIN_SPA = 4,
- DOMAIN_FRANCE = 5,
- DOMAIN_MKK = 6,
- DOMAIN_ISRAEL = 7,
- DOMAIN_MKK1 = 8,
- DOMAIN_MKK2 = 9,
- DOMAIN_MKK3 = 10,
- DOMAIN_MAX
-};
-
#define SetToDs(pbuf) \
*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS)
@@ -199,52 +172,6 @@ enum WIFI_REG_DOMAIN {
#define GetAddr3Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 16))
-#define GetAddr4Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 24))
-
-static inline unsigned char *get_da(unsigned char *pframe)
-{
- unsigned char *da;
- unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
-
- switch (to_fr_ds) {
- case 0x00: /* ToDs=0, FromDs=0 */
- da = GetAddr1Ptr(pframe);
- break;
- case 0x01: /* ToDs=0, FromDs=1 */
- da = GetAddr1Ptr(pframe);
- break;
- case 0x02: /* ToDs=1, FromDs=0 */
- da = GetAddr3Ptr(pframe);
- break;
- default: /* ToDs=1, FromDs=1 */
- da = GetAddr3Ptr(pframe);
- break;
- }
- return da;
-}
-
-static inline unsigned char *get_sa(unsigned char *pframe)
-{
- unsigned char *sa;
- unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
-
- switch (to_fr_ds) {
- case 0x00: /* ToDs=0, FromDs=0 */
- sa = GetAddr2Ptr(pframe);
- break;
- case 0x01: /* ToDs=0, FromDs=1 */
- sa = GetAddr3Ptr(pframe);
- break;
- case 0x02: /* ToDs=1, FromDs=0 */
- sa = GetAddr2Ptr(pframe);
- break;
- default: /* ToDs=1, FromDs=1 */
- sa = GetAddr4Ptr(pframe);
- break;
- }
- return sa;
-}
-
static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
{
unsigned char *sa;
@@ -270,30 +197,9 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
return sa;
}
-static inline int IsFrameTypeCtrl(unsigned char *pframe)
-{
- if (GetFrameType(pframe) == WIFI_CTRL_TYPE)
- return true;
- else
- return false;
-}
-
/*-----------------------------------------------------------------------------
Below is for the security related definition
------------------------------------------------------------------------------*/
-#define _RESERVED_FRAME_TYPE_ 0
-#define _SKB_FRAME_TYPE_ 2
-#define _PRE_ALLOCMEM_ 1
-#define _PRE_ALLOCHDR_ 3
-#define _PRE_ALLOCLLCHDR_ 4
-#define _PRE_ALLOCICVHDR_ 5
-#define _PRE_ALLOCMICHDR_ 6
-
-#define _SIFSTIME_ \
- ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11A) ? 16 : 10)
-#define _ACKCTSLNG_ 14 /* 14 bytes long, including crclng */
-#define _CRCLNG_ 4
-
#define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */
#define _ASOCRSP_IE_OFFSET_ 6
#define _REASOCREQ_IE_OFFSET_ 10
@@ -324,22 +230,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
#define AUTH_ODD_TO 0
#define AUTH_EVEN_TO 1
-#define WLAN_ETHCONV_ENCAP 1
-#define WLAN_ETHCONV_RFC1042 2
-#define WLAN_ETHCONV_8021h 3
-
-#define cap_ESS BIT(0)
-#define cap_IBSS BIT(1)
-#define cap_CFPollable BIT(2)
-#define cap_CFRequest BIT(3)
-#define cap_Privacy BIT(4)
-#define cap_ShortPremble BIT(5)
-#define cap_PBCC BIT(6)
-#define cap_ChAgility BIT(7)
-#define cap_SpecMgmt BIT(8)
-#define cap_QoSi BIT(9)
-#define cap_ShortSlot BIT(10)
-
/*-----------------------------------------------------------------------------
Below is the definition for 802.11i / 802.1x
------------------------------------------------------------------------------*/
@@ -360,7 +250,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
Below is the definition for WMM
------------------------------------------------------------------------------*/
#define _WMM_IE_Length_ 7 /* for WMM STA */
-#define _WMM_Para_Element_Length_ 24
/*-----------------------------------------------------------------------------
Below is the definition for 802.11n
@@ -432,13 +321,6 @@ enum ht_cap_ampdu_factor {
#define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8)BIT(3))
#define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8)BIT(4))
-#define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16)BIT(6))
-#define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16)BIT(7))
-#define HT_INFO_STBC_PARAM_SECONDARY_BC ((u16)BIT(8))
-#define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16)BIT(9))
-#define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16)BIT(10))
-#define HT_INFO_STBC_PARAM_PCO_PHASE ((u16)BIT(11))
-
/* ===============WPS Section=============== */
/* For WPSv1.0 */
#define WPSOUI 0x0050f204
@@ -497,48 +379,10 @@ enum ht_cap_ampdu_factor {
#define WPS_CONFIG_METHOD_VDISPLAY 0x2008
#define WPS_CONFIG_METHOD_PDISPLAY 0x4008
-/* Value of Category ID of WPS Primary Device Type Attribute */
-#define WPS_PDT_CID_DISPLAYS 0x0007
-#define WPS_PDT_CID_MULIT_MEDIA 0x0008
-#define WPS_PDT_CID_RTK_WIDI WPS_PDT_CID_MULIT_MEDIA
-
-/* Value of Sub Category ID of WPS Primary Device Type Attribute */
-#define WPS_PDT_SCID_MEDIA_SERVER 0x0005
-#define WPS_PDT_SCID_RTK_DMP WPS_PDT_SCID_MEDIA_SERVER
-
-/* Value of Device Password ID */
-#define WPS_DPID_P 0x0000
-#define WPS_DPID_USER_SPEC 0x0001
-#define WPS_DPID_MACHINE_SPEC 0x0002
-#define WPS_DPID_REKEY 0x0003
-#define WPS_DPID_PBC 0x0004
-#define WPS_DPID_REGISTRAR_SPEC 0x0005
-
/* Value of WPS RF Bands Attribute */
#define WPS_RF_BANDS_2_4_GHZ 0x01
#define WPS_RF_BANDS_5_GHZ 0x02
-/* Value of WPS Association State Attribute */
-#define WPS_ASSOC_STATE_NOT_ASSOCIATED 0x00
-#define WPS_ASSOC_STATE_CONNECTION_SUCCESS 0x01
-#define WPS_ASSOC_STATE_CONFIGURATION_FAILURE 0x02
-#define WPS_ASSOC_STATE_ASSOCIATION_FAILURE 0x03
-#define WPS_ASSOC_STATE_IP_FAILURE 0x04
-
-/* WPS Configuration Method */
-#define WPS_CM_NONE 0x0000
-#define WPS_CM_LABEL 0x0004
-#define WPS_CM_DISPLYA 0x0008
-#define WPS_CM_EXTERNAL_NFC_TOKEN 0x0010
-#define WPS_CM_INTEGRATED_NFC_TOKEN 0x0020
-#define WPS_CM_NFC_INTERFACE 0x0040
-#define WPS_CM_PUSH_BUTTON 0x0080
-#define WPS_CM_KEYPAD 0x0100
-#define WPS_CM_SW_PUHS_BUTTON 0x0280
-#define WPS_CM_HW_PUHS_BUTTON 0x0480
-#define WPS_CM_SW_DISPLAY_P 0x2008
-#define WPS_CM_LCD_DISPLAY_P 0x4008
-
#define IP_MCAST_MAC(mac) \
((mac[0] == 0x01) && (mac[1] == 0x00) && (mac[2] == 0x5e))
#define ICMPV6_MCAST_MAC(mac) \
diff --git a/drivers/staging/rtl8188eu/include/wlan_bssdef.h b/drivers/staging/rtl8188eu/include/wlan_bssdef.h
index 2c184ce8746b..350bbf9057b8 100644
--- a/drivers/staging/rtl8188eu/include/wlan_bssdef.h
+++ b/drivers/staging/rtl8188eu/include/wlan_bssdef.h
@@ -64,7 +64,7 @@ struct ndis_802_11_fixed_ie {
struct ndis_802_11_var_ie {
u8 ElementID;
u8 Length;
- u8 data[1];
+ u8 data[];
};
/*
diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 58954b88a817..c95ae4d6a3b6 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -311,7 +311,7 @@ static char *translate_scan(struct adapter *padapter,
static int wpa_set_auth_algs(struct net_device *dev, u32 value)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
int ret = 0;
if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) {
@@ -345,7 +345,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
int ret = 0;
u32 wep_key_idx, wep_key_len, wep_total_len;
struct ndis_802_11_wep *pwep = NULL;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct security_priv *psecuritypriv = &padapter->securitypriv;
@@ -617,7 +617,7 @@ static int rtw_wx_get_name(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
u32 ht_ielen = 0;
char *p;
u8 ht_cap = false;
@@ -669,7 +669,7 @@ static int rtw_wx_get_freq(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
@@ -690,7 +690,7 @@ static int rtw_wx_get_freq(struct net_device *dev,
static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
union iwreq_data *wrqu, char *b)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
enum ndis_802_11_network_infra networkType;
int ret = 0;
@@ -738,7 +738,7 @@ exit:
static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
union iwreq_data *wrqu, char *b)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s\n", __func__));
@@ -760,7 +760,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
struct iw_request_info *a,
union iwreq_data *wrqu, char *extra)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
u8 j, blInserted = false;
int ret = false;
struct security_priv *psecuritypriv = &padapter->securitypriv;
@@ -837,7 +837,7 @@ static int rtw_wx_get_range(struct net_device *dev,
union iwreq_data *wrqu, char *extra)
{
struct iw_range *range = (struct iw_range *)extra;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
u16 val;
@@ -925,7 +925,7 @@ static int rtw_wx_set_wap(struct net_device *dev,
union iwreq_data *awrq, char *extra)
{
uint ret = 0;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct sockaddr *temp = (struct sockaddr *)awrq;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct list_head *phead;
@@ -990,7 +990,7 @@ static int rtw_wx_get_wap(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
@@ -1015,7 +1015,7 @@ static int rtw_wx_set_mlme(struct net_device *dev,
{
int ret = 0;
u16 reason;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct iw_mlme *mlme = (struct iw_mlme *)extra;
if (!mlme)
@@ -1047,7 +1047,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
{
u8 _status = false;
int ret = 0;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
@@ -1178,7 +1178,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
union iwreq_data *wrqu, char *extra)
{
struct list_head *plist, *phead;
- struct adapter *padapter = rtw_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;
@@ -1246,7 +1246,7 @@ static int rtw_wx_set_essid(struct net_device *dev,
struct iw_request_info *a,
union iwreq_data *wrqu, char *extra)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct __queue *queue = &pmlmepriv->scanned_queue;
struct list_head *phead;
@@ -1348,7 +1348,7 @@ static int rtw_wx_get_essid(struct net_device *dev,
union iwreq_data *wrqu, char *extra)
{
u32 len;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
@@ -1453,7 +1453,7 @@ static int rtw_wx_get_rate(struct net_device *dev,
{
u16 max_rate = 0;
- max_rate = rtw_get_cur_max_rate(rtw_netdev_priv(dev));
+ max_rate = rtw_get_cur_max_rate(netdev_priv(dev));
if (max_rate == 0)
return -EPERM;
@@ -1468,7 +1468,7 @@ static int rtw_wx_set_rts(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
if (wrqu->rts.disabled) {
padapter->registrypriv.rts_thresh = 2347;
@@ -1489,7 +1489,7 @@ static int rtw_wx_get_rts(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh);
@@ -1504,7 +1504,7 @@ static int rtw_wx_set_frag(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
if (wrqu->frag.disabled) {
padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD;
@@ -1525,7 +1525,7 @@ static int rtw_wx_get_frag(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len);
@@ -1556,7 +1556,7 @@ static int rtw_wx_set_enc(struct net_device *dev,
enum ndis_802_11_auth_mode authmode;
struct iw_point *erq = &wrqu->encoding;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
DBG_88E("+%s, flags = 0x%x\n", __func__, erq->flags);
@@ -1665,7 +1665,7 @@ static int rtw_wx_get_enc(struct net_device *dev,
union iwreq_data *wrqu, char *keybuf)
{
uint key;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct iw_point *erq = &wrqu->encoding;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -1740,7 +1740,7 @@ static int rtw_wx_set_gen_ie(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
return rtw_set_wpa_ie(padapter, extra, wrqu->data.length);
}
@@ -1749,7 +1749,7 @@ static int rtw_wx_set_auth(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct iw_param *param = (struct iw_param *)&wrqu->param;
int ret = 0;
@@ -1919,7 +1919,7 @@ static int dummy(struct net_device *dev, struct iw_request_info *a,
static int wpa_set_param(struct net_device *dev, u8 name, u32 value)
{
uint ret = 0;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
switch (name) {
case IEEE_PARAM_WPA_ENABLED:
@@ -1974,7 +1974,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)
{
int ret = 0;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
switch (command) {
case IEEE_MLME_STA_DEAUTH:
@@ -2011,7 +2011,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
break;
case IEEE_CMD_SET_WPA_IE:
- ret = rtw_set_wpa_ie(rtw_netdev_priv(dev),
+ ret = rtw_set_wpa_ie(netdev_priv(dev),
(char *)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len);
break;
@@ -2155,7 +2155,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
u32 wep_key_idx, wep_key_len, wep_total_len;
struct ndis_802_11_wep *pwep = NULL;
struct sta_info *psta = NULL, *pbcmc_sta = NULL;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct security_priv *psecuritypriv = &padapter->securitypriv;
struct sta_priv *pstapriv = &padapter->stapriv;
@@ -2381,7 +2381,7 @@ exit:
static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int len)
{
int ret = 0;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct sta_priv *pstapriv = &padapter->stapriv;
unsigned char *pbuf = param->u.bcn_ie.buf;
@@ -2406,7 +2406,7 @@ static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int
static int rtw_hostapd_sta_flush(struct net_device *dev)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
DBG_88E("%s\n", __func__);
@@ -2419,7 +2419,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
{
int ret = 0;
struct sta_info *psta = NULL;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct sta_priv *pstapriv = &padapter->stapriv;
@@ -2472,7 +2472,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
static int rtw_del_sta(struct net_device *dev, struct ieee_param *param)
{
struct sta_info *psta = NULL;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct sta_priv *pstapriv = &padapter->stapriv;
int updated = 0;
@@ -2507,7 +2507,7 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par
{
int ret = 0;
struct sta_info *psta = NULL;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct sta_priv *pstapriv = &padapter->stapriv;
struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param;
@@ -2563,7 +2563,7 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param)
{
int ret = 0;
struct sta_info *psta = NULL;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct sta_priv *pstapriv = &padapter->stapriv;
@@ -2599,7 +2599,7 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param)
static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, int len)
{
unsigned char wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
int ie_len;
@@ -2634,7 +2634,7 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param,
static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *param, int len)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
int ie_len;
@@ -2663,7 +2663,7 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par
static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *param, int len)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
int ie_len;
@@ -2693,7 +2693,7 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par
static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, int len)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
@@ -2717,7 +2717,7 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param,
static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
if (!check_fwstate(pmlmepriv, WIFI_AP_STATE))
@@ -2731,7 +2731,7 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p
static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
if (!check_fwstate(pmlmepriv, WIFI_AP_STATE))
@@ -2745,7 +2745,7 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para
static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param *param, int len)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
if (!check_fwstate(pmlmepriv, WIFI_AP_STATE))
@@ -2760,7 +2760,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
{
struct ieee_param *param;
int ret = 0;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
/*
* this function is expect to call in master mode, which allows no power saving
@@ -2841,7 +2841,7 @@ static int rtw_wx_set_priv(struct net_device *dev,
int ret = 0;
int len = 0;
char *ext;
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct iw_point *dwrq = (struct iw_point *)awrq;
if (dwrq->length == 0)
@@ -2959,7 +2959,7 @@ static iw_handler rtw_handlers[] = {
static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct iw_statistics *piwstats = &padapter->iwstats;
int tmp_level = 0;
int tmp_qual = 0;
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index c80d30f31869..a826228cbbe9 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -187,7 +187,7 @@ static void loadparam(struct adapter *padapter, struct net_device *pnetdev)
static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
{
- struct adapter *padapter = rtw_netdev_priv(pnetdev);
+ struct adapter *padapter = netdev_priv(pnetdev);
struct sockaddr *addr = p;
if (!padapter->bup)
@@ -198,7 +198,7 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev)
{
- struct adapter *padapter = rtw_netdev_priv(pnetdev);
+ struct adapter *padapter = netdev_priv(pnetdev);
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
struct recv_priv *precvpriv = &padapter->recvpriv;
@@ -248,7 +248,7 @@ static unsigned int rtw_classify8021d(struct sk_buff *skb)
static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb,
struct net_device *sb_dev)
{
- struct adapter *padapter = rtw_netdev_priv(dev);
+ struct adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
skb->priority = rtw_classify8021d(skb);
@@ -296,21 +296,19 @@ static const struct device_type wlan_type = {
.name = "wlan",
};
-struct net_device *rtw_init_netdev(struct adapter *old_padapter)
+struct net_device *rtw_init_netdev(void)
{
struct adapter *padapter;
- struct net_device *pnetdev = NULL;
+ struct net_device *pnetdev;
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n"));
- if (old_padapter)
- pnetdev = rtw_alloc_etherdev_with_old_priv((void *)old_padapter);
-
+ pnetdev = alloc_etherdev_mq(sizeof(struct adapter), 4);
if (!pnetdev)
return NULL;
pnetdev->dev.type = &wlan_type;
- padapter = rtw_netdev_priv(pnetdev);
+ padapter = netdev_priv(pnetdev);
padapter->pnetdev = pnetdev;
DBG_88E("register rtw_netdev_ops to netdev_ops\n");
pnetdev->netdev_ops = &rtw_netdev_ops;
@@ -534,7 +532,7 @@ static int _netdev_open(struct net_device *pnetdev)
{
uint status;
int err;
- struct adapter *padapter = rtw_netdev_priv(pnetdev);
+ struct adapter *padapter = netdev_priv(pnetdev);
struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - dev_open\n"));
@@ -603,7 +601,7 @@ netdev_open_error:
int netdev_open(struct net_device *pnetdev)
{
int ret;
- struct adapter *padapter = rtw_netdev_priv(pnetdev);
+ struct adapter *padapter = netdev_priv(pnetdev);
if (mutex_lock_interruptible(&padapter->hw_init_mutex))
return -ERESTARTSYS;
@@ -689,7 +687,7 @@ void rtw_ips_dev_unload(struct adapter *padapter)
static int netdev_close(struct net_device *pnetdev)
{
- struct adapter *padapter = rtw_netdev_priv(pnetdev);
+ struct adapter *padapter = netdev_priv(pnetdev);
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - drv_close\n"));
diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index 4d6d0347ab8e..57453df0ced8 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -24,37 +24,6 @@ void _rtw_init_queue(struct __queue *pqueue)
spin_lock_init(&pqueue->lock);
}
-struct net_device *rtw_alloc_etherdev_with_old_priv(void *old_priv)
-{
- struct net_device *netdev;
- struct rtw_netdev_priv_indicator *pnpi;
-
- netdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4);
- if (!netdev)
- return NULL;
-
- pnpi = netdev_priv(netdev);
- pnpi->priv = old_priv;
-
- return netdev;
-}
-
-void rtw_free_netdev(struct net_device *netdev)
-{
- struct rtw_netdev_priv_indicator *pnpi;
-
- if (!netdev)
- return;
-
- pnpi = netdev_priv(netdev);
-
- if (!pnpi->priv)
- return;
-
- vfree(pnpi->priv);
- free_netdev(netdev);
-}
-
void rtw_buf_free(u8 **buf, u32 *buf_len)
{
*buf_len = 0;
diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c
index 9c9339863a4a..a647cdc330e4 100644
--- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c
@@ -14,8 +14,7 @@
#include <usb_ops_linux.h>
/* alloc os related resource in struct recv_buf */
-int rtw_os_recvbuf_resource_alloc(struct adapter *padapter,
- struct recv_buf *precvbuf)
+int rtw_os_recvbuf_resource_alloc(struct recv_buf *precvbuf)
{
precvbuf->pskb = NULL;
precvbuf->reuse = false;
diff --git a/drivers/staging/rtl8188eu/os_dep/rtw_android.c b/drivers/staging/rtl8188eu/os_dep/rtw_android.c
index b5209627fd1a..f1470ac56874 100644
--- a/drivers/staging/rtl8188eu/os_dep/rtw_android.c
+++ b/drivers/staging/rtl8188eu/os_dep/rtw_android.c
@@ -52,16 +52,6 @@ struct android_wifi_priv_cmd {
int total_len;
};
-/**
- * Local (static) functions and variables
- */
-
-/* Initialize g_wifi_on to 1 so dhd_bus_start will be called for the first
- * time (only) in dhd_open, subsequential wifi on will be handled by
- * wl_android_wifi_on
- */
-static int g_wifi_on = true;
-
int rtw_android_cmdstr_to_num(char *cmdstr)
{
int cmd_num;
@@ -76,7 +66,7 @@ int rtw_android_cmdstr_to_num(char *cmdstr)
static int rtw_android_get_rssi(struct net_device *net, char *command,
int total_len)
{
- struct adapter *padapter = rtw_netdev_priv(net);
+ struct adapter *padapter = netdev_priv(net);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_network *pcur_network = &pmlmepriv->cur_network;
int bytes_written = 0;
@@ -93,7 +83,7 @@ static int rtw_android_get_rssi(struct net_device *net, char *command,
static int rtw_android_get_link_speed(struct net_device *net, char *command,
int total_len)
{
- struct adapter *padapter = rtw_netdev_priv(net);
+ struct adapter *padapter = netdev_priv(net);
u16 link_speed;
link_speed = rtw_get_cur_max_rate(padapter) / 10;
@@ -111,7 +101,7 @@ static int rtw_android_get_macaddr(struct net_device *net, char *command,
static int android_set_cntry(struct net_device *net, char *command,
int total_len)
{
- struct adapter *adapter = rtw_netdev_priv(net);
+ struct adapter *adapter = netdev_priv(net);
char *country_code = command + strlen(android_wifi_cmd_str[ANDROID_WIFI_CMD_COUNTRY]) + 1;
int ret;
@@ -154,12 +144,6 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
case ANDROID_WIFI_CMD_SETFWPATH:
goto response;
}
- if (!g_wifi_on) {
- DBG_88E("%s: Ignore private cmd \"%s\" - iface %s is down\n",
- __func__, command, ifr->ifr_name);
- ret = 0;
- goto free;
- }
switch (cmd_num) {
case ANDROID_WIFI_CMD_STOP:
break;
@@ -244,7 +228,6 @@ response:
} else {
ret = bytes_written;
}
-free:
kfree(command);
return ret;
}
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index efad43d8e465..3a970d67aa8c 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -48,7 +48,7 @@ static const struct usb_device_id rtw_usb_id_tbl[] = {
MODULE_DEVICE_TABLE(usb, rtw_usb_id_tbl);
-static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
+static int usb_dvobj_init(struct usb_interface *usb_intf)
{
int i;
struct dvobj_priv *pdvobjpriv;
@@ -61,7 +61,7 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
pdvobjpriv = kzalloc(sizeof(*pdvobjpriv), GFP_KERNEL);
if (!pdvobjpriv)
- return NULL;
+ return -ENOMEM;
pdvobjpriv->pusbintf = usb_intf;
pusbd = interface_to_usbdev(usb_intf);
@@ -108,7 +108,7 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
mutex_init(&pdvobjpriv->usb_vendor_req_mutex);
usb_get_dev(pusbd);
- return pdvobjpriv;
+ return 0;
}
static void usb_dvobj_deinit(struct usb_interface *usb_intf)
@@ -322,30 +322,26 @@ static int rtw_resume(struct usb_interface *pusb_intf)
* We accept the new device by returning 0.
*/
-static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
- struct usb_interface *pusb_intf,
- const struct usb_device_id *pdid)
+static int rtw_usb_if1_init(struct usb_interface *pusb_intf)
{
- struct adapter *padapter = NULL;
- struct net_device *pnetdev = NULL;
+ struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
+ struct adapter *padapter;
+ struct net_device *pnetdev;
struct net_device *pmondev;
- int status = _FAIL;
+ int err = 0;
- padapter = vzalloc(sizeof(*padapter));
- if (!padapter)
- goto exit;
+ pnetdev = rtw_init_netdev();
+ if (!pnetdev)
+ return -ENOMEM;
+ SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj));
+
+ padapter = netdev_priv(pnetdev);
padapter->dvobj = dvobj;
dvobj->if1 = padapter;
padapter->bDriverStopped = true;
mutex_init(&padapter->hw_init_mutex);
- pnetdev = rtw_init_netdev(padapter);
- if (!pnetdev)
- goto free_adapter;
- SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj));
- padapter = rtw_netdev_priv(pnetdev);
-
if (padapter->registrypriv.monitor_enable) {
pmondev = rtl88eu_mon_init();
if (!pmondev)
@@ -356,6 +352,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
padapter->HalData = kzalloc(sizeof(struct hal_data_8188e), GFP_KERNEL);
if (!padapter->HalData) {
DBG_88E("Failed to allocate memory for HAL data\n");
+ err = -ENOMEM;
goto free_adapter;
}
@@ -372,6 +369,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
if (rtw_init_drv_sw(padapter) == _FAIL) {
RT_TRACE(_module_hci_intfs_c_, _drv_err_,
("Initialize driver software resource Failed!\n"));
+ err = -ENOMEM;
goto free_hal_data;
}
@@ -380,7 +378,6 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
dvobj->pusbdev->do_remote_wakeup = 1;
pusb_intf->needs_remote_wakeup = 1;
device_init_wakeup(&pusb_intf->dev, 1);
- pr_debug("\n padapter->pwrctrlpriv.bSupportRemoteWakeup~~~~~~\n");
pr_debug("\n padapter->pwrctrlpriv.bSupportRemoteWakeup~~~[%d]~~~\n",
device_may_wakeup(&pusb_intf->dev));
}
@@ -402,7 +399,8 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
pnetdev->dev_addr);
/* step 6. Tell the network stack we exist */
- if (register_netdev(pnetdev) != 0) {
+ err = register_netdev(pnetdev);
+ if (err) {
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("register_netdev() failed\n"));
goto free_hal_data;
}
@@ -414,21 +412,13 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
, padapter->hw_init_completed
);
- status = _SUCCESS;
+ return 0;
free_hal_data:
- if (status != _SUCCESS)
- kfree(padapter->HalData);
+ kfree(padapter->HalData);
free_adapter:
- if (status != _SUCCESS) {
- if (pnetdev)
- rtw_free_netdev(pnetdev);
- else
- vfree(padapter);
- padapter = NULL;
- }
-exit:
- return padapter;
+ free_netdev(pnetdev);
+ return err;
}
static void rtw_usb_if1_deinit(struct adapter *if1)
@@ -453,34 +443,28 @@ static void rtw_usb_if1_deinit(struct adapter *if1)
pr_debug("+r871xu_dev_remove, hw_init_completed=%d\n",
if1->hw_init_completed);
rtw_free_drv_sw(if1);
- rtw_free_netdev(pnetdev);
+ if (pnetdev)
+ free_netdev(pnetdev);
}
static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid)
{
- struct adapter *if1 = NULL;
- struct dvobj_priv *dvobj;
+ int err;
- /* 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"));
- goto exit;
+ err = usb_dvobj_init(pusb_intf);
+ if (err) {
+ pr_debug("usb_dvobj_init failed\n");
+ return err;
}
- if1 = rtw_usb_if1_init(dvobj, pusb_intf, pdid);
- if (!if1) {
- pr_debug("rtw_init_primarystruct adapter Failed!\n");
- goto free_dvobj;
+ err = rtw_usb_if1_init(pusb_intf);
+ if (err) {
+ pr_debug("rtw_usb_if1_init failed\n");
+ usb_dvobj_deinit(pusb_intf);
+ return err;
}
return 0;
-
-free_dvobj:
- usb_dvobj_deinit(pusb_intf);
-exit:
- return -ENODEV;
}
/*
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
index 6926443bba4e..e8222ffb6fea 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
@@ -10,6 +10,20 @@
#include <recv_osdep.h>
#include <rtw_sreset.h>
+#define RTW_USB_CONTROL_MSG_TIMEOUT 500 /* ms */
+
+#define MAX_USBCTRL_VENDORREQ_TIMES 10
+
+#define ALIGNMENT_UNIT 16
+#define MAX_VENDOR_REQ_CMD_SIZE 254
+#define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT)
+
+#define REALTEK_USB_VENQT_READ (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
+#define REALTEK_USB_VENQT_WRITE (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
+
+#define REALTEK_USB_VENQT_CMD_REQ 0x05
+#define REALTEK_USB_VENQT_CMD_IDX 0x00
+
static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbuf)
{
struct hal_data_8188e *haldata = adapt->HalData;
@@ -181,7 +195,7 @@ _exit_recvbuf2recvframe:
return _SUCCESS;
}
-unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr)
+static unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr)
{
unsigned int pipe = 0, ep_num = 0;
struct usb_device *pusbd = pdvobj->pusbdev;
@@ -198,13 +212,13 @@ unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr)
return pipe;
}
-static int usbctrl_vendorreq(struct adapter *adapt, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype)
+static int
+usbctrl_vendorreq(struct adapter *adapt, u16 value, void *pdata, u16 len, u8 reqtype)
{
struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt);
struct usb_device *udev = dvobjpriv->pusbdev;
unsigned int pipe;
int status = 0;
- u8 reqtype;
u8 *pIo_buf;
int vendorreq_times = 0;
@@ -235,36 +249,41 @@ static int usbctrl_vendorreq(struct adapter *adapt, u8 request, u16 value, u16 i
goto release_mutex;
}
- while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) {
- memset(pIo_buf, 0, len);
+ if (reqtype == REALTEK_USB_VENQT_READ) {
+ pipe = usb_rcvctrlpipe(udev, 0);
+ } else if (reqtype == REALTEK_USB_VENQT_WRITE) {
+ pipe = usb_sndctrlpipe(udev, 0);
+ } else {
+ status = -EINVAL;
+ goto free_buf;
+ }
- if (requesttype == 0x01) {
- pipe = usb_rcvctrlpipe(udev, 0);/* read_in */
- reqtype = REALTEK_USB_VENQT_READ;
- } else {
- pipe = usb_sndctrlpipe(udev, 0);/* write_out */
- reqtype = REALTEK_USB_VENQT_WRITE;
+ while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) {
+ if (reqtype == REALTEK_USB_VENQT_READ)
+ memset(pIo_buf, 0, len);
+ else
memcpy(pIo_buf, pdata, len);
- }
- status = usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT);
+ status = usb_control_msg(udev, pipe, REALTEK_USB_VENQT_CMD_REQ,
+ reqtype, value, REALTEK_USB_VENQT_CMD_IDX,
+ pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT);
if (status == len) { /* Success this control transfer. */
- if (requesttype == 0x01)
+ if (reqtype == REALTEK_USB_VENQT_READ)
memcpy(pdata, pIo_buf, len);
} else { /* error cases */
DBG_88E("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n",
- value, (requesttype == 0x01) ? "read" : "write",
+ value, (reqtype == REALTEK_USB_VENQT_READ) ? "read" : "write",
len, status, *(u32 *)pdata, vendorreq_times);
if (status < 0) {
- if (status == (-ESHUTDOWN) || status == -ENODEV)
+ if (status == -ESHUTDOWN || status == -ENODEV)
adapt->bSurpriseRemoved = true;
else
adapt->HalData->srestpriv.wifi_error_status = USB_VEN_REQ_CMD_FAIL;
} else { /* status != len && status >= 0 */
if (status > 0) {
- if (requesttype == 0x01) {
+ if (reqtype == REALTEK_USB_VENQT_READ) {
/* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */
memcpy(pdata, pIo_buf, len);
}
@@ -276,8 +295,9 @@ static int usbctrl_vendorreq(struct adapter *adapt, u8 request, u16 value, u16 i
if ((value >= FW_8188E_START_ADDRESS && value <= FW_8188E_END_ADDRESS) || status == len)
break;
}
- kfree(pIo_buf);
+free_buf:
+ kfree(pIo_buf);
release_mutex:
mutex_unlock(&dvobjpriv->usb_vendor_req_mutex);
exit:
@@ -286,66 +306,35 @@ exit:
u8 usb_read8(struct adapter *adapter, u32 addr)
{
- u8 request;
- u8 requesttype;
- u16 wvalue;
- u16 index;
- u16 len;
- u8 data = 0;
-
- request = 0x05;
- requesttype = 0x01;/* read_in */
- index = 0;/* n/a */
-
- wvalue = (u16)(addr & 0x0000ffff);
- len = 1;
+ u16 wvalue = (u16)(addr & 0xffff);
+ u8 data;
- usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype);
+ usbctrl_vendorreq(adapter, wvalue, &data, 1, REALTEK_USB_VENQT_READ);
return data;
}
u16 usb_read16(struct adapter *adapter, u32 addr)
{
- u8 request;
- u8 requesttype;
- u16 wvalue;
- u16 index;
- u16 len;
+ u16 wvalue = (u16)(addr & 0xffff);
__le32 data;
- request = 0x05;
- requesttype = 0x01;/* read_in */
- index = 0;/* n/a */
- wvalue = (u16)(addr & 0x0000ffff);
- len = 2;
- usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype);
+ usbctrl_vendorreq(adapter, wvalue, &data, 2, REALTEK_USB_VENQT_READ);
return (u16)(le32_to_cpu(data) & 0xffff);
}
u32 usb_read32(struct adapter *adapter, u32 addr)
{
- u8 request;
- u8 requesttype;
- u16 wvalue;
- u16 index;
- u16 len;
+ u16 wvalue = (u16)(addr & 0xffff);
__le32 data;
- request = 0x05;
- requesttype = 0x01;/* read_in */
- index = 0;/* n/a */
-
- wvalue = (u16)(addr & 0x0000ffff);
- len = 4;
-
- usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype);
+ usbctrl_vendorreq(adapter, wvalue, &data, 4, REALTEK_USB_VENQT_READ);
return le32_to_cpu(data);
}
-static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs)
+static void usb_read_port_complete(struct urb *purb)
{
struct recv_buf *precvbuf = (struct recv_buf *)purb->context;
struct adapter *adapt = (struct adapter *)precvbuf->adapter;
@@ -508,67 +497,29 @@ void rtw_hal_inirp_deinit(struct adapter *padapter)
int usb_write8(struct adapter *adapter, u32 addr, u8 val)
{
- u8 request;
- u8 requesttype;
- u16 wvalue;
- u16 index;
- u16 len;
- u8 data;
+ u16 wvalue = (u16)(addr & 0xffff);
+ u8 data = val;
- request = 0x05;
- requesttype = 0x00;/* write_out */
- index = 0;/* n/a */
- wvalue = (u16)(addr & 0x0000ffff);
- len = 1;
- data = val;
- return usbctrl_vendorreq(adapter, request, wvalue,
- index, &data, len, requesttype);
+ return usbctrl_vendorreq(adapter, wvalue, &data, 1, REALTEK_USB_VENQT_WRITE);
}
int usb_write16(struct adapter *adapter, u32 addr, u16 val)
{
- u8 request;
- u8 requesttype;
- u16 wvalue;
- u16 index;
- u16 len;
- __le32 data;
-
- request = 0x05;
- requesttype = 0x00;/* write_out */
- index = 0;/* n/a */
+ u16 wvalue = (u16)(addr & 0xffff);
+ __le32 data = cpu_to_le32(val & 0xffff);
- wvalue = (u16)(addr & 0x0000ffff);
- len = 2;
-
- data = cpu_to_le32(val & 0x0000ffff);
-
- return usbctrl_vendorreq(adapter, request, wvalue,
- index, &data, len, requesttype);
+ return usbctrl_vendorreq(adapter, wvalue, &data, 2, REALTEK_USB_VENQT_WRITE);
}
int usb_write32(struct adapter *adapter, u32 addr, u32 val)
{
- u8 request;
- u8 requesttype;
- u16 wvalue;
- u16 index;
- u16 len;
- __le32 data;
-
- request = 0x05;
- requesttype = 0x00;/* write_out */
- index = 0;/* n/a */
+ u16 wvalue = (u16)(addr & 0xffff);
+ __le32 data = cpu_to_le32(val);
- wvalue = (u16)(addr & 0x0000ffff);
- len = 4;
- data = cpu_to_le32(val);
-
- return usbctrl_vendorreq(adapter, request, wvalue,
- index, &data, len, requesttype);
+ return usbctrl_vendorreq(adapter, wvalue, &data, 4, REALTEK_USB_VENQT_WRITE);
}
-static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs)
+static void usb_write_port_complete(struct urb *purb)
{
struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context;
struct adapter *padapter = pxmitbuf->padapter;
@@ -724,20 +675,14 @@ u32 usb_write_port(struct adapter *padapter, u32 addr, u32 cnt, struct xmit_buf
("%s(): usb_submit_urb, status =%x\n",
__func__, status));
- switch (status) {
- case -ENODEV:
+ if (status == -ENODEV)
padapter->bDriverStopped = true;
- break;
- default:
- break;
- }
+
goto exit;
}
ret = _SUCCESS;
-/* We add the URB_ZERO_PACKET flag to urb so that the host will send the zero packet automatically. */
-
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("-%s\n", __func__));
exit:
diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
index b0efa2eb705e..a9c42fb80583 100644
--- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
@@ -164,7 +164,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev)
{
- struct adapter *padapter = rtw_netdev_priv(pnetdev);
+ struct adapter *padapter = netdev_priv(pnetdev);
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
s32 res = 0;
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index ff843d7ec606..b626ac45db80 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -690,7 +690,7 @@ bool rtl92e_start_adapter(struct net_device *dev)
u8 tmpvalue;
u8 ICVersion, SwitchingRegulatorOutput;
bool bfirmwareok = true;
- u32 tmpRegA, tmpRegC, TempCCk;
+ u32 tmpRegA, TempCCk;
int i = 0;
u32 retry_times = 0;
@@ -800,12 +800,10 @@ start:
}
rtl92e_writew(dev, ATIMWND, 2);
rtl92e_writew(dev, BCN_INTERVAL, 100);
- {
- int i;
- for (i = 0; i < QOS_QUEUE_NUM; i++)
- rtl92e_writel(dev, WDCAPARA_ADD[i], 0x005e4332);
- }
+ for (i = 0; i < QOS_QUEUE_NUM; i++)
+ rtl92e_writel(dev, WDCAPARA_ADD[i], 0x005e4332);
+
rtl92e_writeb(dev, 0xbe, 0xc0);
rtl92e_config_mac(dev);
@@ -889,8 +887,8 @@ start:
if (priv->IC_Cut >= IC_VersionCut_D) {
tmpRegA = rtl92e_get_bb_reg(dev, rOFDM0_XATxIQImbalance,
bMaskDWord);
- tmpRegC = rtl92e_get_bb_reg(dev, rOFDM0_XCTxIQImbalance,
- bMaskDWord);
+ rtl92e_get_bb_reg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord);
+
for (i = 0; i < TxBBGainTableLength; i++) {
if (tmpRegA == dm_tx_bb_gain[i]) {
priv->rfa_txpowertrackingindex = (u8)i;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 9078fadd65f9..e85d9c2cdc96 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -375,9 +375,8 @@ static void _rtl92e_update_beacon(void *data)
if (ieee->pHTInfo->bCurrentHTSupport)
HT_update_self_and_peer_setting(ieee, net);
- ieee->pHTInfo->bCurrentRT2RTLongSlotTime =
- net->bssht.bdRT2RTLongSlotTime;
- ieee->pHTInfo->RT2RT_HT_Mode = net->bssht.RT2RT_HT_Mode;
+ ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bd_rt2rt_long_slot_time;
+ ieee->pHTInfo->RT2RT_HT_Mode = net->bssht.rt2rt_ht_mode;
_rtl92e_update_cap(dev, net->capability);
}
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index e340be3ebb97..c53aa2d305ca 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -260,7 +260,7 @@ void rtl92e_dm_watchdog(struct net_device *dev)
static void _rtl92e_dm_check_ac_dc_power(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
- static char const ac_dc_script[] = "/etc/acpi/wireless-rtl-ac-dc-power.sh";
+ static const char ac_dc_script[] = "/etc/acpi/wireless-rtl-ac-dc-power.sh";
char *argv[] = {(char *)ac_dc_script, DRV_NAME, NULL};
static char *envp[] = {"HOME=/",
"TERM=linux",
@@ -1801,7 +1801,7 @@ static void _rtl92e_dm_check_rf_ctrl_gpio(void *data)
enum rt_rf_power_state eRfPowerStateToSet;
bool bActuallySet = false;
char *argv[3];
- static char const RadioPowerPath[] = "/etc/acpi/events/RadioPower.sh";
+ static const char RadioPowerPath[] = "/etc/acpi/events/RadioPower.sh";
static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin",
NULL};
diff --git a/drivers/staging/rtl8192e/rtl819x_BA.h b/drivers/staging/rtl8192e/rtl819x_BA.h
index 8b6e4c26f0fb..8a35d7a3eee1 100644
--- a/drivers/staging/rtl8192e/rtl819x_BA.h
+++ b/drivers/staging/rtl8192e/rtl819x_BA.h
@@ -20,41 +20,41 @@
#define DELBA_REASON_UNKNOWN_BA 38
#define DELBA_REASON_TIMEOUT 39
union sequence_control {
- u16 ShortData;
+ u16 short_data;
struct {
- u16 FragNum:4;
- u16 SeqNum:12;
+ u16 frag_num:4;
+ u16 seq_num:12;
} field;
};
union ba_param_set {
- u8 charData[2];
- u16 shortData;
+ u8 char_data[2];
+ u16 short_data;
struct {
- u16 AMSDU_Support:1;
- u16 BAPolicy:1;
- u16 TID:4;
- u16 BufferSize:10;
+ u16 amsdu_support:1;
+ u16 ba_policy:1;
+ u16 tid:4;
+ u16 buffer_size:10;
} field;
};
union delba_param_set {
- u8 charData[2];
- u16 shortData;
+ u8 char_data[2];
+ u16 short_data;
struct {
- u16 Reserved:11;
- u16 Initiator:1;
- u16 TID:4;
+ u16 reserved:11;
+ u16 initiator:1;
+ u16 tid:4;
} field;
};
struct ba_record {
- struct timer_list Timer;
- u8 bValid;
- u8 DialogToken;
- union ba_param_set BaParamSet;
- u16 BaTimeoutValue;
- union sequence_control BaStartSeqCtrl;
+ struct timer_list timer;
+ u8 b_valid;
+ u8 dialog_token;
+ union ba_param_set ba_param_set;
+ u16 ba_timeout_value;
+ union sequence_control ba_start_seq_ctrl;
};
#endif
diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 2d5e4a0330c6..7dfe7a055876 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -13,15 +13,15 @@
static void ActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA,
u16 Time)
{
- pBA->bValid = true;
+ pBA->b_valid = true;
if (Time != 0)
- mod_timer(&pBA->Timer, jiffies + msecs_to_jiffies(Time));
+ mod_timer(&pBA->timer, jiffies + msecs_to_jiffies(Time));
}
static void DeActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA)
{
- pBA->bValid = false;
- del_timer_sync(&pBA->Timer);
+ pBA->b_valid = false;
+ del_timer_sync(&pBA->timer);
}
static u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs)
@@ -30,12 +30,12 @@ static u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs)
struct ba_record *pPendingBa = &pTxTs->TxPendingBARecord;
u8 bSendDELBA = false;
- if (pPendingBa->bValid) {
+ if (pPendingBa->b_valid) {
DeActivateBAEntry(ieee, pPendingBa);
bSendDELBA = true;
}
- if (pAdmittedBa->bValid) {
+ if (pAdmittedBa->b_valid) {
DeActivateBAEntry(ieee, pAdmittedBa);
bSendDELBA = true;
}
@@ -44,10 +44,10 @@ static u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs)
static u8 RxTsDeleteBA(struct rtllib_device *ieee, struct rx_ts_record *pRxTs)
{
- struct ba_record *pBa = &pRxTs->RxAdmittedBARecord;
+ struct ba_record *pBa = &pRxTs->rx_admitted_ba_record;
u8 bSendDELBA = false;
- if (pBa->bValid) {
+ if (pBa->b_valid) {
DeActivateBAEntry(ieee, pBa);
bSendDELBA = true;
}
@@ -57,11 +57,11 @@ static u8 RxTsDeleteBA(struct rtllib_device *ieee, struct rx_ts_record *pRxTs)
void ResetBaEntry(struct ba_record *pBA)
{
- pBA->bValid = false;
- pBA->BaParamSet.shortData = 0;
- pBA->BaTimeoutValue = 0;
- pBA->DialogToken = 0;
- pBA->BaStartSeqCtrl.ShortData = 0;
+ pBA->b_valid = false;
+ pBA->ba_param_set.short_data = 0;
+ pBA->ba_timeout_value = 0;
+ pBA->dialog_token = 0;
+ pBA->ba_start_seq_ctrl.short_data = 0;
}
static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
struct ba_record *pBA,
@@ -98,7 +98,7 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
tag = skb_put(skb, 9);
*tag++ = ACT_CAT_BA;
*tag++ = type;
- *tag++ = pBA->DialogToken;
+ *tag++ = pBA->dialog_token;
if (type == ACT_ADDBARSP) {
RT_TRACE(COMP_DBG, "====>to send ADDBARSP\n");
@@ -107,14 +107,14 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
tag += 2;
}
- put_unaligned_le16(pBA->BaParamSet.shortData, tag);
+ put_unaligned_le16(pBA->ba_param_set.short_data, tag);
tag += 2;
- put_unaligned_le16(pBA->BaTimeoutValue, tag);
+ put_unaligned_le16(pBA->ba_timeout_value, tag);
tag += 2;
if (type == ACT_ADDBAREQ) {
- memcpy(tag, (u8 *)&(pBA->BaStartSeqCtrl), 2);
+ memcpy(tag, (u8 *)&(pBA->ba_start_seq_ctrl), 2);
tag += 2;
}
@@ -141,8 +141,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
memset(&DelbaParamSet, 0, 2);
- DelbaParamSet.field.Initiator = (TxRxSelect == TX_DIR) ? 1 : 0;
- DelbaParamSet.field.TID = pBA->BaParamSet.field.TID;
+ DelbaParamSet.field.initiator = (TxRxSelect == TX_DIR) ? 1 : 0;
+ DelbaParamSet.field.tid = pBA->ba_param_set.field.tid;
skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
if (!skb)
@@ -163,7 +163,7 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
*tag++ = ACT_DELBA;
- put_unaligned_le16(DelbaParamSet.shortData, tag);
+ put_unaligned_le16(DelbaParamSet.short_data, tag);
tag += 2;
put_unaligned_le16(ReasonCode, tag);
@@ -260,14 +260,14 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb)
goto OnADDBAReq_Fail;
}
if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst,
- (u8)(pBaParamSet->field.TID), RX_DIR, true)) {
+ (u8)(pBaParamSet->field.tid), RX_DIR, true)) {
rc = ADDBA_STATUS_REFUSED;
netdev_warn(ieee->dev, "%s(): can't get TS\n", __func__);
goto OnADDBAReq_Fail;
}
- pBA = &pTS->RxAdmittedBARecord;
+ pBA = &pTS->rx_admitted_ba_record;
- if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) {
+ if (pBaParamSet->field.ba_policy == BA_POLICY_DELAYED) {
rc = ADDBA_STATUS_INVALID_PARAM;
netdev_warn(ieee->dev, "%s(): BA Policy is not correct\n",
__func__);
@@ -277,16 +277,16 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb)
rtllib_FlushRxTsPendingPkts(ieee, pTS);
DeActivateBAEntry(ieee, pBA);
- pBA->DialogToken = *pDialogToken;
- pBA->BaParamSet = *pBaParamSet;
- pBA->BaTimeoutValue = *pBaTimeoutVal;
- pBA->BaStartSeqCtrl = *pBaStartSeqCtrl;
+ pBA->dialog_token = *pDialogToken;
+ pBA->ba_param_set = *pBaParamSet;
+ pBA->ba_timeout_value = *pBaTimeoutVal;
+ pBA->ba_start_seq_ctrl = *pBaStartSeqCtrl;
if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev) ||
(ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT))
- pBA->BaParamSet.field.BufferSize = 1;
+ pBA->ba_param_set.field.buffer_size = 1;
else
- pBA->BaParamSet.field.BufferSize = 32;
+ pBA->ba_param_set.field.buffer_size = 32;
ActivateBAEntry(ieee, pBA, 0);
rtllib_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS);
@@ -297,10 +297,10 @@ OnADDBAReq_Fail:
{
struct ba_record BA;
- BA.BaParamSet = *pBaParamSet;
- BA.BaTimeoutValue = *pBaTimeoutVal;
- BA.DialogToken = *pDialogToken;
- BA.BaParamSet.field.BAPolicy = BA_POLICY_IMMEDIATE;
+ BA.ba_param_set = *pBaParamSet;
+ BA.ba_timeout_value = *pBaTimeoutVal;
+ BA.dialog_token = *pDialogToken;
+ BA.ba_param_set.field.ba_policy = BA_POLICY_IMMEDIATE;
rtllib_send_ADDBARsp(ieee, dst, &BA, rc);
return 0;
}
@@ -346,7 +346,7 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb)
if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst,
- (u8)(pBaParamSet->field.TID), TX_DIR, false)) {
+ (u8)(pBaParamSet->field.tid), TX_DIR, false)) {
netdev_warn(ieee->dev, "%s(): can't get TS\n", __func__);
ReasonCode = DELBA_REASON_UNKNOWN_BA;
goto OnADDBARsp_Reject;
@@ -357,12 +357,12 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb)
pAdmittedBA = &pTS->TxAdmittedBARecord;
- if (pAdmittedBA->bValid) {
+ if (pAdmittedBA->b_valid) {
netdev_dbg(ieee->dev, "%s(): ADDBA response already admitted\n",
__func__);
return -1;
- } else if (!pPendingBA->bValid ||
- (*pDialogToken != pPendingBA->DialogToken)) {
+ } else if (!pPendingBA->b_valid ||
+ (*pDialogToken != pPendingBA->dialog_token)) {
netdev_warn(ieee->dev,
"%s(): ADDBA Rsp. BA invalid, DELBA!\n",
__func__);
@@ -377,7 +377,7 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb)
if (*pStatusCode == ADDBA_STATUS_SUCCESS) {
- if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) {
+ if (pBaParamSet->field.ba_policy == BA_POLICY_DELAYED) {
pTS->bAddBaReqDelayed = true;
DeActivateBAEntry(ieee, pAdmittedBA);
ReasonCode = DELBA_REASON_END_BA;
@@ -385,10 +385,10 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb)
}
- pAdmittedBA->DialogToken = *pDialogToken;
- pAdmittedBA->BaTimeoutValue = *pBaTimeoutVal;
- pAdmittedBA->BaStartSeqCtrl = pPendingBA->BaStartSeqCtrl;
- pAdmittedBA->BaParamSet = *pBaParamSet;
+ pAdmittedBA->dialog_token = *pDialogToken;
+ pAdmittedBA->ba_timeout_value = *pBaTimeoutVal;
+ pAdmittedBA->ba_start_seq_ctrl = pPendingBA->ba_start_seq_ctrl;
+ pAdmittedBA->ba_param_set = *pBaParamSet;
DeActivateBAEntry(ieee, pAdmittedBA);
ActivateBAEntry(ieee, pAdmittedBA, *pBaTimeoutVal);
} else {
@@ -404,7 +404,7 @@ OnADDBARsp_Reject:
{
struct ba_record BA;
- BA.BaParamSet = *pBaParamSet;
+ BA.ba_param_set = *pBaParamSet;
rtllib_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode);
return 0;
}
@@ -440,15 +440,15 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb)
dst = (u8 *)(&delba->addr2[0]);
pDelBaParamSet = (union delba_param_set *)&delba->payload[2];
- if (pDelBaParamSet->field.Initiator == 1) {
+ if (pDelBaParamSet->field.initiator == 1) {
struct rx_ts_record *pRxTs;
if (!GetTs(ieee, (struct ts_common_info **)&pRxTs, dst,
- (u8)pDelBaParamSet->field.TID, RX_DIR, false)) {
+ (u8)pDelBaParamSet->field.tid, RX_DIR, false)) {
netdev_warn(ieee->dev,
"%s(): can't get TS for RXTS. dst:%pM TID:%d\n",
__func__, dst,
- (u8)pDelBaParamSet->field.TID);
+ (u8)pDelBaParamSet->field.tid);
return -1;
}
@@ -457,7 +457,7 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb)
struct tx_ts_record *pTxTs;
if (!GetTs(ieee, (struct ts_common_info **)&pTxTs, dst,
- (u8)pDelBaParamSet->field.TID, TX_DIR, false)) {
+ (u8)pDelBaParamSet->field.tid, TX_DIR, false)) {
netdev_warn(ieee->dev, "%s(): can't get TS for TXTS\n",
__func__);
return -1;
@@ -477,19 +477,18 @@ void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS,
{
struct ba_record *pBA = &pTS->TxPendingBARecord;
- if (pBA->bValid && !bOverwritePending)
+ if (pBA->b_valid && !bOverwritePending)
return;
DeActivateBAEntry(ieee, pBA);
- pBA->DialogToken++;
- pBA->BaParamSet.field.AMSDU_Support = 0;
- pBA->BaParamSet.field.BAPolicy = Policy;
- pBA->BaParamSet.field.TID =
- pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID;
- pBA->BaParamSet.field.BufferSize = 32;
- pBA->BaTimeoutValue = 0;
- pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096;
+ pBA->dialog_token++;
+ pBA->ba_param_set.field.amsdu_support = 0;
+ pBA->ba_param_set.field.ba_policy = Policy;
+ pBA->ba_param_set.field.tid = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID;
+ pBA->ba_param_set.field.buffer_size = 32;
+ pBA->ba_timeout_value = 0;
+ pBA->ba_start_seq_ctrl.field.seq_num = (pTS->TxCurSeq + 3) % 4096;
ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT);
@@ -506,7 +505,7 @@ void TsInitDelBA(struct rtllib_device *ieee,
if (TxTsDeleteBA(ieee, pTxTs))
rtllib_send_DELBA(ieee, pTsCommonInfo->Addr,
- (pTxTs->TxAdmittedBARecord.bValid) ?
+ (pTxTs->TxAdmittedBARecord.b_valid) ?
(&pTxTs->TxAdmittedBARecord) :
(&pTxTs->TxPendingBARecord),
TxRxSelect, DELBA_REASON_END_BA);
@@ -515,7 +514,7 @@ void TsInitDelBA(struct rtllib_device *ieee,
(struct rx_ts_record *)pTsCommonInfo;
if (RxTsDeleteBA(ieee, pRxTs))
rtllib_send_DELBA(ieee, pTsCommonInfo->Addr,
- &pRxTs->RxAdmittedBARecord,
+ &pRxTs->rx_admitted_ba_record,
TxRxSelect, DELBA_REASON_END_BA);
}
}
@@ -523,17 +522,17 @@ void TsInitDelBA(struct rtllib_device *ieee,
void BaSetupTimeOut(struct timer_list *t)
{
struct tx_ts_record *pTxTs = from_timer(pTxTs, t,
- TxPendingBARecord.Timer);
+ TxPendingBARecord.timer);
pTxTs->bAddBaReqInProgress = false;
pTxTs->bAddBaReqDelayed = true;
- pTxTs->TxPendingBARecord.bValid = false;
+ pTxTs->TxPendingBARecord.b_valid = false;
}
void TxBaInactTimeout(struct timer_list *t)
{
struct tx_ts_record *pTxTs = from_timer(pTxTs, t,
- TxAdmittedBARecord.Timer);
+ TxAdmittedBARecord.timer);
struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device,
TxTsRecord[pTxTs->num]);
TxTsDeleteBA(ieee, pTxTs);
@@ -545,12 +544,12 @@ void TxBaInactTimeout(struct timer_list *t)
void RxBaInactTimeout(struct timer_list *t)
{
struct rx_ts_record *pRxTs = from_timer(pRxTs, t,
- RxAdmittedBARecord.Timer);
+ rx_admitted_ba_record.timer);
struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device,
RxTsRecord[pRxTs->num]);
RxTsDeleteBA(ieee, pRxTs);
- rtllib_send_DELBA(ieee, pRxTs->TsCommonInfo.Addr,
- &pRxTs->RxAdmittedBARecord, RX_DIR,
+ rtllib_send_DELBA(ieee, pRxTs->ts_common_info.Addr,
+ &pRxTs->rx_admitted_ba_record, RX_DIR,
DELBA_REASON_TIMEOUT);
}
diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h
index 11269fe6b395..ce13b41074a7 100644
--- a/drivers/staging/rtl8192e/rtl819x_HT.h
+++ b/drivers/staging/rtl8192e/rtl819x_HT.h
@@ -179,21 +179,20 @@ struct rt_hi_throughput {
} __packed;
struct bss_ht {
+ u8 bd_support_ht;
- u8 bdSupportHT;
+ u8 bd_ht_cap_buf[32];
+ u16 bd_ht_cap_len;
+ u8 bd_ht_info_buf[32];
+ u16 bd_ht_info_len;
- u8 bdHTCapBuf[32];
- u16 bdHTCapLen;
- u8 bdHTInfoBuf[32];
- u16 bdHTInfoLen;
+ enum ht_spec_ver bd_ht_spec_ver;
+ enum ht_channel_width bd_bandwidth;
- enum ht_spec_ver bdHTSpecVer;
- enum ht_channel_width bdBandWidth;
-
- u8 bdRT2RTAggregation;
- u8 bdRT2RTLongSlotTime;
- u8 RT2RT_HT_Mode;
- u8 bdHT1R;
+ u8 bd_rt2rt_aggregation;
+ u8 bd_rt2rt_long_slot_time;
+ u8 rt2rt_ht_mode;
+ u8 bd_ht_1r;
};
extern u8 MCS_FILTER_ALL[16];
diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 9377e48c3f32..48d28c7d870b 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -138,7 +138,7 @@ u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate)
is40MHz = 1;
isShortGI = 1;
}
- return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf];
+ return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate & 0xf];
}
bool IsHTHalfNmodeAPs(struct rtllib_device *ieee)
@@ -158,7 +158,7 @@ bool IsHTHalfNmodeAPs(struct rtllib_device *ieee)
!memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ||
(net->broadcom_cap_exist))
retValue = true;
- else if (net->bssht.bdRT2RTAggregation)
+ else if (net->bssht.bd_rt2rt_aggregation)
retValue = true;
else
retValue = false;
@@ -171,11 +171,11 @@ static void HTIOTPeerDetermine(struct rtllib_device *ieee)
struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
struct rtllib_network *net = &ieee->current_network;
- if (net->bssht.bdRT2RTAggregation) {
+ if (net->bssht.bd_rt2rt_aggregation) {
pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK;
- if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE)
+ if (net->bssht.rt2rt_ht_mode & RT_HT_CAP_USE_92SE)
pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK_92SE;
- if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_SOFTAP)
+ if (net->bssht.rt2rt_ht_mode & RT_HT_CAP_USE_SOFTAP)
pHTInfo->IOTPeer = HT_IOT_PEER_92U_SOFTAP;
} else if (net->broadcom_cap_exist) {
pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
@@ -214,7 +214,6 @@ static u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr)
return 0;
}
-
static bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee)
{
return false;
@@ -236,7 +235,6 @@ static u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee,
{
u8 retValue = 0;
-
if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM)
retValue = 1;
@@ -263,7 +261,6 @@ static void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss)
if (pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE)
pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_TX_AMSDU;
-
}
void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo)
@@ -316,7 +313,6 @@ void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap,
pCapELE->PSMP = 0;
pCapELE->LSigTxopProtect = 0;
-
netdev_dbg(ieee->dev,
"TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n",
pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
@@ -391,7 +387,6 @@ void HTConstructInfoElement(struct rtllib_device *ieee, u8 *posHTInfo,
memset(pHTInfoEle->BasicMSC, 0, 16);
-
*len = 22 + 2;
} else {
@@ -445,7 +440,6 @@ static u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS)
break;
default:
break;
-
}
return true;
@@ -479,8 +473,8 @@ u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
if (availableMcsRate[i] != 0) {
bitMap = availableMcsRate[i];
for (j = 0; j < 8; j++) {
- if ((bitMap%2) != 0) {
- if (HTMcsToDataRate(ieee, (8*i+j)) >
+ if ((bitMap % 2) != 0) {
+ if (HTMcsToDataRate(ieee, (8 * i + j)) >
HTMcsToDataRate(ieee, mcsRate))
mcsRate = 8 * i + j;
}
@@ -494,7 +488,6 @@ u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
static u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS,
u8 *pOperateMCS)
{
-
u8 i;
for (i = 0; i <= 15; i++)
@@ -544,7 +537,6 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
else
pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf);
-
#ifdef VERBOSE_DEBUG
print_hex_dump_bytes("%s: ", __func__, DUMP_PREFIX_NONE,
pPeerHTCap, sizeof(struct ht_capab_ele));
@@ -565,7 +557,6 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
((pPeerHTCap->DssCCk == 1) ? true :
false) : false);
-
pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize == 0) ? 3839 : 7935;
@@ -577,7 +568,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
if (ieee->rtllib_ap_sec_type &&
- (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))) {
+ (ieee->rtllib_ap_sec_type(ieee) & (SEC_ALG_WEP | SEC_ALG_TKIP))) {
if ((pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) ||
(pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN))
pHTInfo->bCurrentAMPDUEnable = false;
@@ -591,7 +582,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
} else {
- if (ieee->current_network.bssht.bdRT2RTAggregation) {
+ if (ieee->current_network.bssht.bd_rt2rt_aggregation) {
if (ieee->pairwise_key_type != KEY_TYPE_NA)
pHTInfo->CurrentAMPDUFactor =
pPeerHTCap->MaxRxAMPDUFactor;
@@ -639,7 +630,6 @@ void HTInitializeHTInfo(struct rtllib_device *ieee)
{
struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
- netdev_vdbg(ieee->dev, "%s()\n", __func__);
pHTInfo->bCurrentHTSupport = false;
pHTInfo->bCurBW40MHz = false;
@@ -688,18 +678,17 @@ void HTInitializeHTInfo(struct rtllib_device *ieee)
void HTInitializeBssDesc(struct bss_ht *pBssHT)
{
+ pBssHT->bd_support_ht = false;
+ memset(pBssHT->bd_ht_cap_buf, 0, sizeof(pBssHT->bd_ht_cap_buf));
+ pBssHT->bd_ht_cap_len = 0;
+ memset(pBssHT->bd_ht_info_buf, 0, sizeof(pBssHT->bd_ht_info_buf));
+ pBssHT->bd_ht_info_len = 0;
- pBssHT->bdSupportHT = false;
- memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf));
- pBssHT->bdHTCapLen = 0;
- memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf));
- pBssHT->bdHTInfoLen = 0;
+ pBssHT->bd_ht_spec_ver = HT_SPEC_VER_IEEE;
- pBssHT->bdHTSpecVer = HT_SPEC_VER_IEEE;
-
- pBssHT->bdRT2RTAggregation = false;
- pBssHT->bdRT2RTLongSlotTime = false;
- pBssHT->RT2RT_HT_Mode = (enum rt_ht_capability)0;
+ pBssHT->bd_rt2rt_aggregation = false;
+ pBssHT->bd_rt2rt_long_slot_time = false;
+ pBssHT->rt2rt_ht_mode = (enum rt_ht_capability)0;
}
void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
@@ -708,33 +697,32 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
u8 bIOTAction = 0;
- netdev_vdbg(ieee->dev, "%s()\n", __func__);
/* unmark bEnableHT flag here is the same reason why unmarked in
* function rtllib_softmac_new_net. WB 2008.09.10
*/
- if (pNetwork->bssht.bdSupportHT) {
+ if (pNetwork->bssht.bd_support_ht) {
pHTInfo->bCurrentHTSupport = true;
- pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer;
+ pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bd_ht_spec_ver;
- if (pNetwork->bssht.bdHTCapLen > 0 &&
- pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
+ if (pNetwork->bssht.bd_ht_cap_len > 0 &&
+ pNetwork->bssht.bd_ht_cap_len <= sizeof(pHTInfo->PeerHTCapBuf))
memcpy(pHTInfo->PeerHTCapBuf,
- pNetwork->bssht.bdHTCapBuf,
- pNetwork->bssht.bdHTCapLen);
+ pNetwork->bssht.bd_ht_cap_buf,
+ pNetwork->bssht.bd_ht_cap_len);
- if (pNetwork->bssht.bdHTInfoLen > 0 &&
- pNetwork->bssht.bdHTInfoLen <=
+ if (pNetwork->bssht.bd_ht_info_len > 0 &&
+ pNetwork->bssht.bd_ht_info_len <=
sizeof(pHTInfo->PeerHTInfoBuf))
memcpy(pHTInfo->PeerHTInfoBuf,
- pNetwork->bssht.bdHTInfoBuf,
- pNetwork->bssht.bdHTInfoLen);
+ pNetwork->bssht.bd_ht_info_buf,
+ pNetwork->bssht.bd_ht_info_len);
if (pHTInfo->bRegRT2RTAggregation) {
pHTInfo->bCurrentRT2RTAggregation =
- pNetwork->bssht.bdRT2RTAggregation;
+ pNetwork->bssht.bd_rt2rt_aggregation;
pHTInfo->bCurrentRT2RTLongSlotTime =
- pNetwork->bssht.bdRT2RTLongSlotTime;
- pHTInfo->RT2RT_HT_Mode = pNetwork->bssht.RT2RT_HT_Mode;
+ pNetwork->bssht.bd_rt2rt_long_slot_time;
+ pHTInfo->RT2RT_HT_Mode = pNetwork->bssht.rt2rt_ht_mode;
} else {
pHTInfo->bCurrentRT2RTAggregation = false;
pHTInfo->bCurrentRT2RTLongSlotTime = false;
@@ -756,7 +744,6 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
if (bIOTAction)
pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS;
-
bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
if (bIOTAction)
pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
@@ -783,10 +770,10 @@ void HT_update_self_and_peer_setting(struct rtllib_device *ieee,
{
struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
struct ht_info_ele *pPeerHTInfo =
- (struct ht_info_ele *)pNetwork->bssht.bdHTInfoBuf;
+ (struct ht_info_ele *)pNetwork->bssht.bd_ht_info_buf;
if (pHTInfo->bCurrentHTSupport) {
- if (pNetwork->bssht.bdHTInfoLen != 0)
+ if (pNetwork->bssht.bd_ht_info_len != 0)
pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
}
}
@@ -843,8 +830,6 @@ static void HTSetConnectBwModeCallback(struct rtllib_device *ieee)
{
struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
- netdev_vdbg(ieee->dev, "%s()\n", __func__);
-
if (pHTInfo->bCurBW40MHz) {
if (pHTInfo->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_UPPER)
ieee->set_chan(ieee->dev,
diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h
index 9dc93d41939d..4aa9b12a2dd5 100644
--- a/drivers/staging/rtl8192e/rtl819x_TS.h
+++ b/drivers/staging/rtl8192e/rtl819x_TS.h
@@ -42,15 +42,15 @@ struct tx_ts_record {
};
struct rx_ts_record {
- struct ts_common_info TsCommonInfo;
- u16 RxIndicateSeq;
- u16 RxTimeoutIndicateSeq;
- struct list_head RxPendingPktList;
- struct timer_list RxPktPendingTimer;
- struct ba_record RxAdmittedBARecord;
- u16 RxLastSeqNum;
- u8 RxLastFragNum;
- u8 num;
+ struct ts_common_info ts_common_info;
+ u16 rx_indicate_seq;
+ u16 rx_timeout_indicate_seq;
+ struct list_head rx_pending_pkt_list;
+ struct timer_list rx_pkt_pending_timer;
+ struct ba_record rx_admitted_ba_record;
+ u16 rx_last_seq_num;
+ u8 rx_last_frag_num;
+ u8 num;
};
diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c
index 47b2669a3a8e..34b00a76b6bd 100644
--- a/drivers/staging/rtl8192e/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c
@@ -19,7 +19,7 @@ static void TsInactTimeout(struct timer_list *unused)
static void RxPktPendingTimeout(struct timer_list *t)
{
struct rx_ts_record *pRxTs = from_timer(pRxTs, t,
- RxPktPendingTimer);
+ rx_pkt_pending_timer);
struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device,
RxTsRecord[pRxTs->num]);
@@ -30,24 +30,24 @@ static void RxPktPendingTimeout(struct timer_list *t)
bool bPktInBuf = false;
spin_lock_irqsave(&(ieee->reorder_spinlock), flags);
- if (pRxTs->RxTimeoutIndicateSeq != 0xffff) {
- while (!list_empty(&pRxTs->RxPendingPktList)) {
+ if (pRxTs->rx_timeout_indicate_seq != 0xffff) {
+ while (!list_empty(&pRxTs->rx_pending_pkt_list)) {
pReorderEntry = (struct rx_reorder_entry *)
- list_entry(pRxTs->RxPendingPktList.prev,
+ list_entry(pRxTs->rx_pending_pkt_list.prev,
struct rx_reorder_entry, List);
if (index == 0)
- pRxTs->RxIndicateSeq = pReorderEntry->SeqNum;
+ pRxTs->rx_indicate_seq = pReorderEntry->SeqNum;
if (SN_LESS(pReorderEntry->SeqNum,
- pRxTs->RxIndicateSeq) ||
+ pRxTs->rx_indicate_seq) ||
SN_EQUAL(pReorderEntry->SeqNum,
- pRxTs->RxIndicateSeq)) {
+ pRxTs->rx_indicate_seq)) {
list_del_init(&pReorderEntry->List);
if (SN_EQUAL(pReorderEntry->SeqNum,
- pRxTs->RxIndicateSeq))
- pRxTs->RxIndicateSeq =
- (pRxTs->RxIndicateSeq + 1) % 4096;
+ pRxTs->rx_indicate_seq))
+ pRxTs->rx_indicate_seq =
+ (pRxTs->rx_indicate_seq + 1) % 4096;
netdev_dbg(ieee->dev,
"%s(): Indicate SeqNum: %d\n",
@@ -66,7 +66,7 @@ static void RxPktPendingTimeout(struct timer_list *t)
}
if (index > 0) {
- pRxTs->RxTimeoutIndicateSeq = 0xffff;
+ pRxTs->rx_timeout_indicate_seq = 0xffff;
if (index > REORDER_WIN_SIZE) {
netdev_warn(ieee->dev,
@@ -80,9 +80,9 @@ static void RxPktPendingTimeout(struct timer_list *t)
bPktInBuf = false;
}
- if (bPktInBuf && (pRxTs->RxTimeoutIndicateSeq == 0xffff)) {
- pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq;
- mod_timer(&pRxTs->RxPktPendingTimer, jiffies +
+ if (bPktInBuf && (pRxTs->rx_timeout_indicate_seq == 0xffff)) {
+ pRxTs->rx_timeout_indicate_seq = pRxTs->rx_indicate_seq;
+ mod_timer(&pRxTs->rx_pkt_pending_timer, jiffies +
msecs_to_jiffies(ieee->pHTInfo->RxReorderPendingTime)
);
}
@@ -104,7 +104,7 @@ static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo)
{
eth_zero_addr(pTsCommonInfo->Addr);
memset(&pTsCommonInfo->TSpec, 0, sizeof(union tspec_body));
- memset(&pTsCommonInfo->TClass, 0, sizeof(union qos_tclas)*TCLAS_NUM);
+ memset(&pTsCommonInfo->TClass, 0, sizeof(union qos_tclas) * TCLAS_NUM);
pTsCommonInfo->TClasProc = 0;
pTsCommonInfo->TClasNum = 0;
}
@@ -123,10 +123,10 @@ static void ResetTxTsEntry(struct tx_ts_record *pTS)
static void ResetRxTsEntry(struct rx_ts_record *pTS)
{
- ResetTsCommonInfo(&pTS->TsCommonInfo);
- pTS->RxIndicateSeq = 0xffff;
- pTS->RxTimeoutIndicateSeq = 0xffff;
- ResetBaEntry(&pTS->RxAdmittedBARecord);
+ ResetTsCommonInfo(&pTS->ts_common_info);
+ pTS->rx_indicate_seq = 0xffff;
+ pTS->rx_timeout_indicate_seq = 0xffff;
+ ResetBaEntry(&pTS->rx_admitted_ba_record);
}
void TSInitialize(struct rtllib_device *ieee)
@@ -136,7 +136,6 @@ void TSInitialize(struct rtllib_device *ieee)
struct rx_reorder_entry *pRxReorderEntry = ieee->RxReorderEntry;
u8 count = 0;
- netdev_vdbg(ieee->dev, "%s()\n", __func__);
INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List);
INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List);
INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List);
@@ -151,9 +150,9 @@ void TSInitialize(struct rtllib_device *ieee)
timer_setup(&pTxTS->TsAddBaTimer, TsAddBaProcess, 0);
- timer_setup(&pTxTS->TxPendingBARecord.Timer, BaSetupTimeOut,
+ timer_setup(&pTxTS->TxPendingBARecord.timer, BaSetupTimeOut,
0);
- timer_setup(&pTxTS->TxAdmittedBARecord.Timer,
+ timer_setup(&pTxTS->TxAdmittedBARecord.timer,
TxBaInactTimeout, 0);
ResetTxTsEntry(pTxTS);
@@ -167,21 +166,21 @@ void TSInitialize(struct rtllib_device *ieee)
INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List);
for (count = 0; count < TOTAL_TS_NUM; count++) {
pRxTS->num = count;
- INIT_LIST_HEAD(&pRxTS->RxPendingPktList);
+ INIT_LIST_HEAD(&pRxTS->rx_pending_pkt_list);
- timer_setup(&pRxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut,
+ timer_setup(&pRxTS->ts_common_info.SetupTimer, TsSetupTimeOut,
0);
- timer_setup(&pRxTS->TsCommonInfo.InactTimer, TsInactTimeout,
+ timer_setup(&pRxTS->ts_common_info.InactTimer, TsInactTimeout,
0);
- timer_setup(&pRxTS->RxAdmittedBARecord.Timer,
+ timer_setup(&pRxTS->rx_admitted_ba_record.timer,
RxBaInactTimeout, 0);
- timer_setup(&pRxTS->RxPktPendingTimer, RxPktPendingTimeout, 0);
+ timer_setup(&pRxTS->rx_pkt_pending_timer, RxPktPendingTimeout, 0);
ResetRxTsEntry(pRxTS);
- list_add_tail(&pRxTS->TsCommonInfo.List,
+ list_add_tail(&pRxTS->ts_common_info.List,
&ieee->Rx_TS_Unused_List);
pRxTS++;
}
@@ -189,11 +188,10 @@ void TSInitialize(struct rtllib_device *ieee)
for (count = 0; count < REORDER_ENTRY_NUM; count++) {
list_add_tail(&pRxReorderEntry->List,
&ieee->RxReorder_Unused_List);
- if (count == (REORDER_ENTRY_NUM-1))
+ if (count == (REORDER_ENTRY_NUM - 1))
break;
- pRxReorderEntry = &ieee->RxReorderEntry[count+1];
+ pRxReorderEntry = &ieee->RxReorderEntry[count + 1];
}
-
}
static void AdmitTS(struct rtllib_device *ieee,
@@ -254,7 +252,6 @@ static struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee,
pRet->TSpec.f.TSInfo.field.ucTSID == TID &&
pRet->TSpec.f.TSInfo.field.ucDirection == dir)
break;
-
}
if (&pRet->List != psearch_list)
break;
@@ -271,12 +268,12 @@ static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr,
{
u8 count;
- if (pTsCommonInfo == NULL)
+ if (!pTsCommonInfo)
return;
memcpy(pTsCommonInfo->Addr, Addr, 6);
- if (pTSPEC != NULL)
+ if (pTSPEC)
memcpy((u8 *)(&(pTsCommonInfo->TSpec)), (u8 *)pTSPEC,
sizeof(union tspec_body));
@@ -330,7 +327,7 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
}
*ppTS = SearchAdmitTRStream(ieee, Addr, UP, TxRxSelect);
- if (*ppTS != NULL)
+ if (*ppTS)
return true;
if (!bAddNewTs) {
@@ -364,7 +361,7 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
struct rx_ts_record *tmp =
container_of(*ppTS,
struct rx_ts_record,
- TsCommonInfo);
+ ts_common_info);
ResetRxTsEntry(tmp);
}
@@ -405,12 +402,12 @@ static void RemoveTsEntry(struct rtllib_device *ieee,
struct rx_reorder_entry *pRxReorderEntry;
struct rx_ts_record *pRxTS = (struct rx_ts_record *)pTs;
- if (timer_pending(&pRxTS->RxPktPendingTimer))
- del_timer_sync(&pRxTS->RxPktPendingTimer);
+ if (timer_pending(&pRxTS->rx_pkt_pending_timer))
+ del_timer_sync(&pRxTS->rx_pkt_pending_timer);
- while (!list_empty(&pRxTS->RxPendingPktList)) {
+ while (!list_empty(&pRxTS->rx_pending_pkt_list)) {
pRxReorderEntry = (struct rx_reorder_entry *)
- list_entry(pRxTS->RxPendingPktList.prev,
+ list_entry(pRxTS->rx_pending_pkt_list.prev,
struct rx_reorder_entry, List);
netdev_dbg(ieee->dev, "%s(): Delete SeqNum %d!\n",
__func__, pRxReorderEntry->SeqNum);
@@ -518,7 +515,7 @@ void TsStartAddBaProcess(struct rtllib_device *ieee, struct tx_ts_record *pTxTS)
msecs_to_jiffies(TS_ADDBA_DELAY));
} else {
netdev_dbg(ieee->dev, "Immediately Start ADDBA\n");
- mod_timer(&pTxTS->TsAddBaTimer, jiffies+10);
+ mod_timer(&pTxTS->TsAddBaTimer, jiffies + 10);
}
} else
netdev_dbg(ieee->dev, "BA timer is already added\n");
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index 238387d6221b..4a760ecbc31e 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -291,7 +291,7 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak,
tkey->tx_iv16);
} else
- tkey->tx_phase1_done = 1;
+ tkey->tx_phase1_done = 1;
len = skb->len - hdr_len;
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 15bbb63ca130..6e48b31a9afc 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -449,9 +449,9 @@ drop:
static bool AddReorderEntry(struct rx_ts_record *pTS,
struct rx_reorder_entry *pReorderEntry)
{
- struct list_head *pList = &pTS->RxPendingPktList;
+ struct list_head *pList = &pTS->rx_pending_pkt_list;
- while (pList->next != &pTS->RxPendingPktList) {
+ while (pList->next != &pTS->rx_pending_pkt_list) {
if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)
list_entry(pList->next, struct rx_reorder_entry,
List))->SeqNum))
@@ -536,8 +536,8 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
struct rx_reorder_entry *pRxReorderEntry;
u8 RfdCnt = 0;
- del_timer_sync(&pTS->RxPktPendingTimer);
- while (!list_empty(&pTS->RxPendingPktList)) {
+ del_timer_sync(&pTS->rx_pkt_pending_timer);
+ while (!list_empty(&pTS->rx_pending_pkt_list)) {
if (RfdCnt >= REORDER_WIN_SIZE) {
netdev_info(ieee->dev,
"-------------->%s() error! RfdCnt >= REORDER_WIN_SIZE\n",
@@ -546,7 +546,7 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
}
pRxReorderEntry = (struct rx_reorder_entry *)
- list_entry(pTS->RxPendingPktList.prev,
+ list_entry(pTS->rx_pending_pkt_list.prev,
struct rx_reorder_entry, List);
netdev_dbg(ieee->dev, "%s(): Indicate SeqNum %d!\n", __func__,
pRxReorderEntry->SeqNum);
@@ -560,7 +560,7 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
}
rtllib_indicate_packets(ieee, ieee->RfdArray, RfdCnt);
- pTS->RxIndicateSeq = 0xffff;
+ pTS->rx_indicate_seq = 0xffff;
}
static void RxReorderIndicatePacket(struct rtllib_device *ieee,
@@ -576,21 +576,21 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
unsigned long flags;
netdev_dbg(ieee->dev,
- "%s(): Seq is %d, pTS->RxIndicateSeq is %d, WinSize is %d\n",
- __func__, SeqNum, pTS->RxIndicateSeq, WinSize);
+ "%s(): Seq is %d, pTS->rx_indicate_seq is %d, WinSize is %d\n",
+ __func__, SeqNum, pTS->rx_indicate_seq, WinSize);
spin_lock_irqsave(&(ieee->reorder_spinlock), flags);
- WinEnd = (pTS->RxIndicateSeq + WinSize - 1) % 4096;
+ WinEnd = (pTS->rx_indicate_seq + WinSize - 1) % 4096;
/* Rx Reorder initialize condition.*/
- if (pTS->RxIndicateSeq == 0xffff)
- pTS->RxIndicateSeq = SeqNum;
+ if (pTS->rx_indicate_seq == 0xffff)
+ pTS->rx_indicate_seq = SeqNum;
/* Drop out the packet which SeqNum is smaller than WinStart */
- if (SN_LESS(SeqNum, pTS->RxIndicateSeq)) {
+ if (SN_LESS(SeqNum, pTS->rx_indicate_seq)) {
netdev_dbg(ieee->dev,
"Packet Drop! IndicateSeq: %d, NewSeq: %d\n",
- pTS->RxIndicateSeq, SeqNum);
+ pTS->rx_indicate_seq, SeqNum);
pHTInfo->RxReorderDropCounter++;
{
int i;
@@ -608,18 +608,18 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
* 1. Incoming SeqNum is equal to WinStart =>Window shift 1
* 2. Incoming SeqNum is larger than the WinEnd => Window shift N
*/
- if (SN_EQUAL(SeqNum, pTS->RxIndicateSeq)) {
- pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096;
+ if (SN_EQUAL(SeqNum, pTS->rx_indicate_seq)) {
+ pTS->rx_indicate_seq = (pTS->rx_indicate_seq + 1) % 4096;
bMatchWinStart = true;
} else if (SN_LESS(WinEnd, SeqNum)) {
if (SeqNum >= (WinSize - 1))
- pTS->RxIndicateSeq = SeqNum + 1 - WinSize;
+ pTS->rx_indicate_seq = SeqNum + 1 - WinSize;
else
- pTS->RxIndicateSeq = 4095 -
+ pTS->rx_indicate_seq = 4095 -
(WinSize - (SeqNum + 1)) + 1;
netdev_dbg(ieee->dev,
"Window Shift! IndicateSeq: %d, NewSeq: %d\n",
- pTS->RxIndicateSeq, SeqNum);
+ pTS->rx_indicate_seq, SeqNum);
}
/* Indication process.
@@ -636,7 +636,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
/* Current packet is going to be indicated.*/
netdev_dbg(ieee->dev,
"Packets indication! IndicateSeq: %d, NewSeq: %d\n",
- pTS->RxIndicateSeq, SeqNum);
+ pTS->rx_indicate_seq, SeqNum);
ieee->prxbIndicateArray[0] = prxb;
index = 1;
} else {
@@ -658,7 +658,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
netdev_dbg(ieee->dev,
"%s(): Duplicate packet is dropped. IndicateSeq: %d, NewSeq: %d\n",
- __func__, pTS->RxIndicateSeq,
+ __func__, pTS->rx_indicate_seq,
SeqNum);
list_add_tail(&pReorderEntry->List,
&ieee->RxReorder_Unused_List);
@@ -670,7 +670,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
} else {
netdev_dbg(ieee->dev,
"Pkt insert into struct buffer. IndicateSeq: %d, NewSeq: %d\n",
- pTS->RxIndicateSeq, SeqNum);
+ pTS->rx_indicate_seq, SeqNum);
}
} else {
/* Packets are dropped if there are not enough reorder
@@ -693,16 +693,16 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
}
/* Check if there is any packet need indicate.*/
- while (!list_empty(&pTS->RxPendingPktList)) {
+ while (!list_empty(&pTS->rx_pending_pkt_list)) {
netdev_dbg(ieee->dev, "%s(): start RREORDER indicate\n",
__func__);
pReorderEntry = (struct rx_reorder_entry *)
- list_entry(pTS->RxPendingPktList.prev,
+ list_entry(pTS->rx_pending_pkt_list.prev,
struct rx_reorder_entry,
List);
- if (SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) ||
- SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) {
+ if (SN_LESS(pReorderEntry->SeqNum, pTS->rx_indicate_seq) ||
+ SN_EQUAL(pReorderEntry->SeqNum, pTS->rx_indicate_seq)) {
/* This protect struct buffer from overflow. */
if (index >= REORDER_WIN_SIZE) {
netdev_err(ieee->dev,
@@ -714,8 +714,8 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
list_del_init(&pReorderEntry->List);
- if (SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
- pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) %
+ if (SN_EQUAL(pReorderEntry->SeqNum, pTS->rx_indicate_seq))
+ pTS->rx_indicate_seq = (pTS->rx_indicate_seq + 1) %
4096;
ieee->prxbIndicateArray[index] = pReorderEntry->prxb;
@@ -735,9 +735,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
* Rx buffering.
*/
if (index > 0) {
- if (timer_pending(&pTS->RxPktPendingTimer))
- del_timer_sync(&pTS->RxPktPendingTimer);
- pTS->RxTimeoutIndicateSeq = 0xffff;
+ if (timer_pending(&pTS->rx_pkt_pending_timer))
+ del_timer_sync(&pTS->rx_pkt_pending_timer);
+ pTS->rx_timeout_indicate_seq = 0xffff;
if (index > REORDER_WIN_SIZE) {
netdev_err(ieee->dev,
@@ -751,10 +751,10 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
bPktInBuf = false;
}
- if (bPktInBuf && pTS->RxTimeoutIndicateSeq == 0xffff) {
+ if (bPktInBuf && pTS->rx_timeout_indicate_seq == 0xffff) {
netdev_dbg(ieee->dev, "%s(): SET rx timeout timer\n", __func__);
- pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq;
- mod_timer(&pTS->RxPktPendingTimer, jiffies +
+ pTS->rx_timeout_indicate_seq = pTS->rx_indicate_seq;
+ mod_timer(&pTS->rx_pkt_pending_timer, jiffies +
msecs_to_jiffies(pHTInfo->RxReorderPendingTime));
}
spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
@@ -938,11 +938,11 @@ static int rtllib_rx_check_duplicate(struct rtllib_device *ieee,
if (GetTs(ieee, (struct ts_common_info **) &pRxTS, hdr->addr2,
(u8)Frame_QoSTID((u8 *)(skb->data)), RX_DIR, true)) {
- if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) &&
- (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum))
+ if ((fc & (1<<11)) && (frag == pRxTS->rx_last_frag_num) &&
+ (WLAN_GET_SEQ_SEQ(sc) == pRxTS->rx_last_seq_num))
return -1;
- pRxTS->RxLastFragNum = frag;
- pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc);
+ pRxTS->rx_last_frag_num = frag;
+ pRxTS->rx_last_seq_num = WLAN_GET_SEQ_SEQ(sc);
} else {
netdev_warn(ieee->dev, "%s(): No TS! Skip the check!\n",
__func__);
@@ -1850,19 +1850,20 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
*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 = min_t(u16, *tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf));
- memcpy(network->bssht.bdHTCapBuf,
+ network->bssht.bd_ht_spec_ver = HT_SPEC_VER_EWC;
+ network->bssht.bd_ht_cap_len = min_t(u16, *tmp_htcap_len,
+ sizeof(network->bssht.bd_ht_cap_buf));
+ memcpy(network->bssht.bd_ht_cap_buf,
info_element->data,
- network->bssht.bdHTCapLen);
+ network->bssht.bd_ht_cap_len);
}
}
if (*tmp_htcap_len != 0) {
- network->bssht.bdSupportHT = true;
- network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
+ network->bssht.bd_support_ht = true;
+ network->bssht.bd_ht_1r = ((((struct ht_capab_ele *)(network->bssht.bd_ht_cap_buf))->MCS[1]) == 0);
} else {
- network->bssht.bdSupportHT = false;
- network->bssht.bdHT1R = false;
+ network->bssht.bd_support_ht = false;
+ network->bssht.bd_ht_1r = false;
}
}
@@ -1876,16 +1877,17 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
*tmp_htinfo_len = min_t(u8, info_element->len,
MAX_IE_LEN);
if (*tmp_htinfo_len != 0) {
- network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
- network->bssht.bdHTInfoLen = min_t(u16, *tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf));
- memcpy(network->bssht.bdHTInfoBuf,
+ network->bssht.bd_ht_spec_ver = HT_SPEC_VER_EWC;
+ network->bssht.bd_ht_info_len = min_t(u16, *tmp_htinfo_len,
+ sizeof(network->bssht.bd_ht_info_buf));
+ memcpy(network->bssht.bd_ht_info_buf,
info_element->data,
- network->bssht.bdHTInfoLen);
+ network->bssht.bd_ht_info_len);
}
}
}
- if (network->bssht.bdSupportHT) {
+ if (network->bssht.bd_support_ht) {
if (info_element->len >= 4 &&
info_element->data[0] == 0x00 &&
info_element->data[1] == 0xe0 &&
@@ -1898,20 +1900,20 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
}
if (ht_realtek_agg_len >= 5) {
network->realtek_cap_exit = true;
- network->bssht.bdRT2RTAggregation = true;
+ network->bssht.bd_rt2rt_aggregation = true;
if ((ht_realtek_agg_buf[4] == 1) &&
(ht_realtek_agg_buf[5] & 0x02))
- network->bssht.bdRT2RTLongSlotTime = true;
+ network->bssht.bd_rt2rt_long_slot_time = true;
if ((ht_realtek_agg_buf[4] == 1) &&
(ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE))
- network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE;
+ network->bssht.rt2rt_ht_mode |= RT_HT_CAP_USE_92SE;
}
}
if (ht_realtek_agg_len >= 5) {
if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP))
- network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP;
+ network->bssht.rt2rt_ht_mode |= RT_HT_CAP_USE_SOFTAP;
}
if ((info_element->len >= 3 &&
@@ -2020,22 +2022,22 @@ static void rtllib_parse_mfie_ht_cap(struct rtllib_info_element *info_element,
*tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
if (*tmp_htcap_len != 0) {
- ht->bdHTSpecVer = HT_SPEC_VER_EWC;
- ht->bdHTCapLen = min_t(u16, *tmp_htcap_len,
- sizeof(ht->bdHTCapBuf));
- memcpy(ht->bdHTCapBuf, info_element->data, ht->bdHTCapLen);
+ ht->bd_ht_spec_ver = HT_SPEC_VER_EWC;
+ ht->bd_ht_cap_len = min_t(u16, *tmp_htcap_len,
+ sizeof(ht->bd_ht_cap_buf));
+ memcpy(ht->bd_ht_cap_buf, info_element->data, ht->bd_ht_cap_len);
- ht->bdSupportHT = true;
- ht->bdHT1R = ((((struct ht_capab_ele *)
- ht->bdHTCapBuf))->MCS[1]) == 0;
+ ht->bd_support_ht = true;
+ ht->bd_ht_1r = ((((struct ht_capab_ele *)
+ ht->bd_ht_cap_buf))->MCS[1]) == 0;
- ht->bdBandWidth = (enum ht_channel_width)
+ ht->bd_bandwidth = (enum ht_channel_width)
(((struct ht_capab_ele *)
- (ht->bdHTCapBuf))->ChlWidth);
+ (ht->bd_ht_cap_buf))->ChlWidth);
} else {
- ht->bdSupportHT = false;
- ht->bdHT1R = false;
- ht->bdBandWidth = HT_CHANNEL_WIDTH_20;
+ ht->bd_support_ht = false;
+ ht->bd_ht_1r = false;
+ ht->bd_bandwidth = HT_CHANNEL_WIDTH_20;
}
}
@@ -2232,14 +2234,14 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
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 >
- sizeof(network->bssht.bdHTInfoBuf) ?
- sizeof(network->bssht.bdHTInfoBuf) :
+ network->bssht.bd_ht_spec_ver = HT_SPEC_VER_IEEE;
+ network->bssht.bd_ht_info_len = tmp_htinfo_len >
+ sizeof(network->bssht.bd_ht_info_buf) ?
+ sizeof(network->bssht.bd_ht_info_buf) :
tmp_htinfo_len;
- memcpy(network->bssht.bdHTInfoBuf,
+ memcpy(network->bssht.bd_ht_info_buf,
info_element->data,
- network->bssht.bdHTInfoLen);
+ network->bssht.bd_ht_info_len);
}
break;
@@ -2289,7 +2291,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
if (!network->atheros_cap_exist && !network->broadcom_cap_exist &&
!network->cisco_cap_exist && !network->ralink_cap_exist &&
- !network->bssht.bdRT2RTAggregation)
+ !network->bssht.bd_rt2rt_aggregation)
network->unknown_cap_exist = true;
else
network->unknown_cap_exist = false;
@@ -2380,7 +2382,7 @@ static inline int rtllib_network_init(
return 1;
}
- if (network->bssht.bdSupportHT) {
+ if (network->bssht.bd_support_ht) {
if (network->mode == IEEE_A)
network->mode = IEEE_N_5G;
else if (network->mode & (IEEE_G | IEEE_B))
@@ -2456,16 +2458,16 @@ static inline void update_network(struct rtllib_device *ieee,
dst->last_dtim_sta_time = src->last_dtim_sta_time;
memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters));
- dst->bssht.bdSupportHT = src->bssht.bdSupportHT;
- dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation;
- dst->bssht.bdHTCapLen = src->bssht.bdHTCapLen;
- memcpy(dst->bssht.bdHTCapBuf, src->bssht.bdHTCapBuf,
- src->bssht.bdHTCapLen);
- dst->bssht.bdHTInfoLen = src->bssht.bdHTInfoLen;
- memcpy(dst->bssht.bdHTInfoBuf, src->bssht.bdHTInfoBuf,
- src->bssht.bdHTInfoLen);
- dst->bssht.bdHTSpecVer = src->bssht.bdHTSpecVer;
- dst->bssht.bdRT2RTLongSlotTime = src->bssht.bdRT2RTLongSlotTime;
+ dst->bssht.bd_support_ht = src->bssht.bd_support_ht;
+ dst->bssht.bd_rt2rt_aggregation = src->bssht.bd_rt2rt_aggregation;
+ dst->bssht.bd_ht_cap_len = src->bssht.bd_ht_cap_len;
+ memcpy(dst->bssht.bd_ht_cap_buf, src->bssht.bd_ht_cap_buf,
+ src->bssht.bd_ht_cap_len);
+ dst->bssht.bd_ht_info_len = src->bssht.bd_ht_info_len;
+ memcpy(dst->bssht.bd_ht_info_buf, src->bssht.bd_ht_info_buf,
+ src->bssht.bd_ht_info_len);
+ dst->bssht.bd_ht_spec_ver = src->bssht.bd_ht_spec_ver;
+ dst->bssht.bd_rt2rt_long_slot_time = src->bssht.bd_rt2rt_long_slot_time;
dst->broadcom_cap_exist = src->broadcom_cap_exist;
dst->ralink_cap_exist = src->ralink_cap_exist;
dst->atheros_cap_exist = src->atheros_cap_exist;
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index 2d3be91b113d..f9a51f3620d2 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -1692,7 +1692,7 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee,
ieee->current_network.channel,
ieee->current_network.qos_data.supported,
ieee->pHTInfo->bEnableHT,
- ieee->current_network.bssht.bdSupportHT,
+ ieee->current_network.bssht.bd_support_ht,
ieee->current_network.mode,
ieee->current_network.flags);
@@ -1706,7 +1706,7 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee,
/* Join the network for the first time */
ieee->AsocRetryCount = 0;
if ((ieee->current_network.qos_data.supported == 1) &&
- ieee->current_network.bssht.bdSupportHT)
+ ieee->current_network.bssht.bd_support_ht)
HTResetSelfAndSavePeerSetting(ieee,
&(ieee->current_network));
else
@@ -2238,11 +2238,11 @@ rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb,
return 1;
}
memcpy(ieee->pHTInfo->PeerHTCapBuf,
- network->bssht.bdHTCapBuf,
- network->bssht.bdHTCapLen);
+ network->bssht.bd_ht_cap_buf,
+ network->bssht.bd_ht_cap_len);
memcpy(ieee->pHTInfo->PeerHTInfoBuf,
- network->bssht.bdHTInfoBuf,
- network->bssht.bdHTInfoLen);
+ network->bssht.bd_ht_info_buf,
+ network->bssht.bd_ht_info_len);
if (ieee->handle_assoc_response != NULL)
ieee->handle_assoc_response(ieee->dev,
(struct rtllib_assoc_response_frame *)header,
@@ -2443,7 +2443,7 @@ inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee,
* N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD
* 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.
+ * the driver later, when it wakes the queue.
*/
void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee)
{
diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c
index 8add17752eed..89ec72b1895a 100644
--- a/drivers/staging/rtl8192e/rtllib_tx.c
+++ b/drivers/staging/rtl8192e/rtllib_tx.c
@@ -297,7 +297,7 @@ static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee,
netdev_info(ieee->dev, "%s: can't get TS\n", __func__);
return;
}
- if (!pTxTs->TxAdmittedBARecord.bValid) {
+ if (!pTxTs->TxAdmittedBARecord.b_valid) {
if (ieee->wpa_ie_len && (ieee->pairwise_key_type ==
KEY_TYPE_NA)) {
;
@@ -308,7 +308,7 @@ static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee,
}
goto FORCED_AGG_SETTING;
} else if (!pTxTs->bUsingBa) {
- if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum,
+ if (SN_LESS(pTxTs->TxAdmittedBARecord.ba_start_seq_ctrl.field.seq_num,
(pTxTs->TxCurSeq+1)%4096))
pTxTs->bUsingBa = true;
else
@@ -339,7 +339,7 @@ FORCED_AGG_SETTING:
}
}
-static void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee,
+static void rtllib_query_ShortPreambleMode(struct rtllib_device *ieee,
struct cb_desc *tcb_desc)
{
tcb_desc->bUseShortPreamble = false;
@@ -928,7 +928,7 @@ static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
tcb_desc->bdhcp = 1;
}
- rtllib_qurey_ShortPreambleMode(ieee, tcb_desc);
+ rtllib_query_ShortPreambleMode(ieee, tcb_desc);
rtllib_tx_query_agg_cap(ieee, txb->fragments[0],
tcb_desc);
rtllib_query_HTCapShortGI(ieee, tcb_desc);
diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c
index 2e486ccb6432..ab1b8217c4e0 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -140,12 +140,12 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
bool is40M = false, isShortGI = false;
u8 max_mcs = 0;
- if (!memcmp(network->bssht.bdHTCapBuf, EWC11NHTCap, 4))
+ if (!memcmp(network->bssht.bd_ht_cap_buf, EWC11NHTCap, 4))
ht_cap = (struct ht_capab_ele *)
- &network->bssht.bdHTCapBuf[4];
+ &network->bssht.bd_ht_cap_buf[4];
else
ht_cap = (struct ht_capab_ele *)
- &network->bssht.bdHTCapBuf[0];
+ &network->bssht.bd_ht_cap_buf[0];
is40M = (ht_cap->ChlWidth) ? 1 : 0;
isShortGI = (ht_cap->ChlWidth) ?
((ht_cap->ShortGI40Mhz) ? 1 : 0) :
@@ -160,8 +160,7 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
iwe.cmd = SIOCGIWRATE;
iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
iwe.u.bitrate.value = max_rate * 500000;
- start = iwe_stream_add_event_rsl(info, start, stop, &iwe,
- IW_EV_PARAM_LEN);
+ start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_PARAM_LEN);
iwe.cmd = IWEVCUSTOM;
iwe.u.data.length = p - custom;
if (iwe.u.data.length)
@@ -181,15 +180,13 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
if (!(network->stats.mask & RTLLIB_STATMASK_SIGNAL))
iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID;
iwe.u.qual.updated = 7;
- start = iwe_stream_add_event_rsl(info, start, stop, &iwe,
- IW_EV_QUAL_LEN);
+ start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_QUAL_LEN);
iwe.cmd = IWEVCUSTOM;
p = custom;
iwe.u.data.length = p - custom;
if (iwe.u.data.length)
- start = iwe_stream_add_point_rsl(info, start, stop,
- &iwe, custom);
+ start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom);
memset(&iwe, 0, sizeof(iwe));
if (network->wpa_ie_len) {
@@ -238,8 +235,8 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
}
int rtllib_wx_get_scan(struct rtllib_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
struct rtllib_network *network;
unsigned long flags;
@@ -285,8 +282,8 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee,
EXPORT_SYMBOL(rtllib_wx_get_scan);
int rtllib_wx_set_encode(struct rtllib_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *keybuf)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *keybuf)
{
struct iw_point *erq = &(wrqu->encoding);
struct net_device *dev = ieee->dev;
@@ -324,11 +321,11 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
* 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 (ieee->crypt_info.crypt[i]) {
if (key_provided)
break;
lib80211_crypt_delayed_deinit(&ieee->crypt_info,
- &ieee->crypt_info.crypt[i]);
+ &ieee->crypt_info.crypt[i]);
}
}
@@ -344,7 +341,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
sec.enabled = 1;
sec.flags |= SEC_ENABLED;
- if (*crypt != NULL && (*crypt)->ops != NULL &&
+ if (*crypt && (*crypt)->ops &&
strcmp((*crypt)->ops->name, "R-WEP") != 0) {
/* changing to use WEP; deinit previously used algorithm
* on this key
@@ -352,12 +349,12 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);
}
- if (*crypt == NULL) {
+ if (!*crypt) {
struct lib80211_crypt_data *new_crypt;
/* take WEP into use */
new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL);
- if (new_crypt == NULL)
+ if (!new_crypt)
return -ENOMEM;
new_crypt->ops = lib80211_get_crypto_ops("R-WEP");
if (!new_crypt->ops) {
@@ -406,8 +403,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
NULL, (*crypt)->priv);
if (len == 0) {
/* Set a default key of all 0 */
- netdev_info(ieee->dev, "Setting key %d to all zero.\n",
- key);
+ netdev_info(ieee->dev, "Setting key %d to all zero.\n", key);
memset(sec.keys[key], 0, 13);
(*crypt)->ops->set_key(sec.keys[key], 13, NULL,
@@ -460,8 +456,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
EXPORT_SYMBOL(rtllib_wx_set_encode);
int rtllib_wx_get_encode(struct rtllib_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *keybuf)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *keybuf)
{
struct iw_point *erq = &(wrqu->encoding);
int len, key;
@@ -484,7 +480,7 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee,
erq->flags = key + 1;
- if (crypt == NULL || crypt->ops == NULL) {
+ if (!crypt || !crypt->ops) {
erq->length = 0;
erq->flags |= IW_ENCODE_DISABLED;
return 0;
@@ -505,8 +501,8 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee,
EXPORT_SYMBOL(rtllib_wx_get_encode);
int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
int ret = 0;
struct net_device *dev = ieee->dev;
@@ -549,7 +545,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);
for (i = 0; i < NUM_WEP_KEYS; i++) {
- if (ieee->crypt_info.crypt[i] != NULL)
+ if (ieee->crypt_info.crypt[i])
break;
}
if (i == NUM_WEP_KEYS) {
@@ -582,7 +578,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
netdev_dbg(dev, "alg name:%s\n", alg);
ops = lib80211_get_crypto_ops(alg);
- if (ops == NULL) {
+ if (!ops) {
char tempbuf[100];
memset(tempbuf, 0x00, 100);
@@ -590,19 +586,19 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
request_module("%s", tempbuf);
ops = lib80211_get_crypto_ops(alg);
}
- if (ops == NULL) {
+ if (!ops) {
netdev_info(dev, "========>unknown crypto alg %d\n", ext->alg);
ret = -EINVAL;
goto done;
}
- if (*crypt == NULL || (*crypt)->ops != ops) {
+ if (!*crypt || (*crypt)->ops != ops) {
struct lib80211_crypt_data *new_crypt;
lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);
new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL);
- if (new_crypt == NULL) {
+ if (!new_crypt) {
ret = -ENOMEM;
goto done;
}
@@ -610,7 +606,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
new_crypt->priv = new_crypt->ops->init(idx);
- if (new_crypt->priv == NULL) {
+ if (!new_crypt->priv) {
kfree(new_crypt);
ret = -EINVAL;
goto done;
@@ -663,8 +659,8 @@ done:
EXPORT_SYMBOL(rtllib_wx_set_encode_ext);
int rtllib_wx_set_mlme(struct rtllib_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
u8 i = 0;
bool deauth = false;
@@ -710,8 +706,8 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee,
EXPORT_SYMBOL(rtllib_wx_set_mlme);
int rtllib_wx_set_auth(struct rtllib_device *ieee,
- struct iw_request_info *info,
- struct iw_param *data, char *extra)
+ struct iw_request_info *info,
+ struct iw_param *data, char *extra)
{
switch (data->flags & IW_AUTH_INDEX) {
case IW_AUTH_WPA_VERSION:
@@ -766,17 +762,15 @@ int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len)
u8 *buf;
u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
- if (len > MAX_WPA_IE_LEN || (len && ie == NULL))
+ if (len > MAX_WPA_IE_LEN || (len && !ie))
return -EINVAL;
if (len) {
eid = ie[0];
- if ((eid == MFIE_TYPE_GENERIC) && (!memcmp(&ie[2],
- wps_oui, 4))) {
-
+ if ((eid == MFIE_TYPE_GENERIC) && (!memcmp(&ie[2], wps_oui, 4))) {
ieee->wps_ie_len = min_t(size_t, len, MAX_WZC_IE_LEN);
buf = kmemdup(ie, ieee->wps_ie_len, GFP_KERNEL);
- if (buf == NULL)
+ if (!buf)
return -ENOMEM;
ieee->wps_ie = buf;
return 0;
@@ -789,7 +783,7 @@ int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len)
if (len != ie[1]+2)
return -EINVAL;
buf = kmemdup(ie, len, GFP_KERNEL);
- if (buf == NULL)
+ if (!buf)
return -ENOMEM;
kfree(ieee->wpa_ie);
ieee->wpa_ie = buf;
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index b6fee7230ce0..b0e01ee65f7f 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -612,9 +612,9 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
pHTInfo->RxReorderDropCounter++;
{
int i;
- for (i = 0; i < prxb->nr_subframes; i++) {
+ for (i = 0; i < prxb->nr_subframes; i++)
dev_kfree_skb(prxb->subframes[i]);
- }
+
kfree(prxb);
prxb = NULL;
}
@@ -632,11 +632,11 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
pTS->rx_indicate_seq = (pTS->rx_indicate_seq + 1) % 4096;
bMatchWinStart = true;
} else if (SN_LESS(WinEnd, SeqNum)) {
- if (SeqNum >= (WinSize - 1)) {
+ if (SeqNum >= (WinSize - 1))
pTS->rx_indicate_seq = SeqNum + 1 - WinSize;
- } else {
+ else
pTS->rx_indicate_seq = 4095 - (WinSize - (SeqNum + 1)) + 1;
- }
+
IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n", pTS->rx_indicate_seq, SeqNum);
}
@@ -674,9 +674,9 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
list_add_tail(&pReorderEntry->List, &ieee->RxReorder_Unused_List);
{
int i;
- for (i = 0; i < prxb->nr_subframes; i++) {
+ for (i = 0; i < prxb->nr_subframes; i++)
dev_kfree_skb(prxb->subframes[i]);
- }
+
kfree(prxb);
prxb = NULL;
}
@@ -693,9 +693,9 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n");
{
int i;
- for (i = 0; i < prxb->nr_subframes; i++) {
+ for (i = 0; i < prxb->nr_subframes; i++)
dev_kfree_skb(prxb->subframes[i]);
- }
+
kfree(prxb);
prxb = NULL;
}
@@ -785,13 +785,12 @@ static u8 parse_subframe(struct ieee80211_device *ieee,
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 += HTCLNG;
- }
+
// Null packet, don't indicate it to upper layer
ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/
@@ -855,13 +854,11 @@ static u8 parse_subframe(struct ieee80211_device *ieee,
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;
- }
skb_pull(skb, nPadding_Length);
}
@@ -1248,9 +1245,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
TID = Frame_QoSTID(skb->data);
SeqNum = WLAN_GET_SEQ_SEQ(sc);
GetTs(ieee, (struct ts_common_info **)&pTS, hdr->addr2, TID, RX_DIR, true);
- if (TID != 0 && TID != 3) {
+ if (TID != 0 && TID != 3)
ieee->bis_any_nonbepkts = true;
- }
}
//added by amy for reorder
/* skb: hdr + (possible reassembled) full plaintext payload */
@@ -1262,9 +1258,9 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
/* qos data packets & reserved bit is 1 */
if (parse_subframe(ieee, skb, rx_stats, rxb, src, dst) == 0) {
/* only to free rxb, and not submit the packets to upper layer */
- for (i = 0; i < rxb->nr_subframes; i++) {
+ for (i = 0; i < rxb->nr_subframes; i++)
dev_kfree_skb(rxb->subframes[i]);
- }
+
kfree(rxb);
rxb = NULL;
goto rx_dropped;
@@ -1523,11 +1519,9 @@ 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);
- }
}
-
}
int ieee80211_parse_info_param(struct ieee80211_device *ieee,
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 690b664df8fa..25ea8e1b6b65 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -2052,7 +2052,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *
#else
if ((skb_queue_len(&ieee->skb_waitQ[queue_index]) != 0) ||
#endif
- (!ieee->check_nic_enough_desc(ieee->dev, queue_index)) || \
+ (!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
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
index bd8914645e95..96e6aaf859ec 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
@@ -301,9 +301,9 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee,
if (is_multicast_ether_addr(hdr->addr1))
return;
//check packet and mode later
- if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) {
+ if (!ieee->GetNmodeSupportBySecCfg(ieee->dev))
return;
- }
+
if (pHTInfo->bCurrentAMPDUEnable) {
if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)) {
printk("===>can't get TS\n");
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
index 22373c0afebc..78cc8f357bbc 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
@@ -184,9 +184,8 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
// printk("WPA IE\n");
u8 *p = buf;
p += sprintf(p, "wpa_ie=");
- for (i = 0; i < network->wpa_ie_len; i++) {
+ for (i = 0; i < network->wpa_ie_len; i++)
p += sprintf(p, "%02x", network->wpa_ie[i]);
- }
memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVCUSTOM;
@@ -199,9 +198,8 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
u8 *p = buf;
p += sprintf(p, "rsn_ie=");
- for (i = 0; i < network->rsn_ie_len; i++) {
+ for (i = 0; i < network->rsn_ie_len; i++)
p += sprintf(p, "%02x", network->rsn_ie[i]);
- }
memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVCUSTOM;
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
index 379a2ccf4d9f..6823e405eeb8 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
@@ -140,7 +140,7 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, s
// Dialog Token
*tag++ = pBA->dialog_token;
- if (ACT_ADDBARSP == type) {
+ if (type == ACT_ADDBARSP) {
// Status Code
netdev_info(ieee->dev, "=====>to send ADDBARSP\n");
@@ -156,7 +156,7 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, s
put_unaligned_le16(pBA->timeout_value, tag);
tag += 2;
- if (ACT_ADDBAREQ == type) {
+ if (type == ACT_ADDBAREQ) {
// BA Start SeqCtrl
memcpy(tag, (u8 *)&(pBA->start_seq_ctrl), 2);
tag += 2;
diff --git a/drivers/staging/rtl8192u/r8190_rtl8256.c b/drivers/staging/rtl8192u/r8190_rtl8256.c
index fee3bfb99075..54747fda552f 100644
--- a/drivers/staging/rtl8192u/r8190_rtl8256.c
+++ b/drivers/staging/rtl8192u/r8190_rtl8256.c
@@ -73,11 +73,11 @@ void phy_set_rf8256_bandwidth(struct net_device *dev, enum ht_channel_width Band
else
rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path_e)eRFPath, 0x14, bMask12Bits, 0x5ab);
} else {
- RT_TRACE(COMP_ERR, "phy_set_rf8256_bandwidth(): unknown hardware version\n");
+ RT_TRACE(COMP_ERR, "%s(): unknown hardware version\n", __func__);
}
break;
default:
- RT_TRACE(COMP_ERR, "phy_set_rf8256_bandwidth(): unknown Bandwidth: %#X\n", Bandwidth);
+ RT_TRACE(COMP_ERR, "%s(): unknown Bandwidth: %#X\n", __func__, Bandwidth);
break;
}
}
@@ -213,7 +213,7 @@ static void phy_rf8256_config_para_file(struct net_device *dev)
}
if (ret) {
- RT_TRACE(COMP_ERR, "phy_rf8256_config_para_file():Radio[%d] Fail!!", eRFPath);
+ RT_TRACE(COMP_ERR, "%s():Radio[%d] Fail!!", __func__, eRFPath);
goto phy_RF8256_Config_ParaFile_Fail;
}
}
@@ -291,5 +291,4 @@ void phy_set_rf8256_ofdm_tx_power(struct net_device *dev, u8 powerlevel)
}
rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal);
}
- return;
}
diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h
index ec33fb9122e9..4013107cd93a 100644
--- a/drivers/staging/rtl8192u/r8192U.h
+++ b/drivers/staging/rtl8192u/r8192U.h
@@ -46,9 +46,9 @@
#define KEY_BUF_SIZE 5
#define RX_SMOOTH_FACTOR 20
-#define DMESG(x, a...)
-#define DMESGW(x, a...)
-#define DMESGE(x, a...)
+#define DMESG(x, a...) no_printk(x, ##a)
+#define DMESGW(x, a...) no_printk(x, ##a)
+#define DMESGE(x, a...) no_printk(x, ##a)
extern u32 rt_global_debug_component;
#define RT_TRACE(component, x, args...) \
do { \
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 9fc4adc83d77..f48186a89fa1 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -3210,7 +3210,7 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum,
u32 *TotalRxDataNum)
{
u16 SlotIndex;
- u8 i;
+ u16 i;
*TotalRxBcnNum = 0;
*TotalRxDataNum = 0;
@@ -3416,7 +3416,6 @@ int rtl8192_down(struct net_device *dev)
void rtl8192_commit(struct net_device *dev)
{
struct r8192_priv *priv = ieee80211_priv(dev);
- int reset_status = 0;
if (priv->up == 0)
return;
@@ -3428,7 +3427,7 @@ void rtl8192_commit(struct net_device *dev)
ieee80211_softmac_stop_protocol(priv->ieee80211);
rtl8192_rtx_disable(dev);
- reset_status = _rtl8192_up(dev);
+ _rtl8192_up(dev);
}
static void rtl8192_restart(struct work_struct *work)
diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c
index 77bf88696a84..203ea3bfc843 100644
--- a/drivers/staging/rtl8192u/r8192U_wx.c
+++ b/drivers/staging/rtl8192u/r8192U_wx.c
@@ -77,8 +77,8 @@ static int r8192_wx_set_rate(struct net_device *dev,
}
static int r8192_wx_set_rts(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -93,8 +93,8 @@ static int r8192_wx_set_rts(struct net_device *dev,
}
static int r8192_wx_get_rts(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -102,8 +102,8 @@ static int r8192_wx_get_rts(struct net_device *dev,
}
static int r8192_wx_set_power(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -118,8 +118,8 @@ static int r8192_wx_set_power(struct net_device *dev,
}
static int r8192_wx_get_power(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -127,8 +127,8 @@ static int r8192_wx_get_power(struct net_device *dev,
}
static int r8192_wx_force_reset(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -141,8 +141,8 @@ static int r8192_wx_force_reset(struct net_device *dev,
}
static int r8192_wx_set_rawtx(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
struct r8192_priv *priv = ieee80211_priv(dev);
int ret;
@@ -276,7 +276,7 @@ static int rtl8180_wx_get_range(struct net_device *dev,
range->min_pmp = 0;
range->max_pmp = 5000000;
range->min_pmt = 0;
- range->max_pmt = 65535*1000;
+ range->max_pmt = 65535 * 1000;
range->pmp_flags = IW_POWER_PERIOD;
range->pmt_flags = IW_POWER_TIMEOUT;
range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
@@ -294,7 +294,7 @@ static int rtl8180_wx_get_range(struct net_device *dev,
for (i = 0, val = 0; i < 14; i++) {
/* Include only legal frequencies for some countries */
- if ((GET_DOT11D_INFO(priv->ieee80211)->channel_map)[i+1]) {
+ if ((GET_DOT11D_INFO(priv->ieee80211)->channel_map)[i + 1]) {
range->freq[val].i = i + 1;
range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000;
range->freq[val].e = 1;
@@ -309,8 +309,8 @@ static int rtl8180_wx_get_range(struct net_device *dev,
}
range->num_frequency = val;
range->num_channels = val;
- range->enc_capa = IW_ENC_CAPA_WPA|IW_ENC_CAPA_WPA2|
- IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP;
+ range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
+ IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
tmp->scan_capa = 0x01;
return 0;
}
@@ -429,9 +429,9 @@ static int r8192_wx_set_frag(struct net_device *dev,
{
struct r8192_priv *priv = ieee80211_priv(dev);
- if (wrqu->frag.disabled)
+ if (wrqu->frag.disabled) {
priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
- else {
+ } else {
if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
wrqu->frag.value > MAX_FRAG_THRESHOLD)
return -EINVAL;
@@ -456,9 +456,9 @@ static int r8192_wx_get_frag(struct net_device *dev,
}
static int r8192_wx_set_wap(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *awrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *awrq,
+ char *extra)
{
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -519,14 +519,14 @@ static int r8192_wx_set_enc(struct net_device *dev,
/* sometimes, the length is zero while we do not type key value */
if (wrqu->encoding.length != 0) {
for (i = 0; i < 4; i++) {
- hwkey[i] |= key[4*i+0]&mask;
- if (i == 1 && (4*i+1) == wrqu->encoding.length)
+ hwkey[i] |= key[4 * i + 0] & mask;
+ if (i == 1 && (4 * i + 1) == wrqu->encoding.length)
mask = 0x00;
- if (i == 3 && (4*i+1) == wrqu->encoding.length)
+ if (i == 3 && (4 * i + 1) == wrqu->encoding.length)
mask = 0x00;
- hwkey[i] |= (key[4*i+1]&mask)<<8;
- hwkey[i] |= (key[4*i+2]&mask)<<16;
- hwkey[i] |= (key[4*i+3]&mask)<<24;
+ hwkey[i] |= (key[4 * i + 1] & mask) << 8;
+ hwkey[i] |= (key[4 * i + 2] & mask) << 16;
+ hwkey[i] |= (key[4 * i + 3] & mask) << 24;
}
#define CONF_WEP40 0x4
@@ -557,23 +557,23 @@ static int r8192_wx_set_enc(struct net_device *dev,
EnableHWSecurityConfig8192(dev);
setKey(dev,
- key_idx, /* EntryNo */
- key_idx, /* KeyIndex */
- KEY_TYPE_WEP40, /* KeyType */
- zero_addr[key_idx],
- 0, /* DefaultKey */
- hwkey); /* KeyContent */
+ key_idx, /* EntryNo */
+ key_idx, /* KeyIndex */
+ KEY_TYPE_WEP40, /* KeyType */
+ zero_addr[key_idx],
+ 0, /* DefaultKey */
+ hwkey); /* KeyContent */
} else if (wrqu->encoding.length == 0xd) {
ieee->pairwise_key_type = KEY_TYPE_WEP104;
EnableHWSecurityConfig8192(dev);
setKey(dev,
- key_idx, /* EntryNo */
- key_idx, /* KeyIndex */
- KEY_TYPE_WEP104, /* KeyType */
- zero_addr[key_idx],
- 0, /* DefaultKey */
- hwkey); /* KeyContent */
+ key_idx, /* EntryNo */
+ key_idx, /* KeyIndex */
+ KEY_TYPE_WEP104, /* KeyType */
+ zero_addr[key_idx],
+ 0, /* DefaultKey */
+ hwkey); /* KeyContent */
} else {
netdev_warn(dev, "wrong type in WEP, not WEP40 and WEP104\n");
}
@@ -583,7 +583,7 @@ static int r8192_wx_set_enc(struct net_device *dev,
}
static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa,
- union iwreq_data *wrqu, char *p)
+ union iwreq_data *wrqu, char *p)
{
struct r8192_priv *priv = ieee80211_priv(dev);
int *parms = (int *)p;
@@ -595,8 +595,8 @@ static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info
}
static int r8192_wx_set_retry(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
struct r8192_priv *priv = ieee80211_priv(dev);
int err = 0;
@@ -640,8 +640,8 @@ exit:
}
static int r8192_wx_get_retry(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -663,8 +663,8 @@ static int r8192_wx_get_retry(struct net_device *dev,
}
static int r8192_wx_get_sens(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -675,8 +675,8 @@ static int r8192_wx_get_sens(struct net_device *dev,
}
static int r8192_wx_set_sens(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
struct r8192_priv *priv = ieee80211_priv(dev);
short err = 0;
@@ -699,8 +699,8 @@ exit:
/* hw security need to reorganized. */
static int r8192_wx_set_enc_ext(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
int ret = 0;
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -722,13 +722,13 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
goto end_hw_sec;
/* as IW_ENCODE_ALG_CCMP is defined to be 3 and KEY_TYPE_CCMP is defined to 4; */
- alg = (ext->alg == IW_ENCODE_ALG_CCMP)?KEY_TYPE_CCMP:ext->alg;
+ alg = (ext->alg == IW_ENCODE_ALG_CCMP) ? KEY_TYPE_CCMP : ext->alg;
idx = encoding->flags & IW_ENCODE_INDEX;
if (idx)
idx--;
group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY;
- if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || (alg == KEY_TYPE_WEP40)) {
+ if ((!group) || (ieee->iw_mode == IW_MODE_ADHOC) || (alg == KEY_TYPE_WEP40)) {
if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40))
alg = KEY_TYPE_WEP104;
ieee->pairwise_key_type = alg;
@@ -738,29 +738,29 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode != 2)) {
setKey(dev,
- idx, /* EntryNao */
- idx, /* KeyIndex */
- alg, /* KeyType */
- zero, /* MacAddr */
- 0, /* DefaultKey */
- key); /* KeyContent */
+ idx, /* EntryNao */
+ idx, /* KeyIndex */
+ alg, /* KeyType */
+ zero, /* MacAddr */
+ 0, /* DefaultKey */
+ key); /* KeyContent */
} else if (group) {
ieee->group_key_type = alg;
setKey(dev,
- idx, /* EntryNo */
- idx, /* KeyIndex */
- alg, /* KeyType */
- broadcast_addr, /* MacAddr */
- 0, /* DefaultKey */
- key); /* KeyContent */
+ idx, /* EntryNo */
+ idx, /* KeyIndex */
+ alg, /* KeyType */
+ broadcast_addr, /* MacAddr */
+ 0, /* DefaultKey */
+ key); /* KeyContent */
} else { /* pairwise key */
setKey(dev,
- 4, /* EntryNo */
- idx, /* KeyIndex */
- alg, /* KeyType */
- (u8 *)ieee->ap_mac_addr,/* MacAddr */
- 0, /* DefaultKey */
- key); /* KeyContent */
+ 4, /* EntryNo */
+ idx, /* KeyIndex */
+ alg, /* KeyType */
+ (u8 *)ieee->ap_mac_addr,/* MacAddr */
+ 0, /* DefaultKey */
+ key); /* KeyContent */
}
}
@@ -771,21 +771,21 @@ end_hw_sec:
}
static int r8192_wx_set_auth(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *data, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *data, char *extra)
{
int ret = 0;
struct r8192_priv *priv = ieee80211_priv(dev);
mutex_lock(&priv->wx_mutex);
- ret = ieee80211_wx_set_auth(priv->ieee80211, info, &(data->param), extra);
+ ret = ieee80211_wx_set_auth(priv->ieee80211, info, &data->param, extra);
mutex_unlock(&priv->wx_mutex);
return ret;
}
static int r8192_wx_set_mlme(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
{
int ret = 0;
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -798,8 +798,8 @@ static int r8192_wx_set_mlme(struct net_device *dev,
}
static int r8192_wx_set_gen_ie(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *data, char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *data, char *extra)
{
int ret = 0;
struct r8192_priv *priv = ieee80211_priv(dev);
@@ -877,14 +877,11 @@ static iw_handler r8192_wx_handlers[] = {
};
-
static const struct iw_priv_args r8192_private_args[] = {
-
{
SIOCIWFIRSTPRIV + 0x0,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc"
},
-
{
SIOCIWFIRSTPRIV + 0x1,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
@@ -897,9 +894,7 @@ static const struct iw_priv_args r8192_private_args[] = {
{
SIOCIWFIRSTPRIV + 0x3,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset"
-
}
-
};
static iw_handler r8192_private_handler[] = {
diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h
index 0c4325073c63..a44d04effc8b 100644
--- a/drivers/staging/rtl8712/drv_types.h
+++ b/drivers/staging/rtl8712/drv_types.h
@@ -36,8 +36,6 @@ enum _NIC_VERSION {
RTL8716_NIC
};
-struct _adapter;
-
struct qos_priv {
/* bit mask option: u-apsd, s-apsd, ts, block ack... */
unsigned int qos_option;
diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c
index b4a099169c7c..f926809b1021 100644
--- a/drivers/staging/rtl8712/ieee80211.c
+++ b/drivers/staging/rtl8712/ieee80211.c
@@ -173,33 +173,33 @@ int r8712_generate_ie(struct registry_priv *registrypriv)
ie += 2;
/*capability info*/
*(u16 *)ie = 0;
- *(__le16 *)ie |= cpu_to_le16(cap_IBSS);
+ *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_IBSS);
if (registrypriv->preamble == PREAMBLE_SHORT)
- *(__le16 *)ie |= cpu_to_le16(cap_ShortPremble);
+ *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
if (dev_network->Privacy)
- *(__le16 *)ie |= cpu_to_le16(cap_Privacy);
+ *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
sz += 2;
ie += 2;
/*SSID*/
- ie = r8712_set_ie(ie, _SSID_IE_, dev_network->Ssid.SsidLength,
+ ie = r8712_set_ie(ie, WLAN_EID_SSID, dev_network->Ssid.SsidLength,
dev_network->Ssid.Ssid, &sz);
/*supported rates*/
set_supported_rate(dev_network->rates, registrypriv->wireless_mode);
rate_len = r8712_get_rateset_len(dev_network->rates);
if (rate_len > 8) {
- ie = r8712_set_ie(ie, _SUPPORTEDRATES_IE_, 8,
+ ie = r8712_set_ie(ie, WLAN_EID_SUPP_RATES, 8,
dev_network->rates, &sz);
- ie = r8712_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8),
+ ie = r8712_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8),
(dev_network->rates + 8), &sz);
} else {
- ie = r8712_set_ie(ie, _SUPPORTEDRATES_IE_,
+ ie = r8712_set_ie(ie, WLAN_EID_SUPP_RATES,
rate_len, dev_network->rates, &sz);
}
/*DS parameter set*/
- ie = r8712_set_ie(ie, _DSSET_IE_, 1,
+ ie = r8712_set_ie(ie, WLAN_EID_DS_PARAMS, 1,
(u8 *)&dev_network->Configuration.DSConfig, &sz);
/*IBSS Parameter Set*/
- ie = r8712_set_ie(ie, _IBSS_PARA_IE_, 2,
+ ie = r8712_set_ie(ie, WLAN_EID_IBSS_PARAMS, 2,
(u8 *)&dev_network->Configuration.ATIMWindow, &sz);
return sz;
}
diff --git a/drivers/staging/rtl8712/mlme_osdep.h b/drivers/staging/rtl8712/mlme_osdep.h
index 9eaf94f072ff..a02c782588dd 100644
--- a/drivers/staging/rtl8712/mlme_osdep.h
+++ b/drivers/staging/rtl8712/mlme_osdep.h
@@ -22,8 +22,8 @@ void r8712_os_indicate_disconnect(struct _adapter *adapter);
void r8712_os_indicate_connect(struct _adapter *adapter);
void r8712_report_sec_ie(struct _adapter *adapter, u8 authmode, u8 *sec_ie);
int r8712_recv_indicatepkts_in_order(struct _adapter *adapter,
- struct recv_reorder_ctrl *precvreorder_ctrl,
- int bforced);
+ struct recv_reorder_ctrl *precvreorder_ctrl,
+ int bforced);
void r8712_indicate_wx_assoc_event(struct _adapter *padapter);
void r8712_indicate_wx_disassoc_event(struct _adapter *padapter);
diff --git a/drivers/staging/rtl8712/rtl8712_recv.h b/drivers/staging/rtl8712/rtl8712_recv.h
index 3e385b2242d8..f4d20b0efd4e 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.h
+++ b/drivers/staging/rtl8712/rtl8712_recv.h
@@ -66,6 +66,7 @@ struct phy_stat {
__le32 phydw6;
__le32 phydw7;
};
+
#define PHY_STAT_GAIN_TRSW_SHT 0
#define PHY_STAT_PWDB_ALL_SHT 4
#define PHY_STAT_CFOSHO_SHT 5
@@ -84,7 +85,6 @@ union recvstat {
unsigned int value[RXDESC_SIZE>>2];
};
-
struct recv_buf {
struct list_head list;
spinlock_t recvbuf_lock;
diff --git a/drivers/staging/rtl8712/rtl8712_wmac_regdef.h b/drivers/staging/rtl8712/rtl8712_wmac_regdef.h
index 662383fe7a8d..dfe3e9fbed43 100644
--- a/drivers/staging/rtl8712/rtl8712_wmac_regdef.h
+++ b/drivers/staging/rtl8712/rtl8712_wmac_regdef.h
@@ -32,6 +32,5 @@
#define AMPDU_MIN_SPACE (RTL8712_WMAC_ + 0x37)
#define TXOP_STALL_CTRL (RTL8712_WMAC_ + 0x38)
-
#endif /*__RTL8712_WMAC_REGDEF_H__*/
diff --git a/drivers/staging/rtl8712/rtl8712_xmit.c b/drivers/staging/rtl8712/rtl8712_xmit.c
index c247f92207f5..116cb812dcb9 100644
--- a/drivers/staging/rtl8712/rtl8712_xmit.c
+++ b/drivers/staging/rtl8712/rtl8712_xmit.c
@@ -228,9 +228,9 @@ void r8712_do_queue_select(struct _adapter *padapter,
struct dvobj_priv *pdvobj = &padapter->dvobjpriv;
if (pdvobj->nr_endpoint == 6) {
- qsel = (unsigned int) pattrib->priority;
+ qsel = (unsigned int)pattrib->priority;
} else if (pdvobj->nr_endpoint == 4) {
- qsel = (unsigned int) pattrib->priority;
+ qsel = (unsigned int)pattrib->priority;
if (qsel == 0 || qsel == 3)
qsel = 3;
else if (qsel == 1 || qsel == 2)
@@ -317,7 +317,6 @@ void r8712_append_mpdu_unit(struct xmit_buf *pxmitbuf,
0x0000ffff)));
}
-
void r8712_xmitframe_aggr_1st(struct xmit_buf *pxmitbuf,
struct xmit_frame *pxmitframe)
{
@@ -360,7 +359,7 @@ void r8712_dump_aggr_xframe(struct xmit_buf *pxmitbuf,
struct tx_desc *ptxdesc = pxmitbuf->pbuf;
struct cmd_hdr *pcmd_hdr = (struct cmd_hdr *)
(pxmitbuf->pbuf + TXDESC_SIZE);
- u16 total_length = (u16) (ptxdesc->txdw0 & 0xffff);
+ u16 total_length = (u16)(ptxdesc->txdw0 & 0xffff);
/* use 1st xmitframe as media */
xmitframe_xmitbuf_attach(pxmitframe, pxmitbuf);
@@ -369,7 +368,7 @@ void r8712_dump_aggr_xframe(struct xmit_buf *pxmitbuf,
0xffff0000));
/* urb length in cmd_dw1 */
- pcmd_hdr->cmd_dw1 = cpu_to_le32((pxmitbuf->aggr_nr & 0xff)|
+ pcmd_hdr->cmd_dw1 = cpu_to_le32((pxmitbuf->aggr_nr & 0xff) |
((total_length + TXDESC_SIZE) << 16));
pxmitframe->last[0] = 1;
pxmitframe->bpending[0] = false;
@@ -507,7 +506,7 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz)
/*offset 12*/
/* f/w will increase the seqnum by itself, driver pass the
- * correct priority to fw
+ * correct priority to fw.
* fw will check the correct priority for increasing the
* seqnum per tid. about usb using 4-endpoint, qsel points out
* the correct mapping between AC&Endpoint,
@@ -560,7 +559,7 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz)
ptxdesc->txdw2 |= cpu_to_le32(BMC);
/* offset 12 */
/* f/w will increase the seqnum by itself, driver pass the
- * correct priority to fw
+ * correct priority to fw.
* fw will check the correct priority for increasing the seqnum
* per tid. about usb using 4-endpoint, qsel points out the
* correct mapping between AC&Endpoint,
diff --git a/drivers/staging/rtl8712/rtl8712_xmit.h b/drivers/staging/rtl8712/rtl8712_xmit.h
index 0b56bd3ac4d0..5cd651a0de75 100644
--- a/drivers/staging/rtl8712/rtl8712_xmit.h
+++ b/drivers/staging/rtl8712/rtl8712_xmit.h
@@ -36,10 +36,8 @@
#define MAX_AMSDU_XMITBUF_SZ 8704
#define MAX_TXAGG_XMITBUF_SZ 16384 /*16k*/
-
#define tx_cmd tx_desc
-
/*
*defined for TX DESC Operation
*/
@@ -89,10 +87,9 @@ struct tx_desc {
__le32 txdw7;
};
-
union txdesc {
struct tx_desc txdesc;
- unsigned int value[TXDESC_SIZE>>2];
+ unsigned int value[TXDESC_SIZE >> 2];
};
int r8712_xmitframe_complete(struct _adapter *padapter,
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h
index 254182a6ce8e..bf6f0c6a86e5 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.h
+++ b/drivers/staging/rtl8712/rtl871x_cmd.h
@@ -333,6 +333,7 @@ struct getdatarate_parm {
u32 rsvd;
};
+
struct getdatarate_rsp {
u8 datarates[NumRates];
};
@@ -377,6 +378,7 @@ struct getphy_rsp {
struct readBB_parm {
u8 offset;
};
+
struct readBB_rsp {
u8 value;
};
@@ -384,6 +386,7 @@ struct readBB_rsp {
struct readTSSI_parm {
u8 offset;
};
+
struct readTSSI_rsp {
u8 value;
};
@@ -400,6 +403,7 @@ struct writePTM_parm {
struct readRF_parm {
u8 offset;
};
+
struct readRF_rsp {
u32 value;
};
@@ -498,6 +502,7 @@ struct settxagctbl_parm {
struct gettxagctbl_parm {
u32 rsvd;
};
+
struct gettxagctbl_rsp {
u32 txagc[MAX_RATES_LENGTH];
};
@@ -513,6 +518,7 @@ struct setssup_parm {
struct getssup_parm {
u32 rsvd;
};
+
struct getssup_rsp {
u8 ss_ForceUp[MAX_RATES_LENGTH];
};
@@ -524,6 +530,7 @@ struct setssdlevel_parm {
struct getssdlevel_parm {
u32 rsvd;
};
+
struct getssdlevel_rsp {
u8 ss_DLevel[MAX_RATES_LENGTH];
};
@@ -535,6 +542,7 @@ struct setssulevel_parm {
struct getssulevel_parm {
u32 rsvd;
};
+
struct getssulevel_rsp {
u8 ss_ULevel[MAX_RATES_LENGTH];
};
@@ -585,6 +593,7 @@ struct setratable_parm {
struct getratable_parm {
uint rsvd;
};
+
struct getratable_rsp {
u8 ss_ForceUp[NumRates];
u8 ss_ULevel[NumRates];
@@ -621,6 +630,7 @@ struct getbcnokcnt_rsp {
struct getbcnerrcnt_parm {
unsigned int rsvd;
};
+
struct getbcnerrcnt_rsp {
unsigned long bcnerrcnt;
};
diff --git a/drivers/staging/rtl8712/rtl871x_event.h b/drivers/staging/rtl8712/rtl871x_event.h
index d9a5476d2426..759a2d27d8f2 100644
--- a/drivers/staging/rtl8712/rtl871x_event.h
+++ b/drivers/staging/rtl8712/rtl871x_event.h
@@ -102,6 +102,7 @@ struct ADDBA_Req_Report_parm {
unsigned short StartSeqNum;
unsigned char tid;
};
+
#include "rtl8712_event.h"
#endif /* _WLANEVENT_H_ */
diff --git a/drivers/staging/rtl8712/rtl871x_ht.h b/drivers/staging/rtl8712/rtl871x_ht.h
index 4bcf5591c44d..ebd78665775d 100644
--- a/drivers/staging/rtl8712/rtl871x_ht.h
+++ b/drivers/staging/rtl8712/rtl871x_ht.h
@@ -26,7 +26,7 @@ struct ht_priv {
unsigned int rx_ampdu_maxlen; /* for rx reordering ctrl win_sz,
* updated when join_callback.
*/
- struct rtl_ieee80211_ht_cap ht_cap;
+ struct ieee80211_ht_cap ht_cap;
};
#endif /*_RTL871X_HT_H_ */
diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
index c20dd5a6bbd1..c5b12f74ebf8 100644
--- a/drivers/staging/rtl8712/rtl871x_io.h
+++ b/drivers/staging/rtl8712/rtl871x_io.h
@@ -123,7 +123,6 @@ struct intf_hdl {
};
struct reg_protocol_rd {
-
#ifdef __LITTLE_ENDIAN
/* DW1 */
u32 NumOfTrans:4;
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 60dd798a6e51..3b6926613257 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -36,14 +36,12 @@
#include <linux/if_arp.h>
#include <linux/etherdevice.h>
-
#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 0x1E)
#define SCAN_ITEM_SIZE 768
#define MAX_CUSTOM_LEN 64
#define RATE_COUNT 4
-
static const u32 rtl8180_rates[] = {1000000, 2000000, 5500000, 11000000,
6000000, 9000000, 12000000, 18000000,
24000000, 36000000, 48000000, 54000000};
@@ -144,7 +142,7 @@ static noinline_for_stack char *translate_scan_wpa(struct iw_request_info *info,
for (i = 0; i < wpa_len; i++) {
n += scnprintf(buf + n, MAX_WPA_IE_LEN - n,
"%02x", wpa_ie[i]);
- if (n == MAX_WPA_IE_LEN-1)
+ if (n == MAX_WPA_IE_LEN - 1)
break;
}
memset(iwe, 0, sizeof(*iwe));
@@ -164,7 +162,7 @@ static noinline_for_stack char *translate_scan_wpa(struct iw_request_info *info,
for (i = 0; i < rsn_len; i++) {
n += scnprintf(buf + n, MAX_WPA_IE_LEN - n,
"%02x", rsn_ie[i]);
- if (n == MAX_WPA_IE_LEN-1)
+ if (n == MAX_WPA_IE_LEN - 1)
break;
}
memset(iwe, 0, sizeof(*iwe));
@@ -236,7 +234,7 @@ static char *translate_scan(struct _adapter *padapter,
start = iwe_stream_add_point(info, start, stop, &iwe,
pnetwork->network.Ssid.Ssid);
/* parsing HT_CAP_IE */
- p = r8712_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_,
+ p = r8712_get_ie(&pnetwork->network.IEs[12], WLAN_EID_HT_CAPABILITY,
&ht_ielen, pnetwork->network.IELength - 12);
if (p && ht_ielen > 0)
ht_cap = true;
@@ -567,7 +565,7 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie,
while (cnt < ielen) {
eid = buf[cnt];
- if ((eid == _VENDOR_SPECIFIC_IE_) &&
+ if ((eid == WLAN_EID_VENDOR_SPECIFIC) &&
(!memcmp(&buf[cnt + 2], wps_oui, 4))) {
netdev_info(padapter->pnetdev, "r8712u: SET WPS_IE\n");
padapter->securitypriv.wps_ie_len =
@@ -609,7 +607,7 @@ static int r8711_wx_get_name(struct net_device *dev,
if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE) ==
true) {
/* parsing HT_CAP_IE */
- p = r8712_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_,
+ p = r8712_get_ie(&pcur_bss->IEs[12], WLAN_EID_HT_CAPABILITY,
&ht_ielen, pcur_bss->IELength - 12);
if (p && ht_ielen > 0)
ht_cap = true;
@@ -1391,7 +1389,7 @@ static int r8711_wx_get_rate(struct net_device *dev,
struct _adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
- struct rtl_ieee80211_ht_cap *pht_capie;
+ struct ieee80211_ht_cap *pht_capie;
unsigned char rf_type = padapter->registrypriv.rf_config;
int i;
u8 *p;
@@ -1403,12 +1401,12 @@ static int r8711_wx_get_rate(struct net_device *dev,
i = 0;
if (!check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE))
return -ENOLINK;
- p = r8712_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen,
+ p = r8712_get_ie(&pcur_bss->IEs[12], WLAN_EID_HT_CAPABILITY, &ht_ielen,
pcur_bss->IELength - 12);
if (p && ht_ielen > 0) {
ht_cap = true;
- pht_capie = (struct rtl_ieee80211_ht_cap *)(p + 2);
- memcpy(&mcs_rate, pht_capie->supp_mcs_set, 2);
+ pht_capie = (struct ieee80211_ht_cap *)(p + 2);
+ memcpy(&mcs_rate, &pht_capie->mcs, 2);
bw_40MHz = (le16_to_cpu(pht_capie->cap_info) &
IEEE80211_HT_CAP_SUP_WIDTH_20_40) ? 1 : 0;
short_GI = (le16_to_cpu(pht_capie->cap_info) &
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c
index 6074383ec0b5..ba4a71e91ae0 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.c
+++ b/drivers/staging/rtl8712/rtl871x_mlme.c
@@ -124,7 +124,6 @@ static void free_network_nolock(struct mlme_priv *pmlmepriv,
pmlmepriv->num_of_scanned--;
}
-
/* return the wlan_network with the matching addr
* Shall be called under atomic context...
* to avoid possible racing condition...
@@ -147,6 +146,8 @@ static struct wlan_network *r8712_find_network(struct __queue *scanned_queue,
if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN))
break;
}
+ if (plist == phead)
+ pnetwork = NULL;
spin_unlock_irqrestore(&scanned_queue->lock, irqL);
return pnetwork;
}
@@ -358,7 +359,6 @@ static void update_scanned_network(struct _adapter *adapter,
plist = plist->next;
}
-
/* If we didn't find a match, then get a new network slot to initialize
* with this beacon's information
*/
@@ -621,7 +621,6 @@ void r8712_indicate_connect(struct _adapter *padapter)
jiffies + msecs_to_jiffies(60000));
}
-
/*
* r8712_ind_disconnect: the caller has to lock pmlmepriv->lock
*/
@@ -728,7 +727,8 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf)
r8712_find_network(&pmlmepriv->
scanned_queue,
cur_network->network.MacAddress);
- pcur_wlan->fixed = false;
+ if (pcur_wlan)
+ pcur_wlan->fixed = false;
pcur_sta = r8712_get_stainfo(pstapriv,
cur_network->network.MacAddress);
@@ -1642,23 +1642,23 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie,
{
u32 ielen, out_len;
unsigned char *p;
- struct rtl_ieee80211_ht_cap ht_capie;
+ struct ieee80211_ht_cap ht_capie;
unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
phtpriv->ht_option = 0;
- p = r8712_get_ie(in_ie + 12, _HT_CAPABILITY_IE_, &ielen, in_len - 12);
+ p = r8712_get_ie(in_ie + 12, WLAN_EID_HT_CAPABILITY, &ielen, in_len - 12);
if (p && (ielen > 0)) {
if (pqospriv->qos_option == 0) {
out_len = *pout_len;
- r8712_set_ie(out_ie + out_len, _VENDOR_SPECIFIC_IE_,
+ r8712_set_ie(out_ie + out_len, WLAN_EID_VENDOR_SPECIFIC,
_WMM_IE_Length_, WMM_IE, pout_len);
pqospriv->qos_option = 1;
}
out_len = *pout_len;
- memset(&ht_capie, 0, sizeof(struct rtl_ieee80211_ht_cap));
+ memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap));
ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
IEEE80211_HT_CAP_SGI_20 |
IEEE80211_HT_CAP_SGI_40 |
@@ -1667,8 +1667,8 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie,
IEEE80211_HT_CAP_DSSSCCK40);
ht_capie.ampdu_params_info = (IEEE80211_HT_AMPDU_PARM_FACTOR &
0x03) | (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00);
- r8712_set_ie(out_ie + out_len, _HT_CAPABILITY_IE_,
- sizeof(struct rtl_ieee80211_ht_cap),
+ r8712_set_ie(out_ie + out_len, WLAN_EID_HT_CAPABILITY,
+ sizeof(struct ieee80211_ht_cap),
(unsigned char *)&ht_capie, pout_len);
phtpriv->ht_option = 1;
}
@@ -1682,7 +1682,7 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len)
int i;
uint len;
struct sta_info *bmc_sta, *psta;
- struct rtl_ieee80211_ht_cap *pht_capie;
+ struct ieee80211_ht_cap *pht_capie;
struct recv_reorder_ctrl *preorder_ctrl;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
@@ -1698,11 +1698,11 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len)
/*check Max Rx A-MPDU Size*/
len = 0;
p = r8712_get_ie(pie + sizeof(struct NDIS_802_11_FIXED_IEs),
- _HT_CAPABILITY_IE_,
+ WLAN_EID_HT_CAPABILITY,
&len, ie_len -
sizeof(struct NDIS_802_11_FIXED_IEs));
if (p && len > 0) {
- pht_capie = (struct rtl_ieee80211_ht_cap *)(p + 2);
+ pht_capie = (struct ieee80211_ht_cap *)(p + 2);
max_ampdu_sz = (pht_capie->ampdu_params_info &
IEEE80211_HT_AMPDU_PARM_FACTOR);
/* max_ampdu_sz (kbytes); */
@@ -1733,7 +1733,7 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len)
}
len = 0;
p = r8712_get_ie(pie + sizeof(struct NDIS_802_11_FIXED_IEs),
- _HT_ADD_INFO_IE_, &len,
+ WLAN_EID_HT_OPERATION, &len,
ie_len - sizeof(struct NDIS_802_11_FIXED_IEs));
}
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.h b/drivers/staging/rtl8712/rtl871x_mlme.h
index 46effb469fd4..d7d25f240111 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.h
+++ b/drivers/staging/rtl8712/rtl871x_mlme.h
@@ -77,7 +77,6 @@ struct sitesurvey_ctrl {
};
struct mlme_priv {
-
spinlock_t lock;
spinlock_t lock2;
sint fw_state; /*shall we protect this variable? */
diff --git a/drivers/staging/rtl8712/rtl871x_mp.c b/drivers/staging/rtl8712/rtl871x_mp.c
index 24020257bc58..099c512c8519 100644
--- a/drivers/staging/rtl8712/rtl871x_mp.c
+++ b/drivers/staging/rtl8712/rtl871x_mp.c
@@ -387,6 +387,7 @@ void r8712_SwitchBandwidth(struct _adapter *pAdapter)
break;
}
}
+
/*------------------------------Define structure----------------------------*/
struct R_ANTENNA_SELECT_OFDM {
u32 r_tx_antenna:4;
diff --git a/drivers/staging/rtl8712/rtl871x_mp.h b/drivers/staging/rtl8712/rtl871x_mp.h
index e79a67676469..0a60b1e6ccaf 100644
--- a/drivers/staging/rtl8712/rtl871x_mp.h
+++ b/drivers/staging/rtl8712/rtl871x_mp.h
@@ -121,6 +121,7 @@ struct bb_reg_param {
u32 offset;
u32 value;
};
+
/* ======================================================================= */
#define LOWER true
diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c
index f906d3fbe179..31414a960c9e 100644
--- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c
+++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c
@@ -681,6 +681,7 @@ uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv)
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
return status;
}
+
/*------------------------------------------------------------------------*/
uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv)
{
@@ -708,6 +709,7 @@ uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv)
status = RNDIS_STATUS_FAILURE;
return status;
}
+
/*----------------------------------------------------------------------*/
uint oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_priv)
@@ -849,6 +851,7 @@ unsigned int mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv)
{
return _SUCCESS;
}
+
/*-------------------------------------------------------------------------*/
uint oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv)
{
diff --git a/drivers/staging/rtl8712/rtl871x_pwrctrl.h b/drivers/staging/rtl8712/rtl871x_pwrctrl.h
index dd5a79f90b1a..bf6623cfaf27 100644
--- a/drivers/staging/rtl8712/rtl871x_pwrctrl.h
+++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.h
@@ -17,7 +17,6 @@
#include "osdep_service.h"
#include "drv_types.h"
-
#define CMD_ALIVE BIT(2)
enum Power_Mgnt {
@@ -63,12 +62,10 @@ enum Power_Mgnt {
#define PS_STATE_S3 (PS_ALL_ON)
#define PS_STATE_S4 ((PS_ST_ACTIVE) | (PS_ALL_ON))
-
#define PS_IS_RF_ON(x) ((x) & (PS_ALL_ON))
#define PS_IS_ACTIVE(x) ((x) & (PS_ST_ACTIVE))
#define CLR_PS_STATE(x) ((x) = ((x) & (0xF0)))
-
struct reportpwrstate_parm {
unsigned char mode;
unsigned char state; /* the CPWM value */
diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c
index eb4e46a7f743..db2add576418 100644
--- a/drivers/staging/rtl8712/rtl871x_recv.c
+++ b/drivers/staging/rtl8712/rtl871x_recv.c
@@ -21,6 +21,7 @@
#include <linux/if_ether.h>
#include <linux/kmemleak.h>
#include <linux/etherdevice.h>
+#include <linux/ieee80211.h>
#include <net/cfg80211.h>
#include "osdep_service.h"
@@ -69,7 +70,7 @@ void _r8712_init_recv_priv(struct recv_priv *precvpriv,
for (i = 0; i < NR_RECVFRAME; i++) {
INIT_LIST_HEAD(&(precvframe->u.list));
list_add_tail(&(precvframe->u.list),
- &(precvpriv->free_recv_queue.queue));
+ &(precvpriv->free_recv_queue.queue));
r8712_os_recv_resource_alloc(padapter, precvframe);
precvframe->u.hdr.adapter = padapter;
precvframe++;
@@ -175,7 +176,7 @@ sint r8712_recvframe_chkmic(struct _adapter *adapter,
if (bmic_err) {
if (prxattrib->bdecrypted)
r8712_handle_tkip_mic_err(adapter,
- (u8)is_multicast_ether_addr(prxattrib->ra));
+ (u8)is_multicast_ether_addr(prxattrib->ra));
res = _FAIL;
} else {
/* mic checked ok */
@@ -191,14 +192,14 @@ sint r8712_recvframe_chkmic(struct _adapter *adapter,
/* decrypt and set the ivlen,icvlen of the recv_frame */
union recv_frame *r8712_decryptor(struct _adapter *padapter,
- union recv_frame *precv_frame)
+ union recv_frame *precv_frame)
{
struct rx_pkt_attrib *prxattrib = &precv_frame->u.hdr.attrib;
struct security_priv *psecuritypriv = &padapter->securitypriv;
union recv_frame *return_packet = precv_frame;
if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0) ||
- psecuritypriv->sw_decrypt)) {
+ psecuritypriv->sw_decrypt)) {
psecuritypriv->hw_decrypted = false;
switch (prxattrib->encrypt) {
case _WEP40_:
@@ -219,6 +220,7 @@ union recv_frame *r8712_decryptor(struct _adapter *padapter,
}
return return_packet;
}
+
/*###set the security information in the recv_frame */
union recv_frame *r8712_portctrl(struct _adapter *adapter,
union recv_frame *precv_frame)
@@ -251,7 +253,7 @@ union recv_frame *r8712_portctrl(struct _adapter *adapter,
} else {
/*free this frame*/
r8712_free_recvframe(precv_frame,
- &adapter->recvpriv.free_recv_queue);
+ &adapter->recvpriv.free_recv_queue);
prtnframe = NULL;
}
} else {
@@ -273,7 +275,7 @@ union recv_frame *r8712_portctrl(struct _adapter *adapter,
}
static sint recv_decache(union recv_frame *precv_frame, u8 bretry,
- struct stainfo_rxcache *prxcache)
+ struct stainfo_rxcache *prxcache)
{
sint tid = precv_frame->u.hdr.attrib.priority;
u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num & 0xffff) << 4) |
@@ -372,7 +374,7 @@ static sint ap2sta_data_frame(struct _adapter *adapter,
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) &&
check_fwstate(pmlmepriv, _FW_LINKED)) {
/* if NULL-frame, drop packet */
- if ((GetFrameSubType(ptr)) == WIFI_DATA_NULL)
+ if ((GetFrameSubType(ptr)) == IEEE80211_STYPE_NULLFUNC)
return _FAIL;
/* drop QoS-SubType Data, including QoS NULL,
* excluding QoS-Data
@@ -392,7 +394,7 @@ static sint ap2sta_data_frame(struct _adapter *adapter,
return _FAIL;
/* check BSSID */
if (is_zero_ether_addr(pattrib->bssid) ||
- is_zero_ether_addr(mybssid) ||
+ is_zero_ether_addr(mybssid) ||
(memcmp(pattrib->bssid, mybssid, ETH_ALEN)))
return _FAIL;
if (bmcast)
@@ -442,20 +444,20 @@ static sint sta2ap_data_frame(struct _adapter *adapter,
}
static sint validate_recv_ctrl_frame(struct _adapter *adapter,
- union recv_frame *precv_frame)
+ union recv_frame *precv_frame)
{
return _FAIL;
}
static sint validate_recv_mgnt_frame(struct _adapter *adapter,
- union recv_frame *precv_frame)
+ union recv_frame *precv_frame)
{
return _FAIL;
}
static sint validate_recv_data_frame(struct _adapter *adapter,
- union recv_frame *precv_frame)
+ union recv_frame *precv_frame)
{
int res;
u8 bretry;
@@ -466,8 +468,8 @@ static sint validate_recv_data_frame(struct _adapter *adapter,
struct security_priv *psecuritypriv = &adapter->securitypriv;
bretry = GetRetry(ptr);
- pda = get_da(ptr);
- psa = get_sa(ptr);
+ pda = ieee80211_get_DA((struct ieee80211_hdr *)ptr);
+ psa = ieee80211_get_SA((struct ieee80211_hdr *)ptr);
pbssid = get_hdr_bssid(ptr);
if (!pbssid)
return _FAIL;
@@ -564,13 +566,13 @@ sint r8712_validate_recv_frame(struct _adapter *adapter,
pattrib->privacy = GetPrivacy(ptr);
pattrib->order = GetOrder(ptr);
switch (type) {
- case WIFI_MGT_TYPE: /*mgnt*/
+ case IEEE80211_FTYPE_MGMT:
retval = validate_recv_mgnt_frame(adapter, precv_frame);
break;
- case WIFI_CTRL_TYPE:/*ctrl*/
+ case IEEE80211_FTYPE_CTL:
retval = validate_recv_ctrl_frame(adapter, precv_frame);
break;
- case WIFI_DATA_TYPE: /*data*/
+ case IEEE80211_FTYPE_DATA:
pattrib->qos = (subtype & BIT(7)) ? 1 : 0;
retval = validate_recv_data_frame(adapter, precv_frame);
break;
@@ -601,7 +603,7 @@ int r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe)
psnap_type = ptr + pattrib->hdrlen + pattrib->iv_len + SNAP_SIZE;
/* convert hdr + possible LLC headers into Ethernet header */
if ((!memcmp(psnap, (void *)rfc1042_header, SNAP_SIZE) &&
- (memcmp(psnap_type, (void *)SNAP_ETH_TYPE_IPX, 2)) &&
+ (memcmp(psnap_type, (void *)SNAP_ETH_TYPE_IPX, 2)) &&
(memcmp(psnap_type, (void *)SNAP_ETH_TYPE_APPLETALK_AARP, 2))) ||
!memcmp(psnap, (void *)bridge_tunnel_header, SNAP_SIZE)) {
/* remove RFC1042 or Bridge-Tunnel encapsulation and
diff --git a/drivers/staging/rtl8712/rtl871x_recv.h b/drivers/staging/rtl8712/rtl871x_recv.h
index e83c256e1474..1c8298bde033 100644
--- a/drivers/staging/rtl8712/rtl871x_recv.h
+++ b/drivers/staging/rtl8712/rtl871x_recv.h
@@ -29,7 +29,6 @@ struct stainfo_rxcache {
#define PHY_RSSI_SLID_WIN_MAX 100
#define PHY_LINKQUALITY_SLID_WIN_MAX 20
-
struct smooth_rssi_data {
u32 elements[100]; /* array to store values */
u32 index; /* index to current array to store */
@@ -38,7 +37,6 @@ struct smooth_rssi_data {
};
struct rx_pkt_attrib {
-
u8 amsdu;
u8 order;
u8 qos;
@@ -136,7 +134,7 @@ int recv_func(struct _adapter *padapter, void *pcontext);
static inline u8 *get_rxmem(union recv_frame *precvframe)
{
/* always return rx_head... */
- if (precvframe == NULL)
+ if (!precvframe)
return NULL;
return precvframe->u.hdr.rx_head;
}
@@ -144,7 +142,7 @@ static inline u8 *get_rxmem(union recv_frame *precvframe)
static inline u8 *get_recvframe_data(union recv_frame *precvframe)
{
/* always return rx_data */
- if (precvframe == NULL)
+ if (!precvframe)
return NULL;
return precvframe->u.hdr.rx_data;
}
@@ -154,7 +152,7 @@ static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz)
/* used for extract sz bytes from rx_data, update rx_data and return
* the updated rx_data to the caller
*/
- if (precvframe == NULL)
+ if (!precvframe)
return NULL;
precvframe->u.hdr.rx_data += sz;
if (precvframe->u.hdr.rx_data > precvframe->u.hdr.rx_tail) {
@@ -171,7 +169,7 @@ static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz)
* return the updated rx_tail to the caller
* after putting, rx_tail must be still larger than rx_end.
*/
- if (precvframe == NULL)
+ if (!precvframe)
return NULL;
precvframe->u.hdr.rx_tail += sz;
if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) {
@@ -189,7 +187,7 @@ static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz)
* updated rx_end to the caller
* after pulling, rx_end must be still larger than rx_data.
*/
- if (precvframe == NULL)
+ if (!precvframe)
return NULL;
precvframe->u.hdr.rx_tail -= sz;
if (precvframe->u.hdr.rx_tail < precvframe->u.hdr.rx_data) {
diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c
index 5000c87752d3..63d63f7be481 100644
--- a/drivers/staging/rtl8712/rtl871x_security.c
+++ b/drivers/staging/rtl8712/rtl871x_security.c
@@ -30,10 +30,10 @@
#include <linux/atomic.h>
#include <linux/crc32poly.h>
#include <linux/semaphore.h>
+#include <linux/ieee80211.h>
#include "osdep_service.h"
#include "drv_types.h"
-#include "wifi.h"
#include "osdep_intf.h"
/* =====WEP related===== */
@@ -259,7 +259,7 @@ static void secmicputuint32(u8 *p, u32 val)
long i;
for (i = 0; i < 4; i++) {
- *p++ = (u8) (val & 0xff);
+ *p++ = (u8)(val & 0xff);
val >>= 8;
}
}
@@ -907,8 +907,8 @@ static void construct_mic_iv(u8 *mic_iv, sint qc_exists, sint a4_exists,
mic_iv[i] = mpdu[i + 8];
for (i = 8; i < 14; i++)
mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */
- mic_iv[14] = (unsigned char) (payload_length / 256);
- mic_iv[15] = (unsigned char) (payload_length % 256);
+ mic_iv[14] = (unsigned char)(payload_length / 256);
+ mic_iv[15] = (unsigned char)(payload_length % 256);
}
/************************************************/
@@ -995,8 +995,8 @@ static void construct_ctr_preload(u8 *ctr_preload,
ctr_preload[i] = mpdu[i + 8];
for (i = 8; i < 14; i++)
ctr_preload[i] = pn_vector[13 - i];
- ctr_preload[14] = (unsigned char) (c / 256); /* Ctr */
- ctr_preload[15] = (unsigned char) (c % 256);
+ ctr_preload[14] = (unsigned char)(c / 256); /* Ctr */
+ ctr_preload[15] = (unsigned char)(c % 256);
}
/************************************/
@@ -1045,9 +1045,9 @@ static void aes_cipher(u8 *key, uint hdrlen,
else
a4_exists = 1;
- if ((frtype == WIFI_DATA_CFACK) ||
- (frtype == WIFI_DATA_CFPOLL) ||
- (frtype == WIFI_DATA_CFACKPOLL)) {
+ if ((frtype == IEEE80211_STYPE_DATA_CFACK) ||
+ (frtype == IEEE80211_STYPE_DATA_CFPOLL) ||
+ (frtype == IEEE80211_STYPE_DATA_CFACKPOLL)) {
qc_exists = 1;
if (hdrlen != WLAN_HDR_A3_QOS_LEN)
hdrlen += 2;
@@ -1225,9 +1225,9 @@ static void aes_decipher(u8 *key, uint hdrlen,
a4_exists = 0;
else
a4_exists = 1;
- if ((frtype == WIFI_DATA_CFACK) ||
- (frtype == WIFI_DATA_CFPOLL) ||
- (frtype == WIFI_DATA_CFACKPOLL)) {
+ if ((frtype == IEEE80211_STYPE_DATA_CFACK) ||
+ (frtype == IEEE80211_STYPE_DATA_CFPOLL) ||
+ (frtype == IEEE80211_STYPE_DATA_CFACKPOLL)) {
qc_exists = 1;
if (hdrlen != WLAN_HDR_A3_QOS_LEN)
hdrlen += 2;
diff --git a/drivers/staging/rtl8712/rtl871x_security.h b/drivers/staging/rtl8712/rtl871x_security.h
index b2dda16cbd0a..8461b7f05359 100644
--- a/drivers/staging/rtl8712/rtl871x_security.h
+++ b/drivers/staging/rtl8712/rtl871x_security.h
@@ -101,7 +101,7 @@ struct security_priv {
union pn48 Grprxpn; /* PN48 used for Grp Key recv. */
u8 wps_hw_pbc_pressed;/*for hw pbc pressed*/
u8 wps_phase;/*for wps*/
- u8 wps_ie[MAX_WPA_IE_LEN<<2];
+ u8 wps_ie[MAX_WPA_IE_LEN << 2];
int wps_ie_len;
u8 binstallGrpkey;
u8 busetkipkey;
@@ -185,7 +185,7 @@ do {\
txpn._byte_.TSC5 = iv[7];\
} while (0)
-#define ROL32(A, n) (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1)))
+#define ROL32(A, n) (((A) << (n)) | (((A) >> (32 - (n))) & ((1UL << (n)) - 1)))
#define ROR32(A, n) ROL32((A), 32 - (n))
struct mic_data {
diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c
index fd99782a400a..bb4de927fb02 100644
--- a/drivers/staging/rtl8712/rtl871x_xmit.c
+++ b/drivers/staging/rtl8712/rtl871x_xmit.c
@@ -18,10 +18,10 @@
#include "osdep_service.h"
#include "drv_types.h"
-#include "wifi.h"
#include "osdep_intf.h"
#include "usb_ops.h"
+#include <linux/ieee80211.h>
static const u8 P802_1H_OUI[P80211_OUI_LEN] = {0x00, 0x00, 0xf8};
static const u8 RFC1042_OUI[P80211_OUI_LEN] = {0x00, 0x00, 0x00};
@@ -293,7 +293,7 @@ int r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
r8712_set_qos(&pktfile, pattrib);
} else {
pattrib->hdrlen = WLAN_HDR_A3_LEN;
- pattrib->subtype = WIFI_DATA_TYPE;
+ pattrib->subtype = IEEE80211_FTYPE_DATA;
pattrib->priority = 0;
}
if (psta->ieee8021x_blocked) {
@@ -479,7 +479,7 @@ static int make_wlanhdr(struct _adapter *padapter, u8 *hdr,
memset(hdr, 0, WLANHDR_OFFSET);
SetFrameSubType(fctrl, pattrib->subtype);
- if (!(pattrib->subtype & WIFI_DATA_TYPE))
+ if (!(pattrib->subtype & IEEE80211_FTYPE_DATA))
return 0;
bssid = get_bssid(pmlmepriv);
@@ -709,7 +709,7 @@ void r8712_update_protection(struct _adapter *padapter, u8 *ie, uint ie_len)
break;
case AUTO_VCS:
default:
- perp = r8712_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len);
+ perp = r8712_get_ie(ie, WLAN_EID_ERP_INFO, &erp_len, ie_len);
if (!perp) {
pxmitpriv->vcs = NONE_VCS;
} else {
diff --git a/drivers/staging/rtl8712/rtl871x_xmit.h b/drivers/staging/rtl8712/rtl871x_xmit.h
index cc58c7216935..2e6afc7bb0a1 100644
--- a/drivers/staging/rtl8712/rtl871x_xmit.h
+++ b/drivers/staging/rtl8712/rtl871x_xmit.h
@@ -42,7 +42,7 @@ do { \
pattrib_iv[1] = txpn._byte_.TSC1;\
pattrib_iv[2] = txpn._byte_.TSC2;\
pattrib_iv[3] = ((keyidx & 0x3) << 6);\
- txpn.val = (txpn.val == 0xffffff) ? 0 : (txpn.val+1);\
+ txpn.val = (txpn.val == 0xffffff) ? 0 : (txpn.val + 1);\
} while (0)
/* Fixed the Big Endian bug when doing the Tx.
@@ -53,13 +53,13 @@ do { \
pattrib_iv[0] = txpn._byte_.TSC1;\
pattrib_iv[1] = (txpn._byte_.TSC1 | 0x20) & 0x7f;\
pattrib_iv[2] = txpn._byte_.TSC0;\
- pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
+ pattrib_iv[3] = BIT(5) | ((keyidx & 0x3) << 6);\
pattrib_iv[4] = txpn._byte_.TSC2;\
pattrib_iv[5] = txpn._byte_.TSC3;\
pattrib_iv[6] = txpn._byte_.TSC4;\
pattrib_iv[7] = txpn._byte_.TSC5;\
txpn.val = txpn.val == 0xffffffffffffULL ? 0 : \
- (txpn.val+1);\
+ (txpn.val + 1);\
} while (0)
#define AES_IV(pattrib_iv, txpn, keyidx)\
@@ -67,13 +67,13 @@ do { \
pattrib_iv[0] = txpn._byte_.TSC0;\
pattrib_iv[1] = txpn._byte_.TSC1;\
pattrib_iv[2] = 0;\
- pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
+ pattrib_iv[3] = BIT(5) | ((keyidx & 0x3) << 6);\
pattrib_iv[4] = txpn._byte_.TSC2;\
pattrib_iv[5] = txpn._byte_.TSC3;\
pattrib_iv[6] = txpn._byte_.TSC4;\
pattrib_iv[7] = txpn._byte_.TSC5;\
txpn.val = txpn.val == 0xffffffffffffULL ? 0 : \
- (txpn.val+1);\
+ (txpn.val + 1);\
} while (0)
struct hw_xmit {
@@ -280,7 +280,7 @@ void r8712_xmit_direct(struct _adapter *padapter, struct xmit_frame *pxmitframe)
void r8712_xmit_bh(struct tasklet_struct *t);
void xmitframe_xmitbuf_attach(struct xmit_frame *pxmitframe,
- struct xmit_buf *pxmitbuf);
+ struct xmit_buf *pxmitbuf);
#include "rtl8712_xmit.h"
diff --git a/drivers/staging/rtl8712/sta_info.h b/drivers/staging/rtl8712/sta_info.h
index d042d900f30c..9b7e5ffa380d 100644
--- a/drivers/staging/rtl8712/sta_info.h
+++ b/drivers/staging/rtl8712/sta_info.h
@@ -36,7 +36,6 @@ struct wlan_acl_pool {
};
struct stainfo_stats {
-
uint rx_pkts;
uint rx_bytes;
u64 tx_pkts;
diff --git a/drivers/staging/rtl8712/usb_ops.h b/drivers/staging/rtl8712/usb_ops.h
index d62975447d29..7a6b619b73fa 100644
--- a/drivers/staging/rtl8712/usb_ops.h
+++ b/drivers/staging/rtl8712/usb_ops.h
@@ -21,9 +21,9 @@
void r8712_usb_write_mem(struct intf_hdl *pintfhdl, u32 addr,
u32 cnt, u8 *wmem);
u32 r8712_usb_write_port(struct intf_hdl *pintfhdl, u32 addr,
- u32 cnt, u8 *wmem);
+ u32 cnt, u8 *wmem);
u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 addr,
- u32 cnt, u8 *rmem);
+ u32 cnt, u8 *rmem);
void r8712_usb_set_intf_option(u32 *poption);
void r8712_usb_set_intf_funs(struct intf_hdl *pintf_hdl);
uint r8712_usb_init_intf_priv(struct intf_priv *pintfpriv);
@@ -32,7 +32,7 @@ void r8712_usb_set_intf_ops(struct _io_ops *pops);
void r8712_usb_read_port_cancel(struct _adapter *padapter);
void r8712_usb_write_port_cancel(struct _adapter *padapter);
int r8712_usbctrl_vendorreq(struct intf_priv *pintfpriv, u8 request, u16 value,
- u16 index, void *pdata, u16 len, u8 requesttype);
+ u16 index, void *pdata, u16 len, u8 requesttype);
#endif
diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h
index 1b32b3510093..577a95c62d6c 100644
--- a/drivers/staging/rtl8712/wifi.h
+++ b/drivers/staging/rtl8712/wifi.h
@@ -15,90 +15,15 @@
#define _WIFI_H_
#include <linux/compiler.h>
+#include <linux/ieee80211.h>
-#define WLAN_IEEE_OUI_LEN 3
-#define WLAN_CRC_LEN 4
-#define WLAN_BSSID_LEN 6
-#define WLAN_BSS_TS_LEN 8
#define WLAN_HDR_A3_LEN 24
-#define WLAN_HDR_A4_LEN 30
#define WLAN_HDR_A3_QOS_LEN 26
-#define WLAN_HDR_A4_QOS_LEN 32
-#define WLAN_SSID_MAXLEN 32
-#define WLAN_DATA_MAXLEN 2312
-
-#define WLAN_A3_PN_OFFSET 24
-#define WLAN_A4_PN_OFFSET 30
-
-#define WLAN_MIN_ETHFRM_LEN 60
-#define WLAN_MAX_ETHFRM_LEN 1514
#define P80211CAPTURE_VERSION 0x80211001
enum WIFI_FRAME_TYPE {
- WIFI_MGT_TYPE = (0),
- WIFI_CTRL_TYPE = (BIT(2)),
- WIFI_DATA_TYPE = (BIT(3)),
- WIFI_QOS_DATA_TYPE = (BIT(7)|BIT(3)), /*!< QoS Data */
-};
-
-enum WIFI_FRAME_SUBTYPE {
- /* below is for mgt frame */
- WIFI_ASSOCREQ = (0 | WIFI_MGT_TYPE),
- WIFI_ASSOCRSP = (BIT(4) | WIFI_MGT_TYPE),
- WIFI_REASSOCREQ = (BIT(5) | WIFI_MGT_TYPE),
- WIFI_REASSOCRSP = (BIT(5) | BIT(4) | WIFI_MGT_TYPE),
- WIFI_PROBEREQ = (BIT(6) | WIFI_MGT_TYPE),
- WIFI_PROBERSP = (BIT(6) | BIT(4) | WIFI_MGT_TYPE),
- WIFI_BEACON = (BIT(7) | WIFI_MGT_TYPE),
- WIFI_ATIM = (BIT(7) | BIT(4) | WIFI_MGT_TYPE),
- WIFI_DISASSOC = (BIT(7) | BIT(5) | WIFI_MGT_TYPE),
- WIFI_AUTH = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE),
- WIFI_DEAUTH = (BIT(7) | BIT(6) | WIFI_MGT_TYPE),
- WIFI_ACTION = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE),
- /* below is for control frame */
- WIFI_PSPOLL = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE),
- WIFI_RTS = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
- WIFI_CTS = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE),
- WIFI_ACK = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE),
- WIFI_CFEND = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE),
- WIFI_CFEND_CFACK = (BIT(7) | BIT(6) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
- /* below is for data frame */
- WIFI_DATA = (0 | WIFI_DATA_TYPE),
- WIFI_DATA_CFACK = (BIT(4) | WIFI_DATA_TYPE),
- WIFI_DATA_CFPOLL = (BIT(5) | WIFI_DATA_TYPE),
- WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE),
- WIFI_DATA_NULL = (BIT(6) | WIFI_DATA_TYPE),
- WIFI_CF_ACK = (BIT(6) | BIT(4) | WIFI_DATA_TYPE),
- WIFI_CF_POLL = (BIT(6) | BIT(5) | WIFI_DATA_TYPE),
- WIFI_CF_ACKPOLL = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE),
-};
-
-enum WIFI_REASON_CODE {
- _RSON_RESERVED_ = 0,
- _RSON_UNSPECIFIED_ = 1,
- _RSON_AUTH_NO_LONGER_VALID_ = 2,
- _RSON_DEAUTH_STA_LEAVING_ = 3,
- _RSON_INACTIVITY_ = 4,
- _RSON_UNABLE_HANDLE_ = 5,
- _RSON_CLS2_ = 6,
- _RSON_CLS3_ = 7,
- _RSON_DISAOC_STA_LEAVING_ = 8,
- _RSON_ASOC_NOT_AUTH_ = 9,
- /* WPA reason */
- _RSON_INVALID_IE_ = 13,
- _RSON_MIC_FAILURE_ = 14,
- _RSON_4WAY_HNDSHK_TIMEOUT_ = 15,
- _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16,
- _RSON_DIFF_IE_ = 17,
- _RSON_MLTCST_CIPHER_NOT_VALID_ = 18,
- _RSON_UNICST_CIPHER_NOT_VALID_ = 19,
- _RSON_AKMP_NOT_VALID_ = 20,
- _RSON_UNSUPPORT_RSNE_VER_ = 21,
- _RSON_INVALID_RSNE_CAP_ = 22,
- _RSON_IEEE_802DOT1X_AUTH_FAIL_ = 23,
- /* below are Realtek definitions */
- _RSON_PMK_NOT_AVAILABLE_ = 24,
+ WIFI_QOS_DATA_TYPE = (BIT(7) | BIT(3)), /*!< QoS Data */
};
enum WIFI_REG_DOMAIN {
@@ -115,33 +40,24 @@ enum WIFI_REG_DOMAIN {
DOMAIN_MAX
};
-#define _TO_DS_ BIT(8)
-#define _FROM_DS_ BIT(9)
-#define _MORE_FRAG_ BIT(10)
-#define _RETRY_ BIT(11)
-#define _PWRMGT_ BIT(12)
-#define _MORE_DATA_ BIT(13)
-#define _PRIVACY_ BIT(14)
-#define _ORDER_ BIT(15)
-
#define SetToDs(pbuf) ({ \
- *(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_); \
+ *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS); \
})
-#define GetToDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0)
+#define GetToDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0)
#define ClearToDs(pbuf) ({ \
- *(__le16 *)(pbuf) &= (~cpu_to_le16(_TO_DS_)); \
+ *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_TODS)); \
})
#define SetFrDs(pbuf) ({ \
- *(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_); \
+ *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS); \
})
-#define GetFrDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0)
+#define GetFrDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0)
#define ClearFrDs(pbuf) ({ \
- *(__le16 *)(pbuf) &= (~cpu_to_le16(_FROM_DS_)); \
+ *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_FROMDS)); \
})
static inline unsigned char get_tofr_ds(unsigned char *pframe)
@@ -150,56 +66,56 @@ static inline unsigned char get_tofr_ds(unsigned char *pframe)
}
#define SetMFrag(pbuf) ({ \
- *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_); \
+ *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS); \
})
-#define GetMFrag(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_FRAG_)) != 0)
+#define GetMFrag(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0)
#define ClearMFrag(pbuf) ({ \
- *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)); \
+ *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)); \
})
#define SetRetry(pbuf) ({ \
- *(__le16 *)(pbuf) |= cpu_to_le16(_RETRY_); \
+ *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_RETRY); \
})
-#define GetRetry(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0)
+#define GetRetry(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0)
#define ClearRetry(pbuf) ({ \
- *(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_)); \
+ *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_RETRY)); \
})
#define SetPwrMgt(pbuf) ({ \
- *(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_); \
+ *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM); \
})
#define GetPwrMgt(pbuf) (((*(__le16 *)(pbuf)) & \
- cpu_to_le16(_PWRMGT_)) != 0)
+ cpu_to_le16(IEEE80211_FCTL_PM)) != 0)
#define ClearPwrMgt(pbuf) ({ \
- *(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)); \
+ *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_PM)); \
})
#define SetMData(pbuf) ({ \
- *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_); \
+ *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); \
})
#define GetMData(pbuf) (((*(__le16 *)(pbuf)) & \
- cpu_to_le16(_MORE_DATA_)) != 0)
+ cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0)
#define ClearMData(pbuf) ({ \
- *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)); \
+ *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREDATA)); \
})
#define SetPrivacy(pbuf) ({ \
- *(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_); \
+ *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); \
})
#define GetPrivacy(pbuf) (((*(__le16 *)(pbuf)) & \
- cpu_to_le16(_PRIVACY_)) != 0)
+ cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0)
#define GetOrder(pbuf) (((*(__le16 *)(pbuf)) & \
- cpu_to_le16(_ORDER_)) != 0)
+ cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0)
#define GetFrameType(pbuf) (le16_to_cpu(*(__le16 *)(pbuf)) & \
(BIT(3) | BIT(2)))
@@ -234,11 +150,6 @@ static inline unsigned char get_tofr_ds(unsigned char *pframe)
0x000f) | (0xfff0 & (num << 4))); \
})
-#define SetDuration(pbuf, dur) ({ \
- *(__le16 *)((addr_t)(pbuf) + 2) |= \
- cpu_to_le16(0xffff & (dur)); \
-})
-
#define SetPriority(pbuf, tid) ({ \
*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf); \
})
@@ -253,9 +164,6 @@ static inline unsigned char get_tofr_ds(unsigned char *pframe)
#define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1)
-#define GetAid(pbuf) (cpu_to_le16(*(__le16 *)((addr_t)(pbuf) + 2)) \
- & 0x3fff)
-
#define GetAddr1Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 4))
#define GetAddr2Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 10))
@@ -264,51 +172,6 @@ static inline unsigned char get_tofr_ds(unsigned char *pframe)
#define GetAddr4Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 24))
-static inline unsigned char *get_da(unsigned char *pframe)
-{
- unsigned char *da;
- unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
-
- switch (to_fr_ds) {
- case 0x00: /* ToDs=0, FromDs=0 */
- da = GetAddr1Ptr(pframe);
- break;
- case 0x01: /* ToDs=0, FromDs=1 */
- da = GetAddr1Ptr(pframe);
- break;
- case 0x02: /* ToDs=1, FromDs=0 */
- da = GetAddr3Ptr(pframe);
- break;
- default: /* ToDs=1, FromDs=1 */
- da = GetAddr3Ptr(pframe);
- break;
- }
- return da;
-}
-
-static inline unsigned char *get_sa(unsigned char *pframe)
-{
- unsigned char *sa;
- unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
-
- switch (to_fr_ds) {
- case 0x00: /* ToDs=0, FromDs=0 */
- sa = GetAddr2Ptr(pframe);
- break;
- case 0x01: /* ToDs=0, FromDs=1 */
- sa = GetAddr3Ptr(pframe);
- break;
- case 0x02: /* ToDs=1, FromDs=0 */
- sa = GetAddr2Ptr(pframe);
- break;
- default: /* ToDs=1, FromDs=1 */
- sa = GetAddr4Ptr(pframe);
- break;
- }
-
- return sa;
-}
-
static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
{
unsigned char *sa;
@@ -335,19 +198,6 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
* Below is for the security related definition
*-----------------------------------------------------------------------------
*/
-#define _RESERVED_FRAME_TYPE_ 0
-#define _SKB_FRAME_TYPE_ 2
-#define _PRE_ALLOCMEM_ 1
-#define _PRE_ALLOCHDR_ 3
-#define _PRE_ALLOCLLCHDR_ 4
-#define _PRE_ALLOCICVHDR_ 5
-#define _PRE_ALLOCMICHDR_ 6
-
-#define _SIFSTIME_ ((priv->pmib->BssType.net_work_type & \
- WIRELESS_11A) ? 16 : 10)
-#define _ACKCTSLNG_ 14 /*14 bytes long, including crclng */
-#define _CRCLNG_ 4
-
#define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */
#define _ASOCRSP_IE_OFFSET_ 6
#define _REASOCREQ_IE_OFFSET_ 10
@@ -360,21 +210,6 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
#define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_
-#define _SSID_IE_ 0
-#define _SUPPORTEDRATES_IE_ 1
-#define _DSSET_IE_ 3
-#define _IBSS_PARA_IE_ 6
-#define _ERPINFO_IE_ 42
-#define _EXT_SUPPORTEDRATES_IE_ 50
-
-#define _HT_CAPABILITY_IE_ 45
-#define _HT_EXTRA_INFO_IE_ 61
-#define _HT_ADD_INFO_IE_ 61 /* _HT_EXTRA_INFO_IE_ */
-
-#define _VENDOR_SPECIFIC_IE_ 221
-
-#define _RESERVED47_ 47
-
/* ---------------------------------------------------------------------------
* Below is the fixed elements...
* ---------------------------------------------------------------------------
@@ -393,17 +228,6 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
#define AUTH_ODD_TO 0
#define AUTH_EVEN_TO 1
-#define WLAN_ETHCONV_ENCAP 1
-#define WLAN_ETHCONV_RFC1042 2
-#define WLAN_ETHCONV_8021h 3
-
-#define cap_ESS BIT(0)
-#define cap_IBSS BIT(1)
-#define cap_CFPollable BIT(2)
-#define cap_CFRequest BIT(3)
-#define cap_Privacy BIT(4)
-#define cap_ShortPremble BIT(5)
-
/*-----------------------------------------------------------------------------
* Below is the definition for 802.11i / 802.1x
*------------------------------------------------------------------------------
@@ -416,49 +240,6 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
*------------------------------------------------------------------------------
*/
#define _WMM_IE_Length_ 7 /* for WMM STA */
-#define _WMM_Para_Element_Length_ 24
-
-/*-----------------------------------------------------------------------------
- * Below is the definition for 802.11n
- *------------------------------------------------------------------------------
- */
-
-#define SetOrderBit(pbuf) ({ \
- *(__le16 *)(pbuf) |= cpu_to_le16(_ORDER_); \
-})
-
-#define GetOrderBit(pbuf) (((*(__le16 *)(pbuf)) & \
- le16_to_cpu(_ORDER_)) != 0)
-
-/*
- * struct rtl_ieee80211_ht_cap - HT capabilities
- *
- * This structure refers to "HT capabilities element" as
- * described in 802.11n draft section 7.3.2.52
- */
-
-struct rtl_ieee80211_ht_cap {
- __le16 cap_info;
- unsigned char ampdu_params_info;
- unsigned char supp_mcs_set[16];
- __le16 extended_ht_cap_info;
- __le32 tx_BF_cap_info;
- unsigned char antenna_selection_info;
-} __packed;
-
-/**
- * struct ieee80211_ht_addt_info - HT additional information
- *
- * This structure refers to "HT information element" as
- * described in 802.11n draft section 7.3.2.53
- */
-struct ieee80211_ht_addt_info {
- unsigned char control_chan;
- unsigned char ht_param;
- __le16 operation_mode;
- __le16 stbc_param;
- unsigned char basic_set[16];
-} __packed;
#endif /* _WIFI_H_ */
diff --git a/drivers/staging/rtl8712/wlan_bssdef.h b/drivers/staging/rtl8712/wlan_bssdef.h
index b54ccaacc527..ec3749813728 100644
--- a/drivers/staging/rtl8712/wlan_bssdef.h
+++ b/drivers/staging/rtl8712/wlan_bssdef.h
@@ -176,7 +176,7 @@ struct NDIS_802_11_WEP {
#define MIC_CHECK_TIME 60000000
#ifndef Ndis802_11APMode
-#define Ndis802_11APMode (Ndis802_11InfrastructureMax+1)
+#define Ndis802_11APMode (Ndis802_11InfrastructureMax + 1)
#endif
struct wlan_network {
diff --git a/drivers/staging/rtl8712/xmit_osdep.h b/drivers/staging/rtl8712/xmit_osdep.h
index 21f6b31e0f50..b76021b568f8 100644
--- a/drivers/staging/rtl8712/xmit_osdep.h
+++ b/drivers/staging/rtl8712/xmit_osdep.h
@@ -37,16 +37,16 @@ struct xmit_buf;
int r8712_xmit_entry(_pkt *pkt, struct net_device *pnetdev);
void r8712_SetFilter(struct work_struct *work);
int r8712_xmit_resource_alloc(struct _adapter *padapter,
- struct xmit_buf *pxmitbuf);
+ struct xmit_buf *pxmitbuf);
void r8712_xmit_resource_free(struct _adapter *padapter,
- struct xmit_buf *pxmitbuf);
+ struct xmit_buf *pxmitbuf);
void r8712_set_qos(struct pkt_file *ppktfile,
- struct pkt_attrib *pattrib);
+ struct pkt_attrib *pattrib);
void _r8712_open_pktfile(_pkt *pktptr, struct pkt_file *pfile);
uint _r8712_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen);
sint r8712_endofpktfile(struct pkt_file *pfile);
void r8712_xmit_complete(struct _adapter *padapter,
- struct xmit_frame *pxframe);
+ struct xmit_frame *pxframe);
#endif
diff --git a/drivers/staging/rtl8723bs/TODO b/drivers/staging/rtl8723bs/TODO
index 45065fd3fd5d..afa620ceb2d8 100644
--- a/drivers/staging/rtl8723bs/TODO
+++ b/drivers/staging/rtl8723bs/TODO
@@ -1,5 +1,4 @@
TODO:
-- find and remove code blocks guarded by never set CONFIG_FOO defines
- find and remove remaining code valid only for 5 GHz. Most of the obvious
ones have been removed, but things like channel > 14 still exist.
- find and remove any code for other chips that is left over
diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c
index b6f944b37b08..4a9bd4825fab 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -10,11 +10,6 @@
#include <rtw_debug.h>
#include <asm/unaligned.h>
-extern unsigned char RTW_WPA_OUI[];
-extern unsigned char WMM_OUI[];
-extern unsigned char WPS_OUI[];
-extern unsigned char P2P_OUI[];
-
void init_mlme_ap_info(struct adapter *padapter)
{
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -63,8 +58,6 @@ static void update_BCNTIM(struct adapter *padapter)
struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network;
unsigned char *pie = pnetwork_mlmeext->IEs;
- /* DBG_871X("%s\n", __func__); */
-
/* update TIM IE */
/* if (pstapriv->tim_bitmap) */
if (true) {
@@ -74,18 +67,17 @@ static void update_BCNTIM(struct adapter *padapter)
tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap);
- p = rtw_get_ie(
- pie + _FIXED_IE_LENGTH_,
- WLAN_EID_TIM,
- &tim_ielen,
- pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_
+ p = rtw_get_ie(pie + _FIXED_IE_LENGTH_,
+ WLAN_EID_TIM,
+ &tim_ielen,
+ pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_
);
if (p && tim_ielen > 0) {
tim_ielen += 2;
premainder_ie = p + tim_ielen;
- tim_ie_offset = (sint)(p - pie);
+ tim_ie_offset = (signed int)(p - pie);
remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen;
@@ -98,20 +90,18 @@ static void update_BCNTIM(struct adapter *padapter)
offset = _FIXED_IE_LENGTH_;
/* get ssid_ie len */
- p = rtw_get_ie(
- pie + _BEACON_IE_OFFSET_,
- WLAN_EID_SSID,
- &tmp_len,
- (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)
+ p = rtw_get_ie(pie + _BEACON_IE_OFFSET_,
+ WLAN_EID_SSID,
+ &tmp_len,
+ (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)
);
if (p)
offset += tmp_len + 2;
/* get supported rates len */
- p = rtw_get_ie(
- pie + _BEACON_IE_OFFSET_,
- WLAN_EID_SUPP_RATES, &tmp_len,
- (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)
+ p = rtw_get_ie(pie + _BEACON_IE_OFFSET_,
+ WLAN_EID_SUPP_RATES, &tmp_len,
+ (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)
);
if (p)
offset += tmp_len + 2;
@@ -180,20 +170,6 @@ static void update_BCNTIM(struct adapter *padapter)
u8 chk_sta_is_alive(struct sta_info *psta);
u8 chk_sta_is_alive(struct sta_info *psta)
{
- #ifdef DBG_EXPIRATION_CHK
- DBG_871X(
- "sta:%pM, rssi:%d, rx:"STA_PKTS_FMT", expire_to:%u, %s%ssq_len:%u\n"
- , MAC_ARG(psta->hwaddr)
- , psta->rssi_stat.UndecoratedSmoothedPWDB
- /* STA_RX_PKTS_ARG(psta) */
- , STA_RX_PKTS_DIFF_ARG(psta)
- , psta->expire_to
- , psta->state & WIFI_SLEEP_STATE ? "PS, " : ""
- , psta->state & WIFI_STA_ALIVE_CHK_STATE ? "SAC, " : ""
- , psta->sleepq_len
- );
- #endif
-
sta_update_last_rx_pkts(psta);
return true;
@@ -215,13 +191,6 @@ void expire_timeout_chk(struct adapter *padapter)
plist = get_next(phead);
/* check auth_queue */
- #ifdef DBG_EXPIRATION_CHK
- if (phead != plist) {
- DBG_871X(FUNC_NDEV_FMT " auth_list, cnt:%u\n",
- FUNC_NDEV_ARG(padapter->pnetdev),
- pstapriv->auth_list_cnt);
- }
- #endif
while (phead != plist) {
psta = container_of(plist, struct sta_info, auth_list);
@@ -233,16 +202,6 @@ void expire_timeout_chk(struct adapter *padapter)
list_del_init(&psta->auth_list);
pstapriv->auth_list_cnt--;
- DBG_871X(
- "auth expire %02X%02X%02X%02X%02X%02X\n",
- psta->hwaddr[0],
- psta->hwaddr[1],
- psta->hwaddr[2],
- psta->hwaddr[3],
- psta->hwaddr[4],
- psta->hwaddr[5]
- );
-
spin_unlock_bh(&pstapriv->auth_list_lock);
rtw_free_stainfo(padapter, psta);
@@ -261,19 +220,9 @@ void expire_timeout_chk(struct adapter *padapter)
plist = get_next(phead);
/* check asoc_queue */
- #ifdef DBG_EXPIRATION_CHK
- if (phead != plist) {
- DBG_871X(FUNC_NDEV_FMT" asoc_list, cnt:%u\n"
- , FUNC_NDEV_ARG(padapter->pnetdev), pstapriv->asoc_list_cnt);
- }
- #endif
while (phead != plist) {
psta = container_of(plist, struct sta_info, asoc_list);
plist = get_next(plist);
-#ifdef CONFIG_AUTO_AP_MODE
- if (psta->isrc)
- continue;
-#endif
if (chk_sta_is_alive(psta) || !psta->expire_to) {
psta->expire_to = pstapriv->expire_to;
psta->keep_alive_trycnt = 0;
@@ -293,12 +242,11 @@ void expire_timeout_chk(struct adapter *padapter)
if (psta->state & WIFI_SLEEP_STATE) {
if (!(psta->state & WIFI_STA_ALIVE_CHK_STATE)) {
- /* to check if alive by another methods if station is at ps mode. */
+ /* to check if alive by another methods */
+ /* if station is at ps mode. */
psta->expire_to = pstapriv->expire_to;
psta->state |= WIFI_STA_ALIVE_CHK_STATE;
- /* DBG_871X("alive chk, sta:%pM is at ps mode!\n", MAC_ARG(psta->hwaddr)); */
-
/* to update bcn with tim_bitmap for this station */
pstapriv->tim_bitmap |= BIT(psta->aid);
update_beacon(padapter, WLAN_EID_TIM, NULL, true);
@@ -318,29 +266,16 @@ void expire_timeout_chk(struct adapter *padapter)
}
list_del_init(&psta->asoc_list);
pstapriv->asoc_list_cnt--;
- DBG_871X(
- "asoc expire %pM, state = 0x%x\n",
- MAC_ARG(psta->hwaddr),
- psta->state
- );
updated = ap_free_sta(padapter, psta, false, WLAN_REASON_DEAUTH_LEAVING);
} else {
- /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */
+ /* 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_871X(
- "%s sta:%pM, sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n",
- __func__,
- MAC_ARG(psta->hwaddr),
- psta->sleepq_len,
- padapter->xmitpriv.free_xmitframe_cnt,
- pstapriv->asoc_list_cnt
- );
+ )
wakeup_sta_to_xmit(padapter, psta);
- }
}
}
@@ -371,29 +306,21 @@ void expire_timeout_chk(struct adapter *padapter)
psta->keep_alive_trycnt++;
if (ret == _SUCCESS) {
- DBG_871X(
- "asoc check, sta(%pM) is alive\n",
- MAC_ARG(psta->hwaddr)
- );
psta->expire_to = pstapriv->expire_to;
psta->keep_alive_trycnt = 0;
continue;
} else if (psta->keep_alive_trycnt <= 3) {
- DBG_871X(
- "ack check for asoc expire, keep_alive_trycnt =%d\n",
- psta->keep_alive_trycnt);
psta->expire_to = 1;
continue;
}
psta->keep_alive_trycnt = 0;
- DBG_871X("asoc expire %pM, state = 0x%x\n", MAC_ARG(psta->hwaddr),
- psta->state);
spin_lock_bh(&pstapriv->asoc_list_lock);
if (list_empty(&psta->asoc_list) == false) {
list_del_init(&psta->asoc_list);
pstapriv->asoc_list_cnt--;
- updated = ap_free_sta(padapter, psta, false, WLAN_REASON_DEAUTH_LEAVING);
+ updated = ap_free_sta(padapter, psta, false,
+ WLAN_REASON_DEAUTH_LEAVING);
}
spin_unlock_bh(&pstapriv->asoc_list_lock);
}
@@ -452,12 +379,7 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level)
arg[2] = shortGIrate;
arg[3] = psta->init_rate;
- DBG_871X("%s => mac_id:%d , raid:%d , shortGIrate =%d, bitmap = 0x%x\n",
- __func__, psta->mac_id, psta->raid, shortGIrate, tx_ra_bitmap);
-
rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, rssi_level);
- } else {
- DBG_871X("station aid %d exceed the max number\n", psta->aid);
}
}
@@ -491,10 +413,9 @@ void update_bmc_sta(struct adapter *padapter)
/* prepare for add_RATid */
supportRateNum = rtw_get_rateset_len((u8 *)&pcur_network->SupportedRates);
- network_type = rtw_check_network_type(
- (u8 *)&pcur_network->SupportedRates,
- supportRateNum,
- pcur_network->Configuration.DSConfig
+ network_type = rtw_check_network_type((u8 *)&pcur_network->SupportedRates,
+ supportRateNum,
+ pcur_network->Configuration.DSConfig
);
if (IsSupportedTxCCK(network_type)) {
network_type = WIRELESS_11B;
@@ -525,9 +446,6 @@ void update_bmc_sta(struct adapter *padapter)
arg[2] = 0;
arg[3] = psta->init_rate;
- DBG_871X("%s => mac_id:%d , raid:%d , bitmap = 0x%x\n",
- __func__, psta->mac_id, psta->raid, tx_ra_bitmap);
-
rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, 0);
}
@@ -537,8 +455,6 @@ void update_bmc_sta(struct adapter *padapter)
psta->state = _FW_LINKED;
spin_unlock_bh(&psta->lock);
- } else {
- DBG_871X("add_RATid_bmc_sta error!\n");
}
}
@@ -560,8 +476,6 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta)
/* set intf_tag to if1 */
/* psta->intf_tag = 0; */
- DBG_871X("%s\n", __func__);
-
/* psta->mac_id = psta->aid+4; */
/* psta->mac_id = psta->aid+1;//alloc macid when call rtw_alloc_stainfo(), */
/* release macid when call rtw_free_stainfo() */
@@ -621,17 +535,13 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta)
/* B0 Config LDPC Coding Capability */
if (TEST_FLAG(phtpriv_ap->ldpc_cap, LDPC_HT_ENABLE_TX) &&
- GET_HT_CAPABILITY_ELE_LDPC_CAP((u8 *)(&phtpriv_sta->ht_cap))) {
+ GET_HT_CAPABILITY_ELE_LDPC_CAP((u8 *)(&phtpriv_sta->ht_cap)))
SET_FLAG(cur_ldpc_cap, (LDPC_HT_ENABLE_TX | LDPC_HT_CAP_TX));
- DBG_871X("Enable HT Tx LDPC for STA(%d)\n", psta->aid);
- }
/* B7 B8 B9 Config STBC setting */
if (TEST_FLAG(phtpriv_ap->stbc_cap, STBC_HT_ENABLE_TX) &&
- GET_HT_CAPABILITY_ELE_RX_STBC((u8 *)(&phtpriv_sta->ht_cap))) {
+ GET_HT_CAPABILITY_ELE_RX_STBC((u8 *)(&phtpriv_sta->ht_cap)))
SET_FLAG(cur_stbc_cap, (STBC_HT_ENABLE_TX | STBC_HT_CAP_TX));
- DBG_871X("Enable HT Tx STBC for STA(%d)\n", psta->aid);
- }
} else {
phtpriv_sta->ampdu_enable = false;
@@ -717,24 +627,16 @@ static void update_hw_ht_param(struct adapter *padapter)
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- DBG_871X("%s\n", __func__);
-
- /* handle A-MPDU parameter field */
- /*
- AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k
- AMPDU_para [4:2]:Min MPDU Start Spacing
- */
+ /* handle A-MPDU parameter field
+ *
+ * AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k
+ * AMPDU_para [4:2]:Min MPDU Start Spacing
+ */
max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03;
- min_MPDU_spacing = (
- pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c
- ) >> 2;
+ min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2;
- rtw_hal_set_hwreg(
- padapter,
- HW_VAR_AMPDU_MIN_SPACE,
- (u8 *)(&min_MPDU_spacing)
- );
+ rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing));
rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len));
@@ -744,8 +646,6 @@ static void update_hw_ht_param(struct adapter *padapter)
pmlmeinfo->SM_PS = (le16_to_cpu(
pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info
) & 0x0C) >> 2;
- if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC)
- DBG_871X("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__);
/* */
/* Config current HT Protection mode. */
@@ -771,8 +671,6 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf)
struct HT_info_element *pht_info = NULL;
u8 cbw40_enable = 0;
- /* DBG_871X("%s\n", __func__); */
-
bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod;
cur_channel = pnetwork->Configuration.DSConfig;
cur_bwmode = CHANNEL_WIDTH_20;
@@ -802,10 +700,8 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf)
if (!pmlmepriv->cur_network.join_res) { /* setting only at first time */
/* WEP Key will be set before this function, do not clear CAM. */
- if (
- (psecuritypriv->dot11PrivacyAlgrthm != _WEP40_) &&
- (psecuritypriv->dot11PrivacyAlgrthm != _WEP104_)
- )
+ if ((psecuritypriv->dot11PrivacyAlgrthm != _WEP40_) &&
+ (psecuritypriv->dot11PrivacyAlgrthm != _WEP104_))
flush_all_cam_entry(padapter); /* clear CAM */
}
@@ -853,11 +749,10 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf)
}
/* set channel, bwmode */
- p = rtw_get_ie(
- (pnetwork->IEs + sizeof(struct ndis_802_11_fix_ie)),
- WLAN_EID_HT_OPERATION,
- &ie_len,
- (pnetwork->IELength - sizeof(struct ndis_802_11_fix_ie))
+ p = rtw_get_ie((pnetwork->IEs + sizeof(struct ndis_802_11_fix_ie)),
+ WLAN_EID_HT_OPERATION,
+ &ie_len,
+ (pnetwork->IELength - sizeof(struct ndis_802_11_fix_ie))
);
if (p && ie_len) {
pht_info = (struct HT_info_element *)(p + 2);
@@ -894,12 +789,6 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf)
}
set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode);
- DBG_871X(
- "CH =%d, BW =%d, offset =%d\n",
- cur_channel,
- cur_bwmode,
- cur_ch_offset
- );
pmlmeext->cur_channel = cur_channel;
pmlmeext->cur_bwmode = cur_bwmode;
pmlmeext->cur_ch_offset = cur_ch_offset;
@@ -924,12 +813,8 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf)
if (pmlmeext->bstart_bss) {
update_beacon(padapter, WLAN_EID_TIM, NULL, true);
-#ifndef CONFIG_INTERRUPT_BASED_TXBCN /* other case will tx beacon when bcn interrupt coming in. */
/* issue beacon frame */
- if (send_beacon(padapter) == _FAIL)
- DBG_871X("issue_beacon, fail!\n");
-
-#endif /* CONFIG_INTERRUPT_BASED_TXBCN */
+ send_beacon(padapter);
}
/* update bc/mc sta_info */
@@ -959,19 +844,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
*pbss_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network;
u8 *ie = pbss_network->IEs;
- /* SSID */
- /* Supported rates */
- /* DS Params */
- /* WLAN_EID_COUNTRY */
- /* ERP Information element */
- /* Extended supported rates */
- /* WPA/WPA2 */
- /* Wi-Fi Wireless Multimedia Extensions */
- /* ht_capab, ht_oper */
- /* WPS IE */
-
- DBG_871X("%s, len =%d\n", __func__, len);
-
if (!check_fwstate(pmlmepriv, WIFI_AP_STATE))
return _FAIL;
@@ -1136,7 +1008,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
}
if ((p == NULL) || (ie_len == 0))
- break;
+ break;
}
/* wmm */
@@ -1155,7 +1027,8 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
*(p + 8) |= BIT(7);/* QoS Info, support U-APSD */
- /* disable all ACM bits since the WMM admission control is not supported */
+ /* disable all ACM bits since the WMM admission */
+ /* control is not supported */
*(p + 10) &= ~BIT(4); /* BE */
*(p + 14) &= ~BIT(4); /* BK */
*(p + 18) &= ~BIT(4); /* VI */
@@ -1208,7 +1081,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
);
if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) ||
- (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) {
+ (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) {
pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY & (0x07 << 2));
} else {
pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00);
@@ -1265,7 +1138,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
pmlmepriv->htpriv.ht_option = false;
if ((psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_TKIP) ||
- (psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_TKIP)) {
+ (psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_TKIP)) {
/* todo: */
/* ht_cap = false; */
}
@@ -1318,8 +1191,6 @@ void rtw_set_macaddr_acl(struct adapter *padapter, int mode)
struct sta_priv *pstapriv = &padapter->stapriv;
struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
- DBG_871X("%s, mode =%d\n", __func__, mode);
-
pacl_list->mode = mode;
}
@@ -1333,8 +1204,6 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
struct __queue *pacl_node_q = &pacl_list->acl_node_q;
- DBG_871X("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, MAC_ARG(addr));
-
if ((NUM_ACL - 1) < pacl_list->num)
return (-1);
@@ -1350,7 +1219,6 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
if (paclnode->valid == true) {
added = true;
- DBG_871X("%s, sta has been added\n", __func__);
break;
}
}
@@ -1381,8 +1249,6 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
}
}
- DBG_871X("%s, acl_num =%d\n", __func__, pacl_list->num);
-
spin_unlock_bh(&(pacl_node_q->lock));
return ret;
@@ -1397,8 +1263,6 @@ void rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
struct __queue *pacl_node_q = &pacl_list->acl_node_q;
u8 baddr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; /* Baddr is used for clearing acl_list */
- DBG_871X("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, MAC_ARG(addr));
-
spin_lock_bh(&(pacl_node_q->lock));
phead = get_list_head(pacl_node_q);
@@ -1424,8 +1288,6 @@ void rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
spin_unlock_bh(&(pacl_node_q->lock));
- DBG_871X("%s, acl_num =%d\n", __func__, pacl_list->num);
-
}
u8 rtw_ap_set_pairwise_key(struct adapter *padapter, struct sta_info *psta)
@@ -1477,8 +1339,6 @@ static int rtw_ap_set_key(
struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
int res = _SUCCESS;
- /* DBG_871X("%s\n", __func__); */
-
pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
if (pcmd == NULL) {
res = _FAIL;
@@ -1532,8 +1392,6 @@ exit:
int rtw_ap_set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid)
{
- DBG_871X("%s\n", __func__);
-
return rtw_ap_set_key(padapter, key, alg, keyid, 1);
}
@@ -1558,14 +1416,11 @@ int rtw_ap_set_wep_key(
alg = _NO_PRIVACY_;
}
- DBG_871X("%s\n", __func__);
-
return rtw_ap_set_key(padapter, key, alg, keyid, set_tx);
}
static void update_bcn_fixed_ie(struct adapter *padapter)
{
- DBG_871X("%s\n", __func__);
}
static void update_bcn_erpinfo_ie(struct adapter *padapter)
@@ -1577,8 +1432,6 @@ static void update_bcn_erpinfo_ie(struct adapter *padapter)
unsigned char *p, *ie = pnetwork->IEs;
u32 len = 0;
- DBG_871X("%s, ERP_enable =%d\n", __func__, pmlmeinfo->ERP_enable);
-
if (!pmlmeinfo->ERP_enable)
return;
@@ -1610,27 +1463,22 @@ static void update_bcn_erpinfo_ie(struct adapter *padapter)
static void update_bcn_htcap_ie(struct adapter *padapter)
{
- DBG_871X("%s\n", __func__);
}
static void update_bcn_htinfo_ie(struct adapter *padapter)
{
- DBG_871X("%s\n", __func__);
}
static void update_bcn_rsn_ie(struct adapter *padapter)
{
- DBG_871X("%s\n", __func__);
}
static void update_bcn_wpa_ie(struct adapter *padapter)
{
- DBG_871X("%s\n", __func__);
}
static void update_bcn_wmm_ie(struct adapter *padapter)
{
- DBG_871X("%s\n", __func__);
}
static void update_bcn_wps_ie(struct adapter *padapter)
@@ -1648,8 +1496,6 @@ static void update_bcn_wps_ie(struct adapter *padapter)
unsigned char *ie = pnetwork->IEs;
u32 ielen = pnetwork->IELength;
- DBG_871X("%s\n", __func__);
-
pwps_ie = rtw_get_wps_ie(
ie + _FIXED_IE_LENGTH_,
ielen - _FIXED_IE_LENGTH_,
@@ -1689,26 +1535,6 @@ static void update_bcn_wps_ie(struct adapter *padapter)
}
kfree(pbackup_remainder_ie);
-
- /* deal with the case without set_tx_beacon_cmd() in update_beacon() */
-#if defined(CONFIG_INTERRUPT_BASED_TXBCN)
- if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) {
- u8 sr = 0;
-
- rtw_get_wps_attr_content(
- pwps_ie_src,
- wps_ielen,
- WPS_ATTR_SELECTED_REGISTRAR,
- (u8 *)(&sr),
- NULL
- );
-
- if (sr) {
- set_fwstate(pmlmepriv, WIFI_UNDER_WPS);
- DBG_871X("%s, set WIFI_UNDER_WPS\n", __func__);
- }
- }
-#endif
}
static void update_bcn_p2p_ie(struct adapter *padapter)
@@ -1717,8 +1543,6 @@ static void update_bcn_p2p_ie(struct adapter *padapter)
static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui)
{
- DBG_871X("%s\n", __func__);
-
if (!memcmp(RTW_WPA_OUI, oui, 4))
update_bcn_wpa_ie(padapter);
@@ -1730,9 +1554,6 @@ static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui)
else if (!memcmp(P2P_OUI, oui, 4))
update_bcn_p2p_ie(padapter);
-
- else
- DBG_871X("unknown OUI type!\n");
}
void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx)
@@ -1741,8 +1562,6 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx)
struct mlme_ext_priv *pmlmeext;
/* struct mlme_ext_info *pmlmeinfo; */
- /* DBG_871X("%s\n", __func__); */
-
if (!padapter)
return;
@@ -1806,26 +1625,24 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx)
spin_unlock_bh(&pmlmepriv->bcn_update_lock);
-#ifndef CONFIG_INTERRUPT_BASED_TXBCN
if (tx) {
/* send_beacon(padapter);//send_beacon must execute on TSR level */
set_tx_beacon_cmd(padapter);
}
-#endif /* CONFIG_INTERRUPT_BASED_TXBCN */
}
/*
-op_mode
-Set to 0 (HT pure) under the following conditions
- - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or
- - all STAs in the BSS are 20 MHz HT in 20 MHz BSS
-Set to 1 (HT non-member protection) if there may be non-HT STAs
- in both the primary and the secondary channel
-Set to 2 if only HT STAs are associated in BSS,
- however and at least one 20 MHz HT STA is associated
-Set to 3 (HT mixed mode) when one or more non-HT STAs are associated
- (currently non-GF HT station is considered as non-HT STA also)
-*/
+ * op_mode
+ * Set to 0 (HT pure) under the following conditions
+ * - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or
+ * - all STAs in the BSS are 20 MHz HT in 20 MHz BSS
+ * Set to 1 (HT non-member protection) if there may be non-HT STAs
+ * in both the primary and the secondary channel
+ * Set to 2 if only HT STAs are associated in BSS,
+ * however and at least one 20 MHz HT STA is associated
+ * Set to 3 (HT mixed mode) when one or more non-HT STAs are associated
+ * (currently non-GF HT station is considered as non-HT STA also)
+ */
static int rtw_ht_operation_update(struct adapter *padapter)
{
u16 cur_op_mode, new_op_mode;
@@ -1836,12 +1653,6 @@ static int rtw_ht_operation_update(struct adapter *padapter)
if (pmlmepriv->htpriv.ht_option)
return 0;
- /* if (!iface->conf->ieee80211n || iface->conf->ht_op_mode_fixed) */
- /* return 0; */
-
- DBG_871X("%s current operation mode = 0x%X\n",
- __func__, pmlmepriv->ht_op_mode);
-
if (!(pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)
&& pmlmepriv->num_sta_ht_no_gf) {
pmlmepriv->ht_op_mode |=
@@ -1891,9 +1702,6 @@ static int rtw_ht_operation_update(struct adapter *padapter)
op_mode_changes++;
}
- DBG_871X("%s new operation mode = 0x%X changes =%d\n",
- __func__, pmlmepriv->ht_op_mode, op_mode_changes);
-
return op_mode_changes;
}
@@ -1937,7 +1745,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
pmlmepriv->num_sta_no_short_preamble++;
if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
- (pmlmepriv->num_sta_no_short_preamble == 1)) {
+ (pmlmepriv->num_sta_no_short_preamble == 1)) {
beacon_updated = true;
update_beacon(padapter, 0xFF, NULL, true);
}
@@ -2009,9 +1817,6 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
if (psta->flags & WLAN_STA_HT) {
u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info);
- DBG_871X("HT: STA %pM HT Capabilities "
- "Info: 0x%04x\n", MAC_ARG(psta->hwaddr), ht_capab);
-
if (psta->no_ht_set) {
psta->no_ht_set = 0;
pmlmepriv->num_sta_no_ht--;
@@ -2022,10 +1827,6 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
psta->no_ht_gf_set = 1;
pmlmepriv->num_sta_ht_no_gf++;
}
- DBG_871X("%s STA %pM - no "
- "greenfield, num of non-gf stations %d\n",
- __func__, MAC_ARG(psta->hwaddr),
- pmlmepriv->num_sta_ht_no_gf);
}
if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH) == 0) {
@@ -2033,10 +1834,6 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
psta->ht_20mhz_set = 1;
pmlmepriv->num_sta_ht_20mhz++;
}
- DBG_871X("%s STA %pM - 20 MHz HT, "
- "num of 20MHz HT STAs %d\n",
- __func__, MAC_ARG(psta->hwaddr),
- pmlmepriv->num_sta_ht_20mhz);
}
} else {
@@ -2044,11 +1841,6 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
psta->no_ht_set = 1;
pmlmepriv->num_sta_no_ht++;
}
- if (pmlmepriv->htpriv.ht_option == true) {
- DBG_871X("%s STA %pM - no HT, num of non-HT stations %d\n",
- __func__, MAC_ARG(psta->hwaddr),
- pmlmepriv->num_sta_no_ht);
- }
}
if (rtw_ht_operation_update(padapter) > 0) {
@@ -2058,8 +1850,6 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta)
/* update associated stations cap. */
associated_clients_update(padapter, beacon_updated);
-
- DBG_871X("%s, updated =%d\n", __func__, beacon_updated);
}
u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta)
@@ -2120,11 +1910,6 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta)
update_beacon(padapter, WLAN_EID_HT_OPERATION, NULL, true);
}
- /* update associated stations cap. */
- /* associated_clients_update(padapter, beacon_updated); //move it to avoid deadlock */
-
- DBG_871X("%s, updated =%d\n", __func__, beacon_updated);
-
return beacon_updated;
}
@@ -2182,8 +1967,6 @@ void rtw_sta_flush(struct adapter *padapter)
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev));
-
if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
return;
@@ -2310,9 +2093,10 @@ void rtw_ap_restore_network(struct adapter *padapter)
for (i = 0; i < chk_alive_num; i++) {
psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]);
- if (psta == NULL) {
- DBG_871X(FUNC_ADPT_FMT" sta_info is null\n", FUNC_ADPT_ARG(padapter));
- } else if (psta->state & _FW_LINKED) {
+ if (!psta)
+ continue;
+
+ if (psta->state & _FW_LINKED) {
rtw_sta_media_status_rpt(padapter, psta, 1);
Update_RA_Entry(padapter, psta);
/* pairwise key */
@@ -2415,8 +2199,6 @@ void stop_ap_mode(struct adapter *padapter)
}
spin_unlock_bh(&(pacl_node_q->lock));
- DBG_871X("%s, free acl_node_queue, num =%d\n", __func__, pacl_list->num);
-
rtw_sta_flush(padapter);
/* free_assoc_sta_resources */
diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c
index 44219b7b6123..62cbf84b079a 100644
--- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c
+++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c
@@ -21,19 +21,11 @@ void rtw_btcoex_MediaStatusNotify(struct adapter *padapter, u8 mediaStatus)
void rtw_btcoex_HaltNotify(struct adapter *padapter)
{
- if (!padapter->bup) {
- DBG_871X(FUNC_ADPT_FMT ": bup =%d Skip!\n",
- FUNC_ADPT_ARG(padapter), padapter->bup);
-
+ if (!padapter->bup)
return;
- }
-
- if (padapter->bSurpriseRemoved) {
- DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n",
- FUNC_ADPT_ARG(padapter), padapter->bSurpriseRemoved);
+ if (padapter->bSurpriseRemoved)
return;
- }
hal_btcoex_HaltNotify(padapter);
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 3fe79169a811..e1a8f8b47edd 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -78,13 +78,12 @@ static struct _cmd_callback rtw_cmd_callback[] = {
{GEN_CMD_CODE(_Set_Drv_Extra), NULL},/*57*/
{GEN_CMD_CODE(_Set_H2C_MSG), NULL},/*58*/
{GEN_CMD_CODE(_SetChannelPlan), NULL},/*59*/
- {GEN_CMD_CODE(_LedBlink), NULL},/*60*/
- {GEN_CMD_CODE(_SetChannelSwitch), NULL},/*61*/
- {GEN_CMD_CODE(_TDLS), NULL},/*62*/
- {GEN_CMD_CODE(_ChkBMCSleepq), NULL}, /*63*/
+ {GEN_CMD_CODE(_SetChannelSwitch), NULL},/*60*/
+ {GEN_CMD_CODE(_TDLS), NULL},/*61*/
+ {GEN_CMD_CODE(_ChkBMCSleepq), NULL}, /*62*/
- {GEN_CMD_CODE(_RunInThreadCMD), NULL},/*64*/
+ {GEN_CMD_CODE(_RunInThreadCMD), NULL},/*63*/
};
static struct cmd_hdl wlancmds[] = {
@@ -150,11 +149,10 @@ static struct cmd_hdl wlancmds[] = {
GEN_MLME_EXT_HANDLER(0, h2c_msg_hdl) /*58*/
GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelPlan_param), set_chplan_hdl) /*59*/
- GEN_MLME_EXT_HANDLER(sizeof(struct LedBlink_param), led_blink_hdl) /*60*/
- GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelSwitch_param), set_csa_hdl) /*61*/
- GEN_MLME_EXT_HANDLER(sizeof(struct TDLSoption_param), tdls_hdl) /*62*/
- GEN_MLME_EXT_HANDLER(0, chk_bmc_sleepq_hdl) /*63*/
+ GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelSwitch_param), set_csa_hdl) /*60*/
+ GEN_MLME_EXT_HANDLER(sizeof(struct TDLSoption_param), tdls_hdl) /*61*/
+ GEN_MLME_EXT_HANDLER(0, chk_bmc_sleepq_hdl) /*62*/
GEN_MLME_EXT_HANDLER(sizeof(struct RunInThread_param), run_in_thread_hdl) /*63*/
};
@@ -203,7 +201,7 @@ exit:
return res;
}
-static void c2h_wk_callback(_workitem * work);
+static void c2h_wk_callback(struct work_struct *work);
int rtw_init_evt_priv(struct evt_priv *pevtpriv)
{
/* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
@@ -221,8 +219,6 @@ int rtw_init_evt_priv(struct evt_priv *pevtpriv)
void _rtw_free_evt_priv(struct evt_priv *pevtpriv)
{
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+_rtw_free_evt_priv\n"));
-
_cancel_workitem_sync(&pevtpriv->c2h_wk);
while (pevtpriv->c2h_wk_alive)
msleep(10);
@@ -233,8 +229,6 @@ void _rtw_free_evt_priv(struct evt_priv *pevtpriv)
kfree(c2h);
}
kfree(pevtpriv->c2h_queue);
-
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("-_rtw_free_evt_priv\n"));
}
void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv)
@@ -260,7 +254,7 @@ ISR/Call-Back functions can't call this sub-function.
int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj)
{
- _irqL irqL;
+ unsigned long irqL;
if (obj == NULL)
goto exit;
@@ -279,7 +273,7 @@ exit:
struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue)
{
- _irqL irqL;
+ unsigned long irqL;
struct cmd_obj *obj;
/* spin_lock_bh(&(queue->lock)); */
@@ -299,13 +293,11 @@ struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue)
void rtw_free_evt_priv(struct evt_priv *pevtpriv)
{
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_evt_priv\n"));
_rtw_free_evt_priv(pevtpriv);
}
void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv)
{
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_cmd_priv\n"));
_rtw_free_cmd_priv(pcmdpriv);
}
@@ -319,15 +311,9 @@ int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
if ((pcmdpriv->padapter->hw_init_completed == false && bAllow == false)
|| atomic_read(&(pcmdpriv->cmdthd_running)) == false /* com_thread not running */
- ) {
- /* DBG_871X("%s:%s: drop cmdcode:%u, hw_init_completed:%u, cmdthd_running:%u\n", caller_func, __func__, */
- /* cmd_obj->cmdcode, */
- /* pcmdpriv->padapter->hw_init_completed, */
- /* pcmdpriv->cmdthd_running */
- /* */
-
+ )
return _FAIL;
- }
+
return _SUCCESS;
}
@@ -399,8 +385,6 @@ int rtw_cmd_thread(void *context)
u8 ret;
struct cmd_obj *pcmd;
u8 *pcmdbuf;
- unsigned long cmd_start_time;
- unsigned long cmd_process_time;
u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf);
void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd);
struct adapter *padapter = context;
@@ -415,40 +399,42 @@ int rtw_cmd_thread(void *context)
atomic_set(&(pcmdpriv->cmdthd_running), true);
complete(&pcmdpriv->terminate_cmdthread_comp);
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n"));
-
while (1) {
if (wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp)) {
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp) return != 0, break\n", FUNC_ADPT_ARG(padapter));
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp) return != 0, break\n",
+ FUNC_ADPT_ARG(padapter));
break;
}
if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) {
- DBG_871X_LEVEL(_drv_always_, "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
- __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved, __LINE__);
+ netdev_dbg(padapter->pnetdev,
+ "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
+ __func__, padapter->bDriverStopped,
+ padapter->bSurpriseRemoved, __LINE__);
break;
}
if (pcmdpriv->stop_req) {
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" stop_req:%u, break\n", FUNC_ADPT_ARG(padapter), pcmdpriv->stop_req);
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " stop_req:%u, break\n",
+ FUNC_ADPT_ARG(padapter),
+ pcmdpriv->stop_req);
break;
}
- if (list_empty(&(pcmdpriv->cmd_queue.queue))) {
- /* DBG_871X("%s: cmd queue is empty!\n", __func__); */
+ if (list_empty(&pcmdpriv->cmd_queue.queue))
continue;
- }
- if (rtw_register_cmd_alive(padapter) != _SUCCESS) {
- RT_TRACE(_module_hal_xmit_c_, _drv_notice_,
- ("%s: wait to leave LPS_LCLK\n", __func__));
+ if (rtw_register_cmd_alive(padapter) != _SUCCESS)
continue;
- }
_next:
if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) {
- DBG_871X_LEVEL(_drv_always_, "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
- __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved, __LINE__);
+ netdev_dbg(padapter->pnetdev,
+ "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
+ __func__, padapter->bDriverStopped,
+ padapter->bSurpriseRemoved, __LINE__);
break;
}
@@ -458,8 +444,6 @@ _next:
continue;
}
- cmd_start_time = jiffies;
-
if (rtw_cmd_filter(pcmdpriv, pcmd) == _FAIL) {
pcmd->res = H2C_DROPPED;
goto post_process;
@@ -490,8 +474,9 @@ post_process:
if (mutex_lock_interruptible(&(pcmd->padapter->cmdpriv.sctx_mutex)) == 0) {
if (pcmd->sctx) {
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" pcmd->sctx\n",
- FUNC_ADPT_ARG(pcmd->padapter));
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " pcmd->sctx\n",
+ FUNC_ADPT_ARG(pcmd->padapter));
if (pcmd->res == H2C_SUCCESS)
rtw_sctx_done(&pcmd->sctx);
@@ -501,25 +486,16 @@ post_process:
mutex_unlock(&(pcmd->padapter->cmdpriv.sctx_mutex));
}
- cmd_process_time = jiffies_to_msecs(jiffies - cmd_start_time);
- if (cmd_process_time > 1000) {
- DBG_871X("%s cmd= %d process_time= %lu > 1 sec\n",
- ADPT_ARG(pcmd->padapter), pcmd->cmdcode,
- cmd_process_time);
- }
-
/* call callback function for post-processed */
if (pcmd->cmdcode < ARRAY_SIZE(rtw_cmd_callback)) {
pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback;
if (pcmd_callback == NULL) {
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n", pcmd_callback, pcmd->cmdcode));
rtw_free_cmd_obj(pcmd);
} else {
/* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */
pcmd_callback(pcmd->padapter, pcmd);/* need consider that free cmd_obj in rtw_cmd_callback */
}
} else {
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("%s: cmdcode = 0x%x callback not defined!\n", __func__, pcmd->cmdcode));
rtw_free_cmd_obj(pcmd);
}
@@ -537,8 +513,6 @@ post_process:
break;
}
- /* DBG_871X("%s: leaving... drop cmdcode:%u size:%d\n", __func__, pcmd->cmdcode, pcmd->cmdsz); */
-
if (pcmd->cmdcode == GEN_CMD_CODE(_Set_Drv_Extra)) {
extra_parm = (struct drvextra_cmd_parm *)pcmd->parmbuf;
if (extra_parm->pbuf && extra_parm->size > 0)
@@ -583,8 +557,6 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid,
rtw_free_network_queue(padapter, false);
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("%s: flush network queue\n", __func__));
-
init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey));
/* psurveyPara->bsslimit = 48; */
@@ -597,9 +569,6 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid,
if (ssid[i].SsidLength) {
memcpy(&psurveyPara->ssid[i], &ssid[i], sizeof(struct ndis_802_11_ssid));
psurveyPara->ssid_num++;
-
- DBG_871X(FUNC_ADPT_FMT" ssid:(%s, %d)\n", FUNC_ADPT_ARG(padapter),
- psurveyPara->ssid[i].Ssid, psurveyPara->ssid[i].SsidLength);
}
}
}
@@ -611,9 +580,6 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid,
if (ch[i].hw_value && !(ch[i].flags & RTW_IEEE80211_CHAN_DISABLED)) {
memcpy(&psurveyPara->ch[i], &ch[i], sizeof(struct rtw_ieee80211_channel));
psurveyPara->ch_num++;
-
- DBG_871X(FUNC_ADPT_FMT" ch:%u\n", FUNC_ADPT_ARG(padapter),
- psurveyPara->ch[i].hw_value);
}
}
}
@@ -672,16 +638,9 @@ u8 rtw_createbss_cmd(struct adapter *padapter)
{
struct cmd_obj *pcmd;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
- struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network;
u8 res = _SUCCESS;
- if (pmlmepriv->assoc_ssid.SsidLength == 0) {
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" 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));
- }
-
pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
if (pcmd == NULL) {
res = _FAIL;
@@ -761,22 +720,15 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
struct security_priv *psecuritypriv = &padapter->securitypriv;
struct registry_priv *pregistrypriv = &padapter->registrypriv;
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
- enum NDIS_802_11_NETWORK_INFRASTRUCTURE ndis_network_mode = pnetwork->network.InfrastructureMode;
+ enum ndis_802_11_network_infrastructure ndis_network_mode = pnetwork->network.InfrastructureMode;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
u32 tmp_len;
u8 *ptmp = NULL;
- if (pmlmepriv->assoc_ssid.SsidLength == 0) {
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+Join cmd: Any SSid\n"));
- } else {
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid));
- }
-
pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
if (pcmd == NULL) {
res = _FAIL;
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n"));
goto exit;
}
/* for IEs is fix buf size */
@@ -810,11 +762,10 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength;
- if ((psecnetwork->IELength-12) < (256-1)) {
+ if ((psecnetwork->IELength-12) < (256-1))
memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength-12);
- } else {
+ else
memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], (256-1));
- }
psecnetwork->IELength = 0;
/* Added by Albert 2009/02/18 */
@@ -886,8 +837,6 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu
struct cmd_priv *cmdpriv = &padapter->cmdpriv;
u8 res = _SUCCESS;
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_disassoc_cmd\n"));
-
/* prepare cmd parameter */
param = rtw_zmalloc(sizeof(*param));
if (param == NULL) {
@@ -917,7 +866,7 @@ exit:
return res;
}
-u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype, bool enqueue)
+u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infrastructure networktype, bool enqueue)
{
struct cmd_obj *ph2c;
struct setopmode_parm *psetop;
@@ -970,17 +919,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_
memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN);
- if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
psetstakey_para->algorithm = (unsigned char) psecuritypriv->dot11PrivacyAlgrthm;
- } else {
+ else
GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false);
- }
- if (unicast_key == true) {
+ if (unicast_key == true)
memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16);
- } else {
+ else
memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16);
- }
/* jeff: set this because at least sw key is ready */
padapter->securitypriv.busetkipkey = true;
@@ -1024,7 +971,9 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu
if (!enqueue) {
while ((cam_id = rtw_camid_search(padapter, sta->hwaddr, -1)) >= 0) {
- DBG_871X_LEVEL(_drv_always_, "clear key for addr:%pM, camid:%d\n", MAC_ARG(sta->hwaddr), cam_id);
+ netdev_dbg(padapter->pnetdev,
+ "clear key for addr:%pM, camid:%d\n",
+ MAC_ARG(sta->hwaddr), cam_id);
clear_cam_entry(padapter, cam_id);
rtw_camid_free(padapter, cam_id);
}
@@ -1092,8 +1041,6 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr)
init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm, GEN_CMD_CODE(_AddBAReq));
- /* DBG_871X("rtw_addbareq_cmd, tid =%d\n", tid); */
-
/* rtw_enqueue_cmd(pcmdpriv, ph2c); */
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
@@ -1214,8 +1161,6 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf
u8 res = _SUCCESS;
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_chplan_cmd\n"));
-
/* check if allow software config */
if (swconfig && rtw_hal_is_disable_sw_channel_plan(padapter) == true) {
res = _FAIL;
@@ -1333,7 +1278,6 @@ u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer)
/* check traffic for powersaving. */
if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) ||
(pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) {
- /* DBG_871X("(-)Tx = %d, Rx = %d\n", pmlmepriv->LinkDetectInfo.NumTxOkInPeriod, pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); */
bEnterPS = false;
if (bBusyTraffic == true) {
@@ -1342,14 +1286,10 @@ u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer)
pmlmepriv->LinkDetectInfo.TrafficTransitionCount++;
- /* DBG_871X("Set TrafficTransitionCount to %d\n", pmlmepriv->LinkDetectInfo.TrafficTransitionCount); */
-
if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount > 30/*TrafficTransitionLevel*/)
pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 30;
}
} else {
- /* DBG_871X("(+)Tx = %d, Rx = %d\n", pmlmepriv->LinkDetectInfo.NumTxOkInPeriod, pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); */
-
if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount >= 2)
pmlmepriv->LinkDetectInfo.TrafficTransitionCount -= 2;
else
@@ -1441,7 +1381,6 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type)
switch (lps_ctrl_type) {
case LPS_CTRL_SCAN:
- /* DBG_871X("LPS_CTRL_SCAN\n"); */
hal_btcoex_ScanNotify(padapter, true);
if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
@@ -1450,11 +1389,9 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type)
}
break;
case LPS_CTRL_JOINBSS:
- /* DBG_871X("LPS_CTRL_JOINBSS\n"); */
LPS_Leave(padapter, "LPS_CTRL_JOINBSS");
break;
case LPS_CTRL_CONNECT:
- /* DBG_871X("LPS_CTRL_CONNECT\n"); */
mstatus = 1;/* connect */
/* Reset LPS Setting */
pwrpriv->LpsIdleCount = 0;
@@ -1462,20 +1399,17 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type)
rtw_btcoex_MediaStatusNotify(padapter, mstatus);
break;
case LPS_CTRL_DISCONNECT:
- /* DBG_871X("LPS_CTRL_DISCONNECT\n"); */
mstatus = 0;/* disconnect */
rtw_btcoex_MediaStatusNotify(padapter, mstatus);
LPS_Leave(padapter, "LPS_CTRL_DISCONNECT");
rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus));
break;
case LPS_CTRL_SPECIAL_PACKET:
- /* DBG_871X("LPS_CTRL_SPECIAL_PACKET\n"); */
pwrpriv->DelayLPSLastTimeStamp = jiffies;
hal_btcoex_SpecialPacketNotify(padapter, PACKET_DHCP);
LPS_Leave(padapter, "LPS_CTRL_SPECIAL_PACKET");
break;
case LPS_CTRL_LEAVE:
- /* DBG_871X("LPS_CTRL_LEAVE\n"); */
LPS_Leave(padapter, "LPS_CTRL_LEAVE");
break;
case LPS_CTRL_TRAFFIC_BUSY:
@@ -1580,18 +1514,12 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim)
mutex_lock(&pwrpriv->lock);
- if (pwrpriv->dtim != dtim) {
- DBG_871X("change DTIM from %d to %d, bFwCurrentInPSMode =%d, ps_mode =%d\n", pwrpriv->dtim, dtim,
- pwrpriv->bFwCurrentInPSMode, pwrpriv->pwr_mode);
-
+ if (pwrpriv->dtim != dtim)
pwrpriv->dtim = dtim;
- }
- if ((pwrpriv->bFwCurrentInPSMode == true) && (pwrpriv->pwr_mode > PS_MODE_ACTIVE)) {
+ if (pwrpriv->fw_current_in_ps_mode && (pwrpriv->pwr_mode > PS_MODE_ACTIVE)) {
u8 ps_mode = pwrpriv->pwr_mode;
- /* DBG_871X("change DTIM from %d to %d, ps_mode =%d\n", pwrpriv->dtim, dtim, ps_mode); */
-
rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode));
}
@@ -1875,7 +1803,7 @@ exit:
return res;
}
-static void c2h_wk_callback(_workitem *work)
+static void c2h_wk_callback(struct work_struct *work)
{
struct evt_priv *evtpriv = container_of(work, struct evt_priv, c2h_wk);
struct adapter *adapter = container_of(evtpriv, struct adapter, evtpriv);
@@ -1986,7 +1914,6 @@ void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
_set_timer(&pmlmepriv->scan_to_timer, 1);
} else if (pcmd->res != H2C_SUCCESS) {
_set_timer(&pmlmepriv->scan_to_timer, 1);
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: MgntActrtw_set_802_11_bssid_LIST_SCAN Fail ************\n\n."));
}
/* free cmd */
@@ -2002,7 +1929,6 @@ void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
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."));
return;
}
/* free cmd */
@@ -2035,10 +1961,8 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
if (pcmd->parmbuf == NULL)
goto exit;
- if ((pcmd->res != H2C_SUCCESS)) {
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: rtw_createbss_cmd_callback Fail ************\n\n."));
+ if (pcmd->res != H2C_SUCCESS)
_set_timer(&pmlmepriv->assoc_timer, 1);
- }
del_timer_sync(&pmlmepriv->assoc_timer);
@@ -2049,10 +1973,8 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress);
if (!psta) {
psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress);
- if (psta == NULL) {
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nCan't alloc sta_info when createbss_cmd_callback\n"));
+ if (!psta)
goto createbss_cmd_fail;
- }
}
rtw_indicate_connect(padapter);
@@ -2062,7 +1984,6 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
if (pwlan == NULL) {
pwlan = rtw_get_oldest_wlan_network(&pmlmepriv->scanned_queue);
if (pwlan == NULL) {
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n Error: can't get pwlan in rtw_joinbss_event_callback\n"));
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
goto createbss_cmd_fail;
}
@@ -2106,10 +2027,9 @@ void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pc
struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *) (pcmd->rsp);
struct sta_info *psta = rtw_get_stainfo(pstapriv, psetstakey_rsp->addr);
- if (psta == NULL) {
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: rtw_setstaKey_cmdrsp_callback => can't get sta_info\n\n"));
+ if (!psta)
goto exit;
- }
+
exit:
rtw_free_cmd_obj(pcmd);
}
@@ -2122,10 +2042,8 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *
struct set_assocsta_rsp *passocsta_rsp = (struct set_assocsta_rsp *) (pcmd->rsp);
struct sta_info *psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr);
- if (psta == NULL) {
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: setassocsta_cmdrsp_callbac => can't get sta_info\n\n"));
+ if (!psta)
goto exit;
- }
psta->aid = passocsta_rsp->cam_id;
psta->mac_id = passocsta_rsp->cam_id;
diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c b/drivers/staging/rtl8723bs/core/rtw_debug.c
index c48a8b80af4c..79fd968bb147 100644
--- a/drivers/staging/rtl8723bs/core/rtw_debug.c
+++ b/drivers/staging/rtl8723bs/core/rtw_debug.c
@@ -12,60 +12,15 @@
u32 GlobalDebugLevel = _drv_err_;
-#ifdef DEBUG_RTL871X
-
- u64 GlobalDebugComponents = \
- _module_rtl871x_xmit_c_ |
- _module_xmit_osdep_c_ |
- _module_rtl871x_recv_c_ |
- _module_recv_osdep_c_ |
- _module_rtl871x_mlme_c_ |
- _module_mlme_osdep_c_ |
- _module_rtl871x_sta_mgt_c_ |
- _module_rtl871x_cmd_c_ |
- _module_cmd_osdep_c_ |
- _module_rtl871x_io_c_ |
- _module_io_osdep_c_ |
- _module_os_intfs_c_|
- _module_rtl871x_security_c_|
- _module_rtl871x_eeprom_c_|
- _module_hal_init_c_|
- _module_hci_hal_init_c_|
- _module_rtl871x_ioctl_c_|
- _module_rtl871x_ioctl_set_c_|
- _module_rtl871x_ioctl_query_c_|
- _module_rtl871x_pwrctrl_c_|
- _module_hci_intfs_c_|
- _module_hci_ops_c_|
- _module_hci_ops_os_c_|
- _module_rtl871x_ioctl_os_c|
- _module_rtl8712_cmd_c_|
- _module_hal_xmit_c_|
- _module_rtl8712_recv_c_ |
- _module_mp_ |
- _module_efuse_;
-
-#endif /* DEBUG_RTL871X */
-
#include <rtw_version.h>
-void dump_drv_version(void *sel)
-{
- DBG_871X_SEL_NL(sel, "%s %s\n", "rtl8723bs", DRIVERVERSION);
-}
-
-void dump_log_level(void *sel)
-{
- DBG_871X_SEL_NL(sel, "log_level:%d\n", GlobalDebugLevel);
-}
-
void sd_f0_reg_dump(void *sel, struct adapter *adapter)
{
int i;
for (i = 0x0; i <= 0xff; i++) {
if (i%16 == 0)
- DBG_871X_SEL_NL(sel, "0x%02x ", i);
+ netdev_dbg(adapter->pnetdev, "0x%02x ", i);
DBG_871X_SEL(sel, "%02x ", rtw_sd_f0_read8(adapter, i));
@@ -80,11 +35,11 @@ void mac_reg_dump(void *sel, struct adapter *adapter)
{
int i, j = 1;
- DBG_871X_SEL_NL(sel, "======= MAC REG =======\n");
+ netdev_dbg(adapter->pnetdev, "======= MAC REG =======\n");
for (i = 0x0; i < 0x800; i += 4) {
if (j%4 == 1)
- DBG_871X_SEL_NL(sel, "0x%03x", i);
+ netdev_dbg(adapter->pnetdev, "0x%03x", i);
DBG_871X_SEL(sel, " 0x%08x ", rtw_read32(adapter, i));
if ((j++)%4 == 0)
DBG_871X_SEL(sel, "\n");
@@ -95,10 +50,10 @@ void bb_reg_dump(void *sel, struct adapter *adapter)
{
int i, j = 1;
- DBG_871X_SEL_NL(sel, "======= BB REG =======\n");
+ netdev_dbg(adapter->pnetdev, "======= BB REG =======\n");
for (i = 0x800; i < 0x1000 ; i += 4) {
if (j%4 == 1)
- DBG_871X_SEL_NL(sel, "0x%03x", i);
+ netdev_dbg(adapter->pnetdev, "0x%03x", i);
DBG_871X_SEL(sel, " 0x%08x ", rtw_read32(adapter, i));
if ((j++)%4 == 0)
DBG_871X_SEL(sel, "\n");
@@ -118,14 +73,14 @@ void rf_reg_dump(void *sel, struct adapter *adapter)
else
path_nums = 2;
- DBG_871X_SEL_NL(sel, "======= RF REG =======\n");
+ netdev_dbg(adapter->pnetdev, "======= RF REG =======\n");
for (path = 0; path < path_nums; path++) {
- DBG_871X_SEL_NL(sel, "RF_Path(%x)\n", path);
+ netdev_dbg(adapter->pnetdev, "RF_Path(%x)\n", path);
for (i = 0; i < 0x100; i++) {
value = rtw_hal_read_rfreg(adapter, path, i, 0xffffffff);
if (j%4 == 1)
- DBG_871X_SEL_NL(sel, "0x%02x ", i);
+ netdev_dbg(adapter->pnetdev, "0x%02x ", i);
DBG_871X_SEL(sel, " 0x%08x ", value);
if ((j++)%4 == 0)
DBG_871X_SEL(sel, "\n");
diff --git a/drivers/staging/rtl8723bs/core/rtw_eeprom.c b/drivers/staging/rtl8723bs/core/rtw_eeprom.c
index 3cbd65dee741..be0eda1604d0 100644
--- a/drivers/staging/rtl8723bs/core/rtw_eeprom.c
+++ b/drivers/staging/rtl8723bs/core/rtw_eeprom.c
@@ -35,10 +35,9 @@ void shift_out_bits(_adapter *padapter, u16 data, u16 count)
u16 x, mask;
_func_enter_;
- if (padapter->bSurpriseRemoved == true) {
- RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true"));
+ if (padapter->bSurpriseRemoved)
goto out;
- }
+
mask = 0x01 << (count - 1);
x = rtw_read8(padapter, EE_9346CR);
@@ -48,20 +47,18 @@ _func_enter_;
x &= ~_EEDI;
if (data & mask)
x |= _EEDI;
- if (padapter->bSurpriseRemoved == true) {
- RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true"));
- goto out;
- }
+ if (padapter->bSurpriseRemoved)
+ goto out;
+
rtw_write8(padapter, EE_9346CR, (u8)x);
udelay(CLOCK_RATE);
up_clk(padapter, &x);
down_clk(padapter, &x);
mask = mask >> 1;
} while (mask);
- if (padapter->bSurpriseRemoved == true) {
- RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true"));
+ if (padapter->bSurpriseRemoved)
goto out;
- }
+
x &= ~_EEDI;
rtw_write8(padapter, EE_9346CR, (u8)x);
out:
@@ -72,10 +69,9 @@ u16 shift_in_bits(_adapter *padapter)
{
u16 x, d = 0, i;
_func_enter_;
- if (padapter->bSurpriseRemoved == true) {
- RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true"));
+ if (padapter->bSurpriseRemoved)
goto out;
- }
+
x = rtw_read8(padapter, EE_9346CR);
x &= ~(_EEDO | _EEDI);
@@ -84,10 +80,9 @@ _func_enter_;
for (i = 0; i < 16; i++) {
d = d << 1;
up_clk(padapter, &x);
- if (padapter->bSurpriseRemoved == true) {
- RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true"));
+ if (padapter->bSurpriseRemoved)
goto out;
- }
+
x = rtw_read8(padapter, EE_9346CR);
x &= ~(_EEDI);
@@ -122,26 +117,22 @@ void eeprom_clean(_adapter *padapter)
{
u16 x;
_func_enter_;
- if (padapter->bSurpriseRemoved == true) {
- RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true"));
+ if (padapter->bSurpriseRemoved)
goto out;
- }
+
x = rtw_read8(padapter, EE_9346CR);
- if (padapter->bSurpriseRemoved == true) {
- RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true"));
+ if (padapter->bSurpriseRemoved)
goto out;
- }
+
x &= ~(_EECS | _EEDI);
rtw_write8(padapter, EE_9346CR, (u8)x);
- if (padapter->bSurpriseRemoved == true) {
- RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true"));
+ if (padapter->bSurpriseRemoved)
goto out;
- }
+
up_clk(padapter, &x);
- if (padapter->bSurpriseRemoved == true) {
- RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true"));
+ if (padapter->bSurpriseRemoved)
goto out;
- }
+
down_clk(padapter, &x);
out:
_func_exit_;
@@ -155,17 +146,14 @@ u16 eeprom_read16(_adapter *padapter, u16 reg) /*ReadEEprom*/
_func_enter_;
- if (padapter->bSurpriseRemoved == true) {
- RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true"));
+ if (padapter->bSurpriseRemoved)
goto out;
- }
+
/* select EEPROM, reset bits, set _EECS*/
x = rtw_read8(padapter, EE_9346CR);
- if (padapter->bSurpriseRemoved == true) {
- RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true"));
+ if (padapter->bSurpriseRemoved)
goto out;
- }
x &= ~(_EEDI | _EEDO | _EESK | _EEM0);
x |= _EEM1 | _EECS;
diff --git a/drivers/staging/rtl8723bs/core/rtw_efuse.c b/drivers/staging/rtl8723bs/core/rtw_efuse.c
index 32ca10f01413..a28a06d5a576 100644
--- a/drivers/staging/rtl8723bs/core/rtw_efuse.c
+++ b/drivers/staging/rtl8723bs/core/rtw_efuse.c
@@ -32,12 +32,7 @@ u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0};
#define REG_EFUSE_CTRL 0x0030
#define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */
-bool
-Efuse_Read1ByteFromFakeContent(
- struct adapter *padapter,
- u16 Offset,
- u8 *Value);
-bool
+static bool
Efuse_Read1ByteFromFakeContent(
struct adapter *padapter,
u16 Offset,
@@ -53,12 +48,7 @@ Efuse_Read1ByteFromFakeContent(
return true;
}
-bool
-Efuse_Write1ByteToFakeContent(
- struct adapter *padapter,
- u16 Offset,
- u8 Value);
-bool
+static bool
Efuse_Write1ByteToFakeContent(
struct adapter *padapter,
u16 Offset,
@@ -262,9 +252,6 @@ bool bPseudoTest)
u8 bResult;
u8 readbyte;
- /* DBG_871X("===> EFUSE_OneByteRead(), addr = %x\n", addr); */
- /* DBG_871X("===> EFUSE_OneByteRead() start, 0x34 = 0x%X\n", rtw_read32(padapter, EFUSE_TEST)); */
-
if (bPseudoTest) {
return Efuse_Read1ByteFromFakeContent(padapter, addr, data);
}
@@ -295,8 +282,6 @@ bool bPseudoTest)
} else {
*data = 0xff;
bResult = false;
- DBG_871X("%s: [ERROR] addr = 0x%x bResult =%d time out 1s !!!\n", __func__, addr, bResult);
- DBG_871X("%s: [ERROR] EFUSE_CTRL = 0x%08x !!!\n", __func__, rtw_read32(padapter, EFUSE_CTRL));
}
return bResult;
@@ -309,9 +294,6 @@ u8 efuse_OneByteWrite(struct adapter *padapter, u16 addr, u8 data, bool bPseudoT
u8 bResult = false;
u32 efuseValue = 0;
- /* DBG_871X("===> EFUSE_OneByteWrite(), addr = %x data =%x\n", addr, data); */
- /* DBG_871X("===> EFUSE_OneByteWrite() start, 0x34 = 0x%X\n", rtw_read32(padapter, EFUSE_TEST)); */
-
if (bPseudoTest) {
return Efuse_Write1ByteToFakeContent(padapter, addr, data);
}
@@ -344,9 +326,6 @@ u8 efuse_OneByteWrite(struct adapter *padapter, u16 addr, u8 data, bool bPseudoT
bResult = true;
} else {
bResult = false;
- DBG_871X("%s: [ERROR] addr = 0x%x , efuseValue = 0x%x , bResult =%d time out 1s !!!\n",
- __func__, addr, efuseValue, bResult);
- DBG_871X("%s: [ERROR] EFUSE_CTRL = 0x%08x !!!\n", __func__, rtw_read32(padapter, EFUSE_CTRL));
}
/* disable Efuse program enable */
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index be4cffce4f5d..ae057eefeeb3 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -120,7 +120,7 @@ u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *sourc
/* rtw_set_ie will update frame length */
u8 *rtw_set_ie(u8 *pbuf,
- sint index,
+ signed int index,
uint len,
u8 *source,
uint *frlen) /* frame length */
@@ -140,9 +140,9 @@ u8 *rtw_set_ie(u8 *pbuf,
/*----------------------------------------------------------------------------
index: the information element id index, limit is the limit for search
-----------------------------------------------------------------------------*/
-u8 *rtw_get_ie(u8 *pbuf, sint index, sint *len, sint limit)
+u8 *rtw_get_ie(u8 *pbuf, signed int index, signed int *len, signed int limit)
{
- sint tmp, i;
+ signed int tmp, i;
u8 *p;
if (limit < 1)
@@ -488,11 +488,8 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis
pos += WPA_SELECTOR_LEN;
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));
-
+ } else if (left > 0)
return _FAIL;
- }
/* pairwise_cipher */
if (left >= 2) {
@@ -501,11 +498,8 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis
pos += 2;
left -= 2;
- 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));
+ if (count == 0 || left < count * WPA_SELECTOR_LEN)
return _FAIL;
- }
for (i = 0; i < count; i++) {
*pairwise_cipher |= rtw_get_wpa_cipher_suite(pos);
@@ -514,16 +508,13 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis
left -= WPA_SELECTOR_LEN;
}
- } else if (left == 1) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__));
+ } else if (left == 1)
return _FAIL;
- }
if (is_8021x) {
if (left >= 6) {
pos += 2;
if (!memcmp(pos, SUITE_1X, 4)) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s : there has 802.1x auth\n", __func__));
*is_8021x = 1;
}
}
@@ -559,10 +550,8 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi
pos += RSN_SELECTOR_LEN;
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));
+ } else if (left > 0)
return _FAIL;
- }
/* pairwise_cipher */
if (left >= 2) {
@@ -571,11 +560,8 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi
pos += 2;
left -= 2;
- 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));
+ if (count == 0 || left < count * RSN_SELECTOR_LEN)
return _FAIL;
- }
for (i = 0; i < count; i++) {
*pairwise_cipher |= rtw_get_wpa2_cipher_suite(pos);
@@ -584,19 +570,14 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi
left -= RSN_SELECTOR_LEN;
}
- } else if (left == 1) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__));
-
+ } else if (left == 1)
return _FAIL;
- }
if (is_8021x) {
if (left >= 6) {
pos += 2;
- if (!memcmp(pos, SUITE_1X, 4)) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s (): there has 802.1x auth\n", __func__));
+ if (!memcmp(pos, SUITE_1X, 4))
*is_8021x = 1;
- }
}
}
@@ -607,7 +588,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi
int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len)
{
int len = 0;
- u8 authmode, i;
+ u8 authmode;
uint cnt;
u8 wapi_oui1[4] = {0x0, 0x14, 0x72, 0x01};
u8 wapi_oui2[4] = {0x0, 0x14, 0x72, 0x02};
@@ -626,16 +607,9 @@ int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len)
/* if (authmode == WLAN_EID_BSS_AC_ACCESS_DELAY) */
if (authmode == WLAN_EID_BSS_AC_ACCESS_DELAY && (!memcmp(&in_ie[cnt+6], wapi_oui1, 4) ||
!memcmp(&in_ie[cnt+6], wapi_oui2, 4))) {
- if (wapi_ie) {
+ if (wapi_ie)
memcpy(wapi_ie, &in_ie[cnt], in_ie[cnt+1]+2);
- for (i = 0; i < (in_ie[cnt+1]+2); i = i+8) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n",
- wapi_ie[i], wapi_ie[i+1], wapi_ie[i+2], wapi_ie[i+3], wapi_ie[i+4],
- wapi_ie[i+5], wapi_ie[i+6], wapi_ie[i+7]));
- }
- }
-
if (wapi_len)
*wapi_len = in_ie[cnt+1]+2;
@@ -654,7 +628,7 @@ int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len)
void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len)
{
- u8 authmode, sec_idx, i;
+ u8 authmode;
u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01};
uint cnt;
@@ -662,39 +636,19 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie
cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_);
- sec_idx = 0;
-
while (cnt < in_len) {
authmode = in_ie[cnt];
if ((authmode == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, in_ie[cnt+1]+2));
-
- if (wpa_ie) {
+ if (wpa_ie)
memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt+1]+2);
- for (i = 0; i < (in_ie[cnt+1]+2); i = i+8) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n",
- wpa_ie[i], wpa_ie[i+1], wpa_ie[i+2], wpa_ie[i+3], wpa_ie[i+4],
- wpa_ie[i+5], wpa_ie[i+6], wpa_ie[i+7]));
- }
- }
-
- *wpa_len = in_ie[cnt+1]+2;
- cnt += in_ie[cnt+1]+2; /* get next */
+ *wpa_len = in_ie[cnt + 1] + 2;
+ cnt += in_ie[cnt + 1] + 2; /* get next */
} else {
if (authmode == WLAN_EID_RSN) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n get_rsn_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, in_ie[cnt+1]+2));
-
- if (rsn_ie) {
- memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt+1]+2);
-
- for (i = 0; i < (in_ie[cnt+1]+2); i = i+8) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n",
- rsn_ie[i], rsn_ie[i+1], rsn_ie[i+2], rsn_ie[i+3], rsn_ie[i+4],
- rsn_ie[i+5], rsn_ie[i+6], rsn_ie[i+7]));
- }
- }
+ if (rsn_ie)
+ memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
*rsn_len = in_ie[cnt+1]+2;
cnt += in_ie[cnt+1]+2; /* get next */
@@ -716,7 +670,6 @@ u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen)
eid = ie_ptr[0];
if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&ie_ptr[2], wps_oui, 4))) {
- /* DBG_8192C("==> found WPS_IE.....\n"); */
*wps_ielen = ie_ptr[1]+2;
match = true;
}
@@ -802,7 +755,6 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_att
u16 attr_data_len = get_unaligned_be16(attr_ptr + 2);
u16 attr_len = attr_data_len + 4;
- /* DBG_871X("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */
if (attr_id == target_attr_id) {
target_attr_ptr = attr_ptr;
@@ -863,14 +815,8 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
/* first 3 bytes in vendor specific information element are the IEEE
* OUI of the vendor. The following byte is used a vendor specific
* sub-type. */
- if (elen < 4) {
- if (show_errors) {
- DBG_871X("short vendor specific "
- "information element ignored (len =%lu)\n",
- (unsigned long) elen);
- }
+ if (elen < 4)
return -1;
- }
oui = get_unaligned_be24(pos);
switch (oui) {
@@ -885,13 +831,9 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
elems->wpa_ie_len = elen;
break;
case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */
- if (elen < 5) {
- DBG_871X("short WME "
- "information element ignored "
- "(len =%lu)\n",
- (unsigned long) elen);
+ if (elen < 5)
return -1;
- }
+
switch (pos[4]) {
case WME_OUI_SUBTYPE_INFORMATION_ELEMENT:
case WME_OUI_SUBTYPE_PARAMETER_ELEMENT:
@@ -903,10 +845,6 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
elems->wme_tspec_len = elen;
break;
default:
- DBG_871X("unknown WME "
- "information element ignored "
- "(subtype =%d len =%lu)\n",
- pos[4], (unsigned long) elen);
return -1;
}
break;
@@ -916,10 +854,6 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
elems->wps_ie_len = elen;
break;
default:
- DBG_871X("Unknown Microsoft "
- "information element ignored "
- "(type =%d len =%lu)\n",
- pos[3], (unsigned long) elen);
return -1;
}
break;
@@ -931,19 +865,11 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
elems->vendor_ht_cap_len = elen;
break;
default:
- DBG_871X("Unknown Broadcom "
- "information element ignored "
- "(type =%d len =%lu)\n",
- pos[3], (unsigned long) elen);
return -1;
}
break;
default:
- DBG_871X("unknown vendor specific information "
- "element ignored (vendor OUI %02x:%02x:%02x "
- "len =%lu)\n",
- pos[0], pos[1], pos[2], (unsigned long) elen);
return -1;
}
@@ -958,7 +884,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,
* @show_errors: Whether to show parsing errors in debug log
* Returns: Parsing result
*/
-ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
+enum ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
struct rtw_ieee802_11_elems *elems,
int show_errors)
{
@@ -975,15 +901,8 @@ ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
elen = *pos++;
left -= 2;
- if (elen > left) {
- if (show_errors) {
- DBG_871X("IEEE 802.11 element "
- "parse failed (id =%d elen =%d "
- "left =%lu)\n",
- id, elen, (unsigned long) left);
- }
+ if (elen > left)
return ParseFailed;
- }
switch (id) {
case WLAN_EID_SSID:
@@ -1078,11 +997,6 @@ ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
break;
default:
unknown++;
- if (!show_errors)
- break;
- DBG_871X("IEEE 802.11 element parse "
- "ignored unknown element (id =%d elen =%d)\n",
- id, elen);
break;
}
@@ -1115,16 +1029,14 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr)
}
if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) {
- if ((addr = of_get_property(np, "local-mac-address", &len)) &&
- len == ETH_ALEN) {
+ addr = of_get_property(np, "local-mac-address", &len);
+
+ if (addr && len == ETH_ALEN) {
ether_addr_copy(mac_addr, addr);
} else {
eth_random_addr(mac_addr);
- DBG_871X("MAC Address from efuse error, assign random one !!!\n");
}
}
-
- DBG_871X("rtw_macaddr_cfg MAC Address = %pM\n", MAC_ARG(mac_addr));
}
static int rtw_get_cipher_info(struct wlan_network *pnetwork)
@@ -1137,28 +1049,20 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork)
pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12);
if (pbuf && (wpa_ielen > 0)) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_cipher_info: wpa_ielen: %d", wpa_ielen));
if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) {
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, is_8021x is %d",
- __func__, pnetwork->BcnInfo.pairwise_cipher, pnetwork->BcnInfo.is_8021x));
ret = _SUCCESS;
}
} else {
pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12);
if (pbuf && (wpa_ielen > 0)) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("get RSN IE\n"));
if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("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));
ret = _SUCCESS;
}
}
@@ -1188,10 +1092,6 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork)
pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS;
}
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));
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len));
if (rsn_len > 0) {
pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA2;
@@ -1201,10 +1101,6 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork)
if (bencrypt)
pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WEP;
}
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: pnetwork->encryp_protocol is %x\n",
- pnetwork->BcnInfo.encryp_protocol));
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: pnetwork->encryp_protocol is %x\n",
- pnetwork->BcnInfo.encryp_protocol));
rtw_get_cipher_info(pnetwork);
/* get bwmode and ch_offset */
diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index c3f63f903547..c860ab7d618c 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -130,7 +130,9 @@ u8 _rtw_sd_f0_read8(struct adapter *adapter, u32 addr)
if (_sd_f0_read8)
r_val = _sd_f0_read8(pintfhdl, addr);
else
- DBG_871X_LEVEL(_drv_warning_, FUNC_ADPT_FMT" _sd_f0_read8 callback is NULL\n", FUNC_ADPT_ARG(adapter));
+ netdev_warn(adapter->pnetdev,
+ FUNC_ADPT_FMT " _sd_f0_read8 callback is NULL\n",
+ FUNC_ADPT_ARG(adapter));
return r_val;
}
@@ -172,12 +174,9 @@ int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj)
{
int ret = false;
int value = atomic_inc_return(&dvobj->continual_io_error);
- if (value > MAX_CONTINUAL_IO_ERR) {
- DBG_871X("[dvobj:%p][ERROR] continual_io_error:%d > %d\n", dvobj, value, MAX_CONTINUAL_IO_ERR);
+ if (value > MAX_CONTINUAL_IO_ERR)
ret = true;
- } else {
- /* DBG_871X("[dvobj:%p] continual_io_error:%d\n", dvobj, value); */
- }
+
return ret;
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
index 1cfdf7c93662..bd5056507f53 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c
@@ -28,27 +28,14 @@ u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid)
u8 ret = true;
if (ssid->SsidLength > 32) {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid length >32\n"));
ret = false;
goto exit;
}
-#ifdef CONFIG_VALIDATE_SSID
- for (i = 0; i < ssid->SsidLength; i++) {
- /* wifi, printable ascii code must be supported */
- if (!((ssid->Ssid[i] >= 0x20) && (ssid->Ssid[i] <= 0x7e))) {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid has non-printable ascii\n"));
- ret = false;
- break;
- }
- }
-#endif /* CONFIG_VALIDATE_SSID */
-
exit:
return ret;
}
-u8 rtw_do_join(struct adapter *padapter);
u8 rtw_do_join(struct adapter *padapter)
{
struct list_head *plist, *phead;
@@ -61,8 +48,6 @@ u8 rtw_do_join(struct adapter *padapter)
phead = get_list_head(queue);
plist = get_next(phead);
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("\n rtw_do_join: phead = %p; plist = %p\n\n\n", phead, plist));
-
pmlmepriv->cur_network.join_res = -2;
set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
@@ -81,13 +66,11 @@ u8 rtw_do_join(struct adapter *padapter)
if (pmlmepriv->LinkDetectInfo.bBusyTraffic == false
|| rtw_to_roam(padapter) > 0
) {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_do_join(): site survey if scanned_queue is empty\n."));
/* submit site_survey_cmd */
ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0);
- if (_SUCCESS != ret) {
+ if (ret != _SUCCESS)
pmlmepriv->to_join = false;
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_do_join(): site survey return error\n."));
- }
+
} else {
pmlmepriv->to_join = false;
ret = _FAIL;
@@ -119,15 +102,12 @@ u8 rtw_do_join(struct adapter *padapter)
rtw_generate_random_ibss(pibss);
if (rtw_createbss_cmd(padapter) != _SUCCESS) {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>do_goin: rtw_createbss_cmd status FAIL***\n "));
ret = false;
goto exit;
}
pmlmepriv->to_join = false;
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("***Error => rtw_select_and_join_from_scanned_queue FAIL under STA_Mode***\n "));
-
} else {
/* can't associate ; reset under-linking */
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
@@ -137,12 +117,10 @@ u8 rtw_do_join(struct adapter *padapter)
if (pmlmepriv->LinkDetectInfo.bBusyTraffic == false
|| rtw_to_roam(padapter) > 0
) {
- /* DBG_871X("rtw_do_join() when no desired bss in scanning queue\n"); */
ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0);
- if (_SUCCESS != ret) {
+ if (ret != _SUCCESS)
pmlmepriv->to_join = false;
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("do_join(): site survey return error\n."));
- }
+
} else {
ret = _FAIL;
pmlmepriv->to_join = false;
@@ -163,7 +141,7 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid)
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- DBG_871X_LEVEL(_drv_always_, "set bssid:%pM\n", bssid);
+ netdev_dbg(padapter->pnetdev, "set bssid:%pM\n", bssid);
if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 && bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) ||
(bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF && bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) {
@@ -174,23 +152,16 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid)
spin_lock_bh(&pmlmepriv->lock);
- DBG_871X("Set BSSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv));
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true)
goto handle_tkip_countermeasure;
else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)
goto release_mlme_lock;
if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n"));
-
if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) {
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)
goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */
} else {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set BSSID not the same bssid\n"));
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid =%pM\n", MAC_ARG(bssid)));
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("cur_bssid =%pM\n", MAC_ARG(pmlmepriv->cur_network.network.MacAddress)));
-
rtw_disassoc_cmd(padapter, 0, true);
if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
@@ -224,8 +195,6 @@ release_mlme_lock:
spin_unlock_bh(&pmlmepriv->lock);
exit:
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
- ("rtw_set_802_11_bssid: status =%d\n", status));
return status;
}
@@ -237,35 +206,25 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid)
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_network *pnetwork = &pmlmepriv->cur_network;
- DBG_871X_LEVEL(_drv_always_, "set ssid [%s] fw_state = 0x%08x\n",
- ssid->Ssid, get_fwstate(pmlmepriv));
+ netdev_dbg(padapter->pnetdev, "set ssid [%s] fw_state = 0x%08x\n",
+ ssid->Ssid, get_fwstate(pmlmepriv));
if (padapter->hw_init_completed == false) {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
- ("set_ssid: hw_init_completed ==false =>exit!!!\n"));
status = _FAIL;
goto exit;
}
spin_lock_bh(&pmlmepriv->lock);
- DBG_871X("Set SSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv));
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true)
goto handle_tkip_countermeasure;
else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)
goto release_mlme_lock;
if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
- ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n"));
-
if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) &&
(!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) {
if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
- ("Set SSID is the same ssid, fw_state = 0x%08x\n",
- get_fwstate(pmlmepriv)));
-
if (rtw_is_same_ibss(padapter, pnetwork) == false) {
/* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */
rtw_disassoc_cmd(padapter, 0, true);
@@ -286,10 +245,6 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid)
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_JOINBSS, 1);
}
} else {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set SSID not the same ssid\n"));
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid =[%s] len = 0x%x\n", ssid->Ssid, (unsigned int)ssid->SsidLength));
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("assoc_ssid =[%s] len = 0x%x\n", pmlmepriv->assoc_ssid.Ssid, (unsigned int)pmlmepriv->assoc_ssid.SsidLength));
-
rtw_disassoc_cmd(padapter, 0, true);
if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
@@ -327,8 +282,6 @@ release_mlme_lock:
spin_unlock_bh(&pmlmepriv->lock);
exit:
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
- ("-rtw_set_802_11_ssid: status =%d\n", status));
return status;
}
@@ -347,23 +300,19 @@ u8 rtw_set_802_11_connect(struct adapter *padapter, u8 *bssid, struct ndis_802_1
bssid_valid = false;
if (!ssid_valid && !bssid_valid) {
- DBG_871X(FUNC_ADPT_FMT" ssid:%p, ssid_valid:%d, bssid:%p, bssid_valid:%d\n",
- FUNC_ADPT_ARG(padapter), ssid, ssid_valid, bssid, bssid_valid);
status = _FAIL;
goto exit;
}
if (padapter->hw_init_completed == false) {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
- ("set_ssid: hw_init_completed ==false =>exit!!!\n"));
status = _FAIL;
goto exit;
}
spin_lock_bh(&pmlmepriv->lock);
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" fw_state = 0x%08x\n",
- FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv));
+ netdev_dbg(padapter->pnetdev, FUNC_ADPT_FMT " fw_state = 0x%08x\n",
+ FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv));
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true)
goto handle_tkip_countermeasure;
@@ -401,20 +350,13 @@ exit:
}
u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter,
- enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype)
+ enum ndis_802_11_network_infrastructure networktype)
{
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_network *cur_network = &pmlmepriv->cur_network;
- enum NDIS_802_11_NETWORK_INFRASTRUCTURE *pold_state = &(cur_network->network.InfrastructureMode);
-
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_,
- ("+rtw_set_802_11_infrastructure_mode: old =%d new =%d fw_state = 0x%08x\n",
- *pold_state, networktype, get_fwstate(pmlmepriv)));
+ enum ndis_802_11_network_infrastructure *pold_state = &(cur_network->network.InfrastructureMode);
if (*pold_state != networktype) {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, (" change mode!"));
- /* DBG_871X("change mode, old_mode =%d, new_mode =%d, fw_state = 0x%x\n", *pold_state, networktype, get_fwstate(pmlmepriv)); */
-
if (*pold_state == Ndis802_11APMode) {
/* change to other mode from Ndis802_11APMode */
cur_network->join_res = -1;
@@ -463,9 +405,6 @@ u8 rtw_set_802_11_infrastructure_mode(struct 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);
}
return true;
@@ -479,14 +418,11 @@ u8 rtw_set_802_11_disassociate(struct adapter *padapter)
spin_lock_bh(&pmlmepriv->lock);
if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_disassociate: rtw_indicate_disconnect\n"));
-
rtw_disassoc_cmd(padapter, 0, true);
rtw_indicate_disconnect(padapter);
/* modify for CONFIG_IEEE80211W, none 11w can use it */
rtw_free_assoc_resources_cmd(padapter);
- if (_FAIL == rtw_pwr_wakeup(padapter))
- DBG_871X("%s(): rtw_pwr_wakeup fail !!!\n", __func__);
+ rtw_pwr_wakeup(padapter);
}
spin_unlock_bh(&pmlmepriv->lock);
@@ -499,31 +435,22 @@ u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_s
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
u8 res = true;
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("+rtw_set_802_11_bssid_list_scan(), fw_state =%x\n", get_fwstate(pmlmepriv)));
-
if (padapter == NULL) {
res = false;
goto exit;
}
if (padapter->hw_init_completed == false) {
res = false;
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n ===rtw_set_802_11_bssid_list_scan:hw_init_completed ==false ===\n"));
goto exit;
}
if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) ||
(pmlmepriv->LinkDetectInfo.bBusyTraffic == true)) {
/* Scan or linking is in progress, do nothing. */
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_bssid_list_scan fail since fw_state = %x\n", get_fwstate(pmlmepriv)));
res = true;
- if (check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)) == true)
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###_FW_UNDER_SURVEY|_FW_UNDER_LINKING\n\n"));
- else
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###pmlmepriv->sitesurveyctrl.traffic_busy ==true\n\n"));
} else {
if (rtw_is_scan_deny(padapter)) {
- DBG_871X(FUNC_ADPT_FMT": scan deny\n", FUNC_ADPT_ARG(padapter));
indicate_wx_scan_complete_event(padapter);
return _SUCCESS;
}
@@ -539,18 +466,14 @@ exit:
return res;
}
-u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum NDIS_802_11_AUTHENTICATION_MODE authmode)
+u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11_authentication_mode authmode)
{
struct security_priv *psecuritypriv = &padapter->securitypriv;
int res;
u8 ret;
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_802_11_auth.mode(): mode =%x\n", authmode));
-
psecuritypriv->ndisauthtype = authmode;
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_set_802_11_authentication_mode:psecuritypriv->ndisauthtype =%d", psecuritypriv->ndisauthtype));
-
if (psecuritypriv->ndisauthtype > 3)
psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
@@ -567,14 +490,13 @@ u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum NDIS_802_11
u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep)
{
- sint keyid, res;
+ signed int keyid, res;
struct security_priv *psecuritypriv = &(padapter->securitypriv);
u8 ret = _SUCCESS;
keyid = wep->KeyIndex & 0x3fffffff;
if (keyid >= 4) {
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MgntActrtw_set_802_11_add_wep:keyid>4 =>fail\n"));
ret = false;
goto exit;
}
@@ -582,35 +504,21 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep)
switch (wep->KeyLength) {
case 5:
psecuritypriv->dot11PrivacyAlgrthm = _WEP40_;
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength =5\n"));
break;
case 13:
psecuritypriv->dot11PrivacyAlgrthm = _WEP104_;
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength = 13\n"));
break;
default:
psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength!=5 or 13\n"));
break;
}
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
- ("rtw_set_802_11_add_wep:before memcpy, wep->KeyLength = 0x%x wep->KeyIndex = 0x%x keyid =%x\n",
- wep->KeyLength, wep->KeyIndex, keyid));
-
memcpy(&(psecuritypriv->dot11DefKey[keyid].skey[0]), &(wep->KeyMaterial), wep->KeyLength);
psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength;
psecuritypriv->dot11PrivacyKeyIndex = keyid;
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_set_802_11_add_wep:security key material : %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
- psecuritypriv->dot11DefKey[keyid].skey[0], psecuritypriv->dot11DefKey[keyid].skey[1], psecuritypriv->dot11DefKey[keyid].skey[2],
- psecuritypriv->dot11DefKey[keyid].skey[3], psecuritypriv->dot11DefKey[keyid].skey[4], psecuritypriv->dot11DefKey[keyid].skey[5],
- psecuritypriv->dot11DefKey[keyid].skey[6], psecuritypriv->dot11DefKey[keyid].skey[7], psecuritypriv->dot11DefKey[keyid].skey[8],
- psecuritypriv->dot11DefKey[keyid].skey[9], psecuritypriv->dot11DefKey[keyid].skey[10], psecuritypriv->dot11DefKey[keyid].skey[11],
- psecuritypriv->dot11DefKey[keyid].skey[12]));
-
res = rtw_set_key(padapter, psecuritypriv, keyid, 1, true);
if (res == _FAIL)
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 2c9425e2a1e9..4707dba90397 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -12,8 +12,6 @@
#include <hal_btcoex.h>
#include <linux/jiffies.h>
-extern u8 rtw_do_join(struct adapter *padapter);
-
int rtw_init_mlme_priv(struct adapter *padapter)
{
int i;
@@ -67,9 +65,6 @@ int rtw_init_mlme_priv(struct adapter *padapter)
pmlmepriv->roam_flags = 0
| RTW_ROAM_ON_EXPIRED
| RTW_ROAM_ON_RESUME
- #ifdef CONFIG_LAYER2_ROAMING_ACTIVE /* FIXME */
- | RTW_ROAM_ACTIVE
- #endif
;
pmlmepriv->roam_scanr_exp_ms = RTW_ROAM_SCAN_RESULT_EXP_MS;
@@ -160,8 +155,6 @@ struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv)
list_del_init(&pnetwork->list);
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
- ("rtw_alloc_network: ptr =%p\n", plist));
pnetwork->network_type = 0;
pnetwork->fixed = false;
pnetwork->last_scanned = jiffies;
@@ -207,8 +200,6 @@ void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwor
pmlmepriv->num_of_scanned--;
- /* DBG_871X("_rtw_free_network:SSID =%s\n", pnetwork->network.Ssid.Ssid); */
-
spin_unlock_bh(&free_queue->lock);
}
@@ -298,16 +289,16 @@ void rtw_free_network_queue(struct adapter *padapter, u8 isfreeall)
spin_unlock_bh(&scanned_queue->lock);
}
-sint rtw_if_up(struct adapter *padapter)
+signed int rtw_if_up(struct adapter *padapter)
{
- sint res;
+ signed int res;
if (padapter->bDriverStopped || padapter->bSurpriseRemoved ||
- (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_if_up:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved));
+ (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false))
res = false;
- } else
+ else
res = true;
+
return res;
}
@@ -344,7 +335,6 @@ u8 *rtw_get_beacon_interval_from_ie(u8 *ie)
void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv)
{
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv\n"));
_rtw_free_mlme_priv(pmlmepriv);
}
@@ -361,7 +351,6 @@ static struct wlan_network *rtw_dequeue_network(struct __queue *queue)
void rtw_free_network_nolock(struct adapter *padapter, struct wlan_network *pnetwork);
void rtw_free_network_nolock(struct adapter *padapter, struct wlan_network *pnetwork)
{
- /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_network ==> ssid = %s\n\n" , pnetwork->network.Ssid.Ssid)); */
_rtw_free_network_nolock(&(padapter->mlmepriv), pnetwork);
rtw_cfg80211_unlink_bss(padapter, pnetwork);
}
@@ -398,8 +387,6 @@ int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork)
inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b)
{
- /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("(%s,%d)(%s,%d)\n", */
- /* a->Ssid.Ssid, a->Ssid.SsidLength, b->Ssid.Ssid, b->Ssid.SsidLength)); */
return (a->Ssid.SsidLength == b->Ssid.SsidLength)
&& !memcmp(a->Ssid.Ssid, b->Ssid.Ssid, a->Ssid.SsidLength);
}
@@ -492,17 +479,6 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
u8 sq_final;
long rssi_final;
- #if defined(DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) && 1
- if (strcmp(dst->Ssid.Ssid, DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) == 0) {
- DBG_871X(FUNC_ADPT_FMT" %s(%pM, ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n"
- , FUNC_ADPT_ARG(padapter)
- , src->Ssid.Ssid, MAC_ARG(src->MacAddress), src->Configuration.DSConfig
- , ss_ori, sq_ori, rssi_ori
- , ss_smp, sq_smp, rssi_smp
- );
- }
- #endif
-
/* The rule below is 1/5 for sample value, 4/5 for history value */
if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network(&(padapter->mlmepriv.cur_network.network), src, 0)) {
/* Take the recvpriv's value for the connected AP*/
@@ -536,14 +512,6 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
dst->PhyInfo.SignalStrength = ss_final;
dst->PhyInfo.SignalQuality = sq_final;
dst->Rssi = rssi_final;
-
- #if defined(DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) && 1
- if (strcmp(dst->Ssid.Ssid, DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) == 0) {
- DBG_871X(FUNC_ADPT_FMT" %s(%pM), SignalStrength:%u, SignalQuality:%u, RawRSSI:%ld\n"
- , FUNC_ADPT_ARG(padapter)
- , dst->Ssid.Ssid, MAC_ARG(dst->MacAddress), dst->PhyInfo.SignalStrength, dst->PhyInfo.SignalQuality, dst->Rssi);
- }
- #endif
}
static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork)
@@ -556,8 +524,6 @@ static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex
&(pmlmepriv->cur_network.network));
if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && (is_same_network(&(pmlmepriv->cur_network.network), pnetwork, 0))) {
- /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,"Same Network\n"); */
-
/* if (pmlmepriv->cur_network.network.IELength<= pnetwork->IELength) */
{
update_network(&(pmlmepriv->cur_network.network), pnetwork, adapter, true);
@@ -599,7 +565,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t
}
if (rtw_roam_flags(adapter)) {
- /* TODO: don't select netowrk in the same ess as oldest if it's new enough*/
+ /* TODO: don't select network in the same ess as oldest if it's new enough*/
}
if (oldest == NULL || time_after(oldest->last_scanned, pnetwork->last_scanned))
@@ -617,10 +583,9 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t
/* If there are no more slots, expire the oldest */
/* list_del_init(&oldest->list); */
pnetwork = oldest;
- if (!pnetwork) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n"));
+ if (!pnetwork)
goto exit;
- }
+
memcpy(&(pnetwork->network), target, get_wlan_bssid_ex_sz(target));
/* variable initialize */
pnetwork->fixed = false;
@@ -638,10 +603,8 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t
pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */
- if (!pnetwork) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n"));
+ if (!pnetwork)
goto exit;
- }
bssid_ex_sz = get_wlan_bssid_ex_sz(target);
target->Length = bssid_ex_sz;
@@ -744,10 +707,8 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor
}
}
- if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0)) {
- DBG_871X("desired_encmode: %d, privacy: %d\n", desired_encmode, privacy);
+ if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0))
bselected = false;
- }
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) {
if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode)
@@ -760,7 +721,6 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor
/* TODO: Perry : For Power Management */
void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf)
{
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_event\n"));
}
void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf)
@@ -771,19 +731,14 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf)
pnetwork = (struct wlan_bssid_ex *)pbuf;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_survey_event_callback, 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_callback: return a wrong bss ***\n"));
+ if (len > (sizeof(struct wlan_bssid_ex)))
return;
- }
spin_lock_bh(&pmlmepriv->lock);
/* update IBSS_network 's timestamp */
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) {
- /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,"rtw_survey_event_callback : WIFI_ADHOC_MASTER_STATE\n\n"); */
if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) {
struct wlan_network *ibss_wlan = NULL;
@@ -822,14 +777,9 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf)
pmlmepriv->wps_probe_req_ie = NULL;
}
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback: fw_state:%x\n\n", get_fwstate(pmlmepriv)));
-
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) {
del_timer_sync(&pmlmepriv->scan_to_timer);
_clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
- } else {
-
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status =%x, survey done event comes too late!\n", get_fwstate(pmlmepriv)));
}
rtw_set_signal_stat_timer(&adapter->recvpriv);
@@ -842,14 +792,13 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf)
if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS) {
_set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
} else {
+ u8 ret = _SUCCESS;
struct wlan_bssid_ex *pdev_network = &(adapter->registrypriv.dev_network);
u8 *pibss = adapter->registrypriv.dev_network.MacAddress;
/* pmlmepriv->fw_state ^= _FW_UNDER_SURVEY;because don't set assoc_timer */
_clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("switching to adhoc master\n"));
-
memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid));
rtw_update_registrypriv_dev_network(adapter);
@@ -857,10 +806,11 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf)
pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
- if (rtw_createbss_cmd(adapter) != _SUCCESS)
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error =>rtw_createbss_cmd status FAIL\n"));
-
pmlmepriv->to_join = false;
+
+ ret = rtw_createbss_cmd(adapter);
+ if (ret != _SUCCESS)
+ goto unlock;
}
}
} else {
@@ -875,8 +825,6 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf)
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
rtw_indicate_connect(adapter);
} else {
- DBG_871X("try_to_join, but select scanning queue fail, to_roam:%d\n", rtw_to_roam(adapter));
-
if (rtw_to_roam(adapter) != 0) {
if (rtw_dec_to_roam(adapter) == 0
|| _SUCCESS != rtw_sitesurvey_cmd(adapter, &pmlmepriv->assoc_ssid, 1, NULL, 0)
@@ -905,8 +853,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf)
}
}
- /* DBG_871X("scan complete in %dms\n", jiffies_to_msecs(jiffies - pmlmepriv->scan_start_time)); */
-
+unlock:
spin_unlock_bh(&pmlmepriv->lock);
rtw_os_xmit_schedule(adapter);
@@ -930,7 +877,6 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv)
struct __queue *scan_queue = &pmlmepriv->scanned_queue;
struct list_head *plist, *phead, *ptemp;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+free_scanqueue\n"));
spin_lock_bh(&scan_queue->lock);
spin_lock_bh(&free_queue->lock);
@@ -967,8 +913,6 @@ static void find_network(struct adapter *adapter)
pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress);
if (pwlan)
pwlan->fixed = false;
- else
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_assoc_resources : pwlan == NULL\n\n"));
if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) &&
(adapter->stapriv.asoc_sta_count == 1))
@@ -986,10 +930,6 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue)
struct dvobj_priv *psdpriv = adapter->dvobj;
struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_free_assoc_resources\n"));
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("tgt_network->network.MacAddress =%pM ssid =%s\n",
- MAC_ARG(tgt_network->network.MacAddress), tgt_network->network.Ssid.Ssid));
-
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) {
struct sta_info *psta;
@@ -1027,8 +967,6 @@ void rtw_indicate_connect(struct adapter *padapter)
{
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_connect\n"));
-
pmlmepriv->to_join = false;
if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) {
@@ -1041,7 +979,6 @@ void rtw_indicate_connect(struct adapter *padapter)
rtw_set_to_roam(padapter, 0);
rtw_set_scan_deny(padapter, 3000);
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("-rtw_indicate_connect: fw_state = 0x%08x\n", get_fwstate(pmlmepriv)));
}
/*
@@ -1051,12 +988,8 @@ void rtw_indicate_disconnect(struct adapter *padapter)
{
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_disconnect\n"));
-
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING|WIFI_UNDER_WPS);
- /* DBG_871X("clear wps when %s\n", __func__); */
-
if (rtw_to_roam(padapter) > 0)
_clr_fwstate_(pmlmepriv, _FW_LINKED);
@@ -1078,8 +1011,6 @@ void rtw_indicate_disconnect(struct adapter *padapter)
inline void rtw_indicate_scan_done(struct adapter *padapter, bool aborted)
{
- DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
-
rtw_os_indicate_scan_done(padapter, aborted);
if (is_primary_adapter(padapter) &&
@@ -1105,15 +1036,12 @@ void rtw_scan_abort(struct adapter *adapter)
if (adapter->bDriverStopped || adapter->bSurpriseRemoved)
break;
- DBG_871X(FUNC_NDEV_FMT"fw_state = _FW_UNDER_SURVEY!\n", FUNC_NDEV_ARG(adapter->pnetdev));
msleep(20);
}
- if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) {
- if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved)
- DBG_871X(FUNC_NDEV_FMT"waiting for scan_abort time out!\n", FUNC_NDEV_ARG(adapter->pnetdev));
+ if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
rtw_indicate_scan_done(adapter, true);
- }
+
pmlmeext->scan_abort = false;
}
@@ -1131,8 +1059,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str
if (psta) { /* update ptarget_sta */
- DBG_871X("%s\n", __func__);
-
psta->aid = pnetwork->join_res;
update_sta_info(padapter, psta);
@@ -1184,10 +1110,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str
preorder_ctrl = &psta->recvreorder_ctrl[i];
preorder_ctrl->enable = false;
preorder_ctrl->indicate_seq = 0xffff;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d indicate_seq:%u\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq);
- #endif
preorder_ctrl->wend_b = 0xffff;
preorder_ctrl->wsize_b = 64;/* max_ampdu_sz;ex. 32(kbytes) -> wsize_b =32 */
}
@@ -1199,10 +1121,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str
preorder_ctrl = &bmc_sta->recvreorder_ctrl[i];
preorder_ctrl->enable = false;
preorder_ctrl->indicate_seq = 0xffff;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d indicate_seq:%u\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq);
- #endif
preorder_ctrl->wend_b = 0xffff;
preorder_ctrl->wsize_b = 64;/* max_ampdu_sz;ex. 32(kbytes) -> wsize_b =32 */
}
@@ -1220,11 +1138,6 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
struct wlan_network *cur_network = &(pmlmepriv->cur_network);
- DBG_871X("%s\n", __func__);
-
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nfw_state:%x, BSSID:%pM\n"
- , get_fwstate(pmlmepriv), MAC_ARG(pnetwork->network.MacAddress)));
-
/* why not use ptarget_wlan?? */
memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length);
/* some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */
@@ -1239,15 +1152,6 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net
padapter->recvpriv.signal_qual = ptarget_wlan->network.PhyInfo.SignalQuality;
/* the ptarget_wlan->network.Rssi is raw data, we use ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) */
padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.PhyInfo.SignalStrength);
- #if defined(DBG_RX_SIGNAL_DISPLAY_PROCESSING) && 1
- DBG_871X(FUNC_ADPT_FMT" signal_strength:%3u, rssi:%3d, signal_qual:%3u"
- "\n"
- , FUNC_ADPT_ARG(padapter)
- , padapter->recvpriv.signal_strength
- , padapter->recvpriv.rssi
- , padapter->recvpriv.signal_qual
- );
- #endif
rtw_set_signal_stat_timer(&padapter->recvpriv);
@@ -1266,7 +1170,6 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net
break;
default:
pmlmepriv->fw_state = WIFI_NULL_STATE;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Invalid network_mode\n"));
break;
}
@@ -1295,30 +1198,19 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf)
struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL;
unsigned int the_same_macaddr = false;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("joinbss event call back received with res =%d\n", pnetwork->join_res));
-
rtw_get_encrypt_decrypt_from_registrypriv(adapter);
- if (pmlmepriv->assoc_ssid.SsidLength == 0)
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ joinbss event call back for Any SSid\n"));
- else
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid));
-
the_same_macaddr = !memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN);
pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network);
- if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n ***joinbss_evt_callback return a wrong bss ***\n\n"));
+ if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex))
return;
- }
spin_lock_bh(&pmlmepriv->lock);
pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 0;
pmlmepriv->LinkDetectInfo.LowPowerTransitionCount = 0;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_joinbss_event_callback !! spin_lock_irqsave\n"));
-
if (pnetwork->join_res > 0) {
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
retry = 0;
@@ -1355,7 +1247,8 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf)
if (ptarget_wlan) {
rtw_joinbss_update_network(adapter, ptarget_wlan, pnetwork);
} else {
- DBG_871X_LEVEL(_drv_always_, "Can't find ptarget_wlan when joinbss_event callback\n");
+ netdev_dbg(adapter->pnetdev,
+ "Can't find ptarget_wlan when joinbss_event callback\n");
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
goto ignore_joinbss_callback;
}
@@ -1364,7 +1257,6 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf)
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork);
if (!ptarget_sta) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't update stainfo when joinbss_event callback\n"));
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
goto ignore_joinbss_callback;
}
@@ -1374,18 +1266,12 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf)
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
pmlmepriv->cur_network_scanned = ptarget_wlan;
rtw_indicate_connect(adapter);
- } else {
- /* adhoc mode will rtw_indicate_connect when rtw_stassoc_event_callback */
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("adhoc mode, fw_state:%x", get_fwstate(pmlmepriv)));
}
/* s5. Cancel assoc_timer */
del_timer_sync(&pmlmepriv->assoc_timer);
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("Cancel assoc_timer\n"));
-
} else {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_joinbss_event_callback err: fw_state:%x", get_fwstate(pmlmepriv)));
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
goto ignore_joinbss_callback;
}
@@ -1398,19 +1284,15 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf)
/* rtw_free_assoc_resources(adapter, 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)));
+ if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == true)
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
- }
} else {/* if join_res < 0 (join fails), then try again */
#ifdef REJOIN
res = _FAIL;
- if (retry < 2) {
+ if (retry < 2)
res = rtw_select_and_join_from_scanned_queue(pmlmepriv);
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_select_and_join_from_scanned_queue again! res:%d\n", res));
- }
if (res == _SUCCESS) {
/* extend time of assoc_timer */
@@ -1420,7 +1302,6 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf)
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
rtw_indicate_connect(adapter);
} else {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Set Assoc_Timer = 1; can't find match ssid in scanned_q\n"));
#endif
_set_timer(&pmlmepriv->assoc_timer, 1);
@@ -1478,12 +1359,9 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf)
rtw_sta_media_status_rpt(adapter, psta, 1);
-#ifndef CONFIG_AUTO_AP_MODE
-
ap_sta_info_defer_update(adapter, psta);
/* report to upper layer */
- DBG_871X("indicate_sta_assoc_event to upper layer - hostapd\n");
spin_lock_bh(&psta->lock);
if (psta->passoc_req && psta->assoc_req_len > 0) {
passoc_req = rtw_zmalloc(psta->assoc_req_len);
@@ -1503,7 +1381,6 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf)
kfree(passoc_req);
}
-#endif /* CONFIG_AUTO_AP_MODE */
}
return;
}
@@ -1513,22 +1390,18 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf)
if (psta) {
/* the sta have been in sta_info_queue => do nothing */
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: rtw_stassoc_event_callback: sta has been in sta_hash_queue\n"));
-
return; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */
}
psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr);
- if (!psta) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't alloc sta_info when rtw_stassoc_event_callback\n"));
+ if (!psta)
return;
- }
/* to do : init sta_info variable */
psta->qos_option = 0;
psta->mac_id = (uint)pstassoc->cam_id;
/* psta->aid = (uint)pstassoc->cam_id; */
- DBG_871X("%s\n", __func__);
+
/* for ad-hoc mode */
rtw_hal_set_odm_var(adapter, HAL_ODM_STA_INFO, psta, true);
@@ -1579,8 +1452,6 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf)
else
mac_id = pstadel->mac_id;
- DBG_871X("%s(mac_id =%d) =%pM\n", __func__, mac_id, MAC_ARG(pstadel->macaddr));
-
if (mac_id >= 0) {
u16 media_status;
@@ -1643,6 +1514,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf)
rtw_free_stainfo(adapter, psta);
if (adapter->stapriv.asoc_sta_count == 1) {/* a sta + bc/mc_stainfo (not Ibss_stainfo) */
+ u8 ret = _SUCCESS;
/* rtw_indicate_disconnect(adapter);removed@20091105 */
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
/* free old ibss network */
@@ -1670,12 +1542,14 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf)
_clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE);
}
- if (rtw_createbss_cmd(adapter) != _SUCCESS)
- RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>stadel_event_callback: rtw_createbss_cmd status FAIL***\n "));
+ ret = rtw_createbss_cmd(adapter);
+ if (ret != _SUCCESS)
+ goto unlock;
}
}
+unlock:
spin_unlock_bh(&pmlmepriv->lock);
}
@@ -1683,7 +1557,6 @@ void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf)
{
struct reportpwrstate_parm *preportpwrstate;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_cpwm_event_callback !!!\n"));
preportpwrstate = (struct reportpwrstate_parm *)pbuf;
preportpwrstate->state |= (u8)(adapter_to_pwrctl(padapter)->cpwm_tog + 0x80);
cpwm_int_hdl(padapter, preportpwrstate);
@@ -1704,8 +1577,6 @@ void _rtw_join_timeout_handler(struct timer_list *t)
mlmepriv.assoc_timer);
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
- DBG_871X("%s, fw_state =%x\n", __func__, get_fwstate(pmlmepriv));
-
if (adapter->bDriverStopped || adapter->bSurpriseRemoved)
return;
@@ -1717,15 +1588,12 @@ void _rtw_join_timeout_handler(struct timer_list *t)
if (rtw_to_roam(adapter) != 0) { /* try another */
int do_join_r;
- DBG_871X("%s try another roaming\n", __func__);
do_join_r = rtw_do_join(adapter);
if (_SUCCESS != do_join_r) {
- DBG_871X("%s roaming do_join return %d\n", __func__, do_join_r);
continue;
}
break;
} else {
- DBG_871X("%s We've try roaming but fail\n", __func__);
rtw_indicate_disconnect(adapter);
break;
}
@@ -1753,8 +1621,6 @@ void rtw_scan_timeout_handler(struct timer_list *t)
mlmepriv.scan_to_timer);
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
- DBG_871X(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv));
-
spin_lock_bh(&pmlmepriv->lock);
_clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
@@ -1791,19 +1657,13 @@ static void rtw_auto_scan_handler(struct adapter *padapter)
&& jiffies_to_msecs(jiffies - pmlmepriv->scan_start_time) > pmlmepriv->auto_scan_int_ms) {
if (!padapter->registrypriv.wifi_spec) {
- if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) {
- DBG_871X(FUNC_ADPT_FMT" _FW_UNDER_SURVEY|_FW_UNDER_LINKING\n", FUNC_ADPT_ARG(padapter));
+ if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING) == true)
goto exit;
- }
- if (pmlmepriv->LinkDetectInfo.bBusyTraffic) {
- DBG_871X(FUNC_ADPT_FMT" exit BusyTraffic\n", FUNC_ADPT_ARG(padapter));
+ if (pmlmepriv->LinkDetectInfo.bBusyTraffic)
goto exit;
- }
}
- DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
-
rtw_set_802_11_bssid_list_scan(padapter, NULL, 0);
}
@@ -1825,10 +1685,7 @@ void rtw_dynamic_check_timer_handler(struct adapter *adapter)
if (adapter->net_closed)
return;
- if (is_primary_adapter(adapter))
- DBG_871X("IsBtDisabled =%d, IsBtControlLps =%d\n", hal_btcoex_IsBtDisabled(adapter), hal_btcoex_IsBtControlLps(adapter));
-
- if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode)
+ if ((adapter_to_pwrctl(adapter)->fw_current_in_ps_mode)
&& !(hal_btcoex_IsBtControlLps(adapter))
) {
u8 bEnterPS;
@@ -1864,15 +1721,12 @@ inline void rtw_clear_scan_deny(struct adapter *adapter)
struct mlme_priv *mlmepriv = &adapter->mlmepriv;
atomic_set(&mlmepriv->set_scan_deny, 0);
-
- DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter));
}
void rtw_set_scan_deny(struct adapter *adapter, u32 ms)
{
struct mlme_priv *mlmepriv = &adapter->mlmepriv;
- DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter));
atomic_set(&mlmepriv->set_scan_deny, 1);
_set_timer(&mlmepriv->set_scan_deny_timer, ms);
}
@@ -1894,15 +1748,6 @@ static int rtw_check_roaming_candidate(struct mlme_priv *mlme
if (rtw_is_desired_network(adapter, competitor) == false)
goto exit;
- DBG_871X("roam candidate:%s %s(%pM, ch%3u) rssi:%d, age:%5d\n",
- (competitor == mlme->cur_network_scanned)?"*":" ",
- competitor->network.Ssid.Ssid,
- MAC_ARG(competitor->network.MacAddress),
- competitor->network.Configuration.DSConfig,
- (int)competitor->network.Rssi,
- jiffies_to_msecs(jiffies - competitor->last_scanned)
- );
-
/* got specific addr to roam */
if (!is_zero_mac_addr(mlme->roam_tgt_addr)) {
if (!memcmp(mlme->roam_tgt_addr, competitor->network.MacAddress, ETH_ALEN))
@@ -1949,32 +1794,20 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme)
pnetwork = container_of(mlme->pscanned, struct wlan_network, list);
if (!pnetwork) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork == NULL)\n", __func__));
ret = _FAIL;
goto exit;
}
mlme->pscanned = get_next(mlme->pscanned);
- DBG_871X("%s(%pM, ch%u) rssi:%d\n"
- , pnetwork->network.Ssid.Ssid
- , MAC_ARG(pnetwork->network.MacAddress)
- , pnetwork->network.Configuration.DSConfig
- , (int)pnetwork->network.Rssi);
-
rtw_check_roaming_candidate(mlme, &candidate, pnetwork);
}
if (!candidate) {
- DBG_871X("%s: return _FAIL(candidate == NULL)\n", __func__);
ret = _FAIL;
goto exit;
} else {
- DBG_871X("%s: candidate: %s(%pM, ch:%u)\n", __func__,
- candidate->network.Ssid.Ssid, MAC_ARG(candidate->network.MacAddress),
- candidate->network.Configuration.DSConfig);
-
mlme->roam_network = candidate;
if (!memcmp(candidate->network.MacAddress, mlme->roam_tgt_addr, ETH_ALEN))
@@ -2028,20 +1861,6 @@ static int rtw_check_join_candidate(struct mlme_priv *mlme
updated = true;
}
- if (updated) {
- DBG_871X("[by_bssid:%u][assoc_ssid:%s]"
- "[to_roam:%u] "
- "new candidate: %s(%pM, ch%u) rssi:%d\n",
- mlme->assoc_by_bssid,
- mlme->assoc_ssid.Ssid,
- rtw_to_roam(adapter),
- (*candidate)->network.Ssid.Ssid,
- MAC_ARG((*candidate)->network.MacAddress),
- (*candidate)->network.Configuration.DSConfig,
- (int)(*candidate)->network.Rssi
- );
- }
-
exit:
return updated;
}
@@ -2079,34 +1898,20 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv)
pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list);
if (!pnetwork) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork == NULL)\n", __func__));
ret = _FAIL;
goto exit;
}
pmlmepriv->pscanned = get_next(pmlmepriv->pscanned);
- DBG_871X("%s(%pM, ch%u) rssi:%d\n"
- , pnetwork->network.Ssid.Ssid
- , MAC_ARG(pnetwork->network.MacAddress)
- , pnetwork->network.Configuration.DSConfig
- , (int)pnetwork->network.Rssi);
-
rtw_check_join_candidate(pmlmepriv, &candidate, pnetwork);
}
if (!candidate) {
- DBG_871X("%s: return _FAIL(candidate == NULL)\n", __func__);
-#ifdef CONFIG_WOWLAN
- _clr_fwstate_(pmlmepriv, _FW_LINKED|_FW_UNDER_LINKING);
-#endif
ret = _FAIL;
goto exit;
} else {
- DBG_871X("%s: candidate: %s(%pM, ch:%u)\n", __func__,
- candidate->network.Ssid.Ssid, MAC_ARG(candidate->network.MacAddress),
- candidate->network.Configuration.DSConfig);
goto candidate_exist;
}
@@ -2114,8 +1919,6 @@ candidate_exist:
/* check for situation of _FW_LINKED */
if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
- DBG_871X("%s: _FW_LINKED while ask_for_joinbss!!!\n", __func__);
-
rtw_disassoc_cmd(adapter, 0, true);
rtw_indicate_disconnect(adapter);
rtw_free_assoc_resources(adapter, 0);
@@ -2129,12 +1932,12 @@ exit:
return ret;
}
-sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv)
+signed int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv)
{
struct cmd_obj *pcmd;
struct setauth_parm *psetauthparm;
struct cmd_priv *pcmdpriv = &(adapter->cmdpriv);
- sint res = _SUCCESS;
+ signed int res = _SUCCESS;
pcmd = rtw_zmalloc(sizeof(struct cmd_obj));
if (!pcmd) {
@@ -2159,21 +1962,19 @@ sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv)
INIT_LIST_HEAD(&pcmd->list);
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("after enqueue set_auth_cmd, auth_mode =%x\n", psecuritypriv->dot11AuthAlgrthm));
-
res = rtw_enqueue_cmd(pcmdpriv, pcmd);
exit:
return res;
}
-sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, sint keyid, u8 set_tx, bool enqueue)
+signed int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, signed int keyid, u8 set_tx, bool enqueue)
{
u8 keylen;
struct cmd_obj *pcmd;
struct setkey_parm *psetkeyparm;
struct cmd_priv *pcmdpriv = &(adapter->cmdpriv);
- sint res = _SUCCESS;
+ signed int res = _SUCCESS;
psetkeyparm = rtw_zmalloc(sizeof(struct setkey_parm));
if (!psetkeyparm) {
@@ -2181,22 +1982,16 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s
goto exit;
}
- if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
+ if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)
psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n rtw_set_key: psetkeyparm->algorithm =(unsigned char)psecuritypriv->dot118021XGrpPrivacy =%d\n", psetkeyparm->algorithm));
- } else {
+ else
psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n rtw_set_key: psetkeyparm->algorithm =(u8)psecuritypriv->dot11PrivacyAlgrthm =%d\n", psetkeyparm->algorithm));
- }
psetkeyparm->keyid = (u8)keyid;/* 0~3 */
psetkeyparm->set_tx = set_tx;
if (is_wep_enc(psetkeyparm->algorithm))
adapter->securitypriv.key_mask |= BIT(psetkeyparm->keyid);
- DBG_871X("==> rtw_set_key algorithm(%x), keyid(%x), key_mask(%x)\n", psetkeyparm->algorithm, psetkeyparm->keyid, adapter->securitypriv.key_mask);
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n rtw_set_key: psetkeyparm->algorithm =%d psetkeyparm->keyid =(u8)keyid =%d\n", psetkeyparm->algorithm, keyid));
-
switch (psetkeyparm->algorithm) {
case _WEP40_:
@@ -2218,7 +2013,6 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s
psetkeyparm->grpkey = 1;
break;
default:
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n rtw_set_key:psecuritypriv->dot11PrivacyAlgrthm = %x (must be 1 or 2 or 4 or 5)\n", psecuritypriv->dot11PrivacyAlgrthm));
res = _FAIL;
kfree(psetkeyparm);
goto exit;
@@ -2342,7 +2136,7 @@ static int rtw_append_pmkid(struct adapter *Adapter, int iEntry, u8 *ie, uint ie
return ie_len;
}
-sint rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len)
+signed int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len)
{
u8 authmode = 0x0;
uint ielength;
@@ -2352,9 +2146,6 @@ sint rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in
struct security_priv *psecuritypriv = &adapter->securitypriv;
uint ndisauthmode = psecuritypriv->ndisauthtype;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
- ("+rtw_restruct_sec_ie: ndisauthmode =%d\n", ndisauthmode));
-
/* copy fixed ie only */
memcpy(out_ie, in_ie, 12);
ielength = 12;
@@ -2451,7 +2242,6 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter)
}
pdev_network->Configuration.DSConfig = (pregistrypriv->channel);
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("pregistrypriv->channel =%d, pdev_network->Configuration.DSConfig = 0x%x\n", pregistrypriv->channel, pdev_network->Configuration.DSConfig));
if (cur_network->network.InfrastructureMode == Ndis802_11IBSS)
pdev_network->Configuration.ATIMWindow = (0);
@@ -2534,8 +2324,6 @@ void rtw_ht_use_default_setting(struct adapter *padapter)
if (TEST_FLAG(pregistrypriv->ldpc_cap, BIT5))
SET_FLAG(phtpriv->ldpc_cap, LDPC_HT_ENABLE_TX);
}
- if (phtpriv->ldpc_cap)
- DBG_871X("[HT] Support LDPC = 0x%02X\n", phtpriv->ldpc_cap);
/* STBC */
rtw_hal_get_def_var(padapter, HAL_DEF_TX_STBC, (u8 *)&bHwSTBCSupport);
@@ -2549,21 +2337,16 @@ void rtw_ht_use_default_setting(struct adapter *padapter)
if (TEST_FLAG(pregistrypriv->stbc_cap, BIT4))
SET_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_RX);
}
- if (phtpriv->stbc_cap)
- DBG_871X("[HT] Support STBC = 0x%02X\n", phtpriv->stbc_cap);
/* Beamforming setting */
rtw_hal_get_def_var(padapter, HAL_DEF_EXPLICIT_BEAMFORMER, (u8 *)&bHwSupportBeamformer);
rtw_hal_get_def_var(padapter, HAL_DEF_EXPLICIT_BEAMFORMEE, (u8 *)&bHwSupportBeamformee);
CLEAR_FLAGS(phtpriv->beamform_cap);
- if (TEST_FLAG(pregistrypriv->beamform_cap, BIT4) && bHwSupportBeamformer) {
+ if (TEST_FLAG(pregistrypriv->beamform_cap, BIT4) && bHwSupportBeamformer)
SET_FLAG(phtpriv->beamform_cap, BEAMFORMING_HT_BEAMFORMER_ENABLE);
- DBG_871X("[HT] Support Beamformer\n");
- }
- if (TEST_FLAG(pregistrypriv->beamform_cap, BIT5) && bHwSupportBeamformee) {
+
+ if (TEST_FLAG(pregistrypriv->beamform_cap, BIT5) && bHwSupportBeamformee)
SET_FLAG(phtpriv->beamform_cap, BEAMFORMING_HT_BEAMFORMEE_ENABLE);
- DBG_871X("[HT] Support Beamformee\n");
- }
}
void rtw_build_wmm_ie_ht(struct adapter *padapter, u8 *out_ie, uint *pout_len)
@@ -2659,10 +2442,8 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_
if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_RX)) {
if ((channel <= 14 && pregistrypriv->rx_stbc == 0x1) || /* enable for 2.4GHz */
- (pregistrypriv->wifi_spec == 1)) {
+ (pregistrypriv->wifi_spec == 1))
stbc_rx_enable = 1;
- DBG_871X("declare supporting RX STBC\n");
- }
}
/* fill default supported_mcs_set */
@@ -2685,14 +2466,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_
if (stbc_rx_enable)
ht_capie.cap_info |= cpu_to_le16(IEEE80211_HT_CAP_RX_STBC_2R);/* RX STBC two spatial stream */
- #ifdef CONFIG_DISABLE_MCS13TO15
- if (((cbw40_enable == 1) && (operation_bw == CHANNEL_WIDTH_40)) && (pregistrypriv->wifi_spec != 1))
- set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_2R_13TO15_OFF);
- else
- set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_2R);
- #else /* CONFIG_DISABLE_MCS13TO15 */
- set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_2R);
- #endif /* CONFIG_DISABLE_MCS13TO15 */
+ set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_2R);
break;
}
@@ -2759,8 +2533,6 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe
if ((!pmlmeinfo->HT_info_enable) || (!pmlmeinfo->HT_caps_enable))
return;
- DBG_871X("+rtw_update_ht_cap()\n");
-
/* maybe needs check if ap supports rx ampdu. */
if (!(phtpriv->ampdu_enable) && pregistrypriv->ampdu_enable == 1) {
phtpriv->ampdu_enable = true;
@@ -2774,7 +2546,6 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe
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); */
- /* DBG_871X("rtw_update_ht_cap(): max_ampdu_sz =%d\n", max_ampdu_sz); */
phtpriv->rx_ampdu_maxlen = max_ampdu_sz;
}
@@ -2815,14 +2586,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe
break;
case RF_2T2R:
default:
-#ifdef CONFIG_DISABLE_MCS13TO15
- if (pmlmeext->cur_bwmode == CHANNEL_WIDTH_40 && pregistrypriv->wifi_spec != 1)
- set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R_13TO15_OFF);
- else
- set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
-#else /* CONFIG_DISABLE_MCS13TO15 */
set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
-#endif /* CONFIG_DISABLE_MCS13TO15 */
}
/* switch to the 40M Hz mode according to the AP */
@@ -2848,8 +2612,6 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe
pmlmeinfo->SM_PS =
(le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) &
0x0C) >> 2;
- if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC)
- DBG_871X("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__);
/* */
/* Config current HT Protection mode. */
@@ -2873,20 +2635,14 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr
priority = pattrib->priority;
psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
- if (pattrib->psta != psta) {
- DBG_871X("%s, pattrib->psta(%p) != psta(%p)\n", __func__, pattrib->psta, psta);
+ if (pattrib->psta != psta)
return;
- }
- if (!psta) {
- DBG_871X("%s, psta ==NUL\n", __func__);
+ if (!psta)
return;
- }
- if (!(psta->state & _FW_LINKED)) {
- DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
+ if (!(psta->state & _FW_LINKED))
return;
- }
phtpriv = &psta->htpriv;
@@ -2895,7 +2651,6 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr
issued |= (phtpriv->candidate_tid_bitmap>>priority)&0x1;
if (0 == issued) {
- DBG_871X("rtw_issue_addbareq_cmd, p =%d\n", priority);
psta->htpriv.candidate_tid_bitmap |= BIT((u8)priority);
rtw_addbareq_cmd(padapter, (u8) priority, pattrib->ra);
}
@@ -2948,9 +2703,6 @@ void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network)
int do_join_r;
if (0 < rtw_to_roam(padapter)) {
- DBG_871X("roaming from %s(%pM), length:%d\n",
- cur_network->network.Ssid.Ssid, MAC_ARG(cur_network->network.MacAddress),
- cur_network->network.Ssid.SsidLength);
memcpy(&pmlmepriv->assoc_ssid, &cur_network->network.Ssid, sizeof(struct ndis_802_11_ssid));
pmlmepriv->assoc_by_bssid = false;
@@ -2960,13 +2712,11 @@ void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network)
if (_SUCCESS == do_join_r) {
break;
} else {
- DBG_871X("roaming do_join return %d\n", do_join_r);
rtw_dec_to_roam(padapter);
if (rtw_to_roam(padapter) > 0) {
continue;
} else {
- DBG_871X("%s(%d) -to roaming fail, indicate_disconnect\n", __func__, __LINE__);
rtw_indicate_disconnect(padapter);
break;
}
@@ -2976,7 +2726,7 @@ void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network)
}
-sint rtw_linked_check(struct adapter *padapter)
+signed int rtw_linked_check(struct adapter *padapter)
{
if ((check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true) ||
(check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true)) {
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index fa4b0259c5ae..9031cf7657ae 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -71,7 +71,7 @@ static unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20};
/********************************************************
ChannelPlan definitions
*********************************************************/
-static RT_CHANNEL_PLAN_2G RTW_ChannelPlan2G[RT_CHANNEL_DOMAIN_2G_MAX] = {
+static struct rt_channel_plan_2g RTW_ChannelPlan2G[RT_CHANNEL_DOMAIN_2G_MAX] = {
{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, /* 0x00, RT_CHANNEL_DOMAIN_2G_WORLD , Passive scan CH 12, 13 */
{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, /* 0x01, RT_CHANNEL_DOMAIN_2G_ETSI1 */
{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11}, /* 0x02, RT_CHANNEL_DOMAIN_2G_FCC1 */
@@ -81,7 +81,7 @@ static RT_CHANNEL_PLAN_2G RTW_ChannelPlan2G[RT_CHANNEL_DOMAIN_2G_MAX] = {
{{}, 0}, /* 0x06, RT_CHANNEL_DOMAIN_2G_NULL */
};
-static RT_CHANNEL_PLAN_5G RTW_ChannelPlan5G[RT_CHANNEL_DOMAIN_5G_MAX] = {
+static struct rt_channel_plan_5g RTW_ChannelPlan5G[RT_CHANNEL_DOMAIN_5G_MAX] = {
{{}, 0}, /* 0x00, RT_CHANNEL_DOMAIN_5G_NULL */
{{36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}, 19}, /* 0x01, RT_CHANNEL_DOMAIN_5G_ETSI1 */
{{36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165}, 24}, /* 0x02, RT_CHANNEL_DOMAIN_5G_ETSI2 */
@@ -121,7 +121,7 @@ static RT_CHANNEL_PLAN_5G RTW_ChannelPlan5G[RT_CHANNEL_DOMAIN_5G_MAX] = {
{{36, 40, 44, 48, 149, 153, 157, 161}, 8}, /* 0x22, RT_CHANNEL_DOMAIN_5G_FCC4_NO_DFS */
};
-static RT_CHANNEL_PLAN_MAP RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = {
+static struct rt_channel_plan_map RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = {
/* 0x00 ~ 0x1F , Old Define ===== */
{0x02, 0x20}, /* 0x00, RT_CHANNEL_DOMAIN_FCC */
{0x02, 0x0A}, /* 0x01, RT_CHANNEL_DOMAIN_IC */
@@ -209,7 +209,7 @@ static RT_CHANNEL_PLAN_MAP RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = {
};
/* use the combination for max channel numbers */
-static RT_CHANNEL_PLAN_MAP RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = {0x03, 0x02};
+static struct rt_channel_plan_map RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = {0x03, 0x02};
/* Search the @param ch in given @param ch_set
* @ch_set: the given channel set
@@ -217,7 +217,7 @@ static RT_CHANNEL_PLAN_MAP RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = {0x03, 0x02};
*
* return the index of channel_num in channel_set, -1 if not found
*/
-int rtw_ch_set_search_ch(RT_CHANNEL_INFO *ch_set, const u32 ch)
+int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch)
{
int i;
@@ -325,7 +325,7 @@ static void init_mlme_ext_priv_value(struct adapter *padapter)
pmlmeext->action_public_dialog_token = 0xff;
}
-static int has_channel(RT_CHANNEL_INFO *channel_set,
+static int has_channel(struct rt_channel_info *channel_set,
u8 chanset_size,
u8 chan)
{
@@ -340,7 +340,7 @@ static int has_channel(RT_CHANNEL_INFO *channel_set,
return 0;
}
-static void init_channel_list(struct adapter *padapter, RT_CHANNEL_INFO *channel_set,
+static void init_channel_list(struct adapter *padapter, struct rt_channel_info *channel_set,
u8 chanset_size,
struct p2p_channels *channel_list)
{
@@ -392,18 +392,16 @@ static void init_channel_list(struct adapter *padapter, RT_CHANNEL_INFO *channel
}
-static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, RT_CHANNEL_INFO *channel_set)
+static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_channel_info *channel_set)
{
u8 index, chanset_size = 0;
u8 b5GBand = false, b2_4GBand = false;
u8 Index2G = 0, Index5G = 0;
- memset(channel_set, 0, sizeof(RT_CHANNEL_INFO)*MAX_CHANNEL_NUM);
+ memset(channel_set, 0, sizeof(struct rt_channel_info)*MAX_CHANNEL_NUM);
- if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) {
- DBG_871X("ChannelPlan ID %x error !!!!!\n", ChannelPlan);
+ if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE)
return chanset_size;
- }
if (IsSupported24G(padapter->registrypriv.wireless_mode)) {
b2_4GBand = true;
@@ -446,13 +444,11 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, RT_CHANNEL_
channel_set[chanset_size].ScanType = SCAN_PASSIVE;
else
channel_set[chanset_size].ScanType = SCAN_ACTIVE;
- DBG_871X("%s(): channel_set[%d].ChannelNum = %d\n", __func__, chanset_size, channel_set[chanset_size].ChannelNum);
chanset_size++;
}
}
}
- DBG_871X("%s ChannelPlan ID %x Chan num:%d \n", __func__, ChannelPlan, chanset_size);
return chanset_size;
}
@@ -526,14 +522,8 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame)
struct dvobj_priv *psdpriv = padapter->dvobj;
struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
- ("+mgt_dispatcher: type(0x%x) subtype(0x%x)\n",
- GetFrameType(pframe), GetFrameSubType(pframe)));
-
- if (GetFrameType(pframe) != WIFI_MGT_TYPE) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("mgt_dispatcher: type(0x%x) error!\n", GetFrameType(pframe)));
+ if (GetFrameType(pframe) != WIFI_MGT_TYPE)
return;
- }
/* receive the frames that ra(a1) is my address or ra(a1) is bc address. */
if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) &&
@@ -545,10 +535,9 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame)
index = GetFrameSubType(pframe) >> 4;
- if (index >= ARRAY_SIZE(mlme_sta_tbl)) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do not support reserved sub-fr-type =%d\n", index));
+ if (index >= ARRAY_SIZE(mlme_sta_tbl))
return;
- }
+
ptable += index;
if (psta) {
@@ -556,7 +545,6 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame)
if (precv_frame->u.hdr.attrib.seq_num == psta->RxMgmtFrameSeqNum) {
/* drop the duplicate management frame */
pdbgpriv->dbg_rx_dup_mgt_frame_drop_count++;
- DBG_871X("Drop duplicate management frame with seq_num = %d.\n", precv_frame->u.hdr.attrib.seq_num);
return;
}
}
@@ -616,118 +604,6 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame)
return _SUCCESS;
}
-
- /* DBG_871X("+OnProbeReq\n"); */
-
-#ifdef CONFIG_AUTO_AP_MODE
- if (check_fwstate(pmlmepriv, _FW_LINKED) &&
- pmlmepriv->cur_network.join_res) {
- struct sta_info *psta;
- u8 *mac_addr, *peer_addr;
- struct sta_priv *pstapriv = &padapter->stapriv;
- u8 RC_OUI[4] = {0x00, 0xE0, 0x4C, 0x0A};
- /* EID[1] + EID_LEN[1] + RC_OUI[4] + MAC[6] + PairingID[2] + ChannelNum[2] */
-
- p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, WLAN_EID_VENDOR_SPECIFIC, (int *)&ielen,
- len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_);
-
- if (!p || ielen != 14)
- goto _non_rc_device;
-
- if (memcmp(p+2, RC_OUI, sizeof(RC_OUI)))
- goto _non_rc_device;
-
- if (memcmp(p+6, get_sa(pframe), ETH_ALEN)) {
- DBG_871X("%s, do rc pairing (%pM), but mac addr mismatch!(%pM)\n", __func__,
- MAC_ARG(get_sa(pframe)), MAC_ARG(p+6));
-
- goto _non_rc_device;
- }
-
- DBG_871X("%s, got the pairing device(%pM)\n", __func__, MAC_ARG(get_sa(pframe)));
-
- /* new a station */
- psta = rtw_get_stainfo(pstapriv, get_sa(pframe));
- if (psta == NULL) {
- /* allocate a new one */
- DBG_871X("going to alloc stainfo for rc =%pM\n", MAC_ARG(get_sa(pframe)));
- psta = rtw_alloc_stainfo(pstapriv, get_sa(pframe));
- if (!psta) {
- /* TODO: */
- DBG_871X(" Exceed the upper limit of supported clients...\n");
- return _SUCCESS;
- }
-
- spin_lock_bh(&pstapriv->asoc_list_lock);
- if (list_empty(&psta->asoc_list)) {
- psta->expire_to = pstapriv->expire_to;
- list_add_tail(&psta->asoc_list, &pstapriv->asoc_list);
- pstapriv->asoc_list_cnt++;
- }
- spin_unlock_bh(&pstapriv->asoc_list_lock);
-
- /* generate pairing ID */
- mac_addr = myid(&(padapter->eeprompriv));
- peer_addr = psta->hwaddr;
- psta->pid = (u16)(((mac_addr[4]<<8) + mac_addr[5]) + ((peer_addr[4]<<8) + peer_addr[5]));
-
- /* update peer stainfo */
- psta->isrc = true;
- /* psta->aid = 0; */
- /* psta->mac_id = 2; */
-
- /* get a unique AID */
- if (psta->aid > 0) {
- DBG_871X("old AID %d\n", psta->aid);
- } else {
- for (psta->aid = 1; psta->aid <= NUM_STA; psta->aid++)
- if (pstapriv->sta_aid[psta->aid - 1] == NULL)
- break;
-
- if (psta->aid > pstapriv->max_num_sta) {
- psta->aid = 0;
- DBG_871X("no room for more AIDs\n");
- return _SUCCESS;
- }
- pstapriv->sta_aid[psta->aid - 1] = psta;
- DBG_871X("allocate new AID = (%d)\n", psta->aid);
- }
-
- psta->qos_option = 1;
- psta->bw_mode = CHANNEL_WIDTH_20;
- psta->ieee8021x_blocked = false;
- psta->htpriv.ht_option = true;
- psta->htpriv.ampdu_enable = false;
- psta->htpriv.sgi_20m = false;
- psta->htpriv.sgi_40m = false;
- psta->htpriv.ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
- psta->htpriv.agg_enable_bitmap = 0x0;/* reset */
- psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */
-
- rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true);
-
- memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats));
-
- spin_lock_bh(&psta->lock);
- psta->state |= _FW_LINKED;
- spin_unlock_bh(&psta->lock);
-
- report_add_sta_event(padapter, psta->hwaddr, psta->aid);
-
- }
-
- issue_probersp(padapter, get_sa(pframe), false);
-
- return _SUCCESS;
-
- }
-
-_non_rc_device:
-
- return _SUCCESS;
-
-#endif /* CONFIG_AUTO_AP_MODE */
-
p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, (int *)&ielen,
len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_);
@@ -743,12 +619,10 @@ _non_rc_device:
return _SUCCESS;
_issue_probersp:
- if ((check_fwstate(pmlmepriv, _FW_LINKED) &&
- pmlmepriv->cur_network.join_res) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
- /* DBG_871X("+issue_probersp during ap mode\n"); */
+ if ((check_fwstate(pmlmepriv, _FW_LINKED) &&
+ pmlmepriv->cur_network.join_res) ||
+ check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))
issue_probersp(padapter, get_sa(pframe), is_valid_p2p_probereq);
- }
-
}
return _SUCCESS;
@@ -785,11 +659,9 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
p = rtw_get_ie(pframe + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ielen, precv_frame->u.hdr.len - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_);
if (p && ielen > 0) {
- if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) {
+ if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D))
/* Invalid value 0x2D is detected in Extended Supported Rates (ESR) IE. Try to fix the IE length to avoid failed Beacon parsing. */
- DBG_871X("[WIFIDBG] Error in ESR IE is detected in Beacon of BSSID:%pM. Fix the length of ESR IE to avoid failed Beacon parsing.\n", MAC_ARG(GetAddr3Ptr(pframe)));
*(p + 1) = ielen - 1;
- }
}
if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
@@ -834,14 +706,15 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
if (psta) {
ret = rtw_check_bcn_info(padapter, pframe, len);
if (!ret) {
- DBG_871X_LEVEL(_drv_always_, "ap has changed, disconnect now\n ");
- receive_disconnect(padapter, pmlmeinfo->network.MacAddress, 0);
- return _SUCCESS;
+ netdev_dbg(padapter->pnetdev,
+ "ap has changed, disconnect now\n ");
+ receive_disconnect(padapter,
+ pmlmeinfo->network.MacAddress, 0);
+ return _SUCCESS;
}
/* update WMM, ERP in the beacon */
/* todo: the timer is used instead of the number of the beacon received */
if ((sta_rx_pkts(psta) & 0xf) == 0)
- /* DBG_871X("update_bcn_info\n"); */
update_beacon_info(padapter, pframe, len, psta);
adaptive_early_32k(pmlmeext, pframe, len);
@@ -852,7 +725,6 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
/* update WMM, ERP in the beacon */
/* todo: the timer is used instead of the number of the beacon received */
if ((sta_rx_pkts(psta) & 0xf) == 0) {
- /* DBG_871X("update_bcn_info\n"); */
update_beacon_info(padapter, pframe, len, psta);
}
} else {
@@ -901,8 +773,6 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE)
return _FAIL;
- DBG_871X("+OnAuth\n");
-
sa = GetAddr2Ptr(pframe);
auth_mode = psecuritypriv->dot11AuthAlgrthm;
@@ -928,8 +798,6 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
algorithm = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset));
seq = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset + 2));
- DBG_871X("auth alg =%x, seq =%X\n", algorithm, seq);
-
if (auth_mode == 2 &&
psecuritypriv->dot11PrivacyAlgrthm != _WEP40_ &&
psecuritypriv->dot11PrivacyAlgrthm != _WEP104_)
@@ -937,8 +805,6 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
if ((algorithm > 0 && auth_mode == 0) || /* rx a shared-key auth but shared not enabled */
(algorithm == 0 && auth_mode == 1)) { /* rx a open-system auth but shared-key is enabled */
- DBG_871X("auth rejected due to bad alg [alg =%d, auth_mib =%d] %02X%02X%02X%02X%02X%02X\n",
- algorithm, auth_mode, sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]);
status = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
@@ -954,10 +820,8 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
if (pstat == NULL) {
/* allocate a new one */
- DBG_871X("going to alloc stainfo for sa =%pM\n", MAC_ARG(sa));
pstat = rtw_alloc_stainfo(pstapriv, sa);
if (pstat == NULL) {
- DBG_871X(" Exceed the upper limit of supported clients...\n");
status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
goto auth_fail;
}
@@ -997,8 +861,6 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
if ((pstat->auth_seq + 1) != seq) {
- DBG_871X("(1)auth rejected because out of seq [rx_seq =%d, exp_seq =%d]!\n",
- seq, pstat->auth_seq+1);
status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
goto auth_fail;
}
@@ -1010,8 +872,6 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
pstat->expire_to = pstapriv->assoc_to;
pstat->authalg = algorithm;
} else {
- DBG_871X("(2)auth rejected because out of seq [rx_seq =%d, exp_seq =%d]!\n",
- seq, pstat->auth_seq+1);
status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
goto auth_fail;
}
@@ -1025,14 +885,11 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
pstat->authalg = algorithm;
pstat->auth_seq = 2;
} else if (seq == 3) {
- /* checking for challenging txt... */
- DBG_871X("checking for challenging txt...\n");
p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, (int *)&ie_len,
len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4);
if ((p == NULL) || (ie_len <= 0)) {
- DBG_871X("auth rejected because challenge failure!(1)\n");
status = WLAN_STATUS_CHALLENGE_FAIL;
goto auth_fail;
}
@@ -1043,13 +900,10 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
/* challenging txt is correct... */
pstat->expire_to = pstapriv->assoc_to;
} else {
- DBG_871X("auth rejected because challenge failure!\n");
status = WLAN_STATUS_CHALLENGE_FAIL;
goto auth_fail;
}
} else {
- DBG_871X("(3)auth rejected because out of seq [rx_seq =%d, exp_seq =%d]!\n",
- seq, pstat->auth_seq+1);
status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
goto auth_fail;
}
@@ -1093,8 +947,6 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram
u8 *pframe = precv_frame->u.hdr.rx_data;
uint pkt_len = precv_frame->u.hdr.len;
- DBG_871X("%s\n", __func__);
-
/* check A1 matches or not */
if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN))
return _SUCCESS;
@@ -1108,7 +960,6 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram
status = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset + 4));
if (status != 0) {
- DBG_871X("clnt auth fail, status: %d\n", status);
if (status == 13) { /* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */
if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open;
@@ -1127,10 +978,8 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram
p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, (int *)&len,
pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_);
- if (p == NULL) {
- /* DBG_871X("marc: no challenge text?\n"); */
+ if (!p)
goto authclnt_fail;
- }
memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len);
pmlmeinfo->auth_seq = 3;
@@ -1150,12 +999,11 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram
}
} else {
/* this is also illegal */
- /* DBG_871X("marc: clnt auth failed due to illegal seq =%x\n", seq); */
goto authclnt_fail;
}
if (go2asoc) {
- DBG_871X_LEVEL(_drv_always_, "auth success, start assoc\n");
+ netdev_dbg(padapter->pnetdev, "auth success, start assoc\n");
start_clnt_assoc(padapter);
return _SUCCESS;
}
@@ -1202,11 +1050,8 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
}
- if (pkt_len < sizeof(struct ieee80211_hdr_3addr) + ie_offset) {
- DBG_871X("handle_assoc(reassoc =%d) - too short payload (len =%lu)"
- "\n", reassoc, (unsigned long)pkt_len);
+ if (pkt_len < sizeof(struct ieee80211_hdr_3addr) + ie_offset)
return _FAIL;
- }
pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
if (!pstat) {
@@ -1220,9 +1065,6 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
left = pkt_len - (sizeof(struct ieee80211_hdr_3addr) + ie_offset);
pos = pframe + (sizeof(struct ieee80211_hdr_3addr) + ie_offset);
-
- DBG_871X("%s\n", __func__);
-
/* check if this stat has been successfully authenticated/assocated */
if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS)) {
if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) {
@@ -1243,8 +1085,6 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
/* now parse all ieee802_11 ie to point to elems */
if (rtw_ieee802_11_parse_elems(pos, left, &elems, 1) == ParseFailed ||
!elems.ssid) {
- DBG_871X("STA %pM sent invalid association request\n",
- MAC_ARG(pstat->hwaddr));
status = WLAN_STATUS_CHALLENGE_FAIL;
goto OnAssocReqFail;
}
@@ -1273,7 +1113,6 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
/* check if the supported rate is ok */
p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_SUPP_RATES, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset);
if (p == NULL) {
- DBG_871X("Rx a sta assoc-req which supported rate is empty!\n");
/* use our own rate set as statoin used */
/* memcpy(supportRate, AP_BSSRATE, AP_BSSRATE_LEN); */
/* supportRateNum = AP_BSSRATE_LEN; */
@@ -1369,17 +1208,11 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS);
if (!wpa_ie) {
if (elems.wps_ie) {
- DBG_871X("STA included WPS IE in "
- "(Re)Association Request - assume WPS is "
- "used\n");
pstat->flags |= WLAN_STA_WPS;
/* wpabuf_free(sta->wps_ie); */
/* sta->wps_ie = wpabuf_alloc_copy(elems.wps_ie + 4, */
/* elems.wps_ie_len - 4); */
} else {
- DBG_871X("STA did not include WPA/RSN IE "
- "in (Re)Association Request - possible WPS "
- "use\n");
pstat->flags |= WLAN_STA_MAYBE_WPS;
}
@@ -1394,8 +1227,6 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
rtw_get_wps_attr_content(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, WPS_ATTR_SELECTED_REGISTRAR, &selected_registrar, NULL);
if (!selected_registrar) {
- DBG_871X("selected_registrar is false , or AP is not ready to do WPS\n");
-
status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
goto OnAssocReqFail;
@@ -1407,9 +1238,6 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
int copy_len;
if (psecuritypriv->wpa_psk == 0) {
- DBG_871X("STA %pM: WPA/RSN IE in association "
- "request, but AP don't support WPA/RSN\n", MAC_ARG(pstat->hwaddr));
-
status = WLAN_STATUS_INVALID_IE;
goto OnAssocReqFail;
@@ -1417,9 +1245,6 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
}
if (elems.wps_ie) {
- DBG_871X("STA included WPS IE in "
- "(Re)Association Request - WPS is "
- "used\n");
pstat->flags |= WLAN_STA_WPS;
copy_len = 0;
} else {
@@ -1515,8 +1340,6 @@ unsigned int OnAssocReq(struct adapter *padapter, union 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_871X("HT: %pM tried to use TKIP with HT association\n", MAC_ARG(pstat->hwaddr));
-
/* status = WLAN_STATUS_CIPHER_SUITE_REJECTED; */
/* goto OnAssocReqFail; */
}
@@ -1547,9 +1370,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
/* get a unique AID */
- if (pstat->aid > 0) {
- DBG_871X(" old AID %d\n", pstat->aid);
- } else {
+ if (pstat->aid == 0) {
for (pstat->aid = 1; pstat->aid <= NUM_STA; pstat->aid++)
if (pstapriv->sta_aid[pstat->aid - 1] == NULL)
break;
@@ -1559,8 +1380,6 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
pstat->aid = 0;
- DBG_871X(" no room for more AIDs\n");
-
status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
goto OnAssocReqFail;
@@ -1568,7 +1387,6 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
} else {
pstapriv->sta_aid[pstat->aid - 1] = pstat;
- DBG_871X("allocate new AID = (%d)\n", pstat->aid);
}
}
@@ -1653,8 +1471,6 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame)
u8 *pframe = precv_frame->u.hdr.rx_data;
uint pkt_len = precv_frame->u.hdr.len;
- DBG_871X("%s\n", __func__);
-
/* check A1 matches or not */
if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN))
return _SUCCESS;
@@ -1670,7 +1486,6 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame)
/* status */
status = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 2));
if (status > 0) {
- DBG_871X("assoc reject, status code: %d\n", status);
pmlmeinfo->state = WIFI_FW_NULL_STATE;
res = -4;
goto report_assoc_result;
@@ -1748,8 +1563,6 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN));
- DBG_871X("%s Reason code(%d)\n", __func__, reason);
-
if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
struct sta_info *psta;
struct sta_priv *pstapriv = &padapter->stapriv;
@@ -1758,8 +1571,9 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
/* rtw_free_stainfo(padapter, psta); */
/* spin_unlock_bh(&(pstapriv->sta_hash_lock)); */
- DBG_871X_LEVEL(_drv_always_, "ap recv deauth reason code(%d) sta:%pM\n",
- reason, GetAddr2Ptr(pframe));
+ netdev_dbg(padapter->pnetdev,
+ "ap recv deauth reason code(%d) sta:%pM\n", reason,
+ GetAddr2Ptr(pframe));
psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
if (psta) {
@@ -1797,8 +1611,10 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame)
}
}
- DBG_871X_LEVEL(_drv_always_, "sta recv deauth reason code(%d) sta:%pM, ignore = %d\n",
- reason, GetAddr3Ptr(pframe), ignore_received_deauth);
+ netdev_dbg(padapter->pnetdev,
+ "sta recv deauth reason code(%d) sta:%pM, ignore = %d\n",
+ reason, GetAddr3Ptr(pframe),
+ ignore_received_deauth);
if (0 == ignore_received_deauth) {
receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
@@ -1823,8 +1639,6 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)
reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN));
- DBG_871X("%s Reason code(%d)\n", __func__, reason);
-
if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
struct sta_info *psta;
struct sta_priv *pstapriv = &padapter->stapriv;
@@ -1833,8 +1647,9 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)
/* rtw_free_stainfo(padapter, psta); */
/* spin_unlock_bh(&(pstapriv->sta_hash_lock)); */
- DBG_871X_LEVEL(_drv_always_, "ap recv disassoc reason code(%d) sta:%pM\n",
- reason, GetAddr2Ptr(pframe));
+ netdev_dbg(padapter->pnetdev,
+ "ap recv disassoc reason code(%d) sta:%pM\n",
+ reason, GetAddr2Ptr(pframe));
psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
if (psta) {
@@ -1854,8 +1669,9 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)
return _SUCCESS;
} else {
- DBG_871X_LEVEL(_drv_always_, "sta recv disassoc reason code(%d) sta:%pM\n",
- reason, GetAddr3Ptr(pframe));
+ netdev_dbg(padapter->pnetdev,
+ "sta recv disassoc reason code(%d) sta:%pM\n",
+ reason, GetAddr3Ptr(pframe));
receive_disconnect(padapter, GetAddr3Ptr(pframe), reason);
}
@@ -1866,7 +1682,6 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame)
unsigned int OnAtim(struct adapter *padapter, union recv_frame *precv_frame)
{
- DBG_871X("%s\n", __func__);
return _SUCCESS;
}
@@ -1879,8 +1694,6 @@ unsigned int on_action_spct(struct adapter *padapter, union recv_frame *precv_fr
u8 category;
u8 action;
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev));
-
psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
if (!psta)
@@ -1919,8 +1732,6 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra
u8 *pframe = precv_frame->u.hdr.rx_data;
struct sta_priv *pstapriv = &padapter->stapriv;
- DBG_871X("%s\n", __func__);
-
/* check RA matches or not */
if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */
return _SUCCESS;
@@ -1943,7 +1754,6 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra
return _SUCCESS;
action = frame_body[1];
- DBG_871X("%s, action =%d\n", __func__, action);
switch (action) {
case WLAN_ACTION_ADDBA_REQ: /* ADDBA request */
@@ -1965,7 +1775,6 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra
if (status == 0) {
/* successful */
- DBG_871X("agg_enable for TID =%d\n", tid);
psta->htpriv.agg_enable_bitmap |= BIT(tid);
psta->htpriv.candidate_tid_bitmap &= ~BIT(tid);
} else {
@@ -1973,13 +1782,11 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra
}
if (psta->state & WIFI_STA_ALIVE_CHK_STATE) {
- DBG_871X("%s alive check - rx ADDBA response\n", __func__);
psta->htpriv.agg_enable_bitmap &= ~BIT(tid);
psta->expire_to = pstapriv->expire_to;
psta->state ^= WIFI_STA_ALIVE_CHK_STATE;
}
- /* DBG_871X("marc: ADDBA RSP: %x\n", pmlmeinfo->agg_enable_bitmap); */
break;
case WLAN_ACTION_DELBA: /* DELBA */
@@ -1997,13 +1804,7 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra
preorder_ctrl = &psta->recvreorder_ctrl[tid];
preorder_ctrl->enable = false;
preorder_ctrl->indicate_seq = 0xffff;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d indicate_seq:%u\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq);
- #endif
}
-
- DBG_871X("%s(): DELBA: %x(%x)\n", __func__, pmlmeinfo->agg_enable_bitmap, reason_code);
/* todo: how to notify the host while receiving DELETE BA */
break;
@@ -2025,17 +1826,11 @@ static s32 rtw_action_public_decache(union recv_frame *recv_frame, s32 token)
if (GetRetry(frame)) {
if (token >= 0) {
if ((seq_ctrl == mlmeext->action_public_rxseq)
- && (token == mlmeext->action_public_dialog_token)) {
- DBG_871X(FUNC_ADPT_FMT" seq_ctrl = 0x%x, rxseq = 0x%x, token:%d\n",
- FUNC_ADPT_ARG(adapter), seq_ctrl, mlmeext->action_public_rxseq, token);
+ && (token == mlmeext->action_public_dialog_token))
return _FAIL;
- }
} else {
- if (seq_ctrl == mlmeext->action_public_rxseq) {
- DBG_871X(FUNC_ADPT_FMT" seq_ctrl = 0x%x, rxseq = 0x%x\n",
- FUNC_ADPT_ARG(adapter), seq_ctrl, mlmeext->action_public_rxseq);
+ if (seq_ctrl == mlmeext->action_public_rxseq)
return _FAIL;
- }
}
}
@@ -2084,7 +1879,6 @@ static unsigned int on_action_public_default(union recv_frame *precv_frame, u8 a
u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr);
u8 token;
struct adapter *adapter = precv_frame->u.hdr.adapter;
- int cnt = 0;
char msg[64];
token = frame_body[2];
@@ -2092,7 +1886,7 @@ static unsigned int on_action_public_default(union recv_frame *precv_frame, u8 a
if (rtw_action_public_decache(precv_frame, token) == _FAIL)
goto exit;
- cnt += sprintf((msg+cnt), "%s(token:%u)", action_public_str(action), token);
+ scnprintf(msg, sizeof(msg), "%s(token:%u)", action_public_str(action), token);
rtw_cfg80211_rx_action(adapter, pframe, frame_len, msg);
ret = _SUCCESS;
@@ -2163,20 +1957,15 @@ unsigned int OnAction_sa_query(struct adapter *padapter, union recv_frame *precv
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
unsigned short tid;
- /* Baron */
-
- DBG_871X("OnAction_sa_query\n");
switch (pframe[WLAN_HDR_A3_LEN+1]) {
case 0: /* SA Query req */
memcpy(&tid, &pframe[WLAN_HDR_A3_LEN+2], sizeof(unsigned short));
- DBG_871X("OnAction_sa_query request, action =%d, tid =%04x\n", pframe[WLAN_HDR_A3_LEN+1], tid);
issue_action_SA_Query(padapter, GetAddr2Ptr(pframe), 1, tid);
break;
case 1: /* SA Query rsp */
del_timer_sync(&pmlmeext->sa_query_timer);
- DBG_871X("OnAction_sa_query response, action =%d, tid =%04x, cancel timer\n", pframe[WLAN_HDR_A3_LEN+1], pframe[WLAN_HDR_A3_LEN+2]);
break;
default:
break;
@@ -2219,8 +2008,6 @@ unsigned int OnAction(struct adapter *padapter, union recv_frame *precv_frame)
unsigned int DoReserved(struct adapter *padapter, union recv_frame *precv_frame)
{
-
- /* DBG_871X("rcvd mgt frame(%x, %x)\n", (GetFrameSubType(pframe) >> 4), *(unsigned int *)GetAddr1Ptr(pframe)); */
return _SUCCESS;
}
@@ -2234,14 +2021,11 @@ static struct xmit_frame *_alloc_mgtxmitframe(struct xmit_priv *pxmitpriv, bool
else
pmgntframe = rtw_alloc_xmitframe_ext(pxmitpriv);
- if (pmgntframe == NULL) {
- DBG_871X(FUNC_ADPT_FMT" alloc xmitframe fail, once:%d\n", FUNC_ADPT_ARG(pxmitpriv->adapter), once);
+ if (!pmgntframe)
goto exit;
- }
pxmitbuf = rtw_alloc_xmitbuf_ext(pxmitpriv);
if (pxmitbuf == NULL) {
- DBG_871X(FUNC_ADPT_FMT" alloc xmitbuf fail\n", FUNC_ADPT_ARG(pxmitpriv->adapter));
rtw_free_xmitframe(pxmitpriv, pmgntframe);
pmgntframe = NULL;
goto exit;
@@ -2273,7 +2057,6 @@ void update_mgnt_tx_rate(struct adapter *padapter, u8 rate)
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
pmlmeext->tx_rate = rate;
- /* DBG_871X("%s(): rate = %x\n", __func__, rate); */
}
void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrib)
@@ -2341,7 +2124,7 @@ void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe)
s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms)
{
s32 ret = _FAIL;
- _irqL irqL;
+ unsigned long irqL;
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf;
struct submit_ctx sctx;
@@ -2399,13 +2182,11 @@ s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmg
static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode)
{
u8 *ssid_ie;
- sint ssid_len_ori;
+ signed int ssid_len_ori;
int len_diff = 0;
ssid_ie = rtw_get_ie(ies, WLAN_EID_SSID, &ssid_len_ori, ies_len);
- /* DBG_871X("%s hidden_ssid_mode:%u, ssid_ie:%p, ssid_len_ori:%d\n", __func__, hidden_ssid_mode, ssid_ie, ssid_len_ori); */
-
if (ssid_ie && ssid_len_ori > 0) {
switch (hidden_ssid_mode) {
case 1:
@@ -2447,13 +2228,9 @@ void issue_beacon(struct adapter *padapter, int timeout_ms)
struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
- /* DBG_871X("%s\n", __func__); */
-
pmgntframe = alloc_mgtxmitframe(pxmitpriv);
- if (!pmgntframe) {
- DBG_871X("%s, alloc mgnt frame fail\n", __func__);
+ if (!pmgntframe)
return;
- }
spin_lock_bh(&pmlmepriv->bcn_update_lock);
@@ -2483,7 +2260,6 @@ void issue_beacon(struct adapter *padapter, int timeout_ms)
pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) {
- /* DBG_871X("ie len =%d\n", cur_network->IELength); */
{
int len_diff;
@@ -2573,14 +2349,11 @@ _issue_bcn:
spin_unlock_bh(&pmlmepriv->bcn_update_lock);
- if ((pattrib->pktlen + TXDESC_SIZE) > 512) {
- DBG_871X("beacon frame too large\n");
+ if ((pattrib->pktlen + TXDESC_SIZE) > 512)
return;
- }
pattrib->last_txcmdsz = pattrib->pktlen;
- /* DBG_871X("issue bcn_sz =%d\n", pattrib->last_txcmdsz); */
if (timeout_ms > 0)
dump_mgntframe_and_wait(padapter, pmgntframe, timeout_ms);
else
@@ -2606,17 +2379,12 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
unsigned int rate_len;
- /* DBG_871X("%s\n", __func__); */
-
if (da == NULL)
return;
pmgntframe = alloc_mgtxmitframe(pxmitpriv);
- if (pmgntframe == NULL) {
- DBG_871X("%s, alloc mgnt frame fail\n", __func__);
+ if (!pmgntframe)
return;
- }
-
/* update attribute */
pattrib = &pmgntframe->attrib;
@@ -2687,8 +2455,8 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
/* retrieve SSID IE from cur_network->Ssid */
{
u8 *ssid_ie;
- sint ssid_ielen;
- sint ssid_ielen_diff;
+ signed int ssid_ielen;
+ signed int ssid_ielen_diff;
u8 buf[MAX_IE_SZ];
u8 *ies = pmgntframe->buf_addr+TXDESC_OFFSET+sizeof(struct ieee80211_hdr_3addr);
@@ -2705,7 +2473,9 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
remainder_ielen = (pframe-remainder_ie);
if (remainder_ielen > MAX_IE_SZ) {
- DBG_871X_LEVEL(_drv_warning_, FUNC_ADPT_FMT" remainder_ielen > MAX_IE_SZ\n", FUNC_ADPT_ARG(padapter));
+ netdev_warn(padapter->pnetdev,
+ FUNC_ADPT_FMT " remainder_ielen > MAX_IE_SZ\n",
+ FUNC_ADPT_ARG(padapter));
remainder_ielen = MAX_IE_SZ;
}
@@ -2772,36 +2542,6 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
}
-#ifdef CONFIG_AUTO_AP_MODE
-{
- struct sta_info *psta;
- struct sta_priv *pstapriv = &padapter->stapriv;
-
- DBG_871X("(%s)\n", __func__);
-
- /* check rc station */
- psta = rtw_get_stainfo(pstapriv, da);
- if (psta && psta->isrc && psta->pid > 0) {
- u8 RC_OUI[4] = {0x00, 0xE0, 0x4C, 0x0A};
- u8 RC_INFO[14] = {0};
- /* EID[1] + EID_LEN[1] + RC_OUI[4] + MAC[6] + PairingID[2] + ChannelNum[2] */
- u16 cu_ch = (u16)cur_network->Configuration.DSConfig;
-
- DBG_871X("%s, reply rc(pid = 0x%x) device %pM in ch =%d\n", __func__,
- psta->pid, MAC_ARG(psta->hwaddr), cu_ch);
-
- /* append vendor specific ie */
- memcpy(RC_INFO, RC_OUI, sizeof(RC_OUI));
- memcpy(&RC_INFO[4], mac, ETH_ALEN);
- memcpy(&RC_INFO[10], (u8 *)&psta->pid, 2);
- memcpy(&RC_INFO[12], (u8 *)&cu_ch, 2);
-
- pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, sizeof(RC_INFO), RC_INFO, &pattrib->pktlen);
- }
-}
-#endif /* CONFIG_AUTO_AP_MODE */
-
-
pattrib->last_txcmdsz = pattrib->pktlen;
@@ -2829,8 +2569,6 @@ static int _issue_probereq(struct adapter *padapter,
int bssrate_len = 0;
u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+issue_probereq\n"));
-
pmgntframe = alloc_mgtxmitframe(pxmitpriv);
if (!pmgntframe)
goto exit;
@@ -2897,8 +2635,6 @@ static int _issue_probereq(struct 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));
-
if (wait_ack) {
ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe);
} else {
@@ -2942,16 +2678,6 @@ int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid,
#endif
}
- if (try_cnt && wait_ms) {
- if (da)
- DBG_871X(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n",
- FUNC_ADPT_ARG(padapter), MAC_ARG(da), rtw_get_oper_ch(padapter),
- ret == _SUCCESS?", acked":"", i, try_cnt, (i + 1) * wait_ms);
- else
- DBG_871X(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n",
- FUNC_ADPT_ARG(padapter), rtw_get_oper_ch(padapter),
- ret == _SUCCESS?", acked":"", i, try_cnt, (i + 1) * wait_ms);
- }
exit:
return ret;
}
@@ -3039,13 +2765,11 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short
use_shared_key = 1;
}
le_tmp = cpu_to_le16(val16);
- /* DBG_871X("%s auth_algo = %s auth_seq =%d\n", __func__, (pmlmeinfo->auth_algo == 0)?"OPEN":"SHARED", pmlmeinfo->auth_seq); */
/* setting IV for auth seq #3 */
if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) {
__le32 le_tmp32;
- /* DBG_871X("==> iv(%d), key_index(%d)\n", pmlmeinfo->iv, pmlmeinfo->key_index); */
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));
@@ -3085,7 +2809,6 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short
pattrib->last_txcmdsz = pattrib->pktlen;
rtw_wep_encrypt(padapter, (u8 *)pmgntframe);
- DBG_871X("%s\n", __func__);
dump_mgntframe(padapter, pmgntframe);
}
@@ -3106,8 +2829,6 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i
u8 *ie = pnetwork->IEs;
__le16 lestatus, le_tmp;
- DBG_871X("%s\n", __func__);
-
pmgntframe = alloc_mgtxmitframe(pxmitpriv);
if (pmgntframe == NULL)
return;
@@ -3286,20 +3007,17 @@ void issue_assocreq(struct adapter *padapter)
/* Check if the AP's supported rates are also supported by STA. */
get_rate_set(padapter, sta_bssrate, &sta_bssrate_len);
- /* DBG_871X("sta_bssrate_len =%d\n", sta_bssrate_len); */
if (pmlmeext->cur_channel == 14) /* for JAPAN, channel 14 can only uses B Mode(CCK) */
sta_bssrate_len = 4;
/* for (i = 0; i < sta_bssrate_len; i++) { */
- /* DBG_871X("sta_bssrate[%d]=%02X\n", i, sta_bssrate[i]); */
/* */
for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) {
if (pmlmeinfo->network.SupportedRates[i] == 0)
break;
- DBG_871X("network.SupportedRates[%d]=%02X\n", i, pmlmeinfo->network.SupportedRates[i]);
}
@@ -3311,26 +3029,17 @@ void issue_assocreq(struct adapter *padapter)
/* Check if the AP's supported rates are also supported by STA. */
for (j = 0; j < sta_bssrate_len; j++) {
/* Avoid the proprietary data rate (22Mbps) of Handlink WSG-4000 AP */
- if ((pmlmeinfo->network.SupportedRates[i]|IEEE80211_BASIC_RATE_MASK)
- == (sta_bssrate[j]|IEEE80211_BASIC_RATE_MASK)) {
- /* DBG_871X("match i = %d, j =%d\n", i, j); */
+ if ((pmlmeinfo->network.SupportedRates[i] | IEEE80211_BASIC_RATE_MASK)
+ == (sta_bssrate[j] | IEEE80211_BASIC_RATE_MASK))
break;
- } else {
- /* DBG_871X("not match: %02X != %02X\n", (pmlmeinfo->network.SupportedRates[i]|IEEE80211_BASIC_RATE_MASK), (sta_bssrate[j]|IEEE80211_BASIC_RATE_MASK)); */
- }
}
- if (j == sta_bssrate_len) {
- /* the rate is not supported by STA */
- DBG_871X("%s(): the rate[%d]=%02X is not supported by STA!\n", __func__, i, pmlmeinfo->network.SupportedRates[i]);
- } else {
+ if (j != sta_bssrate_len)
/* the rate is supported by STA */
bssrate[index++] = pmlmeinfo->network.SupportedRates[i];
- }
}
bssrate_len = index;
- DBG_871X("bssrate_len = %d\n", bssrate_len);
if (bssrate_len == 0) {
rtw_free_xmitbuf(pxmitpriv, pmgntframe->pxmitbuf);
@@ -3422,8 +3131,6 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da,
struct mlme_ext_priv *pmlmeext;
struct mlme_ext_info *pmlmeinfo;
- /* DBG_871X("%s:%d\n", __func__, power_mode); */
-
if (!padapter)
goto exit;
@@ -3506,8 +3213,6 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow
else
rtw_hal_macid_wakeup(padapter, psta->mac_id);
} else {
- DBG_871X(FUNC_ADPT_FMT ": Can't find sta info for %pM, skip macid %s!!\n",
- FUNC_ADPT_ARG(padapter), MAC_ARG(da), power_mode?"sleep":"wakeup");
rtw_warn_on(1);
}
@@ -3531,16 +3236,6 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow
#endif
}
- if (try_cnt && wait_ms) {
- if (da)
- DBG_871X(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n",
- FUNC_ADPT_ARG(padapter), MAC_ARG(da), rtw_get_oper_ch(padapter),
- ret == _SUCCESS?", acked":"", i, try_cnt, (i + 1) * wait_ms);
- else
- DBG_871X(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n",
- FUNC_ADPT_ARG(padapter), rtw_get_oper_ch(padapter),
- ret == _SUCCESS?", acked":"", i, try_cnt, (i + 1) * wait_ms);
- }
exit:
return ret;
}
@@ -3582,8 +3277,6 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da,
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- DBG_871X("%s\n", __func__);
-
pmgntframe = alloc_mgtxmitframe(pxmitpriv);
if (pmgntframe == NULL)
goto exit;
@@ -3679,16 +3372,6 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int
#endif
}
- if (try_cnt && wait_ms) {
- if (da)
- DBG_871X(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n",
- FUNC_ADPT_ARG(padapter), MAC_ARG(da), rtw_get_oper_ch(padapter),
- ret == _SUCCESS?", acked":"", i, try_cnt, (i + 1) * wait_ms);
- else
- DBG_871X(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n",
- FUNC_ADPT_ARG(padapter), rtw_get_oper_ch(padapter),
- ret == _SUCCESS?", acked":"", i, try_cnt, (i + 1) * wait_ms);
- }
exit:
return ret;
}
@@ -3707,8 +3390,6 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da,
int ret = _FAIL;
__le16 le_tmp;
- /* DBG_871X("%s to %pM\n", __func__, MAC_ARG(da)); */
-
pmgntframe = alloc_mgtxmitframe(pxmitpriv);
if (pmgntframe == NULL) {
goto exit;
@@ -3757,7 +3438,6 @@ exit:
int issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason)
{
- DBG_871X("%s to %pM\n", __func__, MAC_ARG(da));
return _issue_deauth(padapter, da, reason, false);
}
@@ -3787,16 +3467,6 @@ int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int
#endif
}
- if (try_cnt && wait_ms) {
- if (da)
- DBG_871X(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n",
- FUNC_ADPT_ARG(padapter), MAC_ARG(da), rtw_get_oper_ch(padapter),
- ret == _SUCCESS?", acked":"", i, try_cnt, (i + 1) * wait_ms);
- else
- DBG_871X(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n",
- FUNC_ADPT_ARG(padapter), rtw_get_oper_ch(padapter),
- ret == _SUCCESS?", acked":"", i, try_cnt, (i + 1) * wait_ms);
- }
exit:
return ret;
}
@@ -3814,13 +3484,9 @@ void issue_action_SA_Query(struct adapter *padapter, unsigned char *raddr, unsig
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
__le16 le_tmp;
- DBG_871X("%s\n", __func__);
-
pmgntframe = alloc_mgtxmitframe(pxmitpriv);
- if (pmgntframe == NULL) {
- DBG_871X("%s: alloc_mgtxmitframe fail\n", __func__);
+ if (!pmgntframe)
return;
- }
/* update attribute */
pattrib = &pmgntframe->attrib;
@@ -3894,8 +3560,6 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
struct registry_priv *pregpriv = &padapter->registrypriv;
__le16 le_tmp;
- DBG_871X("%s, category =%d, action =%d, status =%d\n", __func__, category, action, status);
-
pmgntframe = alloc_mgtxmitframe(pxmitpriv);
if (!pmgntframe)
return;
@@ -3959,8 +3623,6 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
if (psta) {
start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07]&0xfff) + 1;
- DBG_871X("BA_starting_seqctrl = %d for TID =%d\n", start_seq, status & 0x07);
-
psta->BA_starting_seqctrl[status & 0x07] = start_seq;
BA_starting_seqctrl = start_seq << 4;
@@ -4051,10 +3713,6 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)
if (true == pmlmeinfo->bwmode_updated)
return;
-
- DBG_871X("%s\n", __func__);
-
-
category = RTW_WLAN_CATEGORY_PUBLIC;
action = ACT_PUBLIC_BSSCOEXIST;
@@ -4192,26 +3850,17 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr)
if (psta == NULL)
return _SUCCESS;
- /* DBG_871X("%s:%s\n", __func__, (initiator == 0)?"RX_DIR":"TX_DIR"); */
-
if (initiator == 0) {/* recipient */
for (tid = 0; tid < MAXTID; tid++) {
if (psta->recvreorder_ctrl[tid].enable) {
- DBG_871X("rx agg disable tid(%d)\n", tid);
issue_action_BA(padapter, addr, WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F));
psta->recvreorder_ctrl[tid].enable = false;
psta->recvreorder_ctrl[tid].indicate_seq = 0xffff;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d indicate_seq:%u\n", __func__, __LINE__,
- psta->recvreorder_ctrl[tid].indicate_seq);
- #endif
}
}
} else if (initiator == 1) {/* originator */
- /* DBG_871X("tx agg_enable_bitmap(0x%08x)\n", psta->htpriv.agg_enable_bitmap); */
for (tid = 0; tid < MAXTID; tid++) {
if (psta->htpriv.agg_enable_bitmap & BIT(tid)) {
- DBG_871X("tx agg disable tid(%d)\n", tid);
issue_action_BA(padapter, addr, WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F));
psta->htpriv.agg_enable_bitmap &= ~BIT(tid);
psta->htpriv.candidate_tid_bitmap &= ~BIT(tid);
@@ -4229,7 +3878,6 @@ unsigned int send_beacon(struct adapter *padapter)
u8 bxmitok = false;
int issue = 0;
int poll = 0;
- unsigned long start = jiffies;
rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL);
rtw_hal_set_hwreg(padapter, HW_VAR_DL_BCN_SEL, NULL);
@@ -4249,19 +3897,10 @@ unsigned int send_beacon(struct adapter *padapter)
}
- if (false == bxmitok) {
- DBG_871X("%s fail! %u ms\n", __func__, jiffies_to_msecs(jiffies - start));
+ if (!bxmitok)
return _FAIL;
- } else {
- unsigned long passing_time = jiffies_to_msecs(jiffies - start);
-
- if (passing_time > 100 || issue > 3)
- DBG_871X("%s success, issue:%d, poll:%d, %lu ms\n", __func__, issue, poll, passing_time);
- /* else */
- /* DBG_871X("%s success, issue:%d, poll:%d, %u ms\n", __func__, issue, poll, passing_time); */
-
+ else
return _SUCCESS;
- }
}
/****************************************************************************
@@ -4273,7 +3912,7 @@ Following are some utility functions for WiFi MLME
void site_survey(struct adapter *padapter)
{
unsigned char survey_channel = 0, val8;
- RT_SCAN_TYPE ScanType = SCAN_PASSIVE;
+ enum rt_scan_type ScanType = SCAN_PASSIVE;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
u32 initialgain = 0;
@@ -4289,18 +3928,6 @@ void site_survey(struct adapter *padapter)
}
}
- DBG_871X(FUNC_ADPT_FMT" ch:%u (cnt:%u) at %dms, %c%c%c\n"
- , FUNC_ADPT_ARG(padapter)
- , survey_channel
- , pmlmeext->sitesurvey_res.channel_idx
- , jiffies_to_msecs(jiffies - padapter->mlmepriv.scan_start_time)
- , ScanType?'A':'P', pmlmeext->sitesurvey_res.scan_mode?'A':'P'
- , pmlmeext->sitesurvey_res.ssid[0].SsidLength?'S':' '
- );
-#ifdef DBG_FIXED_CHAN
- DBG_871X(FUNC_ADPT_FMT" fixed_chan:%u\n", pmlmeext->fixed_chan);
-#endif
-
if (survey_channel != 0) {
/* PAUSE 4-AC Queue when site_survey */
/* rtw_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */
@@ -4351,18 +3978,6 @@ void site_survey(struct adapter *padapter)
channel_scan_time_ms = pmlmeext->chan_scan_time;
set_survey_timer(pmlmeext, channel_scan_time_ms);
-#if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
- {
- struct noise_info info;
-
- info.bPauseDIG = false;
- info.IGIValue = 0;
- info.max_time = channel_scan_time_ms/2;/* ms */
- info.chan = survey_channel;
- rtw_hal_set_odm_var(padapter, HAL_ODM_NOISE_MONITOR, &info, false);
- }
-#endif
-
} else {
/* channel number is 0 or this channel is not valid. */
@@ -4426,10 +4041,8 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str
len = packet_len - sizeof(struct ieee80211_hdr_3addr);
- if (len > MAX_IE_SZ) {
- /* DBG_871X("IE too long for survey event\n"); */
+ if (len > MAX_IE_SZ)
return _FAIL;
- }
memset(bssid, 0, sizeof(struct wlan_bssid_ex));
@@ -4465,16 +4078,13 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str
/* checking SSID */
p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_SSID, &len, bssid->IELength - ie_offset);
- if (p == NULL) {
- DBG_871X("marc: cannot find SSID for survey event\n");
+ if (!p)
return _FAIL;
- }
if (*(p + 1)) {
- if (len > NDIS_802_11_LENGTH_SSID) {
- DBG_871X("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len);
+ if (len > NDIS_802_11_LENGTH_SSID)
return _FAIL;
- }
+
memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1));
bssid->Ssid.SsidLength = *(p + 1);
} else
@@ -4486,20 +4096,18 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str
i = 0;
p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_SUPP_RATES, &len, bssid->IELength - ie_offset);
if (p) {
- if (len > NDIS_802_11_LENGTH_RATES_EX) {
- DBG_871X("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len);
+ if (len > NDIS_802_11_LENGTH_RATES_EX)
return _FAIL;
- }
+
memcpy(bssid->SupportedRates, (p + 2), len);
i = len;
}
p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_EXT_SUPP_RATES, &len, bssid->IELength - ie_offset);
if (p) {
- if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) {
- DBG_871X("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len);
+ if (len > (NDIS_802_11_LENGTH_RATES_EX-i))
return _FAIL;
- }
+
memcpy(bssid->SupportedRates + i, (p + 2), len);
}
@@ -4565,16 +4173,6 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str
pmlmepriv->num_sta_no_ht++;
}
- #if defined(DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) & 1
- if (strcmp(bssid->Ssid.Ssid, DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) == 0) {
- DBG_871X("Receiving %s(%pM, DSConfig:%u) from ch%u with ss:%3u, sq:%3u, RawRSSI:%3ld\n"
- , bssid->Ssid.Ssid, MAC_ARG(bssid->MacAddress), bssid->Configuration.DSConfig
- , rtw_get_oper_ch(padapter)
- , bssid->PhyInfo.SignalStrength, bssid->PhyInfo.SignalQuality, bssid->Rssi
- );
- }
- #endif
-
/* mark bss info receiving from nearby channel as SignalQuality 101 */
if (bssid->Configuration.DSConfig != rtw_get_oper_ch(padapter))
bssid->PhyInfo.SignalQuality = 101;
@@ -4618,8 +4216,6 @@ void start_create_ibss(struct adapter *padapter)
/* issue beacon */
if (send_beacon(padapter) == _FAIL) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("issuing beacon frame fail....\n"));
-
report_join_res(padapter, -1);
pmlmeinfo->state = WIFI_FW_NULL_STATE;
} else {
@@ -4632,7 +4228,6 @@ void start_create_ibss(struct adapter *padapter)
rtw_indicate_connect(padapter);
}
} else {
- DBG_871X("start_create_ibss, invalid cap:%x\n", caps);
return;
}
/* update bc/mc sta_info */
@@ -4693,7 +4288,6 @@ void start_clnt_join(struct adapter *padapter)
report_join_res(padapter, 1);
} else {
- /* DBG_871X("marc: invalid cap:%x\n", caps); */
return;
}
@@ -4716,7 +4310,7 @@ void start_clnt_auth(struct adapter *padapter)
pmlmeext->retry = 0;
- DBG_871X_LEVEL(_drv_always_, "start auth\n");
+ netdev_dbg(padapter->pnetdev, "start auth\n");
issue_auth(padapter, NULL, 0);
set_link_timer(pmlmeext, REAUTH_TO);
@@ -4748,8 +4342,6 @@ unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr
if (!(!memcmp(MacAddr, get_my_bssid(&pmlmeinfo->network), ETH_ALEN)))
return _SUCCESS;
- DBG_871X("%s\n", __func__);
-
if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) {
if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {
pmlmeinfo->state = WIFI_FW_NULL_STATE;
@@ -4768,7 +4360,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid
{
struct registry_priv *pregistrypriv;
struct mlme_ext_priv *pmlmeext;
- RT_CHANNEL_INFO *chplan_new;
+ struct rt_channel_info *chplan_new;
u8 channel;
u8 i;
@@ -4781,8 +4373,8 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid
(!pmlmeext->update_channel_plan_by_ap_done)) {
u8 *ie, *p;
u32 len;
- RT_CHANNEL_PLAN chplan_ap;
- RT_CHANNEL_INFO chplan_sta[MAX_CHANNEL_NUM];
+ struct rt_channel_plan chplan_ap;
+ struct rt_channel_info chplan_sta[MAX_CHANNEL_NUM];
u8 country[4];
u8 fcn; /* first channel number */
u8 noc; /* number of channel */
@@ -4801,8 +4393,6 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid
memset(country, 0, 4);
memcpy(country, p, 3);
p += 3;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
- ("%s: 802.11d country =%s\n", __func__, country));
i = 0;
while ((ie - p) >= 3) {
@@ -4821,26 +4411,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid
}
chplan_ap.Len = i;
-#ifdef DEBUG_RTL871X
- i = 0;
- DBG_871X("%s: AP[%s] channel plan {", __func__, bssid->Ssid.Ssid);
- while ((i < chplan_ap.Len) && (chplan_ap.Channel[i] != 0)) {
- DBG_8192C("%02d,", chplan_ap.Channel[i]);
- i++;
- }
- DBG_871X("}\n");
-#endif
-
memcpy(chplan_sta, pmlmeext->channel_set, sizeof(chplan_sta));
-#ifdef DEBUG_RTL871X
- i = 0;
- DBG_871X("%s: STA channel plan {", __func__);
- while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) {
- DBG_871X("%02d(%c),", chplan_sta[i].ChannelNum, chplan_sta[i].ScanType == SCAN_PASSIVE?'p':'a');
- i++;
- }
- DBG_871X("}\n");
-#endif
memset(pmlmeext->channel_set, 0, sizeof(pmlmeext->channel_set));
chplan_new = pmlmeext->channel_set;
@@ -4968,16 +4539,6 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid
}
pmlmeext->update_channel_plan_by_ap_done = 1;
-
-#ifdef DEBUG_RTL871X
- k = 0;
- DBG_871X("%s: new STA channel plan {", __func__);
- while ((k < MAX_CHANNEL_NUM) && (chplan_new[k].ChannelNum != 0)) {
- DBG_871X("%02d(%c),", chplan_new[k].ChannelNum, chplan_new[k].ScanType == SCAN_PASSIVE?'p':'c');
- k++;
- }
- DBG_871X("}\n");
-#endif
}
/* If channel is used by AP, set channel scan type to active */
@@ -4992,9 +4553,6 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid
break;
chplan_new[i].ScanType = SCAN_ACTIVE;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
- ("%s: change channel %d scan type from passive to active\n",
- __func__, channel));
}
break;
}
@@ -5107,8 +4665,6 @@ void report_surveydone_event(struct adapter *padapter)
psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct C2HEvent_Header));
psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt;
- DBG_871X("survey done event(%x) band:%d for %s\n", psurveydone_evt->bss_cnt, padapter->setband, ADPT_ARG(padapter));
-
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
return;
@@ -5155,8 +4711,6 @@ void report_join_res(struct adapter *padapter, int res)
memcpy((unsigned char *)(&(pjoinbss_evt->network.network)), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex));
pjoinbss_evt->network.join_res = pjoinbss_evt->network.aid = res;
- DBG_871X("report_join_res(%d)\n", res);
-
rtw_joinbss_event_prehandle(padapter, (u8 *)&pjoinbss_evt->network);
@@ -5262,8 +4816,6 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
pdel_sta_evt->mac_id = mac_id;
- DBG_871X("report_del_sta_event: delete STA, mac_id =%d\n", mac_id);
-
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
}
@@ -5306,8 +4858,6 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int
memcpy((unsigned char *)(&(padd_sta_evt->macaddr)), MacAddr, ETH_ALEN);
padd_sta_evt->cam_id = cam_idx;
- DBG_871X("report_add_sta_event: add STA\n");
-
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
}
@@ -5439,7 +4989,7 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res)
rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type));
rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr);
- goto exit_mlmeext_joinbss_event_callback;
+ return;
}
if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)
@@ -5475,8 +5025,6 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res)
pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta;
- /* DBG_871X("set_sta_rate\n"); */
-
psta->wireless_mode = pmlmeext->cur_wireless_mode;
/* set per sta rate after updating HT cap. */
@@ -5501,11 +5049,6 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res)
if (get_iface_type(padapter) == IFACE_PORT0)
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_CONNECT, 0);
-
-exit_mlmeext_joinbss_event_callback:
-
- DBG_871X("=>%s\n", __func__);
-
}
/* currently only adhoc mode will go here */
@@ -5515,8 +5058,6 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *p
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
u8 join_type;
- DBG_871X("%s\n", __func__);
-
if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) {
if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { /* adhoc master or sta_count>1 */
@@ -5584,13 +5125,8 @@ void _linked_info_dump(struct adapter *padapter)
if (padapter->bLinkInfoDump) {
- DBG_871X("\n ============[%s] linked status check ===================\n", ADPT_ARG(padapter));
-
if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) {
rtw_hal_get_def_var(padapter, HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, &UndecoratedSmoothedPWDB);
-
- DBG_871X("AP[%pM] - UndecoratedSmoothedPWDB:%d\n",
- MAC_ARG(padapter->mlmepriv.cur_network.network.MacAddress), UndecoratedSmoothedPWDB);
} else if ((pmlmeinfo->state&0x03) == _HW_STATE_AP_) {
struct list_head *phead, *plist;
@@ -5603,9 +5139,6 @@ void _linked_info_dump(struct adapter *padapter)
while (phead != plist) {
psta = container_of(plist, struct sta_info, asoc_list);
plist = get_next(plist);
-
- DBG_871X("STA[%pM]:UndecoratedSmoothedPWDB:%d\n",
- MAC_ARG(psta->hwaddr), psta->rssi_stat.UndecoratedSmoothedPWDB);
}
spin_unlock_bh(&pstapriv->asoc_list_lock);
@@ -5629,27 +5162,6 @@ static u8 chk_ap_is_alive(struct adapter *padapter, struct sta_info *psta)
{
u8 ret = false;
- #ifdef DBG_EXPIRATION_CHK
- DBG_871X(FUNC_ADPT_FMT" rx:"STA_PKTS_FMT", beacon:%llu, probersp_to_self:%llu"
- /*", probersp_bm:%llu, probersp_uo:%llu, probereq:%llu, BI:%u"*/
- ", retry:%u\n"
- , FUNC_ADPT_ARG(padapter)
- , STA_RX_PKTS_DIFF_ARG(psta)
- , psta->sta_stats.rx_beacon_pkts - psta->sta_stats.last_rx_beacon_pkts
- , psta->sta_stats.rx_probersp_pkts - psta->sta_stats.last_rx_probersp_pkts
- /*, psta->sta_stats.rx_probersp_bm_pkts - psta->sta_stats.last_rx_probersp_bm_pkts
- , psta->sta_stats.rx_probersp_uo_pkts - psta->sta_stats.last_rx_probersp_uo_pkts
- , psta->sta_stats.rx_probereq_pkts - psta->sta_stats.last_rx_probereq_pkts
- , pmlmeinfo->bcn_interval*/
- , pmlmeext->retry
- );
-
- DBG_871X(FUNC_ADPT_FMT" tx_pkts:%llu, link_count:%u\n", FUNC_ADPT_ARG(padapter)
- , padapter->xmitpriv.tx_pkts
- , pmlmeinfo->link_count
- );
- #endif
-
if ((sta_rx_data_pkts(psta) == sta_last_rx_data_pkts(psta))
&& sta_rx_beacon_pkts(psta) == sta_last_rx_beacon_pkts(psta)
&& sta_rx_probersp_pkts(psta) == sta_last_rx_probersp_pkts(psta)
@@ -5702,28 +5214,23 @@ void linked_status_chk(struct adapter *padapter)
{
if (rx_chk != _SUCCESS) {
if (pmlmeext->retry == 0) {
- #ifdef DBG_EXPIRATION_CHK
- DBG_871X("issue_probereq to trigger probersp, retry =%d\n", pmlmeext->retry);
- #endif
issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress, 0, 0, 0, 0);
issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress, 0, 0, 0, 0);
issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress, 0, 0, 0, 0);
}
}
- if (tx_chk != _SUCCESS && pmlmeinfo->link_count++ == link_count_limit) {
- #ifdef DBG_EXPIRATION_CHK
- DBG_871X("%s issue_nulldata 0\n", __func__);
- #endif
+ if (tx_chk != _SUCCESS &&
+ pmlmeinfo->link_count++ == link_count_limit)
tx_chk = issue_nulldata_in_interrupt(padapter, NULL);
- }
}
if (rx_chk == _FAIL) {
pmlmeext->retry++;
if (pmlmeext->retry > rx_chk_limit) {
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" disconnect or roaming\n",
- FUNC_ADPT_ARG(padapter));
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " disconnect or roaming\n",
+ FUNC_ADPT_ARG(padapter));
receive_disconnect(padapter, pmlmeinfo->network.MacAddress
, WLAN_REASON_EXPIRATION_CHK);
return;
@@ -5783,8 +5290,6 @@ void survey_timer_hdl(struct timer_list *t)
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
- /* DBG_871X("marc: survey timer\n"); */
-
/* issue rtw_sitesurvey_cmd */
if (pmlmeext->sitesurvey_res.state > SCAN_START) {
if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
@@ -5792,12 +5297,7 @@ void survey_timer_hdl(struct timer_list *t)
}
if (pmlmeext->scan_abort) {
- {
- pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num;
- DBG_871X("%s idx:%d\n", __func__
- , pmlmeext->sitesurvey_res.channel_idx
- );
- }
+ pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num;
pmlmeext->scan_abort = false;/* reset */
}
@@ -5836,7 +5336,6 @@ void link_timer_hdl(struct timer_list *t)
if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
- DBG_871X("link_timer_hdl:no beacon while connecting\n");
pmlmeinfo->state = WIFI_FW_NULL_STATE;
report_join_res(padapter, -3);
} else if (pmlmeinfo->state & WIFI_FW_AUTH_STATE) {
@@ -5855,7 +5354,6 @@ void link_timer_hdl(struct timer_list *t)
/* */
}
- DBG_871X("link_timer_hdl: auth timeout and try again\n");
pmlmeinfo->auth_seq = 1;
issue_auth(padapter, NULL, 0);
set_link_timer(pmlmeext, REAUTH_TO);
@@ -5867,7 +5365,6 @@ void link_timer_hdl(struct timer_list *t)
return;
}
- DBG_871X("link_timer_hdl: assoc timeout and try again\n");
issue_assocreq(padapter);
set_link_timer(pmlmeext, REASSOC_TO);
}
@@ -5905,7 +5402,6 @@ void sa_query_timer_hdl(struct timer_list *t)
}
spin_unlock_bh(&pmlmepriv->lock);
- DBG_871X("SA query timeout disconnect\n");
}
u8 NULL_hdl(struct adapter *padapter, u8 *pbuf)
@@ -5913,99 +5409,6 @@ u8 NULL_hdl(struct adapter *padapter, u8 *pbuf)
return H2C_SUCCESS;
}
-#ifdef CONFIG_AUTO_AP_MODE
-static int rtw_auto_ap_start_beacon(struct adapter *adapter)
-{
- int ret = 0;
- u8 *pbuf = NULL;
- uint len;
- u8 supportRate[16];
- int sz = 0, rateLen;
- u8 *ie;
- u8 wireless_mode, oper_channel;
- u8 ssid[3] = {0}; /* hidden ssid */
- u32 ssid_len = sizeof(ssid);
- struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
-
-
- if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
- return -EINVAL;
-
-
- len = 128;
- pbuf = rtw_zmalloc(len);
- if (!pbuf)
- return -ENOMEM;
-
-
- /* generate beacon */
- ie = pbuf;
-
- /* timestamp will be inserted by hardware */
- sz += 8;
- ie += sz;
-
- /* beacon interval : 2bytes */
- *(u16 *)ie = cpu_to_le16((u16)100);/* BCN_INTERVAL = 100; */
- sz += 2;
- ie += 2;
-
- /* capability info */
- *(u16 *)ie = 0;
- *(u16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_ESS);
- *(u16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
- /* u16*)ie |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); */
- sz += 2;
- ie += 2;
-
- /* SSID */
- ie = rtw_set_ie(ie, WLAN_EID_SSID, ssid_len, ssid, &sz);
-
- /* supported rates */
- wireless_mode = WIRELESS_11BG_24N;
- rtw_set_supported_rate(supportRate, wireless_mode);
- rateLen = rtw_get_rateset_len(supportRate);
- if (rateLen > 8) {
- ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, 8, supportRate, &sz);
- } else {
- ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, rateLen, supportRate, &sz);
- }
-
-
- /* DS parameter set */
- if (check_buddy_fwstate(adapter, _FW_LINKED) &&
- check_buddy_fwstate(adapter, WIFI_STATION_STATE)) {
- struct adapter *pbuddystruct adapter = adapter->pbuddystruct adapter;
- struct mlme_ext_priv *pbuddy_mlmeext = &pbuddystruct adapter->mlmeextpriv;
-
- oper_channel = pbuddy_mlmeext->cur_channel;
- } else {
- oper_channel = adapter_to_dvobj(adapter)->oper_channel;
- }
- ie = rtw_set_ie(ie, WLAN_EID_DS_PARAMS, 1, &oper_channel, &sz);
-
- /* ext supported rates */
- if (rateLen > 8) {
- ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (supportRate + 8), &sz);
- }
-
- DBG_871X("%s, start auto ap beacon sz =%d\n", __func__, sz);
-
- /* lunch ap mode & start to issue beacon */
- if (rtw_check_beacon_data(adapter, pbuf, sz) == _SUCCESS) {
-
- } else {
- ret = -EINVAL;
- }
-
-
- kfree(pbuf);
-
- return ret;
-
-}
-#endif/* CONFIG_AUTO_AP_MODE */
-
u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf)
{
u8 type;
@@ -6030,12 +5433,6 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf)
rtw_hal_set_hwreg(padapter, HW_VAR_SET_OPMODE, (u8 *)(&type));
/* Set_MSR(padapter, type); */
-
-#ifdef CONFIG_AUTO_AP_MODE
- if (psetop->mode == Ndis802_11APMode)
- rtw_auto_ap_start_beacon(padapter);
-#endif
-
if (psetop->mode == Ndis802_11APMode) {
/* Do this after port switch to */
/* prevent from downloading rsvd page to wrong port */
@@ -6214,8 +5611,6 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf)
pmlmeext->cur_bwmode = CHANNEL_WIDTH_20;
break;
}
-
- DBG_871X("set HT ch/bw before connected\n");
}
}
break;
@@ -6294,16 +5689,15 @@ static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_c
j = 0;
for (i = 0; i < in_num; i++) {
- DBG_871X(FUNC_ADPT_FMT" "CHAN_FMT"\n", FUNC_ADPT_ARG(padapter), CHAN_ARG(&in[i]));
-
set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, in[i].hw_value);
if (in[i].hw_value && !(in[i].flags & RTW_IEEE80211_CHAN_DISABLED)
&& set_idx >= 0
&& rtw_mlme_band_check(padapter, in[i].hw_value)
) {
if (j >= out_num) {
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" out_num:%u not enough\n",
- FUNC_ADPT_ARG(padapter), out_num);
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " out_num:%u not enough\n",
+ FUNC_ADPT_ARG(padapter), out_num);
break;
}
@@ -6322,13 +5716,13 @@ static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_c
if (j == 0) {
for (i = 0; i < pmlmeext->max_chan_nums; i++) {
- DBG_871X(FUNC_ADPT_FMT" ch:%u\n", FUNC_ADPT_ARG(padapter), pmlmeext->channel_set[i].ChannelNum);
-
if (rtw_mlme_band_check(padapter, pmlmeext->channel_set[i].ChannelNum)) {
if (j >= out_num) {
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" out_num:%u not enough\n",
- FUNC_ADPT_ARG(padapter), out_num);
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " out_num:%u not enough\n",
+ FUNC_ADPT_ARG(padapter),
+ out_num);
break;
}
@@ -6454,8 +5848,10 @@ u8 setkey_hdl(struct adapter *padapter, u8 *pbuf)
ctrl = BIT(15) | BIT6 | ((pparm->algorithm) << 2) | pparm->keyid;
write_cam(padapter, cam_id, ctrl, addr, pparm->key);
- DBG_871X_LEVEL(_drv_always_, "set group key camid:%d, addr:%pM, kid:%d, type:%s\n"
- , cam_id, MAC_ARG(addr), pparm->keyid, security_type_str(pparm->algorithm));
+ netdev_dbg(padapter->pnetdev,
+ "set group key camid:%d, addr:%pM, kid:%d, type:%s\n",
+ cam_id, MAC_ARG(addr), pparm->keyid,
+ security_type_str(pparm->algorithm));
}
if (cam_id >= 0 && cam_id <= 3)
@@ -6483,7 +5879,8 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf)
psta = rtw_get_stainfo(pstapriv, pparm->addr);
if (!psta) {
- DBG_871X_LEVEL(_drv_always_, "%s sta:%pM not found\n", __func__, MAC_ARG(pparm->addr));
+ netdev_dbg(padapter->pnetdev, "%s sta:%pM not found\n",
+ __func__, MAC_ARG(pparm->addr));
ret = H2C_REJECTED;
goto exit;
}
@@ -6496,13 +5893,17 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf)
write_to_cam:
if (pparm->algorithm == _NO_PRIVACY_) {
while ((cam_id = rtw_camid_search(padapter, pparm->addr, -1)) >= 0) {
- DBG_871X_LEVEL(_drv_always_, "clear key for addr:%pM, camid:%d\n", MAC_ARG(pparm->addr), cam_id);
+ netdev_dbg(padapter->pnetdev,
+ "clear key for addr:%pM, camid:%d\n",
+ MAC_ARG(pparm->addr), cam_id);
clear_cam_entry(padapter, cam_id);
rtw_camid_free(padapter, cam_id);
}
} else {
- DBG_871X_LEVEL(_drv_always_, "set pairwise key camid:%d, addr:%pM, kid:%d, type:%s\n",
- cam_id, MAC_ARG(pparm->addr), pparm->keyid, security_type_str(pparm->algorithm));
+ netdev_dbg(padapter->pnetdev,
+ "set pairwise key camid:%d, addr:%pM, kid:%d, type:%s\n",
+ cam_id, MAC_ARG(pparm->addr), pparm->keyid,
+ security_type_str(pparm->algorithm));
ctrl = BIT(15) | ((pparm->algorithm) << 2) | pparm->keyid;
write_cam(padapter, cam_id, ctrl, pparm->addr, pparm->key);
}
@@ -6617,10 +6018,6 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf)
#ifdef CHECK_EVENT_SEQ
/* checking event sequence... */
if (evt_seq != (atomic_read(&pevt_priv->event_seq) & 0x7f)) {
- RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
- ("Event Seq Error! %d vs %d\n", (evt_seq & 0x7f),
- (atomic_read(&pevt_priv->event_seq) & 0x7f)));
-
pevt_priv->event_seq = (evt_seq+1)&0x7f;
goto _abort_event_;
@@ -6628,21 +6025,14 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf)
#endif
/* 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));
+ if (evt_code >= MAX_C2HEVT)
goto _abort_event_;
- }
/* checking if event size match the event parm size */
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));
+ (wlanevents[evt_code].parmsize != evt_sz))
goto _abort_event_;
- }
-
atomic_inc(&pevt_priv->event_seq);
peventbuf += 2;
@@ -6725,10 +6115,8 @@ u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf)
u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf)
{
- if (send_beacon(padapter) == _FAIL) {
- DBG_871X("issue_beacon, fail!\n");
+ if (send_beacon(padapter) == _FAIL)
return H2C_PARAMETERS_ERROR;
- }
/* tx bc/mc frames after update TIM */
chk_bmc_sleepq_hdl(padapter, NULL);
@@ -6750,7 +6138,6 @@ int rtw_chk_start_clnt_join(struct adapter *padapter, u8 *ch, u8 *bw, u8 *offset
}
if (connect_allow) {
- DBG_871X("start_join_set_ch_bw: ch =%d, bwmode =%d, ch_offset =%d\n", cur_ch, cur_bw, cur_ch_offset);
*ch = cur_ch;
*bw = cur_bw;
*offset = cur_ch_offset;
@@ -6790,10 +6177,6 @@ u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf)
set_ch_parm = (struct set_ch_parm *)pbuf;
- DBG_871X(FUNC_NDEV_FMT" ch:%u, bw:%u, ch_offset:%u\n",
- FUNC_NDEV_ARG(padapter->pnetdev),
- set_ch_parm->ch, set_ch_parm->bw, set_ch_parm->ch_offset);
-
pmlmeext->cur_channel = set_ch_parm->ch;
pmlmeext->cur_ch_offset = set_ch_parm->ch_offset;
pmlmeext->cur_bwmode = set_ch_parm->bw;
@@ -6826,17 +6209,6 @@ u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf)
return H2C_SUCCESS;
}
-u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf)
-{
- struct LedBlink_param *ledBlink_param;
-
- if (!pbuf)
- return H2C_PARAMETERS_ERROR;
-
- ledBlink_param = (struct LedBlink_param *)pbuf;
- return H2C_SUCCESS;
-}
-
u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf)
{
return H2C_REJECTED;
diff --git a/drivers/staging/rtl8723bs/core/rtw_odm.c b/drivers/staging/rtl8723bs/core/rtw_odm.c
index 93e8f17d2574..f6b73a2a0270 100644
--- a/drivers/staging/rtl8723bs/core/rtw_odm.c
+++ b/drivers/staging/rtl8723bs/core/rtw_odm.c
@@ -90,18 +90,19 @@ static const char * const odm_dbg_level_str[] = {
#define RTW_ODM_DBG_LEVEL_NUM 6
-void rtw_odm_dbg_comp_msg(void *sel, struct adapter *adapter)
+void rtw_odm_dbg_comp_msg(struct adapter *adapter)
{
u64 dbg_comp;
int i;
rtw_hal_get_def_var(adapter, HW_DEF_ODM_DBG_FLAG, &dbg_comp);
- DBG_871X_SEL_NL(sel, "odm.DebugComponents = 0x%016llx\n", dbg_comp);
+ netdev_dbg(adapter->pnetdev, "odm.DebugComponents = 0x%016llx\n",
+ dbg_comp);
for (i = 0; i < RTW_ODM_COMP_MAX; i++) {
if (odm_comp_str[i])
- DBG_871X_SEL_NL(sel, "%cBIT%-2d %s\n",
- (BIT0 << i) & dbg_comp ? '+' : ' ',
- i, odm_comp_str[i]);
+ netdev_dbg(adapter->pnetdev, "%cBIT%-2d %s\n",
+ (BIT0 << i) & dbg_comp ? '+' : ' ', i,
+ odm_comp_str[i]);
}
}
@@ -116,11 +117,11 @@ void rtw_odm_dbg_level_msg(void *sel, struct adapter *adapter)
int i;
rtw_hal_get_def_var(adapter, HW_DEF_ODM_DBG_LEVEL, &dbg_level);
- DBG_871X_SEL_NL(sel, "odm.DebugLevel = %u\n", dbg_level);
+ netdev_dbg(adapter->pnetdev, "odm.DebugLevel = %u\n", dbg_level);
for (i = 0; i < RTW_ODM_DBG_LEVEL_NUM; i++) {
if (odm_dbg_level_str[i])
- DBG_871X_SEL_NL(sel, "%u %s\n",
- i, odm_dbg_level_str[i]);
+ netdev_dbg(adapter->pnetdev, "%u %s\n", i,
+ odm_dbg_level_str[i]);
}
}
@@ -135,12 +136,12 @@ void rtw_odm_ability_msg(void *sel, struct adapter *adapter)
int i;
rtw_hal_get_hwreg(adapter, HW_VAR_DM_FLAG, (u8 *)&ability);
- DBG_871X_SEL_NL(sel, "odm.SupportAbility = 0x%08x\n", ability);
+ netdev_dbg(adapter->pnetdev, "odm.SupportAbility = 0x%08x\n", ability);
for (i = 0; i < RTW_ODM_ABILITY_MAX; i++) {
if (odm_ability_str[i])
- DBG_871X_SEL_NL(sel, "%cBIT%-2d %s\n",
- (BIT0 << i) & ability ? '+' : ' ', i,
- odm_ability_str[i]);
+ netdev_dbg(adapter->pnetdev, "%cBIT%-2d %s\n",
+ (BIT0 << i) & ability ? '+' : ' ', i,
+ odm_ability_str[i]);
}
}
@@ -152,19 +153,19 @@ inline void rtw_odm_ability_set(struct adapter *adapter, u32 ability)
void rtw_odm_adaptivity_parm_msg(void *sel, struct adapter *adapter)
{
struct hal_com_data *pHalData = GET_HAL_DATA(adapter);
- DM_ODM_T *odm = &pHalData->odmpriv;
-
- DBG_871X_SEL_NL(sel, "%10s %16s %8s %10s %11s %14s\n",
- "TH_L2H_ini", "TH_EDCCA_HL_diff", "IGI_Base",
- "ForceEDCCA", "AdapEn_RSSI", "IGI_LowerBound");
- DBG_871X_SEL_NL(sel, "0x%-8x %-16d 0x%-6x %-10d %-11u %-14u\n",
- (u8)odm->TH_L2H_ini,
- odm->TH_EDCCA_HL_diff,
- odm->IGI_Base,
- odm->ForceEDCCA,
- odm->AdapEn_RSSI,
- odm->IGI_LowerBound
- );
+ struct dm_odm_t *odm = &pHalData->odmpriv;
+
+ netdev_dbg(adapter->pnetdev, "%10s %16s %8s %10s %11s %14s\n",
+ "TH_L2H_ini", "TH_EDCCA_HL_diff", "IGI_Base", "ForceEDCCA",
+ "AdapEn_RSSI", "IGI_LowerBound");
+ netdev_dbg(adapter->pnetdev,
+ "0x%-8x %-16d 0x%-6x %-10d %-11u %-14u\n",
+ (u8)odm->TH_L2H_ini,
+ odm->TH_EDCCA_HL_diff,
+ odm->IGI_Base,
+ odm->ForceEDCCA,
+ odm->AdapEn_RSSI,
+ odm->IGI_LowerBound);
}
void rtw_odm_adaptivity_parm_set(struct adapter *adapter, s8 TH_L2H_ini,
@@ -173,7 +174,7 @@ void rtw_odm_adaptivity_parm_set(struct adapter *adapter, s8 TH_L2H_ini,
u8 IGI_LowerBound)
{
struct hal_com_data *pHalData = GET_HAL_DATA(adapter);
- DM_ODM_T *odm = &pHalData->odmpriv;
+ struct dm_odm_t *odm = &pHalData->odmpriv;
odm->TH_L2H_ini = TH_L2H_ini;
odm->TH_EDCCA_HL_diff = TH_EDCCA_HL_diff;
@@ -186,8 +187,9 @@ void rtw_odm_adaptivity_parm_set(struct adapter *adapter, s8 TH_L2H_ini,
void rtw_odm_get_perpkt_rssi(void *sel, struct adapter *adapter)
{
struct hal_com_data *hal_data = GET_HAL_DATA(adapter);
- DM_ODM_T *odm = &hal_data->odmpriv;
+ struct dm_odm_t *odm = &hal_data->odmpriv;
- DBG_871X_SEL_NL(sel, "RxRate = %s, RSSI_A = %d(%%), RSSI_B = %d(%%)\n",
- HDATA_RATE(odm->RxRate), odm->RSSI_A, odm->RSSI_B);
+ netdev_dbg(adapter->pnetdev,
+ "RxRate = %s, RSSI_A = %d(%%), RSSI_B = %d(%%)\n",
+ HDATA_RATE(odm->RxRate), odm->RSSI_A, odm->RSSI_B);
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
index 5b05d1eaa328..251b9abdf591 100644
--- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
@@ -22,11 +22,9 @@ void _ips_enter(struct adapter *padapter)
pwrpriv->ips_mode = pwrpriv->ips_mode_req;
pwrpriv->ips_enter_cnts++;
- DBG_871X("==>ips_enter cnts:%d\n", pwrpriv->ips_enter_cnts);
if (rf_off == pwrpriv->change_rfpwrstate) {
pwrpriv->bpower_saving = true;
- DBG_871X("nolinked power save enter\n");
if (pwrpriv->ips_mode == IPS_LEVEL_2)
pwrpriv->bkeepfwalive = true;
@@ -59,15 +57,11 @@ int _ips_leave(struct adapter *padapter)
pwrpriv->bips_processing = true;
pwrpriv->change_rfpwrstate = rf_on;
pwrpriv->ips_leave_cnts++;
- DBG_871X("==>ips_leave cnts:%d\n", pwrpriv->ips_leave_cnts);
result = rtw_ips_pwr_up(padapter);
if (result == _SUCCESS) {
pwrpriv->rf_pwrstate = rf_on;
}
- DBG_871X("nolinked power save leave\n");
-
- DBG_871X("==> ips_leave.....LED(0x%08x)...\n", rtw_read32(padapter, 0x4c));
pwrpriv->bips_processing = false;
pwrpriv->bkeepfwalive = false;
@@ -89,7 +83,7 @@ int ips_leave(struct adapter *padapter)
ret = _ips_leave(padapter);
mutex_unlock(&pwrpriv->lock);
- if (_SUCCESS == ret)
+ if (ret == _SUCCESS)
hal_btcoex_IpsNotify(padapter, IPS_NONE);
return ret;
@@ -103,15 +97,11 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter)
bool ret = false;
- if (adapter_to_pwrctl(adapter)->bpower_saving) {
- /* DBG_871X("%s: already in LPS or IPS mode\n", __func__); */
+ if (adapter_to_pwrctl(adapter)->bpower_saving)
goto exit;
- }
- if (time_before(jiffies, adapter_to_pwrctl(adapter)->ips_deny_time)) {
- /* DBG_871X("%s ips_deny_time\n", __func__); */
+ if (time_before(jiffies, adapter_to_pwrctl(adapter)->ips_deny_time))
goto exit;
- }
if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR)
|| check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS)
@@ -134,9 +124,12 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter)
if (pxmit_priv->free_xmitbuf_cnt != NR_XMITBUFF ||
pxmit_priv->free_xmit_extbuf_cnt != NR_XMIT_EXTBUFF) {
- DBG_871X_LEVEL(_drv_always_, "There are some pkts to transmit\n");
- DBG_871X_LEVEL(_drv_always_, "free_xmitbuf_cnt: %d, free_xmit_extbuf_cnt: %d\n",
- pxmit_priv->free_xmitbuf_cnt, pxmit_priv->free_xmit_extbuf_cnt);
+ netdev_dbg(adapter->pnetdev,
+ "There are some pkts to transmit\n");
+ netdev_dbg(adapter->pnetdev,
+ "free_xmitbuf_cnt: %d, free_xmit_extbuf_cnt: %d\n",
+ pxmit_priv->free_xmitbuf_cnt,
+ pxmit_priv->free_xmit_extbuf_cnt);
goto exit;
}
@@ -161,15 +154,11 @@ void rtw_ps_processor(struct adapter *padapter)
mutex_lock(&adapter_to_pwrctl(padapter)->lock);
ps_deny = rtw_ps_deny_get(padapter);
mutex_unlock(&adapter_to_pwrctl(padapter)->lock);
- if (ps_deny != 0) {
- DBG_871X(FUNC_ADPT_FMT ": ps_deny = 0x%08X, skip power save!\n",
- FUNC_ADPT_ARG(padapter), ps_deny);
+ if (ps_deny != 0)
goto exit;
- }
if (pwrpriv->bInSuspend) {/* system suspend or autosuspend */
pdbgpriv->dbg_ps_insuspend_cnt++;
- DBG_871X("%s, pwrpriv->bInSuspend == true ignore this process\n", __func__);
return;
}
@@ -182,7 +171,6 @@ void rtw_ps_processor(struct adapter *padapter)
goto exit;
if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4) == 0)) {
- DBG_871X("==>%s\n", __func__);
pwrpriv->change_rfpwrstate = rf_off;
{
ips_enter(padapter);
@@ -221,7 +209,6 @@ void traffic_check_for_leave_lps(struct adapter *padapter, u8 tx, u32 tx_packets
if (adapter_to_pwrctl(padapter)->bLeisurePs
&& (adapter_to_pwrctl(padapter)->pwr_mode != PS_MODE_ACTIVE)
&& !(hal_btcoex_IsBtControlLps(padapter))) {
- DBG_871X("leave lps via Tx = %d\n", xmit_cnt);
bLeaveLPS = true;
}
}
@@ -234,15 +221,12 @@ void traffic_check_for_leave_lps(struct adapter *padapter, u8 tx, u32 tx_packets
if (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 4/*2*/) {
if (adapter_to_pwrctl(padapter)->bLeisurePs
&& (adapter_to_pwrctl(padapter)->pwr_mode != PS_MODE_ACTIVE)
- && !(hal_btcoex_IsBtControlLps(padapter))) {
- DBG_871X("leave lps via Rx = %d\n", pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod);
+ && !(hal_btcoex_IsBtControlLps(padapter)))
bLeaveLPS = true;
- }
}
}
if (bLeaveLPS)
- /* DBG_871X("leave lps via %s, Tx = %d, Rx = %d\n", tx?"Tx":"Rx", pmlmepriv->LinkDetectInfo.NumTxOkInPeriod, pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); */
/* rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_LEAVE, 1); */
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_LEAVE, tx?0:1);
}
@@ -264,44 +248,28 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv)
pslv = PS_STATE(pslv);
- if (pwrpriv->brpwmtimeout) {
- DBG_871X("%s: RPWM timeout, force to set RPWM(0x%02X) again!\n", __func__, pslv);
- } else {
- if ((pwrpriv->rpwm == pslv)
- || ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) {
- RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_,
- ("%s: Already set rpwm[0x%02X], new = 0x%02X!\n", __func__, pwrpriv->rpwm, pslv));
+ if (!pwrpriv->brpwmtimeout) {
+ if (pwrpriv->rpwm == pslv ||
+ (pwrpriv->rpwm >= PS_STATE_S2 && pslv >= PS_STATE_S2))
return;
- }
+
}
if ((padapter->bSurpriseRemoved) || !(padapter->hw_init_completed)) {
- RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_,
- ("%s: SurpriseRemoved(%d) hw_init_completed(%d)\n",
- __func__, padapter->bSurpriseRemoved, padapter->hw_init_completed));
-
pwrpriv->cpwm = PS_STATE_S4;
return;
}
if (padapter->bDriverStopped) {
- RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_,
- ("%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));
+ if (pslv < PS_STATE_S2)
return;
- }
}
rpwm = pslv | pwrpriv->tog;
/* only when from PS_STATE S0/S1 to S2 and higher needs ACK */
if ((pwrpriv->cpwm < PS_STATE_S2) && (pslv >= PS_STATE_S2))
rpwm |= PS_ACK;
- RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
- ("rtw_set_rpwm: rpwm = 0x%02x cpwm = 0x%02x\n", rpwm, pwrpriv->cpwm));
pwrpriv->rpwm = pslv;
@@ -335,7 +303,6 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv)
}
if (jiffies_to_msecs(jiffies - start_time) > LPS_RPWM_WAIT_MS) {
- DBG_871X("%s: polling cpwm timeout! poll_cnt =%d, cpwm_orig =%02x, cpwm_now =%02x\n", __func__, poll_cnt, cpwm_orig, cpwm_now);
_set_timer(&pwrpriv->pwr_rpwm_timer, 1);
break;
}
@@ -350,17 +317,8 @@ static u8 PS_RDY_CHECK(struct adapter *padapter)
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
- if (pwrpriv->bInSuspend && pwrpriv->wowlan_mode)
- return true;
- else if (pwrpriv->bInSuspend && pwrpriv->wowlan_ap_mode)
- return true;
- else if (pwrpriv->bInSuspend)
- return false;
-#else
if (pwrpriv->bInSuspend)
return false;
-#endif
curr_time = jiffies;
@@ -377,10 +335,9 @@ static u8 PS_RDY_CHECK(struct adapter *padapter)
)
return false;
- if ((padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) && !(padapter->securitypriv.binstallGrpkey)) {
- DBG_871X("Group handshake still in progress !!!\n");
+ if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X &&
+ !padapter->securitypriv.binstallGrpkey)
return false;
- }
if (!rtw_cfg80211_pwr_mgmt(padapter))
return false;
@@ -391,21 +348,12 @@ static u8 PS_RDY_CHECK(struct adapter *padapter)
void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode, const char *msg)
{
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
- struct debug_priv *pdbgpriv = &padapter->dvobj->drv_dbg;
-#endif
-
- RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
- ("%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));
+ if (ps_mode > PM_Card_Disable)
return;
- }
if (pwrpriv->pwr_mode == ps_mode)
- if (PS_MODE_ACTIVE == ps_mode)
+ if (ps_mode == PS_MODE_ACTIVE)
return;
@@ -416,37 +364,11 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a
if (!(hal_btcoex_IsBtControlLps(padapter))
|| (hal_btcoex_IsBtControlLps(padapter)
&& !(hal_btcoex_IsLpsOn(padapter)))) {
- DBG_871X(FUNC_ADPT_FMT" Leave 802.11 power save - %s\n",
- FUNC_ADPT_ARG(padapter), msg);
-
pwrpriv->pwr_mode = ps_mode;
rtw_set_rpwm(padapter, PS_STATE_S4);
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
- if (pwrpriv->wowlan_mode || pwrpriv->wowlan_ap_mode) {
- unsigned long start_time;
- u32 delay_ms;
- u8 val8;
- delay_ms = 20;
- start_time = jiffies;
- do {
- rtw_hal_get_hwreg(padapter, HW_VAR_SYS_CLKR, &val8);
- if (!(val8 & BIT(4))) { /* 0x08 bit4 = 1 --> in 32k, bit4 = 0 --> leave 32k */
- pwrpriv->cpwm = PS_STATE_S4;
- break;
- }
- if (jiffies_to_msecs(jiffies - start_time) > delay_ms) {
- DBG_871X("%s: Wait for FW 32K leave more than %u ms!!!\n",
- __func__, delay_ms);
- pdbgpriv->dbg_wow_leave_ps_fail_cnt++;
- break;
- }
- msleep(1);
- } while (1);
- }
-#endif
rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode));
- pwrpriv->bFwCurrentInPSMode = false;
+ pwrpriv->fw_current_in_ps_mode = false;
hal_btcoex_LpsNotify(padapter, ps_mode);
}
@@ -456,12 +378,9 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a
) {
u8 pslv;
- DBG_871X(FUNC_ADPT_FMT" Enter 802.11 power save - %s\n",
- FUNC_ADPT_ARG(padapter), msg);
-
hal_btcoex_LpsNotify(padapter, ps_mode);
- pwrpriv->bFwCurrentInPSMode = true;
+ pwrpriv->fw_current_in_ps_mode = true;
pwrpriv->pwr_mode = ps_mode;
pwrpriv->smart_ps = smart_ps;
pwrpriv->bcn_ant_mode = bcn_ant_mode;
@@ -508,13 +427,11 @@ s32 LPS_RF_ON_check(struct adapter *padapter, u32 delay_ms)
if (padapter->bSurpriseRemoved) {
err = -2;
- DBG_871X("%s: device surprise removed!!\n", __func__);
break;
}
if (jiffies_to_msecs(jiffies - start_time) > delay_ms) {
err = -1;
- DBG_871X("%s: Wait for FW LPS leave more than %u ms!!!\n", __func__, delay_ms);
break;
}
msleep(1);
@@ -554,15 +471,13 @@ void LPS_Enter(struct adapter *padapter, const char *msg)
/* Idle for a while if we connect to AP a while ago. */
if (pwrpriv->LpsIdleCount >= 2) { /* 4 Sec */
if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) {
- sprintf(buf, "WIFI-%s", msg);
+ scnprintf(buf, sizeof(buf), "WIFI-%s", msg);
pwrpriv->bpower_saving = true;
rtw_set_ps_mode(padapter, pwrpriv->power_mgnt, padapter->registrypriv.smart_ps, 0, buf);
}
} else
pwrpriv->LpsIdleCount++;
}
-
-/* DBG_871X("-LeisurePSEnter\n"); */
}
/* */
@@ -577,14 +492,12 @@ void LPS_Leave(struct adapter *padapter, const char *msg)
struct pwrctrl_priv *pwrpriv = dvobj_to_pwrctl(dvobj);
char buf[32] = {0};
-/* DBG_871X("+LeisurePSLeave\n"); */
-
if (hal_btcoex_IsBtControlLps(padapter))
return;
if (pwrpriv->bLeisurePs) {
if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) {
- sprintf(buf, "WIFI-%s", msg);
+ scnprintf(buf, sizeof(buf), "WIFI-%s", msg);
rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, buf);
if (pwrpriv->pwr_mode == PS_MODE_ACTIVE)
@@ -593,8 +506,6 @@ void LPS_Leave(struct adapter *padapter, const char *msg)
}
pwrpriv->bpower_saving = false;
-/* DBG_871X("-LeisurePSLeave\n"); */
-
}
void LeaveAllPowerSaveModeDirect(struct adapter *Adapter)
@@ -603,20 +514,13 @@ void LeaveAllPowerSaveModeDirect(struct adapter *Adapter)
struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv);
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(Adapter);
- DBG_871X("%s.....\n", __func__);
-
- if (Adapter->bSurpriseRemoved) {
- DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n",
- FUNC_ADPT_ARG(Adapter), Adapter->bSurpriseRemoved);
+ if (Adapter->bSurpriseRemoved)
return;
- }
if (check_fwstate(pmlmepriv, _FW_LINKED)) { /* connect */
- if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) {
- DBG_871X("%s: Driver Already Leave LPS\n", __func__);
+ if (pwrpriv->pwr_mode == PS_MODE_ACTIVE)
return;
- }
mutex_lock(&pwrpriv->lock);
@@ -627,8 +531,7 @@ void LeaveAllPowerSaveModeDirect(struct adapter *Adapter)
rtw_lps_ctrl_wk_cmd(pri_padapter, LPS_CTRL_LEAVE, 0);
} else {
if (pwrpriv->rf_pwrstate == rf_off)
- if (!ips_leave(pri_padapter))
- DBG_871X("======> ips_leave fail.............\n");
+ ips_leave(pri_padapter);
}
}
@@ -642,17 +545,11 @@ void LeaveAllPowerSaveMode(struct adapter *Adapter)
u8 enqueue = 0;
int n_assoc_iface = 0;
- if (!Adapter->bup) {
- DBG_871X(FUNC_ADPT_FMT ": bup =%d Skip!\n",
- FUNC_ADPT_ARG(Adapter), Adapter->bup);
+ if (!Adapter->bup)
return;
- }
- if (Adapter->bSurpriseRemoved) {
- DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n",
- FUNC_ADPT_ARG(Adapter), Adapter->bSurpriseRemoved);
+ if (Adapter->bSurpriseRemoved)
return;
- }
if (check_fwstate(&(dvobj->padapters->mlmepriv), WIFI_ASOC_STATE))
n_assoc_iface++;
@@ -665,8 +562,7 @@ void LeaveAllPowerSaveMode(struct adapter *Adapter)
LPS_Leave_check(Adapter);
} else {
if (adapter_to_pwrctl(Adapter)->rf_pwrstate == rf_off) {
- if (!ips_leave(Adapter))
- DBG_871X("======> ips_leave fail.............\n");
+ ips_leave(Adapter);
}
}
}
@@ -697,10 +593,9 @@ void LPS_Leave_check(struct adapter *padapter)
if (bReady)
break;
- if (jiffies_to_msecs(jiffies - start_time) > 100) {
- DBG_871X("Wait for cpwm event than 100 ms!!!\n");
+ if (jiffies_to_msecs(jiffies - start_time) > 100)
break;
- }
+
msleep(1);
}
}
@@ -720,10 +615,8 @@ void cpwm_int_hdl(struct adapter *padapter, struct reportpwrstate_parm *preportp
mutex_lock(&pwrpriv->lock);
- if (pwrpriv->rpwm < PS_STATE_S2) {
- DBG_871X("%s: Redundant CPWM Int. RPWM = 0x%02X CPWM = 0x%02x\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm);
+ if (pwrpriv->rpwm < PS_STATE_S2)
goto exit;
- }
pwrpriv->cpwm = PS_STATE(preportpwrstate->state);
pwrpriv->cpwm_tog = preportpwrstate->state & PS_TOGGLE;
@@ -739,8 +632,6 @@ void cpwm_int_hdl(struct adapter *padapter, struct reportpwrstate_parm *preportp
exit:
mutex_unlock(&pwrpriv->lock);
- RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
- ("cpwm_int_hdl: cpwm = 0x%02x\n", pwrpriv->cpwm));
}
static void cpwm_event_callback(struct work_struct *work)
@@ -750,8 +641,6 @@ static void cpwm_event_callback(struct work_struct *work)
struct adapter *adapter = dvobj->if1;
struct reportpwrstate_parm report;
- /* DBG_871X("%s\n", __func__); */
-
report.state = PS_STATE_S2;
cpwm_int_hdl(adapter, &report);
}
@@ -766,20 +655,17 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work)
pwrpriv = container_of(work, struct pwrctrl_priv, rpwmtimeoutwi);
dvobj = pwrctl_to_dvobj(pwrpriv);
padapter = dvobj->if1;
-/* DBG_871X("+%s: rpwm = 0x%02X cpwm = 0x%02X\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); */
mutex_lock(&pwrpriv->lock);
- if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) {
- DBG_871X("%s: rpwm = 0x%02X cpwm = 0x%02X CPWM done!\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm);
+ if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2))
goto exit;
- }
+
mutex_unlock(&pwrpriv->lock);
if (rtw_read8(padapter, 0x100) != 0xEA) {
struct reportpwrstate_parm report;
report.state = PS_STATE_S2;
- DBG_871X("\n%s: FW already leave 32K!\n\n", __func__);
cpwm_int_hdl(padapter, &report);
return;
@@ -787,10 +673,9 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work)
mutex_lock(&pwrpriv->lock);
- if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) {
- DBG_871X("%s: cpwm =%d, nothing to do!\n", __func__, pwrpriv->cpwm);
+ if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2))
goto exit;
- }
+
pwrpriv->brpwmtimeout = true;
rtw_set_rpwm(padapter, pwrpriv->rpwm);
pwrpriv->brpwmtimeout = false;
@@ -806,12 +691,8 @@ static void pwr_rpwm_timeout_handler(struct timer_list *t)
{
struct pwrctrl_priv *pwrpriv = from_timer(pwrpriv, t, pwr_rpwm_timer);
- DBG_871X("+%s: rpwm = 0x%02X cpwm = 0x%02X\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm);
-
- if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) {
- DBG_871X("+%s: cpwm =%d, nothing to do!\n", __func__, pwrpriv->cpwm);
+ if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2))
return;
- }
_set_workitem(&pwrpriv->rpwmtimeoutwi);
}
@@ -856,11 +737,7 @@ s32 rtw_register_task_alive(struct adapter *padapter, u32 task)
register_task_alive(pwrctrl, task);
- if (pwrctrl->bFwCurrentInPSMode) {
- RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
- ("%s: task = 0x%x cpwm = 0x%02x alives = 0x%08x\n",
- __func__, task, pwrctrl->cpwm, pwrctrl->alives));
-
+ if (pwrctrl->fw_current_in_ps_mode) {
if (pwrctrl->cpwm < pslv) {
if (pwrctrl->cpwm < PS_STATE_S2)
res = _FAIL;
@@ -871,7 +748,7 @@ s32 rtw_register_task_alive(struct adapter *padapter, u32 task)
mutex_unlock(&pwrctrl->lock);
- if (_FAIL == res)
+ if (res == _FAIL)
if (pwrctrl->cpwm >= PS_STATE_S2)
res = _SUCCESS;
@@ -908,11 +785,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task)
unregister_task_alive(pwrctrl, task);
- if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && pwrctrl->bFwCurrentInPSMode) {
- RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
- ("%s: cpwm = 0x%02x alives = 0x%08x\n",
- __func__, pwrctrl->cpwm, pwrctrl->alives));
-
+ if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && pwrctrl->fw_current_in_ps_mode) {
if (pwrctrl->cpwm > pslv)
if ((pslv >= PS_STATE_S2) || (pwrctrl->alives == 0))
rtw_set_rpwm(padapter, pslv);
@@ -949,11 +822,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter)
register_task_alive(pwrctrl, XMIT_ALIVE);
- if (pwrctrl->bFwCurrentInPSMode) {
- RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
- ("rtw_register_tx_alive: cpwm = 0x%02x alives = 0x%08x\n",
- pwrctrl->cpwm, pwrctrl->alives));
-
+ if (pwrctrl->fw_current_in_ps_mode) {
if (pwrctrl->cpwm < pslv) {
if (pwrctrl->cpwm < PS_STATE_S2)
res = _FAIL;
@@ -964,7 +833,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter)
mutex_unlock(&pwrctrl->lock);
- if (_FAIL == res)
+ if (res == _FAIL)
if (pwrctrl->cpwm >= PS_STATE_S2)
res = _SUCCESS;
@@ -998,11 +867,7 @@ s32 rtw_register_cmd_alive(struct adapter *padapter)
register_task_alive(pwrctrl, CMD_ALIVE);
- if (pwrctrl->bFwCurrentInPSMode) {
- RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_info_,
- ("rtw_register_cmd_alive: cpwm = 0x%02x alives = 0x%08x\n",
- pwrctrl->cpwm, pwrctrl->alives));
-
+ if (pwrctrl->fw_current_in_ps_mode) {
if (pwrctrl->cpwm < pslv) {
if (pwrctrl->cpwm < PS_STATE_S2)
res = _FAIL;
@@ -1013,7 +878,7 @@ s32 rtw_register_cmd_alive(struct adapter *padapter)
mutex_unlock(&pwrctrl->lock);
- if (_FAIL == res)
+ if (res == _FAIL)
if (pwrctrl->cpwm >= PS_STATE_S2)
res = _SUCCESS;
@@ -1047,11 +912,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter)
unregister_task_alive(pwrctrl, XMIT_ALIVE);
- if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && pwrctrl->bFwCurrentInPSMode) {
- RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
- ("%s: cpwm = 0x%02x alives = 0x%08x\n",
- __func__, pwrctrl->cpwm, pwrctrl->alives));
-
+ if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && pwrctrl->fw_current_in_ps_mode) {
if (pwrctrl->cpwm > pslv)
if ((pslv >= PS_STATE_S2) || (pwrctrl->alives == 0))
rtw_set_rpwm(padapter, pslv);
@@ -1087,11 +948,7 @@ void rtw_unregister_cmd_alive(struct adapter *padapter)
unregister_task_alive(pwrctrl, CMD_ALIVE);
- if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && pwrctrl->bFwCurrentInPSMode) {
- RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_info_,
- ("%s: cpwm = 0x%02x alives = 0x%08x\n",
- __func__, pwrctrl->cpwm, pwrctrl->alives));
-
+ if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && pwrctrl->fw_current_in_ps_mode) {
if (pwrctrl->cpwm > pslv) {
if ((pslv >= PS_STATE_S2) || (pwrctrl->alives == 0))
rtw_set_rpwm(padapter, pslv);
@@ -1124,7 +981,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */
pwrctrlpriv->bLeisurePs = pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE;
- pwrctrlpriv->bFwCurrentInPSMode = false;
+ pwrctrlpriv->fw_current_in_ps_mode = false;
pwrctrlpriv->rpwm = 0;
pwrctrlpriv->cpwm = PS_STATE_S4;
@@ -1149,29 +1006,11 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
pwrctrlpriv->wowlan_mode = false;
pwrctrlpriv->wowlan_ap_mode = false;
-
-#ifdef CONFIG_PNO_SUPPORT
- pwrctrlpriv->pno_inited = false;
- pwrctrlpriv->pnlo_info = NULL;
- pwrctrlpriv->pscan_info = NULL;
- pwrctrlpriv->pno_ssid_list = NULL;
- pwrctrlpriv->pno_in_resume = true;
-#endif
}
void rtw_free_pwrctrl_priv(struct adapter *adapter)
{
-#ifdef CONFIG_PNO_SUPPORT
- if (pwrctrlpriv->pnlo_info)
- printk("****** pnlo_info memory leak********\n");
-
- if (pwrctrlpriv->pscan_info)
- printk("****** pscan_info memory leak********\n");
-
- if (pwrctrlpriv->pno_ssid_list)
- printk("****** pno_ssid_list memory leak********\n");
-#endif
}
inline void rtw_set_ips_deny(struct adapter *padapter, u32 ms)
@@ -1207,27 +1046,14 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal
pwrpriv->ips_deny_time = deny_time;
- if (pwrpriv->ps_processing) {
- DBG_871X("%s wait ps_processing...\n", __func__);
+ if (pwrpriv->ps_processing)
while (pwrpriv->ps_processing && jiffies_to_msecs(jiffies - start) <= 3000)
mdelay(10);
- if (pwrpriv->ps_processing)
- DBG_871X("%s wait ps_processing timeout\n", __func__);
- else
- DBG_871X("%s wait ps_processing done\n", __func__);
- }
- if (!(pwrpriv->bInternalAutoSuspend) && pwrpriv->bInSuspend) {
- DBG_871X("%s wait bInSuspend...\n", __func__);
+ if (!(pwrpriv->bInternalAutoSuspend) && pwrpriv->bInSuspend)
while (pwrpriv->bInSuspend && jiffies_to_msecs(jiffies - start) <= 3000
- ) {
+ )
mdelay(10);
- }
- if (pwrpriv->bInSuspend)
- DBG_871X("%s wait bInSuspend timeout\n", __func__);
- else
- DBG_871X("%s wait bInSuspend done\n", __func__);
- }
/* System suspend is not allowed to wakeup */
if (!(pwrpriv->bInternalAutoSuspend) && pwrpriv->bInSuspend) {
@@ -1249,9 +1075,7 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal
if (rf_off == pwrpriv->rf_pwrstate) {
{
- DBG_8192C("%s call ips_leave....\n", __func__);
- if (_FAIL == ips_leave(padapter)) {
- DBG_8192C("======> ips_leave fail.............\n");
+ if (ips_leave(padapter) == _FAIL) {
ret = _FAIL;
goto exit;
}
@@ -1260,11 +1084,6 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal
/* TODO: the following checking need to be merged... */
if (padapter->bDriverStopped || !padapter->bup || !padapter->hw_init_completed) {
- DBG_8192C("%s: bDriverStopped =%d, bup =%d, hw_init_completed =%u\n"
- , caller
- , padapter->bDriverStopped
- , padapter->bup
- , padapter->hw_init_completed);
ret = false;
goto exit;
}
@@ -1284,7 +1103,7 @@ int rtw_pm_set_lps(struct adapter *padapter, u8 mode)
if (mode < PS_MODE_NUM) {
if (pwrctrlpriv->power_mgnt != mode) {
- if (PS_MODE_ACTIVE == mode)
+ if (mode == PS_MODE_ACTIVE)
LeaveAllPowerSaveMode(padapter);
else
pwrctrlpriv->LpsIdleCount = 2;
@@ -1305,12 +1124,10 @@ int rtw_pm_set_ips(struct adapter *padapter, u8 mode)
if (mode == IPS_NORMAL || mode == IPS_LEVEL_2) {
rtw_ips_mode_req(pwrctrlpriv, mode);
- DBG_871X("%s %s\n", __func__, mode == IPS_NORMAL?"IPS_NORMAL":"IPS_LEVEL_2");
return 0;
} else if (mode == IPS_NONE) {
rtw_ips_mode_req(pwrctrlpriv, mode);
- DBG_871X("%s %s\n", __func__, "IPS_NONE");
- if ((padapter->bSurpriseRemoved == 0) && (_FAIL == rtw_pwr_wakeup(padapter)))
+ if ((padapter->bSurpriseRemoved == 0) && (rtw_pwr_wakeup(padapter) == _FAIL))
return -EFAULT;
} else
return -EINVAL;
@@ -1322,51 +1139,30 @@ int rtw_pm_set_ips(struct adapter *padapter, u8 mode)
* ATTENTION:
*This function will request pwrctrl LOCK!
*/
-void rtw_ps_deny(struct adapter *padapter, enum PS_DENY_REASON reason)
+void rtw_ps_deny(struct adapter *padapter, enum ps_deny_reason reason)
{
struct pwrctrl_priv *pwrpriv;
- /* DBG_871X("+" FUNC_ADPT_FMT ": Request PS deny for %d (0x%08X)\n", */
- /* FUNC_ADPT_ARG(padapter), reason, BIT(reason)); */
-
pwrpriv = adapter_to_pwrctl(padapter);
mutex_lock(&pwrpriv->lock);
- if (pwrpriv->ps_deny & BIT(reason)) {
- DBG_871X(FUNC_ADPT_FMT ": [WARNING] Reason %d had been set before!!\n",
- FUNC_ADPT_ARG(padapter), reason);
- }
pwrpriv->ps_deny |= BIT(reason);
mutex_unlock(&pwrpriv->lock);
-
- /* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */
- /* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */
}
/*
* ATTENTION:
*This function will request pwrctrl LOCK!
*/
-void rtw_ps_deny_cancel(struct adapter *padapter, enum PS_DENY_REASON reason)
+void rtw_ps_deny_cancel(struct adapter *padapter, enum ps_deny_reason reason)
{
struct pwrctrl_priv *pwrpriv;
-
- /* DBG_871X("+" FUNC_ADPT_FMT ": Cancel PS deny for %d(0x%08X)\n", */
- /* FUNC_ADPT_ARG(padapter), reason, BIT(reason)); */
-
pwrpriv = adapter_to_pwrctl(padapter);
mutex_lock(&pwrpriv->lock);
- if ((pwrpriv->ps_deny & BIT(reason)) == 0) {
- DBG_871X(FUNC_ADPT_FMT ": [ERROR] Reason %d had been canceled before!!\n",
- FUNC_ADPT_ARG(padapter), reason);
- }
pwrpriv->ps_deny &= ~BIT(reason);
mutex_unlock(&pwrpriv->lock);
-
- /* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */
- /* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */
}
/*
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 3c9dbd7443d9..668a703dee7f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -30,11 +30,11 @@ void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
_rtw_init_queue(&psta_recvpriv->defrag_q);
}
-sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
+signed int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
{
- sint i;
+ signed int i;
union recv_frame *precvframe;
- sint res = _SUCCESS;
+ signed int res = _SUCCESS;
spin_lock_init(&precvpriv->lock);
@@ -168,7 +168,7 @@ int rtw_free_recvframe(union recv_frame *precvframe, struct __queue *pfree_recv_
-sint _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
+signed int _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
{
struct adapter *padapter = precvframe->u.hdr.adapter;
@@ -187,9 +187,9 @@ sint _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
return _SUCCESS;
}
-sint rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
+signed int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
{
- sint ret;
+ signed int ret;
/* _spinlock(&pfree_recv_queue->lock); */
spin_lock_bh(&queue->lock);
@@ -201,7 +201,7 @@ sint rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
}
/*
-sint rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
+signed int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
{
return rtw_free_recvframe(precvframe, queue);
}
@@ -248,14 +248,11 @@ u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter)
cnt++;
}
- if (cnt)
- DBG_871X(FUNC_ADPT_FMT" dequeue %d\n", FUNC_ADPT_ARG(adapter), cnt);
-
return cnt;
}
-sint rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue)
+signed int rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue)
{
spin_lock_bh(&queue->lock);
@@ -267,7 +264,7 @@ sint rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queu
return _SUCCESS;
}
-sint rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue)
+signed int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue)
{
spin_lock_bh(&queue->lock);
@@ -305,11 +302,10 @@ struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue)
}
-sint recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe);
-sint recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe)
+static signed int recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe)
{
- sint i, res = _SUCCESS;
+ signed int i, res = _SUCCESS;
u32 datalen;
u8 miccode[8];
u8 bmic_err = false, brpt_micerror = true;
@@ -326,10 +322,6 @@ sint recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe)
stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]);
if (prxattrib->encrypt == _TKIP_) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:prxattrib->encrypt == _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]));
-
/* calculate mic code */
if (stainfo) {
if (IS_MCAST(prxattrib->ra)) {
@@ -338,28 +330,20 @@ sint recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe)
/* rxdata_key_idx =(((iv[3])>>6)&0x3) ; */
mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0];
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n"));
- /* DBG_871X("\n recvframe_chkmic: bcmc key psecuritypriv->dot118021XGrpKeyid(%d), pmlmeinfo->key_index(%d) , recv key_id(%d)\n", */
/* psecuritypriv->dot118021XGrpKeyid, pmlmeinfo->key_index, rxdata_key_idx); */
if (psecuritypriv->binstallGrpkey == false) {
res = _FAIL;
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n"));
- DBG_871X("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n");
goto exit;
}
} else {
mickey = &stainfo->dot11tkiprxmickey.skey[0];
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic: unicast key\n"));
}
datalen = precvframe->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len-prxattrib->icv_len-8;/* icv_len included the mic code */
pframe = precvframe->u.hdr.rx_data;
payload = pframe+prxattrib->hdrlen+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));
-
-
rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0], (unsigned char)prxattrib->priority); /* care the length of the data */
pframemic = payload+datalen;
@@ -367,64 +351,29 @@ sint recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe)
bmic_err = false;
for (i = 0; i < 8; i++) {
- 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)));
+ if (miccode[i] != *(pframemic + i))
bmic_err = true;
- }
}
if (bmic_err == true) {
-
- 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)));
- 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)));
-
- {
- uint i;
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ======demp packet (len =%d) ======\n", precvframe->u.hdr.len));
- for (i = 0; i < precvframe->u.hdr.len; i = i+8) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x",
- *(precvframe->u.hdr.rx_data+i), *(precvframe->u.hdr.rx_data+i+1),
- *(precvframe->u.hdr.rx_data+i+2), *(precvframe->u.hdr.rx_data+i+3),
- *(precvframe->u.hdr.rx_data+i+4), *(precvframe->u.hdr.rx_data+i+5),
- *(precvframe->u.hdr.rx_data+i+6), *(precvframe->u.hdr.rx_data+i+7)));
- }
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ======demp packet end [len =%d]======\n", precvframe->u.hdr.len));
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n 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));
-
/* double check key_index for some timing issue , */
/* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */
if ((IS_MCAST(prxattrib->ra) == true) && (prxattrib->key_index != pmlmeinfo->key_index))
brpt_micerror = false;
- if ((prxattrib->bdecrypted == true) && (brpt_micerror == true)) {
+ if (prxattrib->bdecrypted && brpt_micerror)
rtw_handle_tkip_mic_err(adapter, (u8)IS_MCAST(prxattrib->ra));
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted =%d ", prxattrib->bdecrypted));
- DBG_871X(" mic error :prxattrib->bdecrypted =%d\n", prxattrib->bdecrypted);
- } else {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted =%d ", prxattrib->bdecrypted));
- DBG_871X(" mic error :prxattrib->bdecrypted =%d\n", prxattrib->bdecrypted);
- }
res = _FAIL;
} else {
/* mic checked ok */
- if ((psecuritypriv->bcheck_grpkey == false) && (IS_MCAST(prxattrib->ra) == true)) {
+ if (!psecuritypriv->bcheck_grpkey &&
+ IS_MCAST(prxattrib->ra))
psecuritypriv->bcheck_grpkey = true;
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("psecuritypriv->bcheck_grpkey =true"));
- }
}
-
- } else
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic: rtw_get_stainfo == NULL!!!\n"));
+ }
recvframe_pull_tail(precvframe, 8);
@@ -436,8 +385,7 @@ exit:
}
/* decrypt and set the ivlen, icvlen of the recv_frame */
-union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_frame);
-union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_frame)
+static union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_frame)
{
struct rx_pkt_attrib *prxattrib = &precv_frame->u.hdr.attrib;
@@ -445,17 +393,11 @@ union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_fr
union recv_frame *return_packet = precv_frame;
u32 res = _SUCCESS;
- DBG_COUNTER(padapter->rx_logs.core_rx_post_decrypt);
-
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("prxstat->decrypted =%x prxattrib->encrypt = 0x%03x\n", prxattrib->bdecrypted, prxattrib->encrypt));
-
if (prxattrib->encrypt > 0) {
u8 *iv = precv_frame->u.hdr.rx_data+prxattrib->hdrlen;
prxattrib->key_index = (((iv[3])>>6)&0x3);
if (prxattrib->key_index > WEP_KEYS) {
- DBG_871X("prxattrib->key_index(%d) > WEP_KEYS\n", prxattrib->key_index);
-
switch (prxattrib->encrypt) {
case _WEP40_:
case _WEP104_:
@@ -473,27 +415,15 @@ union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_fr
if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0) || (psecuritypriv->sw_decrypt == true))) {
psecuritypriv->hw_decrypted = false;
- #ifdef DBG_RX_DECRYPTOR
- DBG_871X("[%s] %d:prxstat->bdecrypted:%d, prxattrib->encrypt:%d, Setting psecuritypriv->hw_decrypted = %d\n",
- __func__,
- __LINE__,
- prxattrib->bdecrypted,
- prxattrib->encrypt,
- psecuritypriv->hw_decrypted);
- #endif
-
switch (prxattrib->encrypt) {
case _WEP40_:
case _WEP104_:
- DBG_COUNTER(padapter->rx_logs.core_rx_post_decrypt_wep);
rtw_wep_decrypt(padapter, (u8 *)precv_frame);
break;
case _TKIP_:
- DBG_COUNTER(padapter->rx_logs.core_rx_post_decrypt_tkip);
res = rtw_tkip_decrypt(padapter, (u8 *)precv_frame);
break;
case _AES_:
- DBG_COUNTER(padapter->rx_logs.core_rx_post_decrypt_aes);
res = rtw_aes_decrypt(padapter, (u8 *)precv_frame);
break;
default:
@@ -502,28 +432,8 @@ union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_fr
} else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 &&
(psecuritypriv->busetkipkey == 1 || prxattrib->encrypt != _TKIP_)
) {
- DBG_COUNTER(padapter->rx_logs.core_rx_post_decrypt_hw);
-
psecuritypriv->hw_decrypted = true;
- #ifdef DBG_RX_DECRYPTOR
- DBG_871X("[%s] %d:prxstat->bdecrypted:%d, prxattrib->encrypt:%d, Setting psecuritypriv->hw_decrypted = %d\n",
- __func__,
- __LINE__,
- prxattrib->bdecrypted,
- prxattrib->encrypt,
- psecuritypriv->hw_decrypted);
-
- #endif
} else {
- DBG_COUNTER(padapter->rx_logs.core_rx_post_decrypt_unknown);
- #ifdef DBG_RX_DECRYPTOR
- DBG_871X("[%s] %d:prxstat->bdecrypted:%d, prxattrib->encrypt:%d, Setting psecuritypriv->hw_decrypted = %d\n",
- __func__,
- __LINE__,
- prxattrib->bdecrypted,
- prxattrib->encrypt,
- psecuritypriv->hw_decrypted);
- #endif
}
if (res == _FAIL) {
@@ -536,8 +446,7 @@ union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_fr
}
/* set the security information in the recv_frame */
-union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame);
-union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame)
+static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame)
{
u8 *psta_addr = NULL;
u8 *ptr;
@@ -563,15 +472,12 @@ union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_fram
psta = rtw_get_stainfo(pstapriv, psta_addr);
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm =%d\n", adapter->securitypriv.dot11AuthAlgrthm));
-
if (auth_alg == 2) {
if ((psta) && (psta->ieee8021x_blocked)) {
__be16 be_tmp;
/* blocked */
/* only accept EAPOL frame */
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked == 1\n"));
prtnframe = precv_frame;
@@ -590,22 +496,15 @@ union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_fram
} else {
/* allowed */
/* check decryption status, and decrypt the frame if needed */
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked == 0\n"));
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:precv_frame->hdr.attrib.privacy =%x\n", precv_frame->u.hdr.attrib.privacy));
-
- if (pattrib->bdecrypted == 0)
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:prxstat->decrypted =%x\n", pattrib->bdecrypted));
prtnframe = precv_frame;
/* check is the EAPOL frame or not (Rekey) */
/* if (ether_type == eapol_type) { */
- /* RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("########portctrl:ether_type == 0x888e\n")); */
/* check Rekey */
/* prtnframe =precv_frame; */
/* */
/* else { */
- /* RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:ether_type = 0x%04x\n", ether_type)); */
/* */
}
} else
@@ -614,26 +513,19 @@ union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_fram
return prtnframe;
}
-sint recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache);
-sint recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache)
+static signed int recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache)
{
- sint tid = precv_frame->u.hdr.attrib.priority;
+ signed int tid = precv_frame->u.hdr.attrib.priority;
u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num&0xffff) << 4) |
(precv_frame->u.hdr.attrib.frag_num & 0xf);
- 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));
-
+ if (tid > 15)
return _FAIL;
- }
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]));
-
+ if (seq_ctrl == prxcache->tid_rxseq[tid])
return _FAIL;
- }
}
prxcache->tid_rxseq[tid] = seq_ctrl;
@@ -642,8 +534,7 @@ sint recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo_rxcac
}
-void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame);
-void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame)
+static void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame)
{
unsigned char pwrbit;
u8 *ptr = precv_frame->u.hdr.rx_data;
@@ -663,7 +554,6 @@ void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame
stop_sta_xmit(padapter, psta);
- /* DBG_871X("to sleep, sta_dz_bitmap =%x\n", pstapriv->sta_dz_bitmap); */
}
} else {
if (psta->state & WIFI_SLEEP_STATE) {
@@ -671,16 +561,13 @@ void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame
/* pstapriv->sta_dz_bitmap &= ~BIT(psta->aid); */
wakeup_sta_to_xmit(padapter, psta);
-
- /* DBG_871X("to wakeup, sta_dz_bitmap =%x\n", pstapriv->sta_dz_bitmap); */
}
}
}
}
-void process_wmmps_data(struct adapter *padapter, union recv_frame *precv_frame);
-void process_wmmps_data(struct adapter *padapter, union recv_frame *precv_frame)
+static void process_wmmps_data(struct adapter *padapter, union recv_frame *precv_frame)
{
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
struct sta_priv *pstapriv = &padapter->stapriv;
@@ -731,8 +618,7 @@ void process_wmmps_data(struct adapter *padapter, union recv_frame *precv_frame)
}
}
-void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta);
-void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta)
+static void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta)
{
int sz;
struct sta_info *psta = NULL;
@@ -763,29 +649,24 @@ void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct
traffic_check_for_leave_lps(padapter, false, 0);
}
-sint sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
- struct sta_info **psta);
-sint sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
+static signed int sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
struct sta_info **psta)
{
u8 *ptr = precv_frame->u.hdr.rx_data;
- sint ret = _SUCCESS;
+ signed int ret = _SUCCESS;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
struct sta_priv *pstapriv = &adapter->stapriv;
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
u8 *mybssid = get_bssid(pmlmepriv);
u8 *myhwaddr = myid(&adapter->eeprompriv);
u8 *sta_addr = NULL;
- sint bmcast = IS_MCAST(pattrib->dst);
-
- /* DBG_871X("[%s] %d, seqnum:%d\n", __func__, __LINE__, pattrib->seq_num); */
+ signed int bmcast = IS_MCAST(pattrib->dst);
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) ||
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
/* filter packets that SA is myself or multicast or broadcast */
if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA ==myself\n"));
ret = _FAIL;
goto exit;
}
@@ -807,7 +688,6 @@ sint sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
} else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
/* For Station mode, sa and bssid should always be BSSID, and DA is my mac-address */
if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("bssid != TA under STATION_MODE; drop pkt\n"));
ret = _FAIL;
goto exit;
}
@@ -849,7 +729,6 @@ sint sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
*psta = rtw_get_stainfo(pstapriv, sta_addr); /* get ap_info */
if (!*psta) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under sta2sta_data_frame ; drop pkt\n"));
ret = _FAIL;
goto exit;
}
@@ -858,19 +737,17 @@ exit:
return ret;
}
-sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
- struct sta_info **psta);
-sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
+static signed int ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
struct sta_info **psta)
{
u8 *ptr = precv_frame->u.hdr.rx_data;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
- sint ret = _SUCCESS;
+ signed int ret = _SUCCESS;
struct sta_priv *pstapriv = &adapter->stapriv;
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
u8 *mybssid = get_bssid(pmlmepriv);
u8 *myhwaddr = myid(&adapter->eeprompriv);
- sint bmcast = IS_MCAST(pattrib->dst);
+ signed int bmcast = IS_MCAST(pattrib->dst);
if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) &&
(check_fwstate(pmlmepriv, _FW_LINKED) == true ||
@@ -879,22 +756,12 @@ sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
/* filter packets that SA is myself or multicast or broadcast */
if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA ==myself\n"));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s SA =%pM, myhwaddr =%pM\n",
- __func__, MAC_ARG(pattrib->src), MAC_ARG(myhwaddr));
- #endif
ret = _FAIL;
goto exit;
}
/* da should be for me */
if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
- (" ap2sta_data_frame: compare DA fail; DA =%pM\n", MAC_ARG(pattrib->dst)));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s DA =%pM\n", __func__, MAC_ARG(pattrib->dst));
- #endif
ret = _FAIL;
goto exit;
}
@@ -904,19 +771,9 @@ sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
!memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
(memcmp(pattrib->bssid, mybssid, ETH_ALEN))) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
- (" ap2sta_data_frame: compare BSSID fail ; BSSID =%pM\n", MAC_ARG(pattrib->bssid)));
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("mybssid =%pM\n", MAC_ARG(mybssid)));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s BSSID =%pM, mybssid =%pM\n",
- __func__, MAC_ARG(pattrib->bssid), MAC_ARG(mybssid));
- DBG_871X("this adapter = %d, buddy adapter = %d\n", adapter->adapter_type, adapter->pbuddystruct adapter->adapter_type);
- #endif
-
- if (!bmcast) {
- DBG_871X("issue_deauth to the nonassociated ap =%pM for the reason(7)\n", MAC_ARG(pattrib->bssid));
+
+ if (!bmcast)
issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
- }
ret = _FAIL;
goto exit;
@@ -928,10 +785,6 @@ sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
*psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get ap_info */
if (!*psta) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("ap2sta: can't get psta under STATION_MODE ; drop pkt\n"));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s can't get psta under STATION_MODE ; drop pkt\n", __func__);
- #endif
ret = _FAIL;
goto exit;
}
@@ -957,10 +810,6 @@ sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
*psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */
if (!*psta) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under MP_MODE ; drop pkt\n"));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s can't get psta under WIFI_MP_STATE ; drop pkt\n", __func__);
- #endif
ret = _FAIL;
goto exit;
}
@@ -978,31 +827,22 @@ sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
/* for AP multicast issue , modify by yiwei */
static unsigned long send_issue_deauth_time;
- /* DBG_871X("After send deauth , %u ms has elapsed.\n", jiffies_to_msecs(jiffies - send_issue_deauth_time)); */
-
if (jiffies_to_msecs(jiffies - send_issue_deauth_time) > 10000 || send_issue_deauth_time == 0) {
send_issue_deauth_time = jiffies;
- DBG_871X("issue_deauth to the ap =%pM for the reason(7)\n", MAC_ARG(pattrib->bssid));
-
issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
}
}
}
ret = _FAIL;
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s fw_state:0x%x\n", __func__, get_fwstate(pmlmepriv));
- #endif
}
exit:
return ret;
}
-sint sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
- struct sta_info **psta);
-sint sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
+static signed int sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
struct sta_info **psta)
{
u8 *ptr = precv_frame->u.hdr.rx_data;
@@ -1010,7 +850,7 @@ sint sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
struct sta_priv *pstapriv = &adapter->stapriv;
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
unsigned char *mybssid = get_bssid(pmlmepriv);
- sint ret = _SUCCESS;
+ signed int ret = _SUCCESS;
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
/* For AP mode, RA =BSSID, TX =STA(SRC_ADDR), A3 =DST_ADDR */
@@ -1021,9 +861,6 @@ sint sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
*psta = rtw_get_stainfo(pstapriv, pattrib->src);
if (!*psta) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under AP_MODE; drop pkt\n"));
- DBG_871X("issue_deauth to sta =%pM for the reason(7)\n", MAC_ARG(pattrib->src));
-
issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
ret = RTW_RX_HANDLED;
@@ -1047,7 +884,6 @@ sint sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame,
ret = RTW_RX_HANDLED;
goto exit;
}
- DBG_871X("issue_deauth to sta =%pM for the reason(7)\n", MAC_ARG(pattrib->src));
issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
ret = RTW_RX_HANDLED;
goto exit;
@@ -1057,8 +893,7 @@ exit:
return ret;
}
-sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_frame);
-sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_frame)
+static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_frame)
{
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
struct sta_priv *pstapriv = &padapter->stapriv;
@@ -1066,8 +901,6 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_
struct sta_info *psta = NULL;
/* uint len = precv_frame->u.hdr.len; */
- /* DBG_871X("+validate_recv_ctrl_frame\n"); */
-
if (GetFrameType(pframe) != WIFI_CTRL_TYPE)
return _FAIL;
@@ -1115,7 +948,6 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_
return _FAIL;
if (psta->state & WIFI_STA_ALIVE_CHK_STATE) {
- DBG_871X("%s alive check-rx ps-poll\n", __func__);
psta->expire_to = pstapriv->expire_to;
psta->state ^= WIFI_STA_ALIVE_CHK_STATE;
}
@@ -1147,15 +979,11 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_
pxmitframe->attrib.triggered = 1;
- /* DBG_871X("handling ps-poll, q_len =%d, tim =%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */
-
rtw_hal_xmitframe_enqueue(padapter, pxmitframe);
if (psta->sleepq_len == 0) {
pstapriv->tim_bitmap &= ~BIT(psta->aid);
- /* DBG_871X("after handling ps-poll, tim =%x\n", pstapriv->tim_bitmap); */
-
/* update BCN for TIM IE */
/* update_BCNTIM(padapter); */
update_beacon(padapter, WLAN_EID_TIM, NULL, true);
@@ -1168,15 +996,11 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_
/* spin_unlock_bh(&psta->sleep_q.lock); */
spin_unlock_bh(&pxmitpriv->lock);
- /* DBG_871X("no buffered packets to xmit\n"); */
if (pstapriv->tim_bitmap&BIT(psta->aid)) {
if (psta->sleepq_len == 0) {
- DBG_871X("no buffered packets to xmit\n");
-
/* issue nulldata with More data bit = 0 to indicate we have no buffered packets */
issue_nulldata_in_interrupt(padapter, psta->hwaddr);
} else {
- DBG_871X("error!psta->sleepq_len =%d\n", psta->sleepq_len);
psta->sleepq_len = 0;
}
@@ -1194,19 +1018,189 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_
}
-union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame);
-sint validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_frame);
-sint validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_frame)
+/* perform defrag */
+static union recv_frame *recvframe_defrag(struct adapter *adapter,
+ struct __queue *defrag_q)
{
- /* struct mlme_priv *pmlmepriv = &adapter->mlmepriv; */
+ struct list_head *plist, *phead;
+ u8 wlanhdr_offset;
+ u8 curfragnum;
+ struct recv_frame_hdr *pfhdr, *pnfhdr;
+ union recv_frame *prframe, *pnextrframe;
+ struct __queue *pfree_recv_queue;
+
+ curfragnum = 0;
+ pfree_recv_queue = &adapter->recvpriv.free_recv_queue;
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("+validate_recv_mgnt_frame\n"));
+ phead = get_list_head(defrag_q);
+ plist = get_next(phead);
+ prframe = (union recv_frame *)plist;
+ pfhdr = &prframe->u.hdr;
+ list_del_init(&(prframe->u.list));
+
+ if (curfragnum != pfhdr->attrib.frag_num) {
+ /* the first fragment number must be 0 */
+ /* free the whole queue */
+ rtw_free_recvframe(prframe, pfree_recv_queue);
+ rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
+
+ return NULL;
+ }
+
+ curfragnum++;
+
+ plist = get_list_head(defrag_q);
+
+ plist = get_next(plist);
+
+ while (phead != plist) {
+ pnextrframe = (union recv_frame *)plist;
+ pnfhdr = &pnextrframe->u.hdr;
+
+
+ /* check the fragment sequence (2nd ~n fragment frame) */
+
+ if (curfragnum != pnfhdr->attrib.frag_num) {
+ /* the fragment number must be increasing (after decache) */
+ /* release the defrag_q & prframe */
+ rtw_free_recvframe(prframe, pfree_recv_queue);
+ rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
+ return NULL;
+ }
+
+ curfragnum++;
+
+ /* copy the 2nd~n fragment frame's payload to the first fragment */
+ /* get the 2nd~last fragment frame's payload */
+
+ wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len;
+
+ recvframe_pull(pnextrframe, wlanhdr_offset);
+
+ /* append to first fragment frame's tail (if privacy frame, pull the ICV) */
+ recvframe_pull_tail(prframe, pfhdr->attrib.icv_len);
+
+ /* memcpy */
+ memcpy(pfhdr->rx_tail, pnfhdr->rx_data, pnfhdr->len);
+
+ recvframe_put(prframe, pnfhdr->len);
+
+ pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len;
+ plist = get_next(plist);
+
+ }
+
+ /* free the defrag_q queue and return the prframe */
+ rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
+
+ return prframe;
+}
+
+/* check if need to defrag, if needed queue the frame to defrag_q */
+static union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame)
+{
+ u8 ismfrag;
+ u8 fragnum;
+ u8 *psta_addr;
+ struct recv_frame_hdr *pfhdr;
+ struct sta_info *psta;
+ struct sta_priv *pstapriv;
+ struct list_head *phead;
+ union recv_frame *prtnframe = NULL;
+ struct __queue *pfree_recv_queue, *pdefrag_q;
+
+ pstapriv = &padapter->stapriv;
+
+ pfhdr = &precv_frame->u.hdr;
+
+ pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
+
+ /* need to define struct of wlan header frame ctrl */
+ ismfrag = pfhdr->attrib.mfrag;
+ fragnum = pfhdr->attrib.frag_num;
+
+ psta_addr = pfhdr->attrib.ta;
+ psta = rtw_get_stainfo(pstapriv, psta_addr);
+ if (!psta) {
+ u8 type = GetFrameType(pfhdr->rx_data);
+ if (type != WIFI_DATA_TYPE) {
+ psta = rtw_get_bcmc_stainfo(padapter);
+ pdefrag_q = &psta->sta_recvpriv.defrag_q;
+ } else
+ pdefrag_q = NULL;
+ } else
+ pdefrag_q = &psta->sta_recvpriv.defrag_q;
+
+ if ((ismfrag == 0) && (fragnum == 0))
+ prtnframe = precv_frame;/* isn't a fragment frame */
+
+ if (ismfrag == 1) {
+ /* 0~(n-1) fragment frame */
+ /* enqueue to defraf_g */
+ if (pdefrag_q) {
+ if (fragnum == 0)
+ /* the first fragment */
+ if (!list_empty(&pdefrag_q->queue))
+ /* free current defrag_q */
+ rtw_free_recvframe_queue(pdefrag_q, pfree_recv_queue);
+
+
+ /* Then enqueue the 0~(n-1) fragment into the defrag_q */
+
+ /* spin_lock(&pdefrag_q->lock); */
+ phead = get_list_head(pdefrag_q);
+ list_add_tail(&pfhdr->list, phead);
+ /* spin_unlock(&pdefrag_q->lock); */
+
+ prtnframe = NULL;
+
+ } else {
+ /* can't find this ta's defrag_queue, so free this recv_frame */
+ rtw_free_recvframe(precv_frame, pfree_recv_queue);
+ prtnframe = NULL;
+ }
+
+ }
+
+ if ((ismfrag == 0) && (fragnum != 0)) {
+ /* the last fragment frame */
+ /* enqueue the last fragment */
+ if (pdefrag_q) {
+ /* spin_lock(&pdefrag_q->lock); */
+ phead = get_list_head(pdefrag_q);
+ list_add_tail(&pfhdr->list, phead);
+ /* spin_unlock(&pdefrag_q->lock); */
+
+ /* call recvframe_defrag to defrag */
+ precv_frame = recvframe_defrag(padapter, pdefrag_q);
+ prtnframe = precv_frame;
+
+ } else {
+ /* can't find this ta's defrag_queue, so free this recv_frame */
+ rtw_free_recvframe(precv_frame, pfree_recv_queue);
+ prtnframe = NULL;
+ }
+
+ }
+
+
+ if ((prtnframe) && (prtnframe->u.hdr.attrib.privacy)) {
+ /* after defrag we must check tkip mic code */
+ if (recvframe_chkmic(padapter, prtnframe) == _FAIL) {
+ rtw_free_recvframe(prtnframe, pfree_recv_queue);
+ prtnframe = NULL;
+ }
+ }
+ return prtnframe;
+}
+
+static signed int validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_frame)
+{
+ /* struct mlme_priv *pmlmepriv = &adapter->mlmepriv; */
precv_frame = recvframe_chk_defrag(padapter, precv_frame);
- if (!precv_frame) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("%s: fragment packet\n", __func__));
+ if (!precv_frame)
return _SUCCESS;
- }
{
/* for rx pkt statistics */
@@ -1235,8 +1229,7 @@ sint validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_
}
-sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_frame);
-sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_frame)
+static signed int validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_frame)
{
u8 bretry;
u8 *psa, *pda, *pbssid;
@@ -1244,7 +1237,7 @@ sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_f
u8 *ptr = precv_frame->u.hdr.rx_data;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
struct security_priv *psecuritypriv = &adapter->securitypriv;
- sint ret = _SUCCESS;
+ signed int ret = _SUCCESS;
bretry = GetRetry(ptr);
pda = get_da(ptr);
@@ -1252,9 +1245,6 @@ sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_f
pbssid = get_hdr_bssid(ptr);
if (!pbssid) {
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s pbssid == NULL\n", __func__);
- #endif
ret = _FAIL;
goto exit;
}
@@ -1287,7 +1277,6 @@ sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_f
memcpy(pattrib->ra, GetAddr1Ptr(ptr), ETH_ALEN);
memcpy(pattrib->ta, GetAddr2Ptr(ptr), ETH_ALEN);
ret = _FAIL;
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" case 3\n"));
break;
default:
@@ -1297,9 +1286,6 @@ sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_f
}
if (ret == _FAIL) {
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s case:%d, res:%d\n", __func__, pattrib->to_fr_ds, ret);
- #endif
goto exit;
} else if (ret == RTW_RX_HANDLED) {
goto exit;
@@ -1307,10 +1293,6 @@ sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_f
if (!psta) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" after to_fr_ds_chk; psta == NULL\n"));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s psta == NULL\n", __func__);
- #endif
ret = _FAIL;
goto exit;
}
@@ -1345,23 +1327,13 @@ sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_f
/* decache, drop duplicate recv packets */
if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) == _FAIL) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("decache : drop pkt\n"));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s recv_decache return _FAIL\n", __func__);
- #endif
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));
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n ^^^^^^^^^^^IS_MCAST(pattrib->ra(0x%02x)) =%d^^^^^^^^^^^^^^^6\n", pattrib->ra[0], IS_MCAST(pattrib->ra)));
-
GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, IS_MCAST(pattrib->ra));
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n pattrib->encrypt =%d\n", pattrib->encrypt));
-
SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt);
} else {
pattrib->encrypt = 0;
@@ -1372,7 +1344,7 @@ exit:
return ret;
}
-static sint validate_80211w_mgmt(struct adapter *adapter, union recv_frame *precv_frame)
+static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame *precv_frame)
{
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
@@ -1401,7 +1373,6 @@ static sint validate_80211w_mgmt(struct adapter *adapter, union recv_frame *prec
data_len = pattrib->pkt_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
mgmt_DATA = rtw_zmalloc(data_len);
if (!mgmt_DATA) {
- DBG_871X("%s mgmt allocate fail !!!!!!!!!\n", __func__);
goto validate_80211w_fail;
}
precv_frame = decryptor(adapter, precv_frame);
@@ -1413,19 +1384,16 @@ static sint validate_80211w_mgmt(struct adapter *adapter, union recv_frame *prec
pattrib->pkt_len = pattrib->pkt_len - pattrib->iv_len - pattrib->icv_len;
kfree(mgmt_DATA);
if (!precv_frame) {
- DBG_871X("%s mgmt descrypt fail !!!!!!!!!\n", __func__);
goto validate_80211w_fail;
}
} else if (IS_MCAST(GetAddr1Ptr(ptr)) &&
(subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC)) {
- sint BIP_ret = _SUCCESS;
+ signed int BIP_ret = _SUCCESS;
/* verify BIP MME IE of broadcast/multicast de-auth/disassoc packet */
BIP_ret = rtw_BIP_verify(adapter, (u8 *)precv_frame);
if (BIP_ret == _FAIL) {
- /* DBG_871X("802.11w BIP verify fail\n"); */
goto validate_80211w_fail;
} else if (BIP_ret == RTW_RX_HANDLED) {
- /* DBG_871X("802.11w recv none protected packet\n"); */
/* issue sa query request */
issue_action_SA_Query(adapter, NULL, 0, 0);
goto validate_80211w_fail;
@@ -1438,11 +1406,9 @@ static sint validate_80211w_mgmt(struct adapter *adapter, union recv_frame *prec
ptr[WLAN_HDR_A3_LEN] != RTW_WLAN_CATEGORY_UNPROTECTED_WNM &&
ptr[WLAN_HDR_A3_LEN] != RTW_WLAN_CATEGORY_SELF_PROTECTED &&
ptr[WLAN_HDR_A3_LEN] != RTW_WLAN_CATEGORY_P2P) {
- DBG_871X("action frame category =%d should robust\n", ptr[WLAN_HDR_A3_LEN]);
goto validate_80211w_fail;
}
} else if (subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC) {
- DBG_871X("802.11w recv none protected packet\n");
/* issue sa query request */
issue_action_SA_Query(adapter, NULL, 0, 0);
goto validate_80211w_fail;
@@ -1456,19 +1422,7 @@ validate_80211w_fail:
}
-static inline void dump_rx_packet(u8 *ptr)
-{
- int i;
-
- DBG_871X("#############################\n");
- for (i = 0; i < 64; i = i+8)
- DBG_871X("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i),
- *(ptr+i+1), *(ptr+i+2), *(ptr+i+3), *(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7));
- DBG_871X("#############################\n");
-}
-
-sint validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame);
-sint validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame)
+static signed int validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame)
{
/* shall check frame subtype, to / from ds, da, bssid */
@@ -1476,7 +1430,7 @@ sint validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame)
u8 type;
u8 subtype;
- sint retval = _SUCCESS;
+ signed int retval = _SUCCESS;
u8 bDumpRxPkt;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
@@ -1486,9 +1440,7 @@ sint validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame)
/* add version chk */
if (ver != 0) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail! (ver!= 0)\n"));
retval = _FAIL;
- DBG_COUNTER(adapter->rx_logs.core_rx_pre_ver_err);
goto exit;
}
@@ -1506,48 +1458,27 @@ sint validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame)
pattrib->privacy = GetPrivacy(ptr);
pattrib->order = GetOrder(ptr);
rtw_hal_get_def_var(adapter, HAL_DEF_DBG_DUMP_RXPKT, &(bDumpRxPkt));
- if (bDumpRxPkt == 1) /* dump all rx packets */
- dump_rx_packet(ptr);
- else if ((bDumpRxPkt == 2) && (type == WIFI_MGT_TYPE))
- dump_rx_packet(ptr);
- else if ((bDumpRxPkt == 3) && (type == WIFI_DATA_TYPE))
- dump_rx_packet(ptr);
switch (type) {
case WIFI_MGT_TYPE: /* mgnt */
- DBG_COUNTER(adapter->rx_logs.core_rx_pre_mgmt);
if (validate_80211w_mgmt(adapter, precv_frame) == _FAIL) {
retval = _FAIL;
- DBG_COUNTER(padapter->rx_logs.core_rx_pre_mgmt_err_80211w);
break;
}
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"));
- DBG_COUNTER(adapter->rx_logs.core_rx_pre_mgmt_err);
- }
retval = _FAIL; /* only data frame return _SUCCESS */
break;
case WIFI_CTRL_TYPE: /* ctrl */
- DBG_COUNTER(adapter->rx_logs.core_rx_pre_ctrl);
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"));
- DBG_COUNTER(adapter->rx_logs.core_rx_pre_ctrl_err);
- }
retval = _FAIL; /* only data frame return _SUCCESS */
break;
case WIFI_DATA_TYPE: /* data */
- DBG_COUNTER(adapter->rx_logs.core_rx_pre_data);
-
pattrib->qos = (subtype & BIT(7)) ? 1:0;
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++;
- DBG_COUNTER(adapter->rx_logs.core_rx_pre_data_err);
} else if (retval == _SUCCESS) {
#ifdef DBG_RX_DUMP_EAP
u8 bDumpRxPkt;
@@ -1558,18 +1489,10 @@ sint validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame)
/* get ether_type */
memcpy(&eth_type, ptr + pattrib->hdrlen + pattrib->iv_len + LLC_HEADER_SIZE, 2);
eth_type = ntohs((unsigned short) eth_type);
- if ((bDumpRxPkt == 4) && (eth_type == 0x888e))
- dump_rx_packet(ptr);
#endif
- } else
- DBG_COUNTER(adapter->rx_logs.core_rx_pre_data_handled);
+ }
break;
default:
- DBG_COUNTER(adapter->rx_logs.core_rx_pre_unknown);
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail! type = 0x%x\n", type));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME validate_recv_data_frame fail! type = 0x%x\n", type);
- #endif
retval = _FAIL;
break;
}
@@ -1578,12 +1501,10 @@ exit:
return retval;
}
-
/* remove the wlanhdr and add the eth_hdr */
-sint wlanhdr_to_ethhdr(union recv_frame *precvframe);
-sint wlanhdr_to_ethhdr(union recv_frame *precvframe)
+static signed int wlanhdr_to_ethhdr(union recv_frame *precvframe)
{
- sint rmv_len;
+ signed int rmv_len;
u16 eth_type, len;
u8 bsnaphdr;
u8 *psnap_type;
@@ -1615,44 +1536,10 @@ sint wlanhdr_to_ethhdr(union recv_frame *precvframe)
rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr?SNAP_SIZE:0);
len = precvframe->u.hdr.len - rmv_len;
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n ===pattrib->hdrlen: %x, pattrib->iv_len:%x ===\n\n", pattrib->hdrlen, pattrib->iv_len));
-
memcpy(&be_tmp, ptr+rmv_len, 2);
eth_type = ntohs(be_tmp); /* pattrib->ether_type */
pattrib->eth_type = eth_type;
-#ifdef CONFIG_AUTO_AP_MODE
- if (0x8899 == pattrib->eth_type) {
- struct sta_info *psta = precvframe->u.hdr.psta;
-
- DBG_871X("wlan rx: got eth_type = 0x%x\n", pattrib->eth_type);
-
- if (psta && psta->isrc && psta->pid > 0) {
- u16 rx_pid;
-
- rx_pid = *(u16 *)(ptr+rmv_len+2);
-
- DBG_871X("wlan rx(pid = 0x%x): sta(%pM) pid = 0x%x\n",
- rx_pid, MAC_ARG(psta->hwaddr), psta->pid);
-
- if (rx_pid == psta->pid) {
- int i;
- u16 len = *(u16 *)(ptr+rmv_len+4);
- /* u16 ctrl_type = *(u16*)(ptr+rmv_len+6); */
-
- /* DBG_871X("RC: len = 0x%x, ctrl_type = 0x%x\n", len, ctrl_type); */
- DBG_871X("RC: len = 0x%x\n", len);
-
- for (i = 0; i < len ; i++)
- DBG_871X("0x%x\n", *(ptr+rmv_len+6+i));
- /* DBG_871X("0x%x\n", *(ptr+rmv_len+8+i)); */
-
- DBG_871X("RC-end\n");
- }
- }
- }
-#endif /* CONFIG_AUTO_AP_MODE */
-
if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)) {
ptr += rmv_len;
*ptr = 0x87;
@@ -1677,197 +1564,13 @@ sint wlanhdr_to_ethhdr(union recv_frame *precvframe)
return _SUCCESS;
}
-/* perform defrag */
-static union recv_frame *recvframe_defrag(struct adapter *adapter,
- struct __queue *defrag_q)
-{
- struct list_head *plist, *phead;
- u8 wlanhdr_offset;
- u8 curfragnum;
- struct recv_frame_hdr *pfhdr, *pnfhdr;
- union recv_frame *prframe, *pnextrframe;
- struct __queue *pfree_recv_queue;
-
- curfragnum = 0;
- pfree_recv_queue = &adapter->recvpriv.free_recv_queue;
-
- phead = get_list_head(defrag_q);
- plist = get_next(phead);
- prframe = (union recv_frame *)plist;
- pfhdr = &prframe->u.hdr;
- list_del_init(&(prframe->u.list));
-
- if (curfragnum != pfhdr->attrib.frag_num) {
- /* the first fragment number must be 0 */
- /* free the whole queue */
- rtw_free_recvframe(prframe, pfree_recv_queue);
- rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
-
- return NULL;
- }
-
- curfragnum++;
-
- plist = get_list_head(defrag_q);
-
- plist = get_next(plist);
-
- while (phead != plist) {
- pnextrframe = (union recv_frame *)plist;
- pnfhdr = &pnextrframe->u.hdr;
-
-
- /* check the fragment sequence (2nd ~n fragment frame) */
-
- if (curfragnum != pnfhdr->attrib.frag_num) {
- /* the fragment number must be increasing (after decache) */
- /* release the defrag_q & prframe */
- rtw_free_recvframe(prframe, pfree_recv_queue);
- rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
- return NULL;
- }
-
- curfragnum++;
-
- /* copy the 2nd~n fragment frame's payload to the first fragment */
- /* get the 2nd~last fragment frame's payload */
-
- wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len;
-
- recvframe_pull(pnextrframe, wlanhdr_offset);
-
- /* append to first fragment frame's tail (if privacy frame, pull the ICV) */
- recvframe_pull_tail(prframe, pfhdr->attrib.icv_len);
-
- /* memcpy */
- memcpy(pfhdr->rx_tail, pnfhdr->rx_data, pnfhdr->len);
-
- recvframe_put(prframe, pnfhdr->len);
-
- pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len;
- plist = get_next(plist);
-
- }
-
- /* free the defrag_q queue and return the prframe */
- rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
-
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Performance defrag!!!!!\n"));
-
- return prframe;
-}
-
-/* check if need to defrag, if needed queue the frame to defrag_q */
-union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame)
-{
- u8 ismfrag;
- u8 fragnum;
- u8 *psta_addr;
- struct recv_frame_hdr *pfhdr;
- struct sta_info *psta;
- struct sta_priv *pstapriv;
- struct list_head *phead;
- union recv_frame *prtnframe = NULL;
- struct __queue *pfree_recv_queue, *pdefrag_q;
-
- pstapriv = &padapter->stapriv;
-
- pfhdr = &precv_frame->u.hdr;
-
- pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
-
- /* need to define struct of wlan header frame ctrl */
- ismfrag = pfhdr->attrib.mfrag;
- fragnum = pfhdr->attrib.frag_num;
-
- psta_addr = pfhdr->attrib.ta;
- psta = rtw_get_stainfo(pstapriv, psta_addr);
- if (!psta) {
- u8 type = GetFrameType(pfhdr->rx_data);
- if (type != WIFI_DATA_TYPE) {
- psta = rtw_get_bcmc_stainfo(padapter);
- pdefrag_q = &psta->sta_recvpriv.defrag_q;
- } else
- pdefrag_q = NULL;
- } else
- pdefrag_q = &psta->sta_recvpriv.defrag_q;
-
- if ((ismfrag == 0) && (fragnum == 0))
- prtnframe = precv_frame;/* isn't a fragment frame */
-
- if (ismfrag == 1) {
- /* 0~(n-1) fragment frame */
- /* enqueue to defraf_g */
- if (pdefrag_q) {
- if (fragnum == 0)
- /* the first fragment */
- if (!list_empty(&pdefrag_q->queue))
- /* free current defrag_q */
- rtw_free_recvframe_queue(pdefrag_q, pfree_recv_queue);
-
-
- /* Then enqueue the 0~(n-1) fragment into the defrag_q */
-
- /* spin_lock(&pdefrag_q->lock); */
- phead = get_list_head(pdefrag_q);
- list_add_tail(&pfhdr->list, phead);
- /* spin_unlock(&pdefrag_q->lock); */
-
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Enqueuq: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum));
-
- prtnframe = NULL;
-
- } else {
- /* can't find this ta's defrag_queue, so free this recv_frame */
- rtw_free_recvframe(precv_frame, pfree_recv_queue);
- prtnframe = NULL;
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q == NULL: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum));
- }
-
- }
-
- if ((ismfrag == 0) && (fragnum != 0)) {
- /* the last fragment frame */
- /* enqueue the last fragment */
- if (pdefrag_q) {
- /* spin_lock(&pdefrag_q->lock); */
- phead = get_list_head(pdefrag_q);
- list_add_tail(&pfhdr->list, phead);
- /* spin_unlock(&pdefrag_q->lock); */
-
- /* call recvframe_defrag to defrag */
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("defrag: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum));
- precv_frame = recvframe_defrag(padapter, pdefrag_q);
- prtnframe = precv_frame;
-
- } else {
- /* can't find this ta's defrag_queue, so free this recv_frame */
- rtw_free_recvframe(precv_frame, pfree_recv_queue);
- prtnframe = NULL;
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q == NULL: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum));
- }
-
- }
-
-
- if ((prtnframe) && (prtnframe->u.hdr.attrib.privacy)) {
- /* 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"));
- rtw_free_recvframe(prtnframe, pfree_recv_queue);
- prtnframe = NULL;
- }
- }
- return prtnframe;
-}
-
static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe)
{
int a_len, padding_len;
u16 nSubframe_Length;
u8 nr_subframes, i;
u8 *pdata;
- _pkt *sub_pkt, *subframes[MAX_SUBFRAME_COUNT];
+ struct sk_buff *sub_pkt, *subframes[MAX_SUBFRAME_COUNT];
struct recv_priv *precvpriv = &padapter->recvpriv;
struct __queue *pfree_recv_queue = &(precvpriv->free_recv_queue);
@@ -1887,16 +1590,12 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe)
/* Offset 12 denote 2 mac address */
nSubframe_Length = get_unaligned_be16(pdata + 12);
- if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) {
- DBG_871X("nRemain_Length is %d and nSubframe_Length is : %d\n", a_len, nSubframe_Length);
+ if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length))
break;
- }
sub_pkt = rtw_os_alloc_msdu_pkt(prframe, nSubframe_Length, pdata);
- if (!sub_pkt) {
- DBG_871X("%s(): allocate sub packet fail !!!\n", __func__);
+ if (!sub_pkt)
break;
- }
/* move the data point to data content */
pdata += ETH_HLEN;
@@ -1904,10 +1603,8 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe)
subframes[nr_subframes++] = sub_pkt;
- if (nr_subframes >= MAX_SUBFRAME_COUNT) {
- DBG_871X("ParseSubframe(): Too many Subframes! Packets dropped!\n");
+ if (nr_subframes >= MAX_SUBFRAME_COUNT)
break;
- }
pdata += nSubframe_Length;
a_len -= nSubframe_Length;
@@ -1916,10 +1613,9 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe)
if (padding_len == 4)
padding_len = 0;
- if (a_len < padding_len) {
- DBG_871X("ParseSubframe(): a_len < padding_len !\n");
+ if (a_len < padding_len)
break;
- }
+
pdata += padding_len;
a_len -= padding_len;
}
@@ -1939,8 +1635,7 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe)
return _SUCCESS;
}
-int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num);
-int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num)
+static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num)
{
struct adapter *padapter = preorder_ctrl->padapter;
struct dvobj_priv *psdpriv = padapter->dvobj;
@@ -1951,10 +1646,6 @@ int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num)
/* Rx Reorder initialize condition. */
if (preorder_ctrl->indicate_seq == 0xFFFF) {
preorder_ctrl->indicate_seq = seq_num;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d init IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq, seq_num);
- #endif
/* DbgPrint("check_indicate_seq, 1st->indicate_seq =%d\n", precvpriv->indicate_seq); */
}
@@ -1963,15 +1654,8 @@ int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num)
/* Drop out the packet which SeqNum is smaller than WinStart */
if (SN_LESS(seq_num, preorder_ctrl->indicate_seq)) {
- /* RT_TRACE(COMP_RX_REORDER, DBG_LOUD, ("CheckRxTsIndicateSeq(): Packet Drop! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, NewSeqNum)); */
/* DbgPrint("CheckRxTsIndicateSeq(): Packet Drop! IndicateSeq: %d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("%s IndicateSeq: %d > NewSeq: %d\n", __func__,
- preorder_ctrl->indicate_seq, seq_num);
- #endif
-
-
return false;
}
@@ -1983,12 +1667,7 @@ int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num)
if (SN_EQUAL(seq_num, preorder_ctrl->indicate_seq)) {
preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d SN_EQUAL IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq, seq_num);
- #endif
} else if (SN_LESS(wend, seq_num)) {
- /* RT_TRACE(COMP_RX_REORDER, DBG_LOUD, ("CheckRxTsIndicateSeq(): Window Shift! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, NewSeqNum)); */
/* DbgPrint("CheckRxTsIndicateSeq(): Window Shift! IndicateSeq: %d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */
/* boundary situation, when seq_num cross 0xFFF */
@@ -1997,10 +1676,6 @@ int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num)
else
preorder_ctrl->indicate_seq = 0xFFF - (wsize - (seq_num + 1)) + 1;
pdbgpriv->dbg_rx_ampdu_window_shift_cnt++;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d SN_LESS(wend, seq_num) IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq, seq_num);
- #endif
}
/* DbgPrint("exit->check_indicate_seq(): IndicateSeq: %d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */
@@ -2008,8 +1683,7 @@ int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num)
return true;
}
-int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union recv_frame *prframe);
-int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union recv_frame *prframe)
+static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union recv_frame *prframe)
{
struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
@@ -2034,7 +1708,6 @@ int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union rec
plist = get_next(plist);
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, irql); */
return false;
else
@@ -2055,14 +1728,11 @@ int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union rec
/* spin_unlock(&ppending_recvframe_queue->lock); */
/* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */
-
- /* RT_TRACE(COMP_RX_REORDER, DBG_TRACE, ("InsertRxReorderList(): Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum)); */
return true;
}
-void recv_indicatepkts_pkt_loss_cnt(struct debug_priv *pdbgpriv, u64 prev_seq, u64 current_seq);
-void recv_indicatepkts_pkt_loss_cnt(struct debug_priv *pdbgpriv, u64 prev_seq, u64 current_seq)
+static void recv_indicatepkts_pkt_loss_cnt(struct debug_priv *pdbgpriv, u64 prev_seq, u64 current_seq)
{
if (current_seq < prev_seq)
pdbgpriv->dbg_rx_ampdu_loss_count += (4096 + current_seq - prev_seq);
@@ -2070,8 +1740,8 @@ void recv_indicatepkts_pkt_loss_cnt(struct debug_priv *pdbgpriv, u64 prev_seq, u
pdbgpriv->dbg_rx_ampdu_loss_count += (current_seq - prev_seq);
}
-int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced);
-int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced)
+
+static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced)
{
struct list_head *phead, *plist;
union recv_frame *prframe;
@@ -2083,8 +1753,6 @@ int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctr
struct dvobj_priv *psdpriv = padapter->dvobj;
struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
- DBG_COUNTER(padapter->rx_logs.core_rx_post_indicate_in_oder);
-
/* DbgPrint("+recv_indicatepkts_in_order\n"); */
/* spin_lock_irqsave(&ppending_recvframe_queue->lock, irql); */
@@ -2105,10 +1773,6 @@ int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctr
prframe = (union recv_frame *)plist;
pattrib = &prframe->u.hdr.attrib;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq, pattrib->seq_num);
- #endif
recv_indicatepkts_pkt_loss_cnt(pdbgpriv, preorder_ctrl->indicate_seq, pattrib->seq_num);
preorder_ctrl->indicate_seq = pattrib->seq_num;
@@ -2122,20 +1786,11 @@ int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctr
pattrib = &prframe->u.hdr.attrib;
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));
-
plist = get_next(plist);
list_del_init(&(prframe->u.hdr.list));
- if (SN_EQUAL(preorder_ctrl->indicate_seq, pattrib->seq_num)) {
+ if (SN_EQUAL(preorder_ctrl->indicate_seq, pattrib->seq_num))
preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq, pattrib->seq_num);
- #endif
- }
/* Set this as a lock to make sure that only one thread is indicating packet. */
/* pTS->RxIndicateState = RXTS_INDICATE_PROCESSING; */
@@ -2147,8 +1802,6 @@ int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctr
/* indicate this recv_frame */
/* DbgPrint("recv_indicatepkts_in_order, indicate_seq =%d, seq_num =%d\n", precvpriv->indicate_seq, pattrib->seq_num); */
if (!pattrib->amsdu) {
- /* DBG_871X("recv_indicatepkts_in_order, amsdu!= 1, indicate_seq =%d, seq_num =%d\n", preorder_ctrl->indicate_seq, pattrib->seq_num); */
-
if ((padapter->bDriverStopped == false) &&
(padapter->bSurpriseRemoved == false))
rtw_recv_indicatepkt(padapter, prframe);/* indicate this recv_frame */
@@ -2180,8 +1833,7 @@ int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctr
return bPktInBuf;
}
-int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe);
-int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe)
+static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe)
{
int retval = _SUCCESS;
struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
@@ -2190,8 +1842,6 @@ int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe
struct dvobj_priv *psdpriv = padapter->dvobj;
struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
- DBG_COUNTER(padapter->rx_logs.core_rx_post_indicate_reoder);
-
if (!pattrib->amsdu) {
/* s1. */
wlanhdr_to_ethhdr(prframe);
@@ -2199,17 +1849,11 @@ int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe
if (pattrib->qos != 1) {
if ((padapter->bDriverStopped == false) &&
(padapter->bSurpriseRemoved == false)) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ recv_indicatepkt_reorder -recv_func recv_indicatepkt\n"));
-
rtw_recv_indicatepkt(padapter, prframe);
return _SUCCESS;
}
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s pattrib->qos != 1\n", __func__);
- #endif
-
return _FAIL;
}
@@ -2217,41 +1861,22 @@ int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe
if (preorder_ctrl->enable == false) {
/* indicate this recv_frame */
preorder_ctrl->indicate_seq = pattrib->seq_num;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq, pattrib->seq_num);
- #endif
rtw_recv_indicatepkt(padapter, prframe);
preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1)%4096;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq, pattrib->seq_num);
- #endif
return _SUCCESS;
}
} else if (pattrib->amsdu == 1) { /* temp filter -> means didn't support A-MSDUs in a A-MPDU */
if (preorder_ctrl->enable == false) {
preorder_ctrl->indicate_seq = pattrib->seq_num;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq, pattrib->seq_num);
- #endif
retval = amsdu_to_msdu(padapter, prframe);
preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1)%4096;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq, pattrib->seq_num);
- #endif
if (retval != _SUCCESS) {
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s amsdu_to_msdu fail\n", __func__);
- #endif
}
return retval;
@@ -2260,16 +1885,9 @@ int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe
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));
-
/* s2. check if winstart_b(indicate_seq) needs to been updated */
if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num)) {
pdbgpriv->dbg_rx_ampdu_drop_count++;
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s check_indicate_seq fail\n", __func__);
- #endif
goto _err_exit;
}
@@ -2279,9 +1897,6 @@ int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe
/* DbgPrint("recv_indicatepkt_reorder, enqueue_reorder_recvframe fail!\n"); */
/* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */
/* return _FAIL; */
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s enqueue_reorder_recvframe fail\n", __func__);
- #endif
goto _err_exit;
}
@@ -2325,8 +1940,6 @@ void rtw_reordering_ctrl_timeout_handler(struct timer_list *t)
if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
return;
- /* DBG_871X("+rtw_reordering_ctrl_timeout_handler() =>\n"); */
-
spin_lock_bh(&ppending_recvframe_queue->lock);
if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true) == true)
@@ -2336,8 +1949,7 @@ void rtw_reordering_ctrl_timeout_handler(struct timer_list *t)
}
-int process_recv_indicatepkts(struct adapter *padapter, union recv_frame *prframe);
-int process_recv_indicatepkts(struct adapter *padapter, union recv_frame *prframe)
+static int process_recv_indicatepkts(struct adapter *padapter, union recv_frame *prframe)
{
int retval = _SUCCESS;
/* struct recv_priv *precvpriv = &padapter->recvpriv; */
@@ -2345,15 +1957,10 @@ int process_recv_indicatepkts(struct adapter *padapter, union recv_frame *prfram
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
- DBG_COUNTER(padapter->rx_logs.core_rx_post_indicate);
-
if (phtpriv->ht_option == true) { /* B/G/N Mode */
/* prframe->u.hdr.preorder_ctrl = &precvpriv->recvreorder_ctrl[pattrib->priority]; */
if (recv_indicatepkt_reorder(padapter, prframe) != _SUCCESS) { /* including perform A-MPDU Rx Ordering Buffer Control */
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s recv_indicatepkt_reorder error!\n", __func__);
- #endif
if ((padapter->bDriverStopped == false) &&
(padapter->bSurpriseRemoved == false)) {
@@ -2363,24 +1970,13 @@ int process_recv_indicatepkts(struct adapter *padapter, union recv_frame *prfram
}
} else { /* B/G mode */
retval = wlanhdr_to_ethhdr(prframe);
- if (retval != _SUCCESS) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("wlanhdr_to_ethhdr: drop pkt\n"));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s wlanhdr_to_ethhdr error!\n", __func__);
- #endif
+ if (retval != _SUCCESS)
return retval;
- }
if ((padapter->bDriverStopped == false) && (padapter->bSurpriseRemoved == false)) {
/* indicate this recv_frame */
- RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ process_recv_indicatepkts- recv_func recv_indicatepkt\n"));
rtw_recv_indicatepkt(padapter, prframe);
-
-
} else {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ 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));
retval = _FAIL;
return retval;
}
@@ -2396,12 +1992,9 @@ static int recv_func_prehandle(struct adapter *padapter, union recv_frame *rfram
int ret = _SUCCESS;
struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
- DBG_COUNTER(padapter->rx_logs.core_rx_pre);
-
/* check the frame crtl field and decache */
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"));
rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */
goto exit;
}
@@ -2417,37 +2010,19 @@ static int recv_func_posthandle(struct adapter *padapter, union recv_frame *prfr
struct recv_priv *precvpriv = &padapter->recvpriv;
struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
- DBG_COUNTER(padapter->rx_logs.core_rx_post);
-
prframe = decryptor(padapter, prframe);
if (!prframe) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("decryptor: drop pkt\n"));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s decryptor: drop pkt\n", __func__);
- #endif
ret = _FAIL;
- DBG_COUNTER(padapter->rx_logs.core_rx_post_decrypt_err);
goto _recv_data_drop;
}
prframe = recvframe_chk_defrag(padapter, prframe);
- if (!prframe) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chk_defrag: drop pkt\n"));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s recvframe_chk_defrag: drop pkt\n", __func__);
- #endif
- DBG_COUNTER(padapter->rx_logs.core_rx_post_defrag_err);
+ if (!prframe)
goto _recv_data_drop;
- }
prframe = portctrl(padapter, prframe);
if (!prframe) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("portctrl: drop pkt\n"));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s portctrl: drop pkt\n", __func__);
- #endif
ret = _FAIL;
- DBG_COUNTER(padapter->rx_logs.core_rx_post_portctrl_err);
goto _recv_data_drop;
}
@@ -2455,12 +2030,7 @@ static int recv_func_posthandle(struct adapter *padapter, union recv_frame *prfr
ret = process_recv_indicatepkts(padapter, prframe);
if (ret != _SUCCESS) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recv_func: process_recv_indicatepkts fail!\n"));
- #ifdef DBG_RX_DROP_FRAME
- DBG_871X("DBG_RX_DROP_FRAME %s process_recv_indicatepkts fail!\n", __func__);
- #endif
rtw_free_recvframe(orig_prframe, pfree_recv_queue);/* free this recv_frame */
- DBG_COUNTER(padapter->rx_logs.core_rx_post_indicate_err);
goto _recv_data_drop;
}
@@ -2469,9 +2039,7 @@ _recv_data_drop:
return ret;
}
-
-int recv_func(struct adapter *padapter, union recv_frame *rframe);
-int recv_func(struct adapter *padapter, union recv_frame *rframe)
+static int recv_func(struct adapter *padapter, union recv_frame *rframe)
{
int ret;
struct rx_pkt_attrib *prxattrib = &rframe->u.hdr.attrib;
@@ -2486,16 +2054,10 @@ int recv_func(struct adapter *padapter, union recv_frame *rframe)
while ((pending_frame = rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue))) {
cnt++;
- DBG_COUNTER(padapter->rx_logs.core_rx_dequeue);
recv_func_posthandle(padapter, pending_frame);
}
-
- if (cnt)
- DBG_871X(FUNC_ADPT_FMT" dequeue %d from uc_swdec_pending_queue\n",
- FUNC_ADPT_ARG(padapter), cnt);
}
- DBG_COUNTER(padapter->rx_logs.core_rx);
ret = recv_func_prehandle(padapter, rframe);
if (ret == _SUCCESS) {
@@ -2506,9 +2068,7 @@ int recv_func(struct adapter *padapter, union recv_frame *rframe)
(prxattrib->bdecrypted == 0 || psecuritypriv->sw_decrypt == true) &&
psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPAPSK &&
!psecuritypriv->busetkipkey) {
- DBG_COUNTER(padapter->rx_logs.core_rx_enqueue);
rtw_enqueue_recvframe(rframe, &padapter->recvpriv.uc_swdec_pending_queue);
- /* DBG_871X("%s: no key, enqueue uc_swdec_pending_queue\n", __func__); */
if (recvpriv->free_recvframe_cnt < NR_RECVFRAME/4) {
/* to prevent from recvframe starvation, get recvframe from uc_swdec_pending_queue to free_recvframe_cnt */
@@ -2534,15 +2094,12 @@ s32 rtw_recv_entry(union recv_frame *precvframe)
struct recv_priv *precvpriv;
s32 ret = _SUCCESS;
- /* RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("+rtw_recv_entry\n")); */
-
padapter = precvframe->u.hdr.adapter;
precvpriv = &padapter->recvpriv;
ret = recv_func(padapter, precvframe);
if (ret == _FAIL) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("rtw_recv_entry: recv_func return fail!!!\n"));
goto _recv_entry_drop;
}
@@ -2553,8 +2110,6 @@ s32 rtw_recv_entry(union recv_frame *precvframe)
_recv_entry_drop:
- /* RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("_recv_entry_drop\n")); */
-
return ret;
}
@@ -2625,20 +2180,6 @@ static void rtw_signal_stat_timer_hdl(struct timer_list *t)
recvpriv->signal_strength = tmp_s;
recvpriv->rssi = (s8)translate_percentage_to_dbm(tmp_s);
recvpriv->signal_qual = tmp_q;
-
- #if defined(DBG_RX_SIGNAL_DISPLAY_PROCESSING) && 1
- DBG_871X(FUNC_ADPT_FMT" signal_strength:%3u, rssi:%3d, signal_qual:%3u"
- ", num_signal_strength:%u, num_signal_qual:%u"
- ", on_cur_ch_ms:%d"
- "\n"
- , FUNC_ADPT_ARG(adapter)
- , recvpriv->signal_strength
- , recvpriv->rssi
- , recvpriv->signal_qual
- , num_signal_strength, num_signal_qual
- , rtw_get_on_cur_ch_time(adapter) ? jiffies_to_msecs(jiffies - rtw_get_on_cur_ch_time(adapter)) : 0
- );
- #endif
}
set_timer:
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index a311595deafb..7823055ed32d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -29,63 +29,6 @@ const char *security_type_str(u8 value)
return NULL;
}
-#ifdef DBG_SW_SEC_CNT
-#define WEP_SW_ENC_CNT_INC(sec, ra) \
- if (is_broadcast_mac_addr(ra)) \
- sec->wep_sw_enc_cnt_bc++; \
- else if (is_multicast_mac_addr(ra)) \
- sec->wep_sw_enc_cnt_mc++; \
- else \
- sec->wep_sw_enc_cnt_uc++;
-
-#define WEP_SW_DEC_CNT_INC(sec, ra) \
- if (is_broadcast_mac_addr(ra)) \
- sec->wep_sw_dec_cnt_bc++; \
- else if (is_multicast_mac_addr(ra)) \
- sec->wep_sw_dec_cnt_mc++; \
- else \
- sec->wep_sw_dec_cnt_uc++;
-
-#define TKIP_SW_ENC_CNT_INC(sec, ra) \
- if (is_broadcast_mac_addr(ra)) \
- sec->tkip_sw_enc_cnt_bc++; \
- else if (is_multicast_mac_addr(ra)) \
- sec->tkip_sw_enc_cnt_mc++; \
- else \
- sec->tkip_sw_enc_cnt_uc++;
-
-#define TKIP_SW_DEC_CNT_INC(sec, ra) \
- if (is_broadcast_mac_addr(ra)) \
- sec->tkip_sw_dec_cnt_bc++; \
- else if (is_multicast_mac_addr(ra)) \
- sec->tkip_sw_dec_cnt_mc++; \
- else \
- sec->tkip_sw_dec_cnt_uc++;
-
-#define AES_SW_ENC_CNT_INC(sec, ra) \
- if (is_broadcast_mac_addr(ra)) \
- sec->aes_sw_enc_cnt_bc++; \
- else if (is_multicast_mac_addr(ra)) \
- sec->aes_sw_enc_cnt_mc++; \
- else \
- sec->aes_sw_enc_cnt_uc++;
-
-#define AES_SW_DEC_CNT_INC(sec, ra) \
- if (is_broadcast_mac_addr(ra)) \
- sec->aes_sw_dec_cnt_bc++; \
- else if (is_multicast_mac_addr(ra)) \
- sec->aes_sw_dec_cnt_mc++; \
- else \
- sec->aes_sw_dec_cnt_uc++;
-#else
-#define WEP_SW_ENC_CNT_INC(sec, ra)
-#define WEP_SW_DEC_CNT_INC(sec, ra)
-#define TKIP_SW_ENC_CNT_INC(sec, ra)
-#define TKIP_SW_DEC_CNT_INC(sec, ra)
-#define AES_SW_ENC_CNT_INC(sec, ra)
-#define AES_SW_DEC_CNT_INC(sec, ra)
-#endif /* DBG_SW_SEC_CNT */
-
/* WEP related ===== */
struct arc4context {
@@ -148,7 +91,7 @@ static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32
dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx);
}
-static sint bcrc32initialized;
+static signed int bcrc32initialized;
static u32 crc32_table[256];
@@ -162,7 +105,7 @@ static void crc32_init(void)
if (bcrc32initialized == 1)
return;
else {
- sint i, j;
+ signed int i, j;
u32 c;
u8 *p = (u8 *)&c, *p1;
u8 k;
@@ -184,7 +127,7 @@ static void crc32_init(void)
}
}
-static __le32 getcrc32(u8 *buf, sint len)
+static __le32 getcrc32(u8 *buf, signed int len)
{
u8 *p;
u32 crc;
@@ -209,7 +152,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
unsigned char crc[4];
struct arc4context mycontext;
- sint curfragnum, length;
+ signed int curfragnum, length;
u32 keylength;
u8 *pframe, *payload, *iv; /* wepkey */
@@ -256,8 +199,6 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
}
}
-
- WEP_SW_ENC_CNT_INC(psecuritypriv, pattrib->ra);
}
}
@@ -266,7 +207,7 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
/* exclude ICV */
u8 crc[4];
struct arc4context mycontext;
- sint length;
+ signed int length;
u32 keylength;
u8 *pframe, *payload, *iv, wepkey[16];
u8 keyindex;
@@ -295,18 +236,6 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
/* calculate icv and compare the icv */
*((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4));
- 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_,
- ("%s: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",
- __func__,
- crc[3], payload[length - 1],
- crc[2], payload[length - 2],
- crc[1], payload[length - 3],
- crc[0], payload[length - 4]));
- }
-
- WEP_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra);
}
}
@@ -319,7 +248,7 @@ static u32 secmicgetuint32(u8 *p)
u32 res = 0;
for (i = 0; i < 4; i++)
- res |= ((u32)(*p++)) << (8*i);
+ res |= ((u32)(*p++)) << (8 * i);
return res;
}
@@ -397,7 +326,7 @@ void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst)
rtw_secmicappendbyte(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);
}
@@ -413,15 +342,15 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod
priority[0] = pri;
/* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */
- if (header[1]&1) { /* ToDS == 1 */
+ if (header[1] & 1) { /* ToDS == 1 */
rtw_secmicappend(&micdata, &header[16], 6); /* DA */
- if (header[1]&2) /* From Ds == 1 */
+ if (header[1] & 2) /* From Ds == 1 */
rtw_secmicappend(&micdata, &header[24], 6);
else
rtw_secmicappend(&micdata, &header[10], 6);
} else { /* ToDS == 0 */
rtw_secmicappend(&micdata, &header[4], 6); /* DA */
- if (header[1]&2) /* From Ds == 1 */
+ if (header[1] & 2) /* From Ds == 1 */
rtw_secmicappend(&micdata, &header[16], 6);
else
rtw_secmicappend(&micdata, &header[10], 6);
@@ -549,7 +478,7 @@ static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in R
*/
static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32)
{
- sint i;
+ signed int i;
/* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */
p1k[0] = Lo16(iv32);
@@ -597,7 +526,7 @@ 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)
{
- sint i;
+ signed int i;
u16 PPK[6]; /* temporary key for mixing */
/* Note: all adds in the PPK[] equations below are mod 2**16 */
@@ -651,7 +580,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
u8 crc[4];
u8 hw_hdr_offset = 0;
struct arc4context mycontext;
- sint curfragnum, length;
+ signed int curfragnum, length;
u8 *pframe, *payload, *iv, *prwskey;
union pn48 dot11txpn;
@@ -670,8 +599,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
if (pattrib->encrypt == _TKIP_) {
{
- RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__));
-
if (IS_MCAST(pattrib->ra))
prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
else
@@ -692,7 +619,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
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));
*((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/
arcfour_init(&mycontext, rc4key, 16);
@@ -710,8 +636,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
}
}
-
- TKIP_SW_ENC_CNT_INC(psecuritypriv, pattrib->ra);
}
}
return res;
@@ -727,7 +651,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
u8 ttkey[16];
u8 crc[4];
struct arc4context mycontext;
- sint length;
+ signed int length;
u8 *pframe, *payload, *iv, *prwskey;
union pn48 dot11txpn;
@@ -760,8 +684,11 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
if (jiffies_to_msecs(jiffies - start) > 1000) {
if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
- FUNC_ADPT_ARG(padapter), no_gkey_bc_cnt, no_gkey_mc_cnt);
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
+ FUNC_ADPT_ARG(padapter),
+ no_gkey_bc_cnt,
+ no_gkey_mc_cnt);
}
start = jiffies;
no_gkey_bc_cnt = 0;
@@ -771,8 +698,11 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
}
if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" gkey installed. no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
- FUNC_ADPT_ARG(padapter), no_gkey_bc_cnt, no_gkey_mc_cnt);
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " gkey installed. no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
+ FUNC_ADPT_ARG(padapter),
+ no_gkey_bc_cnt,
+ no_gkey_mc_cnt);
}
start = 0;
no_gkey_bc_cnt = 0;
@@ -802,20 +732,10 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
*((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4));
- 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_decrypt: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]));
+ if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
+ crc[1] != payload[length - 3] || crc[0] != payload[length - 4])
res = _FAIL;
- }
-
- TKIP_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra);
} else {
- RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo == NULL!!!\n", __func__));
res = _FAIL;
}
}
@@ -874,31 +794,31 @@ exit:
static void bitwise_xor(u8 *ina, u8 *inb, u8 *out);
static void construct_mic_iv(u8 *mic_header1,
- sint qc_exists,
- sint a4_exists,
+ signed int qc_exists,
+ signed int a4_exists,
u8 *mpdu,
uint payload_length,
u8 *pn_vector,
uint frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */
static void construct_mic_header1(u8 *mic_header1,
- sint header_length,
+ signed int header_length,
u8 *mpdu,
uint frtype); /* for CONFIG_IEEE80211W, none 11w also can use */
static void construct_mic_header2(u8 *mic_header2,
u8 *mpdu,
- sint a4_exists,
- sint qc_exists);
+ signed int a4_exists,
+ signed int qc_exists);
static void construct_ctr_preload(u8 *ctr_preload,
- sint a4_exists,
- sint qc_exists,
+ signed int a4_exists,
+ signed int qc_exists,
u8 *mpdu,
u8 *pn_vector,
- sint c,
+ signed int c,
uint frtype); /* for CONFIG_IEEE80211W, none 11w also can use */
static void xor_128(u8 *a, u8 *b, u8 *out);
static void xor_32(u8 *a, u8 *b, u8 *out);
static u8 sbox(u8 a);
-static void next_key(u8 *key, sint round);
+static void next_key(u8 *key, signed int round);
static void byte_sub(u8 *in, u8 *out);
static void shift_row(u8 *in, u8 *out);
static void mix_column(u8 *in, u8 *out);
@@ -912,7 +832,7 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext);
/****************************************/
static void xor_128(u8 *a, u8 *b, u8 *out)
{
- sint i;
+ signed int i;
for (i = 0; i < 16; i++)
out[i] = a[i] ^ b[i];
@@ -921,7 +841,7 @@ static void xor_128(u8 *a, u8 *b, u8 *out)
static void xor_32(u8 *a, u8 *b, u8 *out)
{
- sint i;
+ signed int i;
for (i = 0; i < 4; i++)
out[i] = a[i] ^ b[i];
@@ -930,11 +850,11 @@ static void xor_32(u8 *a, u8 *b, u8 *out)
static u8 sbox(u8 a)
{
- return sbox_table[(sint)a];
+ return sbox_table[(signed int)a];
}
-static void next_key(u8 *key, sint round)
+static void next_key(u8 *key, signed int round)
{
u8 rcon;
u8 sbox_key[4];
@@ -961,7 +881,7 @@ static void next_key(u8 *key, sint round)
static void byte_sub(u8 *in, u8 *out)
{
- sint i;
+ signed int i;
for (i = 0; i < 16; i++)
out[i] = sbox(in[i]);
@@ -990,7 +910,7 @@ static void shift_row(u8 *in, u8 *out)
static void mix_column(u8 *in, u8 *out)
{
- sint i;
+ signed int i;
u8 add1b[4];
u8 add1bf7[4];
u8 rotl[4];
@@ -1047,8 +967,8 @@ static void mix_column(u8 *in, u8 *out)
static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
{
- sint round;
- sint i;
+ signed int round;
+ signed int i;
u8 intermediatea[16];
u8 intermediateb[16];
u8 round_key[16];
@@ -1084,14 +1004,14 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
/* nonce */
/************************************************/
static void construct_mic_iv(u8 *mic_iv,
- sint qc_exists,
- sint a4_exists,
+ signed int qc_exists,
+ signed int a4_exists,
u8 *mpdu,
uint payload_length,
u8 *pn_vector,
uint frtype) /* add for CONFIG_IEEE80211W, none 11w also can use */
{
- sint i;
+ signed int i;
mic_iv[0] = 0x59;
@@ -1128,7 +1048,7 @@ static void construct_mic_iv(u8 *mic_iv,
/* Build AAD SC, A1, A2 */
/************************************************/
static void construct_mic_header1(u8 *mic_header1,
- sint header_length,
+ signed int header_length,
u8 *mpdu,
uint frtype) /* for CONFIG_IEEE80211W, none 11w also can use */
{
@@ -1163,10 +1083,10 @@ static void construct_mic_header1(u8 *mic_header1,
/************************************************/
static void construct_mic_header2(u8 *mic_header2,
u8 *mpdu,
- sint a4_exists,
- sint qc_exists)
+ signed int a4_exists,
+ signed int qc_exists)
{
- sint i;
+ signed int i;
for (i = 0; i < 16; i++)
mic_header2[i] = 0x00;
@@ -1208,14 +1128,14 @@ static void construct_mic_header2(u8 *mic_header2,
/* nonce */
/************************************************/
static void construct_ctr_preload(u8 *ctr_preload,
- sint a4_exists,
- sint qc_exists,
+ signed int a4_exists,
+ signed int qc_exists,
u8 *mpdu,
u8 *pn_vector,
- sint c,
+ signed int c,
uint frtype) /* for CONFIG_IEEE80211W, none 11w also can use */
{
- sint i = 0;
+ signed int i = 0;
for (i = 0; i < 16; i++)
ctr_preload[i] = 0x00;
@@ -1250,13 +1170,13 @@ static void construct_ctr_preload(u8 *ctr_preload,
/************************************/
static void bitwise_xor(u8 *ina, u8 *inb, u8 *out)
{
- sint i;
+ signed int i;
for (i = 0; i < 16; i++)
out[i] = ina[i] ^ inb[i];
}
-static sint aes_cipher(u8 *key, uint hdrlen,
+static signed int aes_cipher(u8 *key, uint hdrlen,
u8 *pframe, uint plen)
{
uint qc_exists, a4_exists, i, j, payload_remainder,
@@ -1428,7 +1348,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
/* unsigned char message[MAX_MSG_SIZE]; */
/* Intermediate Buffers */
- sint curfragnum, length;
+ signed int curfragnum, length;
u8 *pframe, *prwskey; /* *payload,*iv */
u8 hw_hdr_offset = 0;
struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib;
@@ -1445,8 +1365,6 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
/* 4 start to encrypt each fragment */
if (pattrib->encrypt == _AES_) {
- RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__));
-
if (IS_MCAST(pattrib->ra))
prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
else
@@ -1465,19 +1383,17 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
}
}
-
- AES_SW_ENC_CNT_INC(psecuritypriv, pattrib->ra);
}
return res;
}
-static sint aes_decipher(u8 *key, uint hdrlen,
+static signed 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;
- sint res = _SUCCESS;
+ signed int res = _SUCCESS;
u8 pn_vector[6];
u8 mic_iv[16];
u8 mic_header1[16];
@@ -1677,21 +1593,8 @@ static sint 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]) {
- RT_TRACE(_module_rtl871x_security_c_,
- _drv_err_,
- ("%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_871X("%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]);
+ if (pframe[hdrlen + 8 + plen - 8 + i] != message[hdrlen + 8 + plen - 8 + i])
res = _FAIL;
- }
}
return res;
}
@@ -1704,7 +1607,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
/* Intermediate Buffers */
- sint length;
+ signed int length;
u8 *pframe, *prwskey; /* *payload,*iv */
struct sta_info *stainfo;
struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib;
@@ -1716,10 +1619,6 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
if (prxattrib->encrypt == _AES_) {
stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);
if (stainfo) {
- RT_TRACE(_module_rtl871x_security_c_,
- _drv_err_,
- ("%s: stainfo!= NULL!!!\n", __func__));
-
if (IS_MCAST(prxattrib->ra)) {
static unsigned long start;
static u32 no_gkey_bc_cnt;
@@ -1738,8 +1637,11 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
if (jiffies_to_msecs(jiffies - start) > 1000) {
if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
- FUNC_ADPT_ARG(padapter), no_gkey_bc_cnt, no_gkey_mc_cnt);
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
+ FUNC_ADPT_ARG(padapter),
+ no_gkey_bc_cnt,
+ no_gkey_mc_cnt);
}
start = jiffies;
no_gkey_bc_cnt = 0;
@@ -1750,8 +1652,11 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
}
if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" gkey installed. no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
- FUNC_ADPT_ARG(padapter), no_gkey_bc_cnt, no_gkey_mc_cnt);
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " gkey installed. no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
+ FUNC_ADPT_ARG(padapter),
+ no_gkey_bc_cnt,
+ no_gkey_mc_cnt);
}
start = 0;
no_gkey_bc_cnt = 0;
@@ -1759,8 +1664,6 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
if (psecuritypriv->dot118021XGrpKeyid != prxattrib->key_index) {
- DBG_871X("not match packet_index =%d, install_index =%d\n"
- , prxattrib->key_index, psecuritypriv->dot118021XGrpKeyid);
res = _FAIL;
goto exit;
}
@@ -1772,11 +1675,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length);
- AES_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra);
} else {
- RT_TRACE(_module_rtl871x_security_c_,
- _drv_err_,
- ("%s: stainfo == NULL!!!\n", __func__));
res = _FAIL;
}
}
@@ -1800,10 +1699,9 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)
ori_len = pattrib->pkt_len-WLAN_HDR_A3_LEN+BIP_AAD_SIZE;
BIP_AAD = rtw_zmalloc(ori_len);
- if (BIP_AAD == NULL) {
- DBG_871X("BIP AAD allocate fail\n");
+ if (!BIP_AAD)
return _FAIL;
- }
+
/* PKT start */
pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data;
/* mapping to wlan header */
@@ -1820,17 +1718,15 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)
memcpy(&le_tmp64, p+4, 6);
temp_ipn = le64_to_cpu(le_tmp64);
/* BIP packet number should bigger than previous BIP packet */
- if (temp_ipn <= pmlmeext->mgnt_80211w_IPN_rx) {
- DBG_871X("replay BIP packet\n");
+ if (temp_ipn <= pmlmeext->mgnt_80211w_IPN_rx)
goto BIP_exit;
- }
+
/* copy key index */
memcpy(&le_tmp, p+2, 2);
keyid = le16_to_cpu(le_tmp);
- if (keyid != padapter->securitypriv.dot11wBIPKeyid) {
- DBG_871X("BIP key index error!\n");
+ if (keyid != padapter->securitypriv.dot11wBIPKeyid)
goto BIP_exit;
- }
+
/* clear the MIC field of MME to zero */
memset(p+2+len-8, 0, 8);
@@ -1851,7 +1747,6 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)
pmlmeext->mgnt_80211w_IPN_rx = temp_ipn;
res = _SUCCESS;
} else {
- DBG_871X("BIP MIC error!\n");
}
} else {
@@ -2080,10 +1975,12 @@ static void rijndaelEncrypt(u32 rk[/*44*/], u8 pt[16], u8 ct[16])
s3 = GETU32(pt + 12) ^ rk[3];
#define ROUND(i, d, s) \
-d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
-d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
-d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
-d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]
+ do { \
+ d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
+ d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
+ d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
+ d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \
+ } while (0)
/* Nr - 1 full rounds: */
r = Nr >> 1;
@@ -2241,7 +2138,7 @@ int omac1_aes_128(u8 *key, u8 *data, size_t data_len, u8 *mac)
void rtw_sec_restore_wep_key(struct adapter *adapter)
{
struct security_priv *securitypriv = &(adapter->securitypriv);
- sint keyid;
+ signed int keyid;
if ((_WEP40_ == securitypriv->dot11PrivacyAlgrthm) || (_WEP104_ == securitypriv->dot11PrivacyAlgrthm)) {
for (keyid = 0; keyid < 4; keyid++) {
@@ -2264,13 +2161,17 @@ u8 rtw_handle_tkip_countermeasure(struct adapter *adapter, const char *caller)
unsigned long passing_ms = jiffies_to_msecs(jiffies - securitypriv->btkip_countermeasure_time);
if (passing_ms > 60*1000) {
- DBG_871X_LEVEL(_drv_always_, "%s(%s) countermeasure time:%lus > 60s\n",
- caller, ADPT_ARG(adapter), passing_ms/1000);
+ netdev_dbg(adapter->pnetdev,
+ "%s(%s) countermeasure time:%lus > 60s\n",
+ caller, ADPT_ARG(adapter),
+ passing_ms / 1000);
securitypriv->btkip_countermeasure = false;
securitypriv->btkip_countermeasure_time = 0;
} else {
- DBG_871X_LEVEL(_drv_always_, "%s(%s) countermeasure time:%lus < 60s\n",
- caller, ADPT_ARG(adapter), passing_ms/1000);
+ netdev_dbg(adapter->pnetdev,
+ "%s(%s) countermeasure time:%lus < 60s\n",
+ caller, ADPT_ARG(adapter),
+ passing_ms / 1000);
status = _FAIL;
}
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
index f96dd0b40e04..85663182b388 100644
--- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
@@ -106,17 +106,11 @@ inline int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta)
{
int offset = (((u8 *)sta) - stapriv->pstainfo_buf)/sizeof(struct sta_info);
- if (!stainfo_offset_valid(offset))
- DBG_871X("%s invalid offset(%d), out of range!!!", __func__, offset);
-
return offset;
}
inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset)
{
- if (!stainfo_offset_valid(offset))
- DBG_871X("%s invalid offset(%d), out of range!!!", __func__, offset);
-
return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info));
}
@@ -216,10 +210,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
index = wifi_mac_hash(hwaddr);
- RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, ("rtw_alloc_stainfo: index = %x", index));
-
if (index >= NUM_STA) {
- RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("ERROR => rtw_alloc_stainfo: index >= NUM_STA"));
spin_unlock_bh(&(pstapriv->sta_hash_lock));
psta = NULL;
goto exit;
@@ -242,17 +233,6 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
for (i = 0; i < 16; i++)
memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2);
- RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_,
- ("alloc number_%d stainfo with hwaddr = %x %x %x %x %x %x \n",
- pstapriv->asoc_sta_count,
- hwaddr[0],
- hwaddr[1],
- hwaddr[2],
- hwaddr[3],
- hwaddr[4],
- hwaddr[5])
- );
-
init_addba_retry_timer(pstapriv->padapter, psta);
/* for A-MPDU Rx reordering buffer control */
@@ -264,10 +244,6 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
preorder_ctrl->enable = false;
preorder_ctrl->indicate_seq = 0xffff;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq);
- #endif
preorder_ctrl->wend_b = 0xffff;
/* preorder_ctrl->wsize_b = (NR_RECVBUFF-2); */
preorder_ctrl->wsize_b = 64;/* 64; */
@@ -363,16 +339,6 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta)
spin_unlock_bh(&pxmitpriv->lock);
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])
- );
pstapriv->asoc_sta_count--;
/* re-init sta_info; 20061114 will be init in alloc_stainfo */
@@ -543,7 +509,6 @@ u32 rtw_init_bcmc_stainfo(struct adapter *padapter)
if (!psta) {
res = _FAIL;
- RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("rtw_alloc_stainfo fail"));
goto exit;
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 975f2830e29e..f9bd7c167da7 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -10,10 +10,6 @@
#include <rtw_debug.h>
#include <hal_com_h2c.h>
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-#include <linux/inetdevice.h>
-#endif
-
static unsigned char ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f};
static unsigned char ARTHEROS_OUI2[] = {0x00, 0x13, 0x74};
@@ -29,9 +25,6 @@ static unsigned char AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5};
static unsigned char RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02};
static unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02};
-extern unsigned char RTW_WPA_OUI[];
-extern unsigned char WPA_TKIP_CIPHER[4];
-
#define R2T_PHY_DELAY (0)
/* define WAIT_FOR_BCN_TO_MIN (3000) */
@@ -319,7 +312,6 @@ inline void rtw_set_oper_ch(struct adapter *adapter, u8 ch)
cnt += scnprintf(msg+cnt, len-cnt, "]");
}
- DBG_871X(FUNC_ADPT_FMT" %s\n", FUNC_ADPT_ARG(adapter), msg);
#endif /* DBG_CH_SWITCH */
}
@@ -387,9 +379,6 @@ void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigne
{
u8 center_ch, chnl_offset80 = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
- if (padapter->bNotifyChannelChange)
- DBG_871X("[%s] ch = %d, offset = %d, bwmode = %d\n", __func__, channel, channel_offset, bwmode);
-
center_ch = rtw_get_center_ch(channel, bwmode, channel_offset);
if (bwmode == CHANNEL_WIDTH_80) {
@@ -515,14 +504,11 @@ void read_cam(struct adapter *padapter, u8 entry, u8 *get_key)
addr = entry << 3;
- /* DBG_8192C("********* DUMP CAM Entry_#%02d***************\n", entry); */
for (j = 0; j < 6; j++) {
cmd = _ReadCAM(padapter, addr+j);
- /* DBG_8192C("offset:0x%02x => 0x%08x\n", addr+j, cmd); */
if (j > 1) /* get key from cam */
memcpy(get_key+(j-2)*4, &cmd, 4);
}
- /* DBG_8192C("*********************************\n"); */
}
void _write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key)
@@ -634,13 +620,6 @@ static s16 _rtw_camid_search(struct adapter *adapter, u8 *addr, s16 kid)
break;
}
- if (addr)
- DBG_871X(FUNC_ADPT_FMT" addr:%pM kid:%d, return cam_id:%d\n"
- , FUNC_ADPT_ARG(adapter), MAC_ARG(addr), kid, cam_id);
- else
- DBG_871X(FUNC_ADPT_FMT" addr:%p kid:%d, return cam_id:%d\n"
- , FUNC_ADPT_ARG(adapter), addr, kid, cam_id);
-
return cam_id;
}
@@ -672,8 +651,9 @@ s16 rtw_camid_alloc(struct adapter *adapter, struct sta_info *sta, u8 kid)
&& !sta) {
/* AP/Ad-hoc mode group key: static alloction to default key by key ID */
if (kid > 3) {
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" group key with invalid key id:%u\n"
- , FUNC_ADPT_ARG(adapter), kid);
+ netdev_dbg(adapter->pnetdev,
+ FUNC_ADPT_FMT " group key with invalid key id:%u\n",
+ FUNC_ADPT_ARG(adapter), kid);
rtw_warn_on(1);
goto bitmap_handle;
}
@@ -698,8 +678,9 @@ s16 rtw_camid_alloc(struct adapter *adapter, struct sta_info *sta, u8 kid)
if (sta || _rtw_camid_is_gk(adapter, i))
cam_id = i;
else
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" group key id:%u the same key id as pairwise key\n"
- , FUNC_ADPT_ARG(adapter), kid);
+ netdev_dbg(adapter->pnetdev,
+ FUNC_ADPT_FMT " group key id:%u the same key id as pairwise key\n",
+ FUNC_ADPT_ARG(adapter), kid);
goto bitmap_handle;
}
@@ -709,11 +690,14 @@ s16 rtw_camid_alloc(struct adapter *adapter, struct sta_info *sta, u8 kid)
if (i == TOTAL_CAM_ENTRY) {
if (sta)
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" pairwise key with %pM id:%u no room\n"
- , FUNC_ADPT_ARG(adapter), MAC_ARG(sta->hwaddr), kid);
+ netdev_dbg(adapter->pnetdev,
+ FUNC_ADPT_FMT " pairwise key with %pM id:%u no room\n",
+ FUNC_ADPT_ARG(adapter),
+ MAC_ARG(sta->hwaddr), kid);
else
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" group key id:%u no room\n"
- , FUNC_ADPT_ARG(adapter), kid);
+ netdev_dbg(adapter->pnetdev,
+ FUNC_ADPT_FMT " group key id:%u no room\n",
+ FUNC_ADPT_ARG(adapter), kid);
rtw_warn_on(1);
goto bitmap_handle;
}
@@ -880,8 +864,6 @@ void WMMOnAssocRsp(struct adapter *padapter)
edca[XMIT_VO_QUEUE] = acParm;
break;
}
-
- DBG_871X("WMM(%x): %x, %x\n", ACI, ACM, acParm);
}
if (padapter->registrypriv.acm_method == 1)
@@ -921,10 +903,8 @@ void WMMOnAssocRsp(struct adapter *padapter)
}
}
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < 4; i++)
pxmitpriv->wmm_para_seq[i] = inx[i];
- DBG_871X("wmm_para_seq(%d): %d\n", i, pxmitpriv->wmm_para_seq[i]);
- }
}
}
@@ -1075,36 +1055,29 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE)
break;
case RF_2T2R:
default:
-#ifdef CONFIG_DISABLE_MCS13TO15
- if (pmlmeext->cur_bwmode == CHANNEL_WIDTH_40 && pregistrypriv->wifi_spec != 1)
- set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R_13TO15_OFF);
- else
- set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
-#else /* CONFIG_DISABLE_MCS13TO15 */
set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
-#endif /* CONFIG_DISABLE_MCS13TO15 */
}
if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
/* Config STBC setting */
- if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_TX_STBC(pIE->data)) {
+ if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) &&
+ GET_HT_CAPABILITY_ELE_TX_STBC(pIE->data))
SET_FLAG(cur_stbc_cap, STBC_HT_ENABLE_TX);
- DBG_871X("Enable HT Tx STBC !\n");
- }
+
phtpriv->stbc_cap = cur_stbc_cap;
} else {
/* Config LDPC Coding Capability */
- if (TEST_FLAG(phtpriv->ldpc_cap, LDPC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_LDPC_CAP(pIE->data)) {
+ if (TEST_FLAG(phtpriv->ldpc_cap, LDPC_HT_ENABLE_TX) &&
+ GET_HT_CAPABILITY_ELE_LDPC_CAP(pIE->data))
SET_FLAG(cur_ldpc_cap, (LDPC_HT_ENABLE_TX | LDPC_HT_CAP_TX));
- DBG_871X("Enable HT Tx LDPC!\n");
- }
+
phtpriv->ldpc_cap = cur_ldpc_cap;
/* Config STBC setting */
- if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_RX_STBC(pIE->data)) {
+ if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) &&
+ GET_HT_CAPABILITY_ELE_RX_STBC(pIE->data))
SET_FLAG(cur_stbc_cap, (STBC_HT_ENABLE_TX | STBC_HT_CAP_TX));
- DBG_871X("Enable HT Tx STBC!\n");
- }
+
phtpriv->stbc_cap = cur_stbc_cap;
}
}
@@ -1137,8 +1110,6 @@ void HTOnAssocRsp(struct adapter *padapter)
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- DBG_871X("%s\n", __func__);
-
if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) {
pmlmeinfo->HT_enable = 1;
} else {
@@ -1254,22 +1225,15 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
len = packet_len - sizeof(struct ieee80211_hdr_3addr);
- if (len > MAX_IE_SZ) {
- DBG_871X("%s IE too long for survey event\n", __func__);
+ if (len > MAX_IE_SZ)
return _FAIL;
- }
- if (memcmp(cur_network->network.MacAddress, pbssid, 6)) {
- DBG_871X("Oops: rtw_check_network_encrypt linked but recv other bssid bcn %pM %pM\n",
- MAC_ARG(pbssid), MAC_ARG(cur_network->network.MacAddress));
+ if (memcmp(cur_network->network.MacAddress, pbssid, 6))
return true;
- }
bssid = rtw_zmalloc(sizeof(struct wlan_bssid_ex));
- if (!bssid) {
- DBG_871X("%s rtw_zmalloc fail !!!\n", __func__);
+ if (!bssid)
return true;
- }
if ((pmlmepriv->timeBcnInfoChkStart != 0) && (jiffies_to_msecs(jiffies - pmlmepriv->timeBcnInfoChkStart) > DISCONNECT_BY_CHK_BCN_FAIL_OBSERV_PERIOD_IN_MS)) {
pmlmepriv->timeBcnInfoChkStart = 0;
@@ -1306,11 +1270,6 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
}
if (ht_cap_info != cur_network->BcnInfo.ht_cap_info ||
((ht_info_infos_0&0x03) != (cur_network->BcnInfo.ht_info_infos_0&0x03))) {
- DBG_871X("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n", __func__,
- ht_cap_info, ht_info_infos_0);
- DBG_871X("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n", __func__,
- cur_network->BcnInfo.ht_cap_info, cur_network->BcnInfo.ht_info_infos_0);
- DBG_871X("%s bw mode change\n", __func__);
{
/* bcn_info_update */
cur_network->BcnInfo.ht_cap_info = ht_cap_info;
@@ -1325,19 +1284,16 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
if (p) {
bcn_channel = *(p + 2);
} else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */
- rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, bssid->IELength - _FIXED_IE_LENGTH_);
- if (pht_info) {
- bcn_channel = pht_info->primary_channel;
- } else { /* we don't find channel IE, so don't check it */
- /* DBG_871X("Oops: %s we don't find channel IE, so don't check it\n", __func__); */
- bcn_channel = Adapter->mlmeextpriv.cur_channel;
- }
+ rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION,
+ &len, bssid->IELength - _FIXED_IE_LENGTH_);
+ if (pht_info)
+ bcn_channel = pht_info->primary_channel;
+ else /* we don't find channel IE, so don't check it */
+ bcn_channel = Adapter->mlmeextpriv.cur_channel;
}
- if (bcn_channel != Adapter->mlmeextpriv.cur_channel) {
- DBG_871X("%s beacon channel:%d cur channel:%d disconnect\n", __func__,
- bcn_channel, Adapter->mlmeextpriv.cur_channel);
+
+ if (bcn_channel != Adapter->mlmeextpriv.cur_channel)
goto _mismatch;
- }
/* checking SSID */
ssid_len = 0;
@@ -1350,18 +1306,11 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
memcpy(bssid->Ssid.Ssid, (p + 2), ssid_len);
bssid->Ssid.SsidLength = ssid_len;
- 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__, bssid->Ssid.Ssid,
- bssid->Ssid.SsidLength, cur_network->network.Ssid.Ssid,
- cur_network->network.Ssid.SsidLength));
-
if (memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) ||
- bssid->Ssid.SsidLength != cur_network->network.Ssid.SsidLength) {
- if (bssid->Ssid.Ssid[0] != '\0' && bssid->Ssid.SsidLength != 0) { /* not hidden ssid */
- DBG_871X("%s(), SSID is not match\n", __func__);
+ bssid->Ssid.SsidLength != cur_network->network.Ssid.SsidLength)
+ if (bssid->Ssid.Ssid[0] != '\0' &&
+ bssid->Ssid.SsidLength != 0) /* not hidden ssid */
goto _mismatch;
- }
- }
/* check encryption info */
val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid);
@@ -1371,63 +1320,41 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
else
bssid->Privacy = 0;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
- ("%s(): cur_network->network.Privacy is %d, bssid.Privacy is %d\n",
- __func__, cur_network->network.Privacy, bssid->Privacy));
- if (cur_network->network.Privacy != bssid->Privacy) {
- DBG_871X("%s(), privacy is not match\n", __func__);
+ if (cur_network->network.Privacy != bssid->Privacy)
goto _mismatch;
- }
rtw_get_sec_ie(bssid->IEs, bssid->IELength, NULL, &rsn_len, NULL, &wpa_len);
- if (rsn_len > 0) {
+ if (rsn_len > 0)
encryp_protocol = ENCRYP_PROTOCOL_WPA2;
- } else if (wpa_len > 0) {
+ else if (wpa_len > 0)
encryp_protocol = ENCRYP_PROTOCOL_WPA;
- } else {
+ else
if (bssid->Privacy)
encryp_protocol = ENCRYP_PROTOCOL_WEP;
- }
- if (cur_network->BcnInfo.encryp_protocol != encryp_protocol) {
- DBG_871X("%s(): enctyp is not match\n", __func__);
+ if (cur_network->BcnInfo.encryp_protocol != encryp_protocol)
goto _mismatch;
- }
if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) {
pbuf = rtw_get_wpa_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12);
if (pbuf && (wpa_ielen > 0)) {
- if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) {
- 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));
- }
+ rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, &group_cipher,
+ &pairwise_cipher, &is_8021x);
} else {
pbuf = rtw_get_wpa2_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12);
- if (pbuf && (wpa_ielen > 0)) {
- if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) {
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
- ("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n",
- __func__, pairwise_cipher, group_cipher, is_8021x));
- }
- }
+ if (pbuf && (wpa_ielen > 0))
+ rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, &group_cipher,
+ &pairwise_cipher, &is_8021x);
}
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
- ("%s cur_network->group_cipher is %d: %d\n", __func__, cur_network->BcnInfo.group_cipher, group_cipher));
- if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || group_cipher != cur_network->BcnInfo.group_cipher) {
- DBG_871X("%s pairwise_cipher(%x:%x) or group_cipher(%x:%x) is not match\n", __func__,
- pairwise_cipher, cur_network->BcnInfo.pairwise_cipher,
- group_cipher, cur_network->BcnInfo.group_cipher);
+ if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher ||
+ group_cipher != cur_network->BcnInfo.group_cipher)
goto _mismatch;
- }
- if (is_8021x != cur_network->BcnInfo.is_8021x) {
- DBG_871X("%s authentication is not match\n", __func__);
+ if (is_8021x != cur_network->BcnInfo.is_8021x)
goto _mismatch;
- }
}
kfree(bssid);
@@ -1440,12 +1367,9 @@ _mismatch:
pmlmepriv->timeBcnInfoChkStart = jiffies;
pmlmepriv->NumOfBcnInfoChkFail++;
- DBG_871X("%s by %s - NumOfChkFail = %d (SeqNum of this Beacon frame = %d).\n", __func__, ADPT_ARG(Adapter), pmlmepriv->NumOfBcnInfoChkFail, GetSequence(pframe));
if ((pmlmepriv->timeBcnInfoChkStart != 0) && (jiffies_to_msecs(jiffies - pmlmepriv->timeBcnInfoChkStart) <= DISCONNECT_BY_CHK_BCN_FAIL_OBSERV_PERIOD_IN_MS)
&& (pmlmepriv->NumOfBcnInfoChkFail >= DISCONNECT_BY_CHK_BCN_FAIL_THRESHOLD)) {
- DBG_871X("%s by %s - NumOfChkFail = %d >= threshold : %d (in %d ms), return FAIL.\n", __func__, ADPT_ARG(Adapter), pmlmepriv->NumOfBcnInfoChkFail,
- DISCONNECT_BY_CHK_BCN_FAIL_THRESHOLD, jiffies_to_msecs(jiffies - pmlmepriv->timeBcnInfoChkStart));
pmlmepriv->timeBcnInfoChkStart = 0;
pmlmepriv->NumOfBcnInfoChkFail = 0;
return _FAIL;
@@ -1583,21 +1507,16 @@ unsigned char check_assoc_AP(u8 *pframe, uint len)
switch (pIE->ElementID) {
case WLAN_EID_VENDOR_SPECIFIC:
if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) {
- DBG_871X("link to Artheros AP\n");
return HT_IOT_PEER_ATHEROS;
} else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) ||
(!memcmp(pIE->data, BROADCOM_OUI2, 3)) ||
(!memcmp(pIE->data, BROADCOM_OUI3, 3))) {
- DBG_871X("link to Broadcom AP\n");
return HT_IOT_PEER_BROADCOM;
} else if (!memcmp(pIE->data, MARVELL_OUI, 3)) {
- DBG_871X("link to Marvell AP\n");
return HT_IOT_PEER_MARVELL;
} else if (!memcmp(pIE->data, RALINK_OUI, 3)) {
- DBG_871X("link to Ralink AP\n");
return HT_IOT_PEER_RALINK;
} else if (!memcmp(pIE->data, CISCO_OUI, 3)) {
- DBG_871X("link to Cisco AP\n");
return HT_IOT_PEER_CISCO;
} else if (!memcmp(pIE->data, REALTEK_OUI, 3)) {
u32 Vender = HT_IOT_PEER_REALTEK;
@@ -1614,21 +1533,16 @@ unsigned char check_assoc_AP(u8 *pframe, uint len)
Vender = HT_IOT_PEER_REALTEK_SOFTAP;
if (pIE->data[4] == 2) {
- if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT) {
+ if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT)
Vender = HT_IOT_PEER_REALTEK_JAGUAR_BCUTAP;
- DBG_871X("link to Realtek JAGUAR_BCUTAP\n");
- }
- if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_CCUT) {
+
+ if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_CCUT)
Vender = HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP;
- DBG_871X("link to Realtek JAGUAR_CCUTAP\n");
- }
}
}
- DBG_871X("link to Realtek AP\n");
return Vender;
} else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) {
- DBG_871X("link to Airgo Cap\n");
return HT_IOT_PEER_AIRGO;
} else {
break;
@@ -1641,7 +1555,6 @@ unsigned char check_assoc_AP(u8 *pframe, uint len)
i += (pIE->Length + 2);
}
- DBG_871X("link to new AP\n");
return HT_IOT_PEER_UNKNOWN;
}
@@ -1760,7 +1673,7 @@ void update_wireless_mode(struct adapter *padapter)
if (pmlmeext->cur_wireless_mode & WIRELESS_11B)
update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB);
- else
+ else
update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB);
}
@@ -1820,15 +1733,7 @@ void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr)
preorder_ctrl = &psta->recvreorder_ctrl[tid];
- #ifdef CONFIG_UPDATE_INDICATE_SEQ_WHILE_PROCESS_ADDBA_REQ
- preorder_ctrl->indicate_seq = start_seq;
- #ifdef DBG_RX_SEQ
- DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d, start_seq: %d\n", __func__, __LINE__,
- preorder_ctrl->indicate_seq, start_seq);
- #endif
- #else
preorder_ctrl->indicate_seq = 0xffff;
- #endif
preorder_ctrl->enable = pmlmeinfo->accept_addba_req;
}
@@ -1872,8 +1777,6 @@ void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len)
tsf = tsf << 32;
tsf |= le32_to_cpu(*pbuf);
- /* DBG_871X("%s(): tsf_upper = 0x%08x, tsf_lower = 0x%08x\n", __func__, (u32)(tsf>>32), (u32)tsf); */
-
/* delay = (timestamp mod 1024*100)/1000 (unit: ms) */
/* delay_ms = do_div(tsf, (pmlmeinfo->bcn_interval*1024))/1000; */
delay_ms = do_div(tsf, (pmlmeinfo->bcn_interval*1024));
@@ -1887,11 +1790,9 @@ void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len)
/* pmlmeext->bcn_delay_ratio[delay_ms] = (pmlmeext->bcn_delay_cnt[delay_ms] * 100) /pmlmeext->bcn_cnt; */
/*
- DBG_871X("%s(): (a)bcn_cnt = %d\n", __func__, pmlmeext->bcn_cnt);
for (i = 0; i<9; i++)
{
- DBG_871X("%s():bcn_delay_cnt[%d]=%d, bcn_delay_ratio[%d]=%d\n", __func__, i,
pmlmeext->bcn_delay_cnt[i] , i, pmlmeext->bcn_delay_ratio[i]);
}
*/
@@ -1906,26 +1807,17 @@ void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len)
DrvBcnEarly = 0xff;
DrvBcnTimeOut = 0xff;
- DBG_871X("%s(): bcn_cnt = %d\n", __func__, pmlmeext->bcn_cnt);
-
for (i = 0; i < 9; i++) {
pmlmeext->bcn_delay_ratio[i] = (pmlmeext->bcn_delay_cnt[i] * 100) / pmlmeext->bcn_cnt;
- DBG_871X("%s():bcn_delay_cnt[%d]=%d, bcn_delay_ratio[%d]=%d\n", __func__, i,
- pmlmeext->bcn_delay_cnt[i], i, pmlmeext->bcn_delay_ratio[i]);
-
ratio_20_delay += pmlmeext->bcn_delay_ratio[i];
ratio_80_delay += pmlmeext->bcn_delay_ratio[i];
- if (ratio_20_delay > 20 && DrvBcnEarly == 0xff) {
+ if (ratio_20_delay > 20 && DrvBcnEarly == 0xff)
DrvBcnEarly = i;
- DBG_871X("%s(): DrvBcnEarly = %d\n", __func__, DrvBcnEarly);
- }
- if (ratio_80_delay > 80 && DrvBcnTimeOut == 0xff) {
+ if (ratio_80_delay > 80 && DrvBcnTimeOut == 0xff)
DrvBcnTimeOut = i;
- DBG_871X("%s(): DrvBcnTimeOut = %d\n", __func__, DrvBcnTimeOut);
- }
/* reset adaptive_early_32k cnt */
pmlmeext->bcn_delay_cnt[i] = 0;
@@ -1962,13 +1854,10 @@ void rtw_alloc_macid(struct adapter *padapter, struct sta_info *psta)
}
spin_unlock_bh(&pdvobj->lock);
- if (i > (NUM_STA-1)) {
+ if (i > (NUM_STA - 1))
psta->mac_id = NUM_STA;
- DBG_871X(" no room for more MACIDs\n");
- } else {
+ else
psta->mac_id = i;
- DBG_871X("%s = %d\n", __func__, psta->mac_id);
- }
}
void rtw_release_macid(struct adapter *padapter, struct sta_info *psta)
@@ -1985,7 +1874,6 @@ void rtw_release_macid(struct adapter *padapter, struct sta_info *psta)
spin_lock_bh(&pdvobj->lock);
if (psta->mac_id < NUM_STA && psta->mac_id != 1) {
if (pdvobj->macid[psta->mac_id] == true) {
- DBG_871X("%s = %d\n", __func__, psta->mac_id);
pdvobj->macid[psta->mac_id] = false;
psta->mac_id = NUM_STA;
}
@@ -2018,182 +1906,3 @@ struct adapter *dvobj_get_port0_adapter(struct dvobj_priv *dvobj)
return dvobj->padapters;
}
-
-#ifdef CONFIG_GPIO_API
-int rtw_get_gpio(struct net_device *netdev, int gpio_num)
-{
- u8 value;
- u8 direction;
- struct adapter *adapter = rtw_netdev_priv(netdev);
- struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(adapter);
-
- rtw_ps_deny(adapter, PS_DENY_IOCTL);
-
- DBG_871X("rf_pwrstate = 0x%02x\n", pwrpriv->rf_pwrstate);
- LeaveAllPowerSaveModeDirect(adapter);
-
- /* Read GPIO Direction */
- direction = (rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) & BIT(gpio_num)) >> gpio_num;
-
- /* According the direction to read register value */
- if (direction)
- value = (rtw_read8(adapter, REG_GPIO_PIN_CTRL + 1) & BIT(gpio_num)) >> gpio_num;
- else
- value = (rtw_read8(adapter, REG_GPIO_PIN_CTRL) & BIT(gpio_num)) >> gpio_num;
-
- rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL);
- DBG_871X("%s direction =%d value =%d\n", __func__, direction, value);
-
- return value;
-}
-EXPORT_SYMBOL(rtw_get_gpio);
-
-int rtw_set_gpio_output_value(struct net_device *netdev, int gpio_num, bool isHigh)
-{
- u8 direction = 0;
- u8 res = -1;
- struct adapter *adapter = rtw_netdev_priv(netdev);
-
- /* Check GPIO is 4~7 */
- if (gpio_num > 7 || gpio_num < 4) {
- DBG_871X("%s The gpio number does not included 4~7.\n", __func__);
- return -1;
- }
-
- rtw_ps_deny(adapter, PS_DENY_IOCTL);
-
- LeaveAllPowerSaveModeDirect(adapter);
-
- /* Read GPIO direction */
- direction = (rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) & BIT(gpio_num)) >> gpio_num;
-
- /* If GPIO is output direction, setting value. */
- if (direction) {
- if (isHigh)
- rtw_write8(adapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 1) | BIT(gpio_num));
- else
- rtw_write8(adapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 1) & ~BIT(gpio_num));
-
- DBG_871X("%s Set gpio %x[%d]=%d\n", __func__, REG_GPIO_PIN_CTRL+1, gpio_num, isHigh);
- res = 0;
- } else {
- DBG_871X("%s The gpio is input, not be set!\n", __func__);
- res = -1;
- }
-
- rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL);
- return res;
-}
-EXPORT_SYMBOL(rtw_set_gpio_output_value);
-
-int rtw_config_gpio(struct net_device *netdev, int gpio_num, bool isOutput)
-{
- struct adapter *adapter = rtw_netdev_priv(netdev);
-
- if (gpio_num > 7 || gpio_num < 4) {
- DBG_871X("%s The gpio number does not included 4~7.\n", __func__);
- return -1;
- }
-
- DBG_871X("%s gpio_num =%d direction =%d\n", __func__, gpio_num, isOutput);
-
- rtw_ps_deny(adapter, PS_DENY_IOCTL);
-
- LeaveAllPowerSaveModeDirect(adapter);
-
- if (isOutput)
- rtw_write8(adapter, REG_GPIO_PIN_CTRL + 2, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) | BIT(gpio_num));
- else
- rtw_write8(adapter, REG_GPIO_PIN_CTRL + 2, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) & ~BIT(gpio_num));
-
- rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL);
-
- return 0;
-}
-EXPORT_SYMBOL(rtw_config_gpio);
-#endif
-
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-void rtw_get_current_ip_address(struct adapter *padapter, u8 *pcurrentip)
-{
- struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- struct in_device *my_ip_ptr = padapter->pnetdev->ip_ptr;
- u8 ipaddress[4];
-
- if ((pmlmeinfo->state & WIFI_FW_LINKING_STATE) ||
- pmlmeinfo->state & WIFI_FW_AP_STATE) {
- if (my_ip_ptr) {
- struct in_ifaddr *my_ifa_list = my_ip_ptr->ifa_list;
-
- if (my_ifa_list) {
- ipaddress[0] = my_ifa_list->ifa_address & 0xFF;
- ipaddress[1] = (my_ifa_list->ifa_address >> 8) & 0xFF;
- ipaddress[2] = (my_ifa_list->ifa_address >> 16) & 0xFF;
- ipaddress[3] = my_ifa_list->ifa_address >> 24;
- DBG_871X("%s: %d.%d.%d.%d ==========\n", __func__,
- ipaddress[0], ipaddress[1], ipaddress[2], ipaddress[3]);
- memcpy(pcurrentip, ipaddress, 4);
- }
- }
- }
-}
-#endif
-#ifdef CONFIG_WOWLAN
-void rtw_get_sec_iv(struct adapter *padapter, u8 *pcur_dot11txpn, u8 *StaAddr)
-{
- struct sta_info *psta;
- struct security_priv *psecpriv = &padapter->securitypriv;
-
- memset(pcur_dot11txpn, 0, 8);
- if (NULL == StaAddr)
- return;
- psta = rtw_get_stainfo(&padapter->stapriv, StaAddr);
- DBG_871X("%s(): StaAddr: %02x %02x %02x %02x %02x %02x\n",
- __func__, StaAddr[0], StaAddr[1], StaAddr[2],
- StaAddr[3], StaAddr[4], StaAddr[5]);
-
- if (psta) {
- if (psecpriv->dot11PrivacyAlgrthm != _NO_PRIVACY_ && psta->dot11txpn.val > 0)
- psta->dot11txpn.val--;
- AES_IV(pcur_dot11txpn, psta->dot11txpn, 0);
-
- DBG_871X("%s(): CurrentIV: %02x %02x %02x %02x %02x %02x %02x %02x\n"
- , __func__, pcur_dot11txpn[0], pcur_dot11txpn[1],
- pcur_dot11txpn[2], pcur_dot11txpn[3], pcur_dot11txpn[4],
- pcur_dot11txpn[5], pcur_dot11txpn[6], pcur_dot11txpn[7]);
- }
-}
-
-void rtw_set_sec_pn(struct adapter *padapter)
-{
- struct sta_info *psta;
- struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
- struct security_priv *psecpriv = &padapter->securitypriv;
-
- psta = rtw_get_stainfo(&padapter->stapriv,
- get_my_bssid(&pmlmeinfo->network));
-
- if (psta) {
- if (pwrpriv->wowlan_fw_iv > psta->dot11txpn.val) {
- if (psecpriv->dot11PrivacyAlgrthm != _NO_PRIVACY_)
- psta->dot11txpn.val = pwrpriv->wowlan_fw_iv + 2;
- } else {
- DBG_871X("%s(): FW IV is smaller than driver\n", __func__);
- psta->dot11txpn.val += 2;
- }
- DBG_871X("%s: dot11txpn: 0x%016llx\n", __func__, psta->dot11txpn.val);
- }
-}
-#endif /* CONFIG_WOWLAN */
-
-#ifdef CONFIG_PNO_SUPPORT
-#define CSCAN_TLV_TYPE_SSID_IE 'S'
-#define CIPHER_IE "key_mgmt ="
-#define CIPHER_NONE "NONE"
-#define CIPHER_WPA_PSK "WPA-PSK"
-#define CIPHER_WPA_EAP "WPA-EAP IEEE8021X"
-
-#endif /* CONFIG_PNO_SUPPORT */
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 41632fa0b3c8..bd3acdd7d75f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -38,7 +38,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
int i;
struct xmit_buf *pxmitbuf;
struct xmit_frame *pxframe;
- sint res = _SUCCESS;
+ signed int res = _SUCCESS;
spin_lock_init(&pxmitpriv->lock);
spin_lock_init(&pxmitpriv->lock_sctx);
@@ -46,8 +46,8 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
init_completion(&pxmitpriv->terminate_xmitthread_comp);
/*
- Please insert all the queue initializaiton using _rtw_init_queue below
- */
+ * Please insert all the queue initializaiton using _rtw_init_queue below
+ */
pxmitpriv->adapter = padapter;
@@ -60,16 +60,15 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
_rtw_init_queue(&pxmitpriv->free_xmit_queue);
/*
- Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME,
- and initialize free_xmit_frame below.
- Please also apply free_txobj to link_up all the xmit_frames...
- */
+ * Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME,
+ * and initialize free_xmit_frame below.
+ * Please also apply free_txobj to link_up all the xmit_frames...
+ */
pxmitpriv->pallocated_frame_buf = vzalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4);
if (!pxmitpriv->pallocated_frame_buf) {
pxmitpriv->pxmit_frame_buf = NULL;
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_frame fail!\n"));
res = _FAIL;
goto exit;
}
@@ -105,7 +104,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4);
if (!pxmitpriv->pallocated_xmitbuf) {
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_buf fail!\n"));
res = _FAIL;
goto exit;
}
@@ -155,7 +153,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
if (!pxmitpriv->xframe_ext_alloc_addr) {
pxmitpriv->xframe_ext = NULL;
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xframe_ext fail!\n"));
res = _FAIL;
goto exit;
}
@@ -188,7 +185,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
pxmitpriv->pallocated_xmit_extbuf = vzalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_buf) + 4);
if (!pxmitpriv->pallocated_xmit_extbuf) {
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n"));
res = _FAIL;
goto exit;
}
@@ -467,34 +463,23 @@ static void update_attrib_phy_info(struct adapter *padapter, struct pkt_attrib *
pattrib->ampdu_spacing = psta->htpriv.rx_ampdu_min_spacing;
pattrib->retry_ctrl = false;
-
-#ifdef CONFIG_AUTO_AP_MODE
- if (psta->isrc && psta->pid > 0)
- pattrib->pctrl = true;
-#endif
}
static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *pattrib, struct sta_info *psta)
{
- sint res = _SUCCESS;
+ signed int res = _SUCCESS;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct security_priv *psecuritypriv = &padapter->securitypriv;
- sint bmcast = IS_MCAST(pattrib->ra);
+ signed int bmcast = IS_MCAST(pattrib->ra);
memset(pattrib->dot118021x_UncstKey.skey, 0, 16);
memset(pattrib->dot11tkiptxmickey.skey, 0, 16);
pattrib->mac_id = psta->mac_id;
if (psta->ieee8021x_blocked == true) {
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\n psta->ieee8021x_blocked == true\n"));
-
pattrib->encrypt = 0;
if ((pattrib->ether_type != 0x888e) && (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false)) {
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\npsta->ieee8021x_blocked == true, pattrib->ether_type(%.4x) != 0x888e\n", pattrib->ether_type));
- #ifdef DBG_TX_DROP_FRAME
- DBG_871X("DBG_TX_DROP_FRAME %s psta->ieee8021x_blocked == true, pattrib->ether_type(%04x) != 0x888e\n", __func__, pattrib->ether_type);
- #endif
res = _FAIL;
goto exit;
}
@@ -536,9 +521,6 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p
pattrib->icv_len = 4;
if (psecuritypriv->busetkipkey == _FAIL) {
- #ifdef DBG_TX_DROP_FRAME
- DBG_871X("DBG_TX_DROP_FRAME %s psecuritypriv->busetkipkey(%d) == _FAIL drop packet\n", __func__, psecuritypriv->busetkipkey);
- #endif
res = _FAIL;
goto exit;
}
@@ -573,20 +555,11 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p
if (pattrib->encrypt > 0)
memcpy(pattrib->dot118021x_UncstKey.skey, psta->dot118021x_UncstKey.skey, 16);
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
- ("update_attrib: encrypt =%d securitypriv.sw_encrypt =%d\n",
- pattrib->encrypt, padapter->securitypriv.sw_encrypt));
-
if (pattrib->encrypt &&
- ((padapter->securitypriv.sw_encrypt == true) || (psecuritypriv->hw_decrypted == false))) {
+ ((padapter->securitypriv.sw_encrypt) || (!psecuritypriv->hw_decrypted)))
pattrib->bswenc = true;
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
- ("update_attrib: encrypt =%d securitypriv.hw_decrypted =%d bswenc =true\n",
- pattrib->encrypt, padapter->securitypriv.sw_encrypt));
- } else {
+ else
pattrib->bswenc = false;
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("update_attrib: bswenc =false\n"));
- }
exit:
@@ -615,7 +588,6 @@ u8 qos_acm(u8 acm_mask, u8 priority)
priority = 5;
break;
default:
- DBG_871X("qos_acm(): invalid pattrib->priority: %d!!!\n", priority);
break;
}
@@ -641,19 +613,17 @@ static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib)
pattrib->subtype = WIFI_QOS_DATA_TYPE;
}
-static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib *pattrib)
+static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct pkt_attrib *pattrib)
{
struct pkt_file pktfile;
struct sta_info *psta = NULL;
struct ethhdr etherhdr;
- sint bmcast;
+ signed int bmcast;
struct sta_priv *pstapriv = &padapter->stapriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
- sint res = _SUCCESS;
-
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib);
+ signed int res = _SUCCESS;
_rtw_open_pktfile(pkt, &pktfile);
_rtw_pktfile_read(&pktfile, (u8 *)&etherhdr, ETH_HLEN);
@@ -667,17 +637,12 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_adhoc);
} else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
memcpy(pattrib->ra, get_bssid(pmlmepriv), ETH_ALEN);
memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_sta);
} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN);
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_ap);
- } else {
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_unknown);
}
pattrib->pktlen = pktfile.pkt_len;
@@ -697,9 +662,7 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib
((tmp[21] == 67) && (tmp[23] == 68))) {
/* 68 : UDP BOOTP client */
/* 67 : UDP BOOTP server */
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("======================update_attrib: get DHCP Packet\n"));
pattrib->dhcp_pkt = 1;
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_dhcp);
}
}
}
@@ -709,13 +672,11 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib
struct iphdr *piphdr = (struct iphdr *)tmp;
pattrib->icmp_pkt = 0;
- if (piphdr->protocol == 0x1) { /* protocol type in ip header 0x1 is ICMP */
+ if (piphdr->protocol == 0x1) /* protocol type in ip header 0x1 is ICMP */
pattrib->icmp_pkt = 1;
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_icmp);
- }
}
} else if (0x888e == pattrib->ether_type) {
- DBG_871X_LEVEL(_drv_always_, "send eapol packet\n");
+ netdev_dbg(padapter->pnetdev, "send eapol packet\n");
}
if ((pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1))
@@ -724,10 +685,8 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib
/* If EAPOL , ARP , OR DHCP packet, driver must be in active mode. */
if (pattrib->icmp_pkt == 1)
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_LEAVE, 1);
- else if (pattrib->dhcp_pkt == 1) {
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_active);
+ else if (pattrib->dhcp_pkt == 1)
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SPECIAL_PACKET, 1);
- }
bmcast = IS_MCAST(pattrib->ra);
@@ -737,15 +696,9 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib
} else {
psta = rtw_get_stainfo(pstapriv, pattrib->ra);
if (!psta) { /* if we cannot get psta => drop the pkt */
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_ucast_sta);
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra:%pM\n", MAC_ARG(pattrib->ra)));
- #ifdef DBG_TX_DROP_FRAME
- DBG_871X("DBG_TX_DROP_FRAME %s get sta_info fail, ra:%pM\n", __func__, MAC_ARG(pattrib->ra));
- #endif
res = _FAIL;
goto exit;
} else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) && (!(psta->state & _FW_LINKED))) {
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_ucast_ap_link);
res = _FAIL;
goto exit;
}
@@ -753,24 +706,15 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib
if (!psta) {
/* if we cannot get psta => drop the pkt */
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_sta);
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra:%pM\n", MAC_ARG(pattrib->ra)));
- #ifdef DBG_TX_DROP_FRAME
- DBG_871X("DBG_TX_DROP_FRAME %s get sta_info fail, ra:%pM\n", __func__, MAC_ARG(pattrib->ra));
- #endif
res = _FAIL;
goto exit;
}
- if (!(psta->state & _FW_LINKED)) {
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_link);
- DBG_871X("%s, psta(%pM)->state(0x%x) != _FW_LINKED\n", __func__, MAC_ARG(psta->hwaddr), psta->state);
+ if (!(psta->state & _FW_LINKED))
return _FAIL;
- }
/* TODO:_lock */
if (update_attrib_sec_info(padapter, pattrib, psta) == _FAIL) {
- DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_sec);
res = _FAIL;
goto exit;
}
@@ -810,7 +754,7 @@ exit:
static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitframe)
{
- sint curfragnum, length;
+ signed int curfragnum, length;
u8 *pframe, *payload, mic[8];
struct mic_data micdata;
struct pkt_attrib *pattrib = &pxmitframe->attrib;
@@ -818,7 +762,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
u8 priority[4] = {0x0, 0x0, 0x0, 0x0};
u8 hw_hdr_offset = 0;
- sint bmcst = IS_MCAST(pattrib->ra);
+ signed int bmcst = IS_MCAST(pattrib->ra);
hw_hdr_offset = TXDESC_OFFSET;
@@ -846,7 +790,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr
if (pframe[1]&2) /* From Ds == 1 */
rtw_secmicappend(&micdata, &pframe[24], 6);
else
- rtw_secmicappend(&micdata, &pframe[10], 6);
+ rtw_secmicappend(&micdata, &pframe[10], 6);
} else { /* ToDS == 0 */
rtw_secmicappend(&micdata, &pframe[4], 6); /* DA */
if (pframe[1]&2) /* From Ds == 1 */
@@ -864,11 +808,8 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr
for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
payload = (u8 *)round_up((SIZE_PTR)(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)));
-
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));
+
if ((curfragnum+1) == pattrib->nr_frags) {
length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0);
rtw_secmicappend(&micdata, payload, length);
@@ -877,29 +818,14 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr
length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0);
rtw_secmicappend(&micdata, payload, length);
payload = payload+length+pattrib->icv_len;
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("curfragnum =%d length =%d pattrib->icv_len =%d", curfragnum, length, pattrib->icv_len));
}
}
rtw_secgetmic(&micdata, &mic[0]);
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("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));
- 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]));
/* add mic code and add the mic code length in last_txcmdsz */
memcpy(payload, &mic[0], 8);
pattrib->last_txcmdsz += 8;
-
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("\n ========last pkt ========\n"));
- payload = payload-pattrib->last_txcmdsz+8;
- for (curfragnum = 0; curfragnum < pattrib->last_txcmdsz; 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)));
}
-/*
-*/
}
return _SUCCESS;
}
@@ -909,7 +835,6 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi
struct pkt_attrib *pattrib = &pxmitframe->attrib;
if (pattrib->bswenc) {
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("### xmitframe_swencrypt\n"));
switch (pattrib->encrypt) {
case _WEP40_:
case _WEP104_:
@@ -924,8 +849,6 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi
default:
break;
}
- } else {
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, ("### xmitframe_hwencrypt\n"));
}
return _SUCCESS;
@@ -939,7 +862,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
u8 qos_option = false;
- sint res = _SUCCESS;
+ signed int res = _SUCCESS;
__le16 *fctrl = &pwlanhdr->frame_control;
memset(hdr, 0, WLANHDR_OFFSET);
@@ -979,7 +902,6 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
if (pattrib->qos_en)
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)));
res = _FAIL;
goto exit;
}
@@ -1008,20 +930,14 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
struct sta_info *psta;
psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
- if (pattrib->psta != psta) {
- DBG_871X("%s, pattrib->psta(%p) != psta(%p)\n", __func__, pattrib->psta, psta);
+ if (pattrib->psta != psta)
return _FAIL;
- }
- if (!psta) {
- DBG_871X("%s, psta ==NUL\n", __func__);
+ if (!psta)
return _FAIL;
- }
- if (!(psta->state & _FW_LINKED)) {
- DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
+ if (!(psta->state & _FW_LINKED))
return _FAIL;
- }
if (psta) {
psta->sta_xmitpriv.txseq_tid[pattrib->priority]++;
@@ -1091,18 +1007,15 @@ u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib)
}
/*
-
-This sub-routine will perform all the following:
-
-1. remove 802.3 header.
-2. create wlan_header, based on the info in pxmitframe
-3. append sta's iv/ext-iv
-4. append LLC
-5. move frag chunk from pframe to pxmitframe->mem
-6. apply sw-encrypt, if necessary.
-
-*/
-s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe)
+ * This sub-routine will perform all the following:
+ * 1. remove 802.3 header.
+ * 2. create wlan_header, based on the info in pxmitframe
+ * 3. append sta's iv/ext-iv
+ * 4. append LLC
+ * 5. move frag chunk from pframe to pxmitframe->mem
+ * 6. apply sw-encrypt, if necessary.
+ */
+s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe)
{
struct pkt_file pktfile;
@@ -1122,10 +1035,8 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram
s32 bmcst = IS_MCAST(pattrib->ra);
s32 res = _SUCCESS;
- if (!pxmitframe->buf_addr) {
- DBG_8192C("==> %s buf_addr == NULL\n", __func__);
+ if (!pxmitframe->buf_addr)
return _FAIL;
- }
pbuf_start = pxmitframe->buf_addr;
@@ -1133,8 +1044,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram
mem_start = pbuf_start + hw_hdr_offset;
if (rtw_make_wlanhdr(padapter, mem_start, pattrib) == _FAIL) {
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("rtw_xmitframe_coalesce: rtw_make_wlanhdr fail; drop pkt\n"));
- DBG_8192C("rtw_xmitframe_coalesce: rtw_make_wlanhdr fail; drop pkt\n");
res = _FAIL;
goto exit;
}
@@ -1161,10 +1070,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram
if (pattrib->iv_len) {
memcpy(pframe, pattrib->iv, pattrib->iv_len);
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_,
- ("rtw_xmitframe_coalesce: 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;
@@ -1204,8 +1109,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram
ClearMFrag(mem_start);
break;
- } else {
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("%s: There're still something in packet!\n", __func__));
}
addr = (SIZE_PTR)(pframe);
@@ -1215,8 +1118,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram
}
if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) {
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n"));
- DBG_8192C("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n");
res = _FAIL;
goto exit;
}
@@ -1233,7 +1134,7 @@ exit:
}
/* broadcast or multicast management pkt use BIP, unicast management pkt use CCMP encryption */
-s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe)
+s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe)
{
u8 *pframe, *mem_start = NULL, *tmp_buf = NULL;
u8 subtype;
@@ -1266,10 +1167,9 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit
goto xmitframe_coalesce_success;
/* IGTK key is not install, it may not support 802.11w */
- if (padapter->securitypriv.binstallBIPkey != true) {
- DBG_871X("no instll BIP key\n");
+ if (!padapter->securitypriv.binstallBIPkey)
goto xmitframe_coalesce_success;
- }
+
/* station mode doesn't need TX BIP, just ready the code */
if (bmcst) {
int frame_body_len;
@@ -1323,15 +1223,11 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit
else
psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
- if (!psta) {
- DBG_871X("%s, psta ==NUL\n", __func__);
+ if (!psta)
goto xmitframe_coalesce_fail;
- }
- if (!(psta->state & _FW_LINKED) || !pxmitframe->buf_addr) {
- DBG_871X("%s, not _FW_LINKED or addr null\n", __func__);
+ if (!(psta->state & _FW_LINKED) || !pxmitframe->buf_addr)
goto xmitframe_coalesce_fail;
- }
/* according 802.11-2012 standard, these five types are not robust types */
if (subtype == WIFI_ACTION &&
@@ -1433,7 +1329,7 @@ void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len)
{
uint protection;
u8 *perp;
- sint erp_len;
+ signed int erp_len;
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
struct registry_priv *pregistrypriv = &padapter->registrypriv;
@@ -1508,12 +1404,8 @@ static struct xmit_buf *__rtw_alloc_cmd_xmitbuf(struct xmit_priv *pxmitpriv,
pxmitbuf->agg_num = 0;
pxmitbuf->pg_num = 0;
- if (pxmitbuf->sctx) {
- DBG_871X("%s pxmitbuf->sctx is not NULL\n", __func__);
+ if (pxmitbuf->sctx)
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC);
- }
- } else {
- DBG_871X("%s fail, no xmitbuf available !!!\n", __func__);
}
return pxmitbuf;
@@ -1526,14 +1418,11 @@ struct xmit_frame *__rtw_alloc_cmdxmitframe(struct xmit_priv *pxmitpriv,
struct xmit_buf *pxmitbuf;
pcmdframe = rtw_alloc_xmitframe(pxmitpriv);
- if (!pcmdframe) {
- DBG_871X("%s, alloc xmitframe fail\n", __func__);
+ if (!pcmdframe)
return NULL;
- }
pxmitbuf = __rtw_alloc_cmd_xmitbuf(pxmitpriv, buf_type);
if (!pxmitbuf) {
- DBG_871X("%s, alloc xmitbuf fail\n", __func__);
rtw_free_xmitframe(pxmitpriv, pcmdframe);
return NULL;
}
@@ -1551,7 +1440,7 @@ struct xmit_frame *__rtw_alloc_cmdxmitframe(struct xmit_priv *pxmitpriv,
struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv)
{
- _irqL irqL;
+ unsigned long irqL;
struct xmit_buf *pxmitbuf = NULL;
struct list_head *plist, *phead;
struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue;
@@ -1572,9 +1461,6 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv)
if (pxmitbuf) {
pxmitpriv->free_xmit_extbuf_cnt--;
- #ifdef DBG_XMIT_BUF_EXT
- DBG_871X("DBG_XMIT_BUF_EXT ALLOC no =%d, free_xmit_extbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmit_extbuf_cnt);
- #endif
pxmitbuf->priv_data = NULL;
@@ -1582,10 +1468,8 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv)
pxmitbuf->pdata = pxmitbuf->ptail = pxmitbuf->phead;
pxmitbuf->agg_num = 1;
- if (pxmitbuf->sctx) {
- DBG_871X("%s pxmitbuf->sctx is not NULL\n", __func__);
+ if (pxmitbuf->sctx)
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC);
- }
}
spin_unlock_irqrestore(&pfree_queue->lock, irqL);
@@ -1595,7 +1479,7 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv)
s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
{
- _irqL irqL;
+ unsigned long irqL;
struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue;
if (!pxmitbuf)
@@ -1607,9 +1491,6 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
list_add_tail(&pxmitbuf->list, get_list_head(pfree_queue));
pxmitpriv->free_xmit_extbuf_cnt++;
- #ifdef DBG_XMIT_BUF_EXT
- DBG_871X("DBG_XMIT_BUF_EXT FREE no =%d, free_xmit_extbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmit_extbuf_cnt);
- #endif
spin_unlock_irqrestore(&pfree_queue->lock, irqL);
@@ -1618,7 +1499,7 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
{
- _irqL irqL;
+ unsigned long irqL;
struct xmit_buf *pxmitbuf = NULL;
struct list_head *plist, *phead;
struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
@@ -1639,9 +1520,6 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
if (pxmitbuf) {
pxmitpriv->free_xmitbuf_cnt--;
- #ifdef DBG_XMIT_BUF
- DBG_871X("DBG_XMIT_BUF ALLOC no =%d, free_xmitbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmitbuf_cnt);
- #endif
pxmitbuf->priv_data = NULL;
@@ -1650,15 +1528,9 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
pxmitbuf->agg_num = 0;
pxmitbuf->pg_num = 0;
- if (pxmitbuf->sctx) {
- DBG_871X("%s pxmitbuf->sctx is not NULL\n", __func__);
+ if (pxmitbuf->sctx)
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC);
- }
}
- #ifdef DBG_XMIT_BUF
- else
- DBG_871X("DBG_XMIT_BUF rtw_alloc_xmitbuf return NULL\n");
- #endif
spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irqL);
@@ -1667,16 +1539,14 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
{
- _irqL irqL;
+ unsigned long irqL;
struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
if (!pxmitbuf)
return _FAIL;
- if (pxmitbuf->sctx) {
- DBG_871X("%s pxmitbuf->sctx is not NULL\n", __func__);
+ if (pxmitbuf->sctx)
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_FREE);
- }
if (pxmitbuf->buf_tag == XMITBUF_CMD) {
} else if (pxmitbuf->buf_tag == XMITBUF_MGNT) {
@@ -1690,9 +1560,6 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
get_list_head(pfree_xmitbuf_queue));
pxmitpriv->free_xmitbuf_cnt++;
- #ifdef DBG_XMIT_BUF
- DBG_871X("DBG_XMIT_BUF FREE no =%d, free_xmitbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmitbuf_cnt);
- #endif
spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irqL);
}
return _SUCCESS;
@@ -1715,23 +1582,22 @@ static void rtw_init_xmitframe(struct xmit_frame *pxframe)
}
/*
-Calling context:
-1. OS_TXENTRY
-2. RXENTRY (rx_thread or RX_ISR/RX_CallBack)
-
-If we turn on USE_RXTHREAD, then, no need for critical section.
-Otherwise, we must use _enter/_exit critical to protect free_xmit_queue...
-
-Must be very very cautious...
-
-*/
+ * Calling context:
+ * 1. OS_TXENTRY
+ * 2. RXENTRY (rx_thread or RX_ISR/RX_CallBack)
+ *
+ * If we turn on USE_RXTHREAD, then, no need for critical section.
+ * Otherwise, we must use _enter/_exit critical to protect free_xmit_queue...
+ *
+ * Must be very, very cautious...
+ */
struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pfree_xmit_queue) */
{
/*
- Please remember to use all the osdep_service api,
- and lock/unlock or _enter/_exit critical to protect
- pfree_xmit_queue
- */
+ * Please remember to use all the osdep_service api,
+ * and lock/unlock or _enter/_exit critical to protect
+ * pfree_xmit_queue
+ */
struct xmit_frame *pxframe = NULL;
struct list_head *plist, *phead;
@@ -1740,7 +1606,6 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf
spin_lock_bh(&pfree_xmit_queue->lock);
if (list_empty(&pfree_xmit_queue->queue)) {
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe:%d\n", pxmitpriv->free_xmitframe_cnt));
pxframe = NULL;
} else {
phead = get_list_head(pfree_xmit_queue);
@@ -1751,7 +1616,6 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf
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));
}
spin_unlock_bh(&pfree_xmit_queue->lock);
@@ -1769,7 +1633,6 @@ struct xmit_frame *rtw_alloc_xmitframe_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_xmitframe_ext:%d\n", pxmitpriv->free_xframe_ext_cnt));
pxframe = NULL;
} else {
phead = get_list_head(queue);
@@ -1778,7 +1641,6 @@ struct xmit_frame *rtw_alloc_xmitframe_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_xmitframe_ext():free_xmitframe_cnt =%d\n", pxmitpriv->free_xframe_ext_cnt));
}
spin_unlock_bh(&queue->lock);
@@ -1811,8 +1673,6 @@ struct xmit_frame *rtw_alloc_xmitframe_once(struct xmit_priv *pxmitpriv)
rtw_init_xmitframe(pxframe);
- DBG_871X("################## %s ##################\n", __func__);
-
exit:
return pxframe;
}
@@ -1821,12 +1681,10 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram
{
struct __queue *queue = NULL;
struct adapter *padapter = pxmitpriv->adapter;
- _pkt *pndis_pkt = NULL;
+ struct sk_buff *pndis_pkt = NULL;
- if (!pxmitframe) {
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("======rtw_free_xmitframe():pxmitframe == NULL!!!!!!!!!!\n"));
+ if (!pxmitframe)
goto exit;
- }
if (pxmitframe->pkt) {
pndis_pkt = pxmitframe->pkt;
@@ -1834,7 +1692,6 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram
}
if (pxmitframe->alloc_addr) {
- DBG_871X("################## %s with alloc_addr ##################\n", __func__);
kfree(pxmitframe->alloc_addr);
goto check_pkt_complete;
}
@@ -1850,14 +1707,10 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram
list_del_init(&pxmitframe->list);
list_add_tail(&pxmitframe->list, get_list_head(queue));
- if (pxmitframe->ext_tag == 0) {
+ if (pxmitframe->ext_tag == 0)
pxmitpriv->free_xmitframe_cnt++;
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_debug_, ("rtw_free_xmitframe():free_xmitframe_cnt =%d\n", pxmitpriv->free_xmitframe_cnt));
- } else if (pxmitframe->ext_tag == 1) {
+ else if (pxmitframe->ext_tag == 1)
pxmitpriv->free_xframe_ext_cnt++;
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_debug_, ("rtw_free_xmitframe():free_xframe_ext_cnt =%d\n", pxmitpriv->free_xframe_ext_cnt));
- } else {
- }
spin_unlock_bh(&queue->lock);
@@ -1892,17 +1745,13 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram
s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe)
{
- DBG_COUNTER(padapter->tx_logs.core_tx_enqueue);
- if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL) {
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
- ("rtw_xmitframe_enqueue: drop xmit pkt for classifier fail\n"));
+ if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL)
return _FAIL;
- }
return _SUCCESS;
}
-struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, sint up, u8 *ac)
+struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, signed int up, u8 *ac)
{
struct tx_servq *ptxservq = NULL;
@@ -1911,21 +1760,18 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *
case 2:
ptxservq = &psta->sta_xmitpriv.bk_q;
*(ac) = 3;
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : 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_pending : 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_pending : VO\n"));
break;
case 0:
@@ -1933,7 +1779,6 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *
default:
ptxservq = &psta->sta_xmitpriv.be_q;
*(ac) = 2;
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BE\n"));
break;
}
@@ -1951,30 +1796,19 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe)
struct tx_servq *ptxservq;
struct pkt_attrib *pattrib = &pxmitframe->attrib;
struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits;
- sint res = _SUCCESS;
-
- DBG_COUNTER(padapter->tx_logs.core_tx_enqueue_class);
+ signed int res = _SUCCESS;
psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
- if (pattrib->psta != psta) {
- DBG_COUNTER(padapter->tx_logs.core_tx_enqueue_class_err_sta);
- DBG_871X("%s, pattrib->psta(%p) != psta(%p)\n", __func__, pattrib->psta, psta);
+ if (pattrib->psta != psta)
return _FAIL;
- }
if (!psta) {
- DBG_COUNTER(padapter->tx_logs.core_tx_enqueue_class_err_nosta);
res = _FAIL;
- DBG_8192C("rtw_xmit_classifier: psta == NULL\n");
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("rtw_xmit_classifier: psta == NULL\n"));
goto exit;
}
- if (!(psta->state & _FW_LINKED)) {
- DBG_COUNTER(padapter->tx_logs.core_tx_enqueue_class_err_fwlink);
- DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
+ if (!(psta->state & _FW_LINKED))
return _FAIL;
- }
ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index));
@@ -2037,9 +1871,9 @@ void rtw_free_hwxmits(struct adapter *padapter)
kfree(pxmitpriv->hwxmits);
}
-void rtw_init_hwxmits(struct hw_xmit *phwxmit, sint entry)
+void rtw_init_hwxmits(struct hw_xmit *phwxmit, signed int entry)
{
- sint i;
+ signed int i;
for (i = 0; i < entry; i++, phwxmit++)
phwxmit->accnt = 0;
@@ -2087,7 +1921,6 @@ static void do_queue_select(struct adapter *padapter, struct pkt_attrib *pattrib
u8 qsel;
qsel = pattrib->priority;
- RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("### do_queue_select priority =%d , qsel = %d\n", pattrib->priority, qsel));
pattrib->qsel = qsel;
}
@@ -2100,7 +1933,7 @@ static void do_queue_select(struct adapter *padapter, struct pkt_attrib *pattrib
*0 success, hardware will handle this xmit frame(packet)
*<0 fail
*/
-s32 rtw_xmit(struct adapter *padapter, _pkt **ppkt)
+s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt)
{
static unsigned long start;
static u32 drop_cnt;
@@ -2110,34 +1943,24 @@ s32 rtw_xmit(struct adapter *padapter, _pkt **ppkt)
s32 res;
- DBG_COUNTER(padapter->tx_logs.core_tx);
-
if (start == 0)
start = jiffies;
pxmitframe = rtw_alloc_xmitframe(pxmitpriv);
if (jiffies_to_msecs(jiffies - start) > 2000) {
- if (drop_cnt)
- DBG_871X("DBG_TX_DROP_FRAME %s no more pxmitframe, drop_cnt:%u\n", __func__, drop_cnt);
start = jiffies;
drop_cnt = 0;
}
if (!pxmitframe) {
drop_cnt++;
- RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("%s: no more pxmitframe\n", __func__));
- DBG_COUNTER(padapter->tx_logs.core_tx_err_pxmitframe);
return -1;
}
res = update_attrib(padapter, *ppkt, &pxmitframe->attrib);
if (res == _FAIL) {
- RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("%s: update attrib fail\n", __func__));
- #ifdef DBG_TX_DROP_FRAME
- DBG_871X("DBG_TX_DROP_FRAME %s update attrib fail\n", __func__);
- #endif
rtw_free_xmitframe(pxmitpriv, pxmitframe);
return -1;
}
@@ -2148,7 +1971,6 @@ s32 rtw_xmit(struct adapter *padapter, _pkt **ppkt)
spin_lock_bh(&pxmitpriv->lock);
if (xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe) == true) {
spin_unlock_bh(&pxmitpriv->lock);
- DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue);
return 1;
}
spin_unlock_bh(&pxmitpriv->lock);
@@ -2176,11 +1998,9 @@ inline bool xmitframe_hiq_filter(struct xmit_frame *xmitframe)
if (attrib->ether_type == 0x0806 ||
attrib->ether_type == 0x888e ||
attrib->dhcp_pkt
- ) {
- DBG_871X(FUNC_ADPT_FMT" ether_type:0x%04x%s\n", FUNC_ADPT_ARG(xmitframe->padapter)
- , attrib->ether_type, attrib->dhcp_pkt?" DHCP":"");
+ )
allow = true;
- }
+
} else if (registry->hiq_filter == RTW_HIQ_FILTER_ALLOW_ALL)
allow = true;
else if (registry->hiq_filter == RTW_HIQ_FILTER_DENY_ALL) {
@@ -2190,42 +2010,29 @@ inline bool xmitframe_hiq_filter(struct xmit_frame *xmitframe)
return allow;
}
-sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe)
+signed int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe)
{
- sint ret = false;
+ signed int ret = false;
struct sta_info *psta = NULL;
struct sta_priv *pstapriv = &padapter->stapriv;
struct pkt_attrib *pattrib = &pxmitframe->attrib;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- sint bmcst = IS_MCAST(pattrib->ra);
+ signed int bmcst = IS_MCAST(pattrib->ra);
bool update_tim = false;
- if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == false) {
- DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_fwstate);
+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == false)
return ret;
- }
psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
- if (pattrib->psta != psta) {
- DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_sta);
- DBG_871X("%s, pattrib->psta(%p) != psta(%p)\n", __func__, pattrib->psta, psta);
+ if (pattrib->psta != psta)
return false;
- }
- if (!psta) {
- DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_nosta);
- DBG_871X("%s, psta ==NUL\n", __func__);
+ if (!psta)
return false;
- }
- if (!(psta->state & _FW_LINKED)) {
- DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_link);
- DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
+ if (!(psta->state & _FW_LINKED))
return false;
- }
if (pattrib->triggered == 1) {
- DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_trigger);
-
if (bmcst && xmitframe_hiq_filter(pxmitframe))
pattrib->qsel = 0x11;/* HIQ */
@@ -2256,8 +2063,6 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr
chk_bmc_sleepq_cmd(padapter);
ret = true;
-
- DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_mcast);
}
spin_unlock_bh(&psta->sleep_q.lock);
@@ -2312,8 +2117,6 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr
}
ret = true;
-
- DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_ucast);
}
}
@@ -2324,7 +2127,7 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr
static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struct sta_info *psta, struct __queue *pframequeue)
{
- sint ret;
+ signed int ret;
struct list_head *plist, *phead;
u8 ac_index;
struct tx_servq *ptxservq;
@@ -2469,7 +2272,6 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
psta->state ^= WIFI_SLEEP_STATE;
if (psta->state & WIFI_STA_ALIVE_CHK_STATE) {
- DBG_871X("%s alive check\n", __func__);
psta->expire_to = pstapriv->expire_to;
psta->state ^= WIFI_STA_ALIVE_CHK_STATE;
}
@@ -2677,10 +2479,10 @@ struct xmit_buf *dequeue_pending_xmitbuf_under_survey(struct xmit_priv *pxmitpri
return pxmitbuf;
}
-sint check_pending_xmitbuf(struct xmit_priv *pxmitpriv)
+signed int check_pending_xmitbuf(struct xmit_priv *pxmitpriv)
{
struct __queue *pqueue;
- sint ret = false;
+ signed int ret = false;
pqueue = &pxmitpriv->pending_xmitbuf_queue;
@@ -2729,13 +2531,11 @@ int rtw_sctx_wait(struct submit_ctx *sctx, const char *msg)
int status = 0;
expire = sctx->timeout_ms ? msecs_to_jiffies(sctx->timeout_ms) : MAX_SCHEDULE_TIMEOUT;
- if (!wait_for_completion_timeout(&sctx->done, expire)) {
+ if (!wait_for_completion_timeout(&sctx->done, expire))
/* timeout, do something?? */
status = RTW_SCTX_DONE_TIMEOUT;
- DBG_871X("%s timeout: %s\n", __func__, msg);
- } else {
+ else
status = sctx->status;
- }
if (status == RTW_SCTX_DONE_SUCCESS)
ret = _SUCCESS;
@@ -2743,26 +2543,9 @@ int rtw_sctx_wait(struct submit_ctx *sctx, const char *msg)
return ret;
}
-static bool rtw_sctx_chk_warning_status(int status)
-{
- switch (status) {
- case RTW_SCTX_DONE_UNKNOWN:
- case RTW_SCTX_DONE_BUF_ALLOC:
- case RTW_SCTX_DONE_BUF_FREE:
-
- case RTW_SCTX_DONE_DRV_STOP:
- case RTW_SCTX_DONE_DEV_REMOVE:
- return true;
- default:
- return false;
- }
-}
-
void rtw_sctx_done_err(struct submit_ctx **sctx, int status)
{
if (*sctx) {
- if (rtw_sctx_chk_warning_status(status))
- DBG_871X("%s status:%d\n", __func__, status);
(*sctx)->status = status;
complete(&((*sctx)->done));
*sctx = NULL;
@@ -2791,6 +2574,4 @@ void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status)
if (pxmitpriv->ack_tx)
rtw_sctx_done_err(&pack_tx_ops, status);
- else
- DBG_871X("%s ack_tx not set\n", __func__);
}
diff --git a/drivers/staging/rtl8723bs/hal/Hal8723BReg.h b/drivers/staging/rtl8723bs/hal/Hal8723BReg.h
index b9aca99478db..6bf7933cbe4a 100644
--- a/drivers/staging/rtl8723bs/hal/Hal8723BReg.h
+++ b/drivers/staging/rtl8723bs/hal/Hal8723BReg.h
@@ -19,111 +19,109 @@
#ifndef __INC_HAL8723BREG_H
#define __INC_HAL8723BREG_H
-
-
/* */
/* */
/* */
/* */
/* */
-/* 0x0000h ~ 0x00FFh System Configuration */
+/* 0x0000h ~ 0x00FFh System Configuration */
/* */
/* */
#define REG_SYS_ISO_CTRL_8723B 0x0000 /* 2 Byte */
#define REG_SYS_FUNC_EN_8723B 0x0002 /* 2 Byte */
#define REG_APS_FSMCO_8723B 0x0004 /* 4 Byte */
-#define REG_SYS_CLKR_8723B 0x0008 /* 2 Byte */
-#define REG_9346CR_8723B 0x000A /* 2 Byte */
-#define REG_EE_VPD_8723B 0x000C /* 2 Byte */
-#define REG_AFE_MISC_8723B 0x0010 /* 1 Byte */
-#define REG_SPS0_CTRL_8723B 0x0011 /* 7 Byte */
+#define REG_SYS_CLKR_8723B 0x0008 /* 2 Byte */
+#define REG_9346CR_8723B 0x000A /* 2 Byte */
+#define REG_EE_VPD_8723B 0x000C /* 2 Byte */
+#define REG_AFE_MISC_8723B 0x0010 /* 1 Byte */
+#define REG_SPS0_CTRL_8723B 0x0011 /* 7 Byte */
#define REG_SPS_OCP_CFG_8723B 0x0018 /* 4 Byte */
-#define REG_RSV_CTRL_8723B 0x001C /* 3 Byte */
-#define REG_RF_CTRL_8723B 0x001F /* 1 Byte */
+#define REG_RSV_CTRL_8723B 0x001C /* 3 Byte */
+#define REG_RF_CTRL_8723B 0x001F /* 1 Byte */
#define REG_LPLDO_CTRL_8723B 0x0023 /* 1 Byte */
-#define REG_AFE_XTAL_CTRL_8723B 0x0024 /* 4 Byte */
+#define REG_AFE_XTAL_CTRL_8723B 0x0024 /* 4 Byte */
#define REG_AFE_PLL_CTRL_8723B 0x0028 /* 4 Byte */
#define REG_MAC_PLL_CTRL_EXT_8723B 0x002c /* 4 Byte */
#define REG_EFUSE_CTRL_8723B 0x0030
#define REG_EFUSE_TEST_8723B 0x0034
-#define REG_PWR_DATA_8723B 0x0038
-#define REG_CAL_TIMER_8723B 0x003C
-#define REG_ACLK_MON_8723B 0x003E
+#define REG_PWR_DATA_8723B 0x0038
+#define REG_CAL_TIMER_8723B 0x003C
+#define REG_ACLK_MON_8723B 0x003E
#define REG_GPIO_MUXCFG_8723B 0x0040
#define REG_GPIO_IO_SEL_8723B 0x0042
#define REG_MAC_PINMUX_CFG_8723B 0x0043
#define REG_GPIO_PIN_CTRL_8723B 0x0044
-#define REG_GPIO_INTM_8723B 0x0048
-#define REG_LEDCFG0_8723B 0x004C
-#define REG_LEDCFG1_8723B 0x004D
-#define REG_LEDCFG2_8723B 0x004E
-#define REG_LEDCFG3_8723B 0x004F
-#define REG_FSIMR_8723B 0x0050
-#define REG_FSISR_8723B 0x0054
-#define REG_HSIMR_8723B 0x0058
-#define REG_HSISR_8723B 0x005c
-#define REG_GPIO_EXT_CTRL 0x0060
+#define REG_GPIO_INTM_8723B 0x0048
+#define REG_LEDCFG0_8723B 0x004C
+#define REG_LEDCFG1_8723B 0x004D
+#define REG_LEDCFG2_8723B 0x004E
+#define REG_LEDCFG3_8723B 0x004F
+#define REG_FSIMR_8723B 0x0050
+#define REG_FSISR_8723B 0x0054
+#define REG_HSIMR_8723B 0x0058
+#define REG_HSISR_8723B 0x005c
+#define REG_GPIO_EXT_CTRL 0x0060
#define REG_MULTI_FUNC_CTRL_8723B 0x0068
#define REG_GPIO_STATUS_8723B 0x006C
-#define REG_SDIO_CTRL_8723B 0x0070
-#define REG_OPT_CTRL_8723B 0x0074
-#define REG_AFE_XTAL_CTRL_EXT_8723B 0x0078
-#define REG_MCUFWDL_8723B 0x0080
+#define REG_SDIO_CTRL_8723B 0x0070
+#define REG_OPT_CTRL_8723B 0x0074
+#define REG_AFE_XTAL_CTRL_EXT_8723B 0x0078
+#define REG_MCUFWDL_8723B 0x0080
#define REG_BT_PATCH_STATUS_8723B 0x0088
-#define REG_HIMR0_8723B 0x00B0
-#define REG_HISR0_8723B 0x00B4
-#define REG_HIMR1_8723B 0x00B8
-#define REG_HISR1_8723B 0x00BC
+#define REG_HIMR0_8723B 0x00B0
+#define REG_HISR0_8723B 0x00B4
+#define REG_HIMR1_8723B 0x00B8
+#define REG_HISR1_8723B 0x00BC
#define REG_PMC_DBG_CTRL2_8723B 0x00CC
#define REG_EFUSE_BURN_GNT_8723B 0x00CF
-#define REG_HPON_FSM_8723B 0x00EC
-#define REG_SYS_CFG_8723B 0x00F0
-#define REG_SYS_CFG1_8723B 0x00FC
-#define REG_ROM_VERSION 0x00FD
+#define REG_HPON_FSM_8723B 0x00EC
+#define REG_SYS_CFG_8723B 0x00F0
+#define REG_SYS_CFG1_8723B 0x00FC
+#define REG_ROM_VERSION 0x00FD
/* */
/* */
-/* 0x0100h ~ 0x01FFh MACTOP General Configuration */
+/* 0x0100h ~ 0x01FFh MACTOP General Configuration */
/* */
/* */
-#define REG_CR_8723B 0x0100
-#define REG_PBP_8723B 0x0104
-#define REG_PKT_BUFF_ACCESS_CTRL_8723B 0x0106
+#define REG_CR_8723B 0x0100
+#define REG_PBP_8723B 0x0104
+#define REG_PKT_BUFF_ACCESS_CTRL_8723B 0x0106
#define REG_TRXDMA_CTRL_8723B 0x010C
#define REG_TRXFF_BNDY_8723B 0x0114
#define REG_TRXFF_STATUS_8723B 0x0118
-#define REG_RXFF_PTR_8723B 0x011C
-#define REG_CPWM_8723B 0x012F
-#define REG_FWIMR_8723B 0x0130
-#define REG_FWISR_8723B 0x0134
-#define REG_FTIMR_8723B 0x0138
+#define REG_RXFF_PTR_8723B 0x011C
+#define REG_CPWM_8723B 0x012F
+#define REG_FWIMR_8723B 0x0130
+#define REG_FWISR_8723B 0x0134
+#define REG_FTIMR_8723B 0x0138
#define REG_PKTBUF_DBG_CTRL_8723B 0x0140
-#define REG_RXPKTBUF_CTRL_8723B 0x0142
-#define REG_PKTBUF_DBG_DATA_L_8723B 0x0144
-#define REG_PKTBUF_DBG_DATA_H_8723B 0x0148
-
-#define REG_TC0_CTRL_8723B 0x0150
-#define REG_TC1_CTRL_8723B 0x0154
-#define REG_TC2_CTRL_8723B 0x0158
-#define REG_TC3_CTRL_8723B 0x015C
-#define REG_TC4_CTRL_8723B 0x0160
+#define REG_RXPKTBUF_CTRL_8723B 0x0142
+#define REG_PKTBUF_DBG_DATA_L_8723B 0x0144
+#define REG_PKTBUF_DBG_DATA_H_8723B 0x0148
+
+#define REG_TC0_CTRL_8723B 0x0150
+#define REG_TC1_CTRL_8723B 0x0154
+#define REG_TC2_CTRL_8723B 0x0158
+#define REG_TC3_CTRL_8723B 0x015C
+#define REG_TC4_CTRL_8723B 0x0160
#define REG_TCUNIT_BASE_8723B 0x0164
-#define REG_RSVD3_8723B 0x0168
-#define REG_C2HEVT_MSG_NORMAL_8723B 0x01A0
-#define REG_C2HEVT_CMD_SEQ_88XX 0x01A1
-#define REG_C2hEVT_CMD_CONTENT_88XX 0x01A2
-#define REG_C2HEVT_CMD_LEN_88XX 0x01AE
+#define REG_RSVD3_8723B 0x0168
+#define REG_C2HEVT_MSG_NORMAL_8723B 0x01A0
+#define REG_C2HEVT_CMD_SEQ_88XX 0x01A1
+#define REG_C2HEVT_CMD_CONTENT_88XX 0x01A2
+#define REG_C2HEVT_CMD_LEN_88XX 0x01AE
#define REG_C2HEVT_CLEAR_8723B 0x01AF
-#define REG_MCUTST_1_8723B 0x01C0
-#define REG_MCUTST_WOWLAN_8723B 0x01C7
-#define REG_FMETHR_8723B 0x01C8
-#define REG_HMETFR_8723B 0x01CC
-#define REG_HMEBOX_0_8723B 0x01D0
-#define REG_HMEBOX_1_8723B 0x01D4
-#define REG_HMEBOX_2_8723B 0x01D8
-#define REG_HMEBOX_3_8723B 0x01DC
-#define REG_LLT_INIT_8723B 0x01E0
+#define REG_MCUTST_1_8723B 0x01C0
+#define REG_MCUTST_WOWLAN_8723B 0x01C7
+#define REG_FMETHR_8723B 0x01C8
+#define REG_HMETFR_8723B 0x01CC
+#define REG_HMEBOX_0_8723B 0x01D0
+#define REG_HMEBOX_1_8723B 0x01D4
+#define REG_HMEBOX_2_8723B 0x01D8
+#define REG_HMEBOX_3_8723B 0x01DC
+#define REG_LLT_INIT_8723B 0x01E0
#define REG_HMEBOX_EXT0_8723B 0x01F0
#define REG_HMEBOX_EXT1_8723B 0x01F4
#define REG_HMEBOX_EXT2_8723B 0x01F8
@@ -131,65 +129,63 @@
/* */
/* */
-/* 0x0200h ~ 0x027Fh TXDMA Configuration */
+/* 0x0200h ~ 0x027Fh TXDMA Configuration */
/* */
/* */
-#define REG_RQPN_8723B 0x0200
-#define REG_FIFOPAGE_8723B 0x0204
+#define REG_RQPN_8723B 0x0200
+#define REG_FIFOPAGE_8723B 0x0204
#define REG_DWBCN0_CTRL_8723B REG_TDECTRL
-#define REG_TXDMA_OFFSET_CHK_8723B 0x020C
-#define REG_TXDMA_STATUS_8723B 0x0210
+#define REG_TXDMA_OFFSET_CHK_8723B 0x020C
+#define REG_TXDMA_STATUS_8723B 0x0210
#define REG_RQPN_NPQ_8723B 0x0214
#define REG_DWBCN1_CTRL_8723B 0x0228
-
/* */
/* */
-/* 0x0280h ~ 0x02FFh RXDMA Configuration */
+/* 0x0280h ~ 0x02FFh RXDMA Configuration */
/* */
/* */
#define REG_RXDMA_AGG_PG_TH_8723B 0x0280
-#define REG_FW_UPD_RDPTR_8723B 0x0284 /* FW shall update this register before FW write RXPKT_RELEASE_POLL to 1 */
-#define REG_RXDMA_CONTROL_8723B 0x0286 /* Control the RX DMA. */
+#define REG_FW_UPD_RDPTR_8723B 0x0284 /* FW shall update this register before FW write RXPKT_RELEASE_POLL to 1 */
+#define REG_RXDMA_CONTROL_8723B 0x0286 /* Control the RX DMA. */
#define REG_RXPKT_NUM_8723B 0x0287 /* The number of packets in RXPKTBUF. */
#define REG_RXDMA_STATUS_8723B 0x0288
#define REG_RXDMA_PRO_8723B 0x0290
-#define REG_EARLY_MODE_CONTROL_8723B 0x02BC
-#define REG_RSVD5_8723B 0x02F0
-#define REG_RSVD6_8723B 0x02F4
-
+#define REG_EARLY_MODE_CONTROL_8723B 0x02BC
+#define REG_RSVD5_8723B 0x02F0
+#define REG_RSVD6_8723B 0x02F4
/* */
/* */
-/* 0x0300h ~ 0x03FFh PCIe */
+/* 0x0300h ~ 0x03FFh PCIe */
/* */
/* */
-#define REG_PCIE_CTRL_REG_8723B 0x0300
-#define REG_INT_MIG_8723B 0x0304 /* Interrupt Migration */
+#define REG_PCIE_CTRL_REG_8723B 0x0300
+#define REG_INT_MIG_8723B 0x0304 /* Interrupt Migration */
#define REG_BCNQ_DESA_8723B 0x0308 /* TX Beacon Descriptor Address */
-#define REG_HQ_DESA_8723B 0x0310 /* TX High Queue Descriptor Address */
+#define REG_HQ_DESA_8723B 0x0310 /* TX High Queue Descriptor Address */
#define REG_MGQ_DESA_8723B 0x0318 /* TX Manage Queue Descriptor Address */
#define REG_VOQ_DESA_8723B 0x0320 /* TX VO Queue Descriptor Address */
-#define REG_VIQ_DESA_8723B 0x0328 /* TX VI Queue Descriptor Address */
+#define REG_VIQ_DESA_8723B 0x0328 /* TX VI Queue Descriptor Address */
#define REG_BEQ_DESA_8723B 0x0330 /* TX BE Queue Descriptor Address */
#define REG_BKQ_DESA_8723B 0x0338 /* TX BK Queue Descriptor Address */
-#define REG_RX_DESA_8723B 0x0340 /* RX Queue Descriptor Address */
+#define REG_RX_DESA_8723B 0x0340 /* RX Queue Descriptor Address */
#define REG_DBI_WDATA_8723B 0x0348 /* DBI Write Data */
#define REG_DBI_RDATA_8723B 0x034C /* DBI Read Data */
-#define REG_DBI_ADDR_8723B 0x0350 /* DBI Address */
-#define REG_DBI_FLAG_8723B 0x0352 /* DBI Read/Write Flag */
-#define REG_MDIO_WDATA_8723B 0x0354 /* MDIO for Write PCIE PHY */
+#define REG_DBI_ADDR_8723B 0x0350 /* DBI Address */
+#define REG_DBI_FLAG_8723B 0x0352 /* DBI Read/Write Flag */
+#define REG_MDIO_WDATA_8723B 0x0354 /* MDIO for Write PCIE PHY */
#define REG_MDIO_RDATA_8723B 0x0356 /* MDIO for Reads PCIE PHY */
#define REG_MDIO_CTL_8723B 0x0358 /* MDIO for Control */
-#define REG_DBG_SEL_8723B 0x0360 /* Debug Selection Register */
+#define REG_DBG_SEL_8723B 0x0360 /* Debug Selection Register */
#define REG_PCIE_HRPWM_8723B 0x0361 /* PCIe RPWM */
#define REG_PCIE_HCPWM_8723B 0x0363 /* PCIe CPWM */
-#define REG_PCIE_MULTIFET_CTRL_8723B 0x036A /* PCIE Multi-Fethc Control */
+#define REG_PCIE_MULTIFET_CTRL_8723B 0x036A /* PCIE Multi-Fethc Control */
/* spec version 11 */
/* */
/* */
-/* 0x0400h ~ 0x047Fh Protocol Configuration */
+/* 0x0400h ~ 0x047Fh Protocol Configuration */
/* */
/* */
#define REG_VOQ_INFORMATION_8723B 0x0400
@@ -198,75 +194,75 @@
#define REG_BKQ_INFORMATION_8723B 0x040C
#define REG_MGQ_INFORMATION_8723B 0x0410
#define REG_HGQ_INFORMATION_8723B 0x0414
-#define REG_BCNQ_INFORMATION_8723B 0x0418
+#define REG_BCNQ_INFORMATION_8723B 0x0418
#define REG_TXPKT_EMPTY_8723B 0x041A
-#define REG_FWHW_TXQ_CTRL_8723B 0x0420
+#define REG_FWHW_TXQ_CTRL_8723B 0x0420
#define REG_HWSEQ_CTRL_8723B 0x0423
-#define REG_TXPKTBUF_BCNQ_BDNY_8723B 0x0424
-#define REG_TXPKTBUF_MGQ_BDNY_8723B 0x0425
+#define REG_TXPKTBUF_BCNQ_BDNY_8723B 0x0424
+#define REG_TXPKTBUF_MGQ_BDNY_8723B 0x0425
#define REG_LIFECTRL_CTRL_8723B 0x0426
-#define REG_MULTI_BCNQ_OFFSET_8723B 0x0427
-#define REG_SPEC_SIFS_8723B 0x0428
-#define REG_RL_8723B 0x042A
-#define REG_TXBF_CTRL_8723B 0x042C
-#define REG_DARFRC_8723B 0x0430
-#define REG_RARFRC_8723B 0x0438
-#define REG_RRSR_8723B 0x0440
-#define REG_ARFR0_8723B 0x0444
-#define REG_ARFR1_8723B 0x044C
-#define REG_CCK_CHECK_8723B 0x0454
+#define REG_MULTI_BCNQ_OFFSET_8723B 0x0427
+#define REG_SPEC_SIFS_8723B 0x0428
+#define REG_RL_8723B 0x042A
+#define REG_TXBF_CTRL_8723B 0x042C
+#define REG_DARFRC_8723B 0x0430
+#define REG_RARFRC_8723B 0x0438
+#define REG_RRSR_8723B 0x0440
+#define REG_ARFR0_8723B 0x0444
+#define REG_ARFR1_8723B 0x044C
+#define REG_CCK_CHECK_8723B 0x0454
#define REG_AMPDU_MAX_TIME_8723B 0x0456
-#define REG_TXPKTBUF_BCNQ_BDNY1_8723B 0x0457
+#define REG_TXPKTBUF_BCNQ_BDNY1_8723B 0x0457
-#define REG_AMPDU_MAX_LENGTH_8723B 0x0458
+#define REG_AMPDU_MAX_LENGTH_8723B 0x0458
#define REG_TXPKTBUF_WMAC_LBK_BF_HD_8723B 0x045D
-#define REG_NDPA_OPT_CTRL_8723B 0x045F
+#define REG_NDPA_OPT_CTRL_8723B 0x045F
#define REG_FAST_EDCA_CTRL_8723B 0x0460
#define REG_RD_RESP_PKT_TH_8723B 0x0463
-#define REG_DATA_SC_8723B 0x0483
-#define REG_TXRPT_START_OFFSET 0x04AC
-#define REG_POWER_STAGE1_8723B 0x04B4
-#define REG_POWER_STAGE2_8723B 0x04B8
-#define REG_AMPDU_BURST_MODE_8723B 0x04BC
-#define REG_PKT_VO_VI_LIFE_TIME_8723B 0x04C0
-#define REG_PKT_BE_BK_LIFE_TIME_8723B 0x04C2
+#define REG_DATA_SC_8723B 0x0483
+#define REG_TXRPT_START_OFFSET 0x04AC
+#define REG_POWER_STAGE1_8723B 0x04B4
+#define REG_POWER_STAGE2_8723B 0x04B8
+#define REG_AMPDU_BURST_MODE_8723B 0x04BC
+#define REG_PKT_VO_VI_LIFE_TIME_8723B 0x04C0
+#define REG_PKT_BE_BK_LIFE_TIME_8723B 0x04C2
#define REG_STBC_SETTING_8723B 0x04C4
#define REG_HT_SINGLE_AMPDU_8723B 0x04C7
#define REG_PROT_MODE_CTRL_8723B 0x04C8
-#define REG_MAX_AGGR_NUM_8723B 0x04CA
-#define REG_RTS_MAX_AGGR_NUM_8723B 0x04CB
-#define REG_BAR_MODE_CTRL_8723B 0x04CC
-#define REG_RA_TRY_RATE_AGG_LMT_8723B 0x04CF
+#define REG_MAX_AGGR_NUM_8723B 0x04CA
+#define REG_RTS_MAX_AGGR_NUM_8723B 0x04CB
+#define REG_BAR_MODE_CTRL_8723B 0x04CC
+#define REG_RA_TRY_RATE_AGG_LMT_8723B 0x04CF
#define REG_MACID_PKT_DROP0_8723B 0x04D0
#define REG_MACID_PKT_SLEEP_8723B 0x04D4
/* */
/* */
-/* 0x0500h ~ 0x05FFh EDCA Configuration */
+/* 0x0500h ~ 0x05FFh EDCA Configuration */
/* */
/* */
-#define REG_EDCA_VO_PARAM_8723B 0x0500
-#define REG_EDCA_VI_PARAM_8723B 0x0504
-#define REG_EDCA_BE_PARAM_8723B 0x0508
-#define REG_EDCA_BK_PARAM_8723B 0x050C
-#define REG_BCNTCFG_8723B 0x0510
-#define REG_PIFS_8723B 0x0512
-#define REG_RDG_PIFS_8723B 0x0513
-#define REG_SIFS_CTX_8723B 0x0514
-#define REG_SIFS_TRX_8723B 0x0516
+#define REG_EDCA_VO_PARAM_8723B 0x0500
+#define REG_EDCA_VI_PARAM_8723B 0x0504
+#define REG_EDCA_BE_PARAM_8723B 0x0508
+#define REG_EDCA_BK_PARAM_8723B 0x050C
+#define REG_BCNTCFG_8723B 0x0510
+#define REG_PIFS_8723B 0x0512
+#define REG_RDG_PIFS_8723B 0x0513
+#define REG_SIFS_CTX_8723B 0x0514
+#define REG_SIFS_TRX_8723B 0x0516
#define REG_AGGR_BREAK_TIME_8723B 0x051A
-#define REG_SLOT_8723B 0x051B
+#define REG_SLOT_8723B 0x051B
#define REG_TX_PTCL_CTRL_8723B 0x0520
-#define REG_TXPAUSE_8723B 0x0522
-#define REG_DIS_TXREQ_CLR_8723B 0x0523
-#define REG_RD_CTRL_8723B 0x0524
+#define REG_TXPAUSE_8723B 0x0522
+#define REG_DIS_TXREQ_CLR_8723B 0x0523
+#define REG_RD_CTRL_8723B 0x0524
/* */
/* Format for offset 540h-542h: */
-/* [3:0]: TBTT prohibit setup in unit of 32us. The time for HW getting beacon content before TBTT. */
-/* [7:4]: Reserved. */
-/* [19:8]: TBTT prohibit hold in unit of 32us. The time for HW holding to send the beacon packet. */
-/* [23:20]: Reserved */
+/* [3:0]: TBTT prohibit setup in unit of 32us. The time for HW getting beacon content before TBTT. */
+/* [7:4]: Reserved. */
+/* [19:8]: TBTT prohibit hold in unit of 32us. The time for HW holding to send the beacon packet. */
+/* [23:20]: Reserved */
/* Description: */
/* | */
/* |<--Setup--|--Hold------------>| */
@@ -276,87 +272,86 @@
/* Note: We cannot update beacon content to HW or send any AC packets during the time between Setup and Hold. */
/* Described by Designer Tim and Bruce, 2011-01-14. */
/* */
-#define REG_TBTT_PROHIBIT_8723B 0x0540
-#define REG_RD_NAV_NXT_8723B 0x0544
-#define REG_NAV_PROT_LEN_8723B 0x0546
-#define REG_BCN_CTRL_8723B 0x0550
-#define REG_BCN_CTRL_1_8723B 0x0551
-#define REG_MBID_NUM_8723B 0x0552
-#define REG_DUAL_TSF_RST_8723B 0x0553
-#define REG_BCN_INTERVAL_8723B 0x0554
-#define REG_DRVERLYINT_8723B 0x0558
-#define REG_BCNDMATIM_8723B 0x0559
-#define REG_ATIMWND_8723B 0x055A
-#define REG_USTIME_TSF_8723B 0x055C
-#define REG_BCN_MAX_ERR_8723B 0x055D
-#define REG_RXTSF_OFFSET_CCK_8723B 0x055E
-#define REG_RXTSF_OFFSET_OFDM_8723B 0x055F
-#define REG_TSFTR_8723B 0x0560
-#define REG_CTWND_8723B 0x0572
-#define REG_SECONDARY_CCA_CTRL_8723B 0x0577
-#define REG_PSTIMER_8723B 0x0580
-#define REG_TIMER0_8723B 0x0584
-#define REG_TIMER1_8723B 0x0588
-#define REG_ACMHWCTRL_8723B 0x05C0
-#define REG_SCH_TXCMD_8723B 0x05F8
-
-/* 0x0600h ~ 0x07FFh WMAC Configuration */
-#define REG_MAC_CR_8723B 0x0600
-#define REG_TCR_8723B 0x0604
-#define REG_RCR_8723B 0x0608
-#define REG_RX_PKT_LIMIT_8723B 0x060C
-#define REG_RX_DLK_TIME_8723B 0x060D
-#define REG_RX_DRVINFO_SZ_8723B 0x060F
-
-#define REG_MACID_8723B 0x0610
-#define REG_BSSID_8723B 0x0618
-#define REG_MAR_8723B 0x0620
-#define REG_MBIDCAMCFG_8723B 0x0628
-
-#define REG_USTIME_EDCA_8723B 0x0638
-#define REG_MAC_SPEC_SIFS_8723B 0x063A
-#define REG_RESP_SIFP_CCK_8723B 0x063C
-#define REG_RESP_SIFS_OFDM_8723B 0x063E
-#define REG_ACKTO_8723B 0x0640
-#define REG_CTS2TO_8723B 0x0641
-#define REG_EIFS_8723B 0x0642
-
-#define REG_NAV_UPPER_8723B 0x0652 /* unit of 128 */
-#define REG_TRXPTCL_CTL_8723B 0x0668
+#define REG_TBTT_PROHIBIT_8723B 0x0540
+#define REG_RD_NAV_NXT_8723B 0x0544
+#define REG_NAV_PROT_LEN_8723B 0x0546
+#define REG_BCN_CTRL_8723B 0x0550
+#define REG_BCN_CTRL_1_8723B 0x0551
+#define REG_MBID_NUM_8723B 0x0552
+#define REG_DUAL_TSF_RST_8723B 0x0553
+#define REG_BCN_INTERVAL_8723B 0x0554
+#define REG_DRVERLYINT_8723B 0x0558
+#define REG_BCNDMATIM_8723B 0x0559
+#define REG_ATIMWND_8723B 0x055A
+#define REG_USTIME_TSF_8723B 0x055C
+#define REG_BCN_MAX_ERR_8723B 0x055D
+#define REG_RXTSF_OFFSET_CCK_8723B 0x055E
+#define REG_RXTSF_OFFSET_OFDM_8723B 0x055F
+#define REG_TSFTR_8723B 0x0560
+#define REG_CTWND_8723B 0x0572
+#define REG_SECONDARY_CCA_CTRL_8723B 0x0577
+#define REG_PSTIMER_8723B 0x0580
+#define REG_TIMER0_8723B 0x0584
+#define REG_TIMER1_8723B 0x0588
+#define REG_ACMHWCTRL_8723B 0x05C0
+#define REG_SCH_TXCMD_8723B 0x05F8
+
+/* 0x0600h ~ 0x07FFh WMAC Configuration */
+#define REG_MAC_CR_8723B 0x0600
+#define REG_TCR_8723B 0x0604
+#define REG_RCR_8723B 0x0608
+#define REG_RX_PKT_LIMIT_8723B 0x060C
+#define REG_RX_DLK_TIME_8723B 0x060D
+#define REG_RX_DRVINFO_SZ_8723B 0x060F
+
+#define REG_MACID_8723B 0x0610
+#define REG_BSSID_8723B 0x0618
+#define REG_MAR_8723B 0x0620
+#define REG_MBIDCAMCFG_8723B 0x0628
+
+#define REG_USTIME_EDCA_8723B 0x0638
+#define REG_MAC_SPEC_SIFS_8723B 0x063A
+#define REG_RESP_SIFP_CCK_8723B 0x063C
+#define REG_RESP_SIFS_OFDM_8723B 0x063E
+#define REG_ACKTO_8723B 0x0640
+#define REG_CTS2TO_8723B 0x0641
+#define REG_EIFS_8723B 0x0642
+
+#define REG_NAV_UPPER_8723B 0x0652 /* unit of 128 */
+#define REG_TRXPTCL_CTL_8723B 0x0668
/* Security */
-#define REG_CAMCMD_8723B 0x0670
-#define REG_CAMWRITE_8723B 0x0674
-#define REG_CAMREAD_8723B 0x0678
-#define REG_CAMDBG_8723B 0x067C
-#define REG_SECCFG_8723B 0x0680
+#define REG_CAMCMD_8723B 0x0670
+#define REG_CAMWRITE_8723B 0x0674
+#define REG_CAMREAD_8723B 0x0678
+#define REG_CAMDBG_8723B 0x067C
+#define REG_SECCFG_8723B 0x0680
/* Power */
-#define REG_WOW_CTRL_8723B 0x0690
-#define REG_PS_RX_INFO_8723B 0x0692
-#define REG_UAPSD_TID_8723B 0x0693
-#define REG_WKFMCAM_CMD_8723B 0x0698
-#define REG_WKFMCAM_NUM_8723B 0x0698
-#define REG_WKFMCAM_RWD_8723B 0x069C
-#define REG_RXFLTMAP0_8723B 0x06A0
-#define REG_RXFLTMAP1_8723B 0x06A2
-#define REG_RXFLTMAP2_8723B 0x06A4
-#define REG_BCN_PSR_RPT_8723B 0x06A8
-#define REG_BT_COEX_TABLE_8723B 0x06C0
-#define REG_BFMER0_INFO_8723B 0x06E4
-#define REG_BFMER1_INFO_8723B 0x06EC
-#define REG_CSI_RPT_PARAM_BW20_8723B 0x06F4
-#define REG_CSI_RPT_PARAM_BW40_8723B 0x06F8
-#define REG_CSI_RPT_PARAM_BW80_8723B 0x06FC
+#define REG_WOW_CTRL_8723B 0x0690
+#define REG_PS_RX_INFO_8723B 0x0692
+#define REG_UAPSD_TID_8723B 0x0693
+#define REG_WKFMCAM_CMD_8723B 0x0698
+#define REG_WKFMCAM_NUM_8723B 0x0698
+#define REG_WKFMCAM_RWD_8723B 0x069C
+#define REG_RXFLTMAP0_8723B 0x06A0
+#define REG_RXFLTMAP1_8723B 0x06A2
+#define REG_RXFLTMAP2_8723B 0x06A4
+#define REG_BCN_PSR_RPT_8723B 0x06A8
+#define REG_BT_COEX_TABLE_8723B 0x06C0
+#define REG_BFMER0_INFO_8723B 0x06E4
+#define REG_BFMER1_INFO_8723B 0x06EC
+#define REG_CSI_RPT_PARAM_BW20_8723B 0x06F4
+#define REG_CSI_RPT_PARAM_BW40_8723B 0x06F8
+#define REG_CSI_RPT_PARAM_BW80_8723B 0x06FC
/* Hardware Port 2 */
-#define REG_MACID1_8723B 0x0700
-#define REG_BSSID1_8723B 0x0708
-#define REG_BFMEE_SEL_8723B 0x0714
-#define REG_SND_PTCL_CTRL_8723B 0x0718
-
+#define REG_MACID1_8723B 0x0700
+#define REG_BSSID1_8723B 0x0708
+#define REG_BFMEE_SEL_8723B 0x0714
+#define REG_SND_PTCL_CTRL_8723B 0x0718
-/* Redifine 8192C register definition for compatibility */
+/* Redifine 8192C register definition for compatibility */
/* TODO: use these definition when using REG_xxx naming rule. */
/* NOTE: DO NOT Remove these definition. Use later. */
@@ -429,13 +424,13 @@
#define IMR_RXFOVW_8723B BIT8 /* Receive FIFO Overflow */
/* 2 ACMHWCTRL 0x05C0 */
-#define AcmHw_HwEn_8723B BIT(0)
-#define AcmHw_VoqEn_8723B BIT(1)
-#define AcmHw_ViqEn_8723B BIT(2)
-#define AcmHw_BeqEn_8723B BIT(3)
-#define AcmHw_VoqStatus_8723B BIT(5)
-#define AcmHw_ViqStatus_8723B BIT(6)
-#define AcmHw_BeqStatus_8723B BIT(7)
+#define ACMHW_HWEN_8723B BIT(0)
+#define ACMHW_VOQEN_8723B BIT(1)
+#define ACMHW_VIQEN_8723B BIT(2)
+#define ACMHW_BEQEN_8723B BIT(3)
+#define ACMHW_VOQSTATUS_8723B BIT(5)
+#define ACMHW_VIQSTATUS_8723B BIT(6)
+#define ACMHW_BEQSTATUS_8723B BIT(7)
/* 8195 (RCR) Receive Configuration Register (Offset 0x608, 32 bits) */
#define RCR_TCPOFLD_EN BIT25 /* Enable TCP checksum offload */
diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c
index c60e8c58d9cc..503790924532 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c
+++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c
@@ -8,10 +8,10 @@
#include "Mp_Precomp.h"
/* Global variables, these are static variables */
-static COEX_DM_8723B_1ANT GLCoexDm8723b1Ant;
-static PCOEX_DM_8723B_1ANT pCoexDm = &GLCoexDm8723b1Ant;
-static COEX_STA_8723B_1ANT GLCoexSta8723b1Ant;
-static PCOEX_STA_8723B_1ANT pCoexSta = &GLCoexSta8723b1Ant;
+static struct coex_dm_8723b_1ant GLCoexDm8723b1Ant;
+static struct coex_dm_8723b_1ant *pCoexDm = &GLCoexDm8723b1Ant;
+static struct coex_sta_8723b_1ant GLCoexSta8723b1Ant;
+static struct coex_sta_8723b_1ant *pCoexSta = &GLCoexSta8723b1Ant;
static const char *const GLBtInfoSrc8723b1Ant[] = {
"BT Info[wifi fw]",
@@ -38,7 +38,7 @@ static u8 halbtc8723b1ant_BtRssiState(
(pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
(pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
) {
- if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) {
+ if (btRssi >= (rssiThresh + BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) {
btRssiState = BTC_RSSI_STATE_HIGH;
BTC_PRINT(
@@ -85,7 +85,7 @@ static u8 halbtc8723b1ant_BtRssiState(
(pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
(pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
) {
- if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) {
+ if (btRssi >= (rssiThresh + BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) {
btRssiState = BTC_RSSI_STATE_MEDIUM;
BTC_PRINT(
BTC_MSG_ALGORITHM,
@@ -104,7 +104,7 @@ static u8 halbtc8723b1ant_BtRssiState(
(pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
(pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)
) {
- if (btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) {
+ if (btRssi >= (rssiThresh1 + BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) {
btRssiState = BTC_RSSI_STATE_HIGH;
BTC_PRINT(
BTC_MSG_ALGORITHM,
@@ -151,7 +151,7 @@ static u8 halbtc8723b1ant_BtRssiState(
}
static void halbtc8723b1ant_UpdateRaMask(
- PBTC_COEXIST pBtCoexist, bool bForceExec, u32 disRateMask
+ struct btc_coexist *pBtCoexist, bool bForceExec, u32 disRateMask
)
{
pCoexDm->curRaMask = disRateMask;
@@ -166,7 +166,7 @@ static void halbtc8723b1ant_UpdateRaMask(
}
static void halbtc8723b1ant_AutoRateFallbackRetry(
- PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
+ struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
)
{
bool bWifiUnderBMode = false;
@@ -204,7 +204,7 @@ static void halbtc8723b1ant_AutoRateFallbackRetry(
}
static void halbtc8723b1ant_RetryLimit(
- PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
+ struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
)
{
pCoexDm->curRetryLimitType = type;
@@ -231,7 +231,7 @@ static void halbtc8723b1ant_RetryLimit(
}
static void halbtc8723b1ant_AmpduMaxTime(
- PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
+ struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
)
{
pCoexDm->curAmpduTimeType = type;
@@ -257,7 +257,7 @@ static void halbtc8723b1ant_AmpduMaxTime(
}
static void halbtc8723b1ant_LimitedTx(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
bool bForceExec,
u8 raMaskType,
u8 arfrType,
@@ -285,7 +285,7 @@ static void halbtc8723b1ant_LimitedTx(
}
static void halbtc8723b1ant_LimitedRx(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
bool bForceExec,
bool bRejApAggPkt,
bool bBtCtrlAggBufSize,
@@ -314,7 +314,7 @@ static void halbtc8723b1ant_LimitedRx(
}
-static void halbtc8723b1ant_QueryBtInfo(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_QueryBtInfo(struct btc_coexist *pBtCoexist)
{
u8 H2C_Parameter[1] = {0};
@@ -331,7 +331,7 @@ static void halbtc8723b1ant_QueryBtInfo(PBTC_COEXIST pBtCoexist)
pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
}
-static void halbtc8723b1ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_MonitorBtCtr(struct btc_coexist *pBtCoexist)
{
u32 regHPTxRx, regLPTxRx, u4Tmp;
u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0;
@@ -353,11 +353,11 @@ static void halbtc8723b1ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
regHPTx = u4Tmp & bMaskLWord;
- regHPRx = (u4Tmp & bMaskHWord)>>16;
+ regHPRx = (u4Tmp & bMaskHWord) >> 16;
u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
regLPTx = u4Tmp & bMaskLWord;
- regLPRx = (u4Tmp & bMaskHWord)>>16;
+ regLPRx = (u4Tmp & bMaskHWord) >> 16;
pCoexSta->highPriorityTx = regHPTx;
pCoexSta->highPriorityRx = regHPRx;
@@ -392,7 +392,7 @@ static void halbtc8723b1ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
}
-static void halbtc8723b1ant_MonitorWiFiCtr(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_MonitorWiFiCtr(struct btc_coexist *pBtCoexist)
{
s32 wifiRssi = 0;
bool bWifiBusy = false, bWifiUnderBMode = false;
@@ -478,7 +478,7 @@ static void halbtc8723b1ant_MonitorWiFiCtr(PBTC_COEXIST pBtCoexist)
}
-static bool halbtc8723b1ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist)
+static bool halbtc8723b1ant_IsWifiStatusChanged(struct btc_coexist *pBtCoexist)
{
static bool bPreWifiBusy, bPreUnder4way, bPreBtHsOn;
bool bWifiBusy = false, bUnder4way = false, bBtHsOn = false;
@@ -513,9 +513,9 @@ static bool halbtc8723b1ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist)
return false;
}
-static void halbtc8723b1ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_UpdateBtLinkInfo(struct btc_coexist *pBtCoexist)
{
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
bool bBtHsOn = false;
pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
@@ -577,9 +577,9 @@ static void halbtc8723b1ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist)
pBtLinkInfo->bHidOnly = false;
}
-static u8 halbtc8723b1ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist)
+static u8 halbtc8723b1ant_ActionAlgorithm(struct btc_coexist *pBtCoexist)
{
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
bool bBtHsOn = false;
u8 algorithm = BT_8723B_1ANT_COEX_ALGO_UNDEFINED;
u8 numOfDiffProfile = 0;
@@ -805,7 +805,7 @@ static u8 halbtc8723b1ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist)
}
static void halbtc8723b1ant_SetSwPenaltyTxRateAdaptive(
- PBTC_COEXIST pBtCoexist, bool bLowPenaltyRa
+ struct btc_coexist *pBtCoexist, bool bLowPenaltyRa
)
{
u8 H2C_Parameter[6] = {0};
@@ -833,7 +833,7 @@ static void halbtc8723b1ant_SetSwPenaltyTxRateAdaptive(
}
static void halbtc8723b1ant_LowPenaltyRa(
- PBTC_COEXIST pBtCoexist, bool bForceExec, bool bLowPenaltyRa
+ struct btc_coexist *pBtCoexist, bool bForceExec, bool bLowPenaltyRa
)
{
pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
@@ -850,7 +850,7 @@ static void halbtc8723b1ant_LowPenaltyRa(
}
static void halbtc8723b1ant_SetCoexTable(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
u32 val0x6c0,
u32 val0x6c4,
u32 val0x6c8,
@@ -887,7 +887,7 @@ static void halbtc8723b1ant_SetCoexTable(
}
static void halbtc8723b1ant_CoexTable(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
bool bForceExec,
u32 val0x6c0,
u32 val0x6c4,
@@ -930,7 +930,7 @@ static void halbtc8723b1ant_CoexTable(
}
static void halbtc8723b1ant_CoexTableWithType(
- PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
+ struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
)
{
BTC_PRINT(
@@ -988,7 +988,7 @@ static void halbtc8723b1ant_CoexTableWithType(
}
static void halbtc8723b1ant_SetFwIgnoreWlanAct(
- PBTC_COEXIST pBtCoexist, bool bEnable
+ struct btc_coexist *pBtCoexist, bool bEnable
)
{
u8 H2C_Parameter[1] = {0};
@@ -1009,7 +1009,7 @@ static void halbtc8723b1ant_SetFwIgnoreWlanAct(
}
static void halbtc8723b1ant_IgnoreWlanAct(
- PBTC_COEXIST pBtCoexist, bool bForceExec, bool bEnable
+ struct btc_coexist *pBtCoexist, bool bForceExec, bool bEnable
)
{
BTC_PRINT(
@@ -1043,7 +1043,7 @@ static void halbtc8723b1ant_IgnoreWlanAct(
}
static void halbtc8723b1ant_SetLpsRpwm(
- PBTC_COEXIST pBtCoexist, u8 lpsVal, u8 rpwmVal
+ struct btc_coexist *pBtCoexist, u8 lpsVal, u8 rpwmVal
)
{
u8 lps = lpsVal;
@@ -1054,7 +1054,7 @@ static void halbtc8723b1ant_SetLpsRpwm(
}
static void halbtc8723b1ant_LpsRpwm(
- PBTC_COEXIST pBtCoexist, bool bForceExec, u8 lpsVal, u8 rpwmVal
+ struct btc_coexist *pBtCoexist, bool bForceExec, u8 lpsVal, u8 rpwmVal
)
{
BTC_PRINT(
@@ -1105,7 +1105,7 @@ static void halbtc8723b1ant_LpsRpwm(
}
static void halbtc8723b1ant_SwMechanism(
- PBTC_COEXIST pBtCoexist, bool bLowPenaltyRA
+ struct btc_coexist *pBtCoexist, bool bLowPenaltyRA
)
{
BTC_PRINT(
@@ -1118,10 +1118,10 @@ static void halbtc8723b1ant_SwMechanism(
}
static void halbtc8723b1ant_SetAntPath(
- PBTC_COEXIST pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
+ struct btc_coexist *pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
)
{
- PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
+ struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
u32 fwVer = 0, u4Tmp = 0, cntBtCalChk = 0;
bool bPgExtSwitch = false;
bool bUseExtSwitch = false;
@@ -1307,7 +1307,7 @@ static void halbtc8723b1ant_SetAntPath(
}
static void halbtc8723b1ant_SetFwPstdma(
- PBTC_COEXIST pBtCoexist, u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5
+ struct btc_coexist *pBtCoexist, u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5
)
{
u8 H2C_Parameter[5] = {0};
@@ -1317,7 +1317,7 @@ static void halbtc8723b1ant_SetFwPstdma(
pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
if (bApEnable) {
- if (byte1&BIT4 && !(byte1&BIT5)) {
+ if (byte1 & BIT4 && !(byte1 & BIT5)) {
BTC_PRINT(
BTC_MSG_INTERFACE,
INTF_NOTIFY,
@@ -1349,9 +1349,9 @@ static void halbtc8723b1ant_SetFwPstdma(
(
"[BTCoex], PS-TDMA H2C cmd = 0x%x%08x\n",
H2C_Parameter[0],
- H2C_Parameter[1]<<24|
- H2C_Parameter[2]<<16|
- H2C_Parameter[3]<<8|
+ H2C_Parameter[1] << 24 |
+ H2C_Parameter[2] << 16 |
+ H2C_Parameter[3] << 8 |
H2C_Parameter[4]
)
);
@@ -1361,10 +1361,10 @@ static void halbtc8723b1ant_SetFwPstdma(
static void halbtc8723b1ant_PsTdma(
- PBTC_COEXIST pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
+ struct btc_coexist *pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
)
{
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
bool bWifiBusy = false;
u8 rssiAdjustVal = 0;
u8 psTdmaByte4Val = 0x50, psTdmaByte0Val = 0x51, psTdmaByte3Val = 0x10;
@@ -1435,7 +1435,7 @@ static void halbtc8723b1ant_PsTdma(
halbtc8723b1ant_SetFwPstdma(
pBtCoexist,
psTdmaByte0Val,
- 0x3a+nWiFiDurationAdjust,
+ 0x3a + nWiFiDurationAdjust,
0x03,
psTdmaByte3Val,
psTdmaByte4Val
@@ -1445,7 +1445,7 @@ static void halbtc8723b1ant_PsTdma(
halbtc8723b1ant_SetFwPstdma(
pBtCoexist,
psTdmaByte0Val,
- 0x2d+nWiFiDurationAdjust,
+ 0x2d + nWiFiDurationAdjust,
0x03,
psTdmaByte3Val,
psTdmaByte4Val
@@ -1661,7 +1661,7 @@ static void halbtc8723b1ant_PsTdma(
pCoexDm->prePsTdma = pCoexDm->curPsTdma;
}
-static bool halbtc8723b1ant_IsCommonAction(PBTC_COEXIST pBtCoexist)
+static bool halbtc8723b1ant_IsCommonAction(struct btc_coexist *pBtCoexist)
{
bool bCommon = false, bWifiConnected = false, bWifiBusy = false;
@@ -1752,7 +1752,7 @@ static bool halbtc8723b1ant_IsCommonAction(PBTC_COEXIST pBtCoexist)
static void halbtc8723b1ant_TdmaDurationAdjustForAcl(
- PBTC_COEXIST pBtCoexist, u8 wifiStatus
+ struct btc_coexist *pBtCoexist, u8 wifiStatus
)
{
static s32 up, dn, m, n, WaitCount;
@@ -1855,7 +1855,7 @@ static void halbtc8723b1ant_TdmaDurationAdjustForAcl(
if (m >= 20) /* m 最大值 = 20 ' 最大120秒 recheck是否調整 WiFi duration. */
m = 20;
- n = 3*m;
+ n = 3 * m;
up = 0;
dn = 0;
WaitCount = 0;
@@ -1871,7 +1871,7 @@ static void halbtc8723b1ant_TdmaDurationAdjustForAcl(
if (m >= 20) /* m 最大值 = 20 ' 最大120秒 recheck是否調整 WiFi duration. */
m = 20;
- n = 3*m;
+ n = 3 * m;
up = 0;
dn = 0;
WaitCount = 0;
@@ -1941,7 +1941,7 @@ static void halbtc8723b1ant_TdmaDurationAdjustForAcl(
}
static void halbtc8723b1ant_PsTdmaCheckForPowerSaveState(
- PBTC_COEXIST pBtCoexist, bool bNewPsState
+ struct btc_coexist *pBtCoexist, bool bNewPsState
)
{
u8 lpsMode = 0x0;
@@ -1963,7 +1963,7 @@ static void halbtc8723b1ant_PsTdmaCheckForPowerSaveState(
}
static void halbtc8723b1ant_PowerSaveState(
- PBTC_COEXIST pBtCoexist, u8 psType, u8 lpsVal, u8 rpwmVal
+ struct btc_coexist *pBtCoexist, u8 psType, u8 lpsVal, u8 rpwmVal
)
{
bool bLowPwrDisable = false;
@@ -2011,7 +2011,7 @@ static void halbtc8723b1ant_PowerSaveState(
/* Non-Software Coex Mechanism start */
/* */
/* */
-static void halbtc8723b1ant_ActionWifiMultiPort(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_ActionWifiMultiPort(struct btc_coexist *pBtCoexist)
{
halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
@@ -2019,15 +2019,15 @@ static void halbtc8723b1ant_ActionWifiMultiPort(PBTC_COEXIST pBtCoexist)
halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
}
-static void halbtc8723b1ant_ActionHs(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_ActionHs(struct btc_coexist *pBtCoexist)
{
halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
}
-static void halbtc8723b1ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_ActionBtInquiry(struct btc_coexist *pBtCoexist)
{
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
bool bWifiConnected = false;
bool bApEnable = false;
bool bWifiBusy = false;
@@ -2067,10 +2067,10 @@ static void halbtc8723b1ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist)
}
static void halbtc8723b1ant_ActionBtScoHidOnlyBusy(
- PBTC_COEXIST pBtCoexist, u8 wifiStatus
+ struct btc_coexist *pBtCoexist, u8 wifiStatus
)
{
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
bool bWifiConnected = false;
pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
@@ -2087,13 +2087,11 @@ static void halbtc8723b1ant_ActionBtScoHidOnlyBusy(
}
static void halbtc8723b1ant_ActionWifiConnectedBtAclBusy(
- PBTC_COEXIST pBtCoexist, u8 wifiStatus
+ struct btc_coexist *pBtCoexist, u8 wifiStatus
)
{
- u8 btRssiState;
-
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
- btRssiState = halbtc8723b1ant_BtRssiState(2, 28, 0);
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ halbtc8723b1ant_BtRssiState(2, 28, 0);
if ((pCoexSta->lowPriorityRx >= 1000) && (pCoexSta->lowPriorityRx != 65535))
pBtLinkInfo->bSlaveRole = true;
@@ -2141,7 +2139,7 @@ static void halbtc8723b1ant_ActionWifiConnectedBtAclBusy(
}
}
-static void halbtc8723b1ant_ActionWifiNotConnected(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_ActionWifiNotConnected(struct btc_coexist *pBtCoexist)
{
/* power save state */
halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
@@ -2152,10 +2150,10 @@ static void halbtc8723b1ant_ActionWifiNotConnected(PBTC_COEXIST pBtCoexist)
}
static void halbtc8723b1ant_ActionWifiNotConnectedScan(
- PBTC_COEXIST pBtCoexist
+ struct btc_coexist *pBtCoexist
)
{
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
@@ -2186,10 +2184,10 @@ static void halbtc8723b1ant_ActionWifiNotConnectedScan(
}
static void halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(
- PBTC_COEXIST pBtCoexist
+ struct btc_coexist *pBtCoexist
)
{
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
@@ -2210,9 +2208,9 @@ static void halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(
}
}
-static void halbtc8723b1ant_ActionWifiConnectedScan(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_ActionWifiConnectedScan(struct btc_coexist *pBtCoexist)
{
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
@@ -2243,10 +2241,10 @@ static void halbtc8723b1ant_ActionWifiConnectedScan(PBTC_COEXIST pBtCoexist)
}
static void halbtc8723b1ant_ActionWifiConnectedSpecialPacket(
- PBTC_COEXIST pBtCoexist
+ struct btc_coexist *pBtCoexist
)
{
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
@@ -2267,7 +2265,7 @@ static void halbtc8723b1ant_ActionWifiConnectedSpecialPacket(
}
}
-static void halbtc8723b1ant_ActionWifiConnected(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_ActionWifiConnected(struct btc_coexist *pBtCoexist)
{
bool bWifiBusy = false;
bool bScan = false, bLink = false, bRoam = false;
@@ -2387,7 +2385,7 @@ static void halbtc8723b1ant_ActionWifiConnected(PBTC_COEXIST pBtCoexist)
}
}
-static void halbtc8723b1ant_RunSwCoexistMechanism(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_RunSwCoexistMechanism(struct btc_coexist *pBtCoexist)
{
u8 algorithm = 0;
@@ -2446,9 +2444,9 @@ static void halbtc8723b1ant_RunSwCoexistMechanism(PBTC_COEXIST pBtCoexist)
}
}
-static void halbtc8723b1ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_RunCoexistMechanism(struct btc_coexist *pBtCoexist)
{
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
bool bWifiConnected = false, bBtHsOn = false;
bool bIncreaseScanDevNum = false;
bool bBtCtrlAggBufSize = false;
@@ -2497,9 +2495,9 @@ static void halbtc8723b1ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
BTC_GET_U4_WIFI_LINK_STATUS,
&wifiLinkStatus
);
- numOfWifiLink = wifiLinkStatus>>16;
+ numOfWifiLink = wifiLinkStatus >> 16;
- if ((numOfWifiLink >= 2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED)) {
+ if ((numOfWifiLink >= 2) || (wifiLinkStatus & WIFI_P2P_GO_CONNECTED)) {
BTC_PRINT(
BTC_MSG_INTERFACE,
INTF_NOTIFY,
@@ -2579,7 +2577,7 @@ static void halbtc8723b1ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
halbtc8723b1ant_ActionWifiConnected(pBtCoexist);
}
-static void halbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b1ant_InitCoexDm(struct btc_coexist *pBtCoexist)
{
/* force to reset coex mechanism */
@@ -2593,7 +2591,7 @@ static void halbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
}
static void halbtc8723b1ant_InitHwConfig(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
bool bBackUp,
bool bWifiOnly
)
@@ -2648,9 +2646,9 @@ static void halbtc8723b1ant_InitHwConfig(
/* */
/* extern function start with EXhalbtc8723b1ant_ */
/* */
-void EXhalbtc8723b1ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b1ant_PowerOnSetting(struct btc_coexist *pBtCoexist)
{
- PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
+ struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
u8 u1Tmp = 0x0;
u16 u2Tmp = 0x0;
@@ -2658,7 +2656,7 @@ void EXhalbtc8723b1ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
/* enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. */
u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2);
- pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1);
+ pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp | BIT0 | BIT1);
/* set GRAN_BT = 1 */
pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
@@ -2700,12 +2698,12 @@ void EXhalbtc8723b1ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
}
}
-void EXhalbtc8723b1ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly)
+void EXhalbtc8723b1ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bWifiOnly)
{
halbtc8723b1ant_InitHwConfig(pBtCoexist, true, bWifiOnly);
}
-void EXhalbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b1ant_InitCoexDm(struct btc_coexist *pBtCoexist)
{
BTC_PRINT(
BTC_MSG_INTERFACE,
@@ -2720,11 +2718,11 @@ void EXhalbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
halbtc8723b1ant_QueryBtInfo(pBtCoexist);
}
-void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b1ant_DisplayCoexInfo(struct btc_coexist *pBtCoexist)
{
- PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
- PBTC_STACK_INFO pStackInfo = &pBtCoexist->stackInfo;
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
+ struct btc_stack_info *pStackInfo = &pBtCoexist->stackInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
u8 *cliBuf = pBtCoexist->cliBuf;
u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0;
u16 u2Tmp[4];
@@ -2839,7 +2837,7 @@ void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
- wifiRssi-100, btHsRssi-100
+ wifiRssi - 100, btHsRssi - 100
);
CL_PRINTF(cliBuf);
@@ -2883,11 +2881,11 @@ void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = %d/ %d/ %d/ %d/ %d", "sta/vwifi/hs/p2pGo/p2pGc", \
- ((wifiLinkStatus&WIFI_STA_CONNECTED) ? 1 : 0),
- ((wifiLinkStatus&WIFI_AP_CONNECTED) ? 1 : 0),
- ((wifiLinkStatus&WIFI_HS_CONNECTED) ? 1 : 0),
- ((wifiLinkStatus&WIFI_P2P_GO_CONNECTED) ? 1 : 0),
- ((wifiLinkStatus&WIFI_P2P_GC_CONNECTED) ? 1 : 0)
+ ((wifiLinkStatus & WIFI_STA_CONNECTED) ? 1 : 0),
+ ((wifiLinkStatus & WIFI_AP_CONNECTED) ? 1 : 0),
+ ((wifiLinkStatus & WIFI_HS_CONNECTED) ? 1 : 0),
+ ((wifiLinkStatus & WIFI_P2P_GO_CONNECTED) ? 1 : 0),
+ ((wifiLinkStatus & WIFI_P2P_GC_CONNECTED) ? 1 : 0)
);
CL_PRINTF(cliBuf);
@@ -2934,7 +2932,7 @@ void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = %s", "BT Info A2DP rate", \
- (btInfoExt&BIT0) ? "Basic rate" : "EDR rate"
+ (btInfoExt & BIT0) ? "Basic rate" : "EDR rate"
);
CL_PRINTF(cliBuf);
@@ -3046,7 +3044,7 @@ void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
CL_SPRINTF(
cliBuf, BT_TMP_BUF_SIZE,
"\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/0x6cc/0x880[29:25]", \
- u1Tmp[0], u4Tmp[0], (u4Tmp[1]&0x3e000000) >> 25
+ u1Tmp[0], u4Tmp[0], (u4Tmp[1] & 0x3e000000) >> 25
);
CL_PRINTF(cliBuf);
@@ -3058,7 +3056,7 @@ void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x764 / 0x76e", \
- u4Tmp[0], ((u1Tmp[0]&0x20) >> 5), (u4Tmp[1] & 0xffff), u1Tmp[1]
+ u4Tmp[0], ((u1Tmp[0] & 0x20) >> 5), (u4Tmp[1] & 0xffff), u1Tmp[1]
);
CL_PRINTF(cliBuf);
@@ -3069,7 +3067,7 @@ void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \
- u4Tmp[0]&0x3, u4Tmp[1]&0xff, u4Tmp[2]&0x3
+ u4Tmp[0] & 0x3, u4Tmp[1] & 0xff, u4Tmp[2] & 0x3
);
CL_PRINTF(cliBuf);
@@ -3081,10 +3079,10 @@ void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \
- ((u1Tmp[0] & 0x8)>>3),
+ ((u1Tmp[0] & 0x8) >> 3),
u1Tmp[1],
- ((u4Tmp[0]&0x01800000)>>23),
- u1Tmp[2]&0x1
+ ((u4Tmp[0] & 0x01800000) >> 23),
+ u1Tmp[2] & 0x1
);
CL_PRINTF(cliBuf);
@@ -3104,7 +3102,7 @@ void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \
- u4Tmp[0]&0xff, u1Tmp[0]
+ u4Tmp[0] & 0xff, u1Tmp[0]
);
CL_PRINTF(cliBuf);
@@ -3117,17 +3115,17 @@ void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c);
faOfdm =
- ((u4Tmp[0]&0xffff0000) >> 16) +
- ((u4Tmp[1]&0xffff0000) >> 16) +
+ ((u4Tmp[0] & 0xffff0000) >> 16) +
+ ((u4Tmp[1] & 0xffff0000) >> 16) +
(u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \
- ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff);
+ ((u4Tmp[3] & 0xffff0000) >> 16) + (u4Tmp[3] & 0xffff);
faCck = (u1Tmp[0] << 8) + u1Tmp[1];
CL_SPRINTF(
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \
- u4Tmp[0]&0xffff, faOfdm, faCck
+ u4Tmp[0] & 0xffff, faOfdm, faCck
);
CL_PRINTF(cliBuf);
@@ -3183,7 +3181,7 @@ void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
}
-void EXhalbtc8723b1ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b1ant_IpsNotify(struct btc_coexist *pBtCoexist, u8 type)
{
if (pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
return;
@@ -3209,7 +3207,7 @@ void EXhalbtc8723b1ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
}
}
-void EXhalbtc8723b1ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b1ant_LpsNotify(struct btc_coexist *pBtCoexist, u8 type)
{
if (pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)
return;
@@ -3227,7 +3225,7 @@ void EXhalbtc8723b1ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
}
}
-void EXhalbtc8723b1ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b1ant_ScanNotify(struct btc_coexist *pBtCoexist, u8 type)
{
bool bWifiConnected = false, bBtHsOn = false;
u32 wifiLinkStatus = 0;
@@ -3283,7 +3281,7 @@ void EXhalbtc8723b1ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
halbtc8723b1ant_QueryBtInfo(pBtCoexist);
pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
- numOfWifiLink = wifiLinkStatus>>16;
+ numOfWifiLink = wifiLinkStatus >> 16;
if (numOfWifiLink >= 2) {
halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
@@ -3317,7 +3315,7 @@ void EXhalbtc8723b1ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
}
}
-void EXhalbtc8723b1ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b1ant_ConnectNotify(struct btc_coexist *pBtCoexist, u8 type)
{
bool bWifiConnected = false, bBtHsOn = false;
u32 wifiLinkStatus = 0;
@@ -3343,7 +3341,7 @@ void EXhalbtc8723b1ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
}
pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);
- numOfWifiLink = wifiLinkStatus>>16;
+ numOfWifiLink = wifiLinkStatus >> 16;
if (numOfWifiLink >= 2) {
halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, bBtCtrlAggBufSize, aggBufSize);
@@ -3374,7 +3372,7 @@ void EXhalbtc8723b1ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
}
}
-void EXhalbtc8723b1ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b1ant_MediaStatusNotify(struct btc_coexist *pBtCoexist, u8 type)
{
u8 H2C_Parameter[3] = {0};
u32 wifiBw;
@@ -3437,14 +3435,14 @@ void EXhalbtc8723b1ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type)
ALGO_TRACE_FW_EXEC,
(
"[BTCoex], FW write 0x66 = 0x%x\n",
- H2C_Parameter[0]<<16 | H2C_Parameter[1]<<8 | H2C_Parameter[2]
+ H2C_Parameter[0] << 16 | H2C_Parameter[1] << 8 | H2C_Parameter[2]
)
);
pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
}
-void EXhalbtc8723b1ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b1ant_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 type)
{
bool bBtHsOn = false;
u32 wifiLinkStatus = 0;
@@ -3504,7 +3502,7 @@ void EXhalbtc8723b1ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
pBtCoexist->fBtcGet(
pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus
);
- numOfWifiLink = wifiLinkStatus>>16;
+ numOfWifiLink = wifiLinkStatus >> 16;
if (numOfWifiLink >= 2) {
halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);
@@ -3533,7 +3531,7 @@ void EXhalbtc8723b1ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
}
void EXhalbtc8723b1ant_BtInfoNotify(
- PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
+ struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
)
{
u8 btInfo = 0;
@@ -3543,7 +3541,7 @@ void EXhalbtc8723b1ant_BtInfoNotify(
pCoexSta->bC2hBtInfoReqSent = false;
- rspSource = tmpBuf[0]&0xf;
+ rspSource = tmpBuf[0] & 0xf;
if (rspSource >= BT_INFO_SRC_8723B_1ANT_MAX)
rspSource = BT_INFO_SRC_8723B_1ANT_WIFI_FW;
pCoexSta->btInfoC2hCnt[rspSource]++;
@@ -3559,7 +3557,7 @@ void EXhalbtc8723b1ant_BtInfoNotify(
pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
if (i == 1)
btInfo = tmpBuf[i];
- if (i == length-1)
+ if (i == length - 1)
BTC_PRINT(
BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i])
);
@@ -3568,22 +3566,22 @@ void EXhalbtc8723b1ant_BtInfoNotify(
}
if (BT_INFO_SRC_8723B_1ANT_WIFI_FW != rspSource) {
- pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2]&0xf;
+ pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2] & 0xf;
if (pCoexSta->btRetryCnt >= 1)
pCoexSta->popEventCnt++;
- if (pCoexSta->btInfoC2h[rspSource][2]&0x20)
+ if (pCoexSta->btInfoC2h[rspSource][2] & 0x20)
pCoexSta->bC2hBtPage = true;
else
pCoexSta->bC2hBtPage = false;
- pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3]*2-90;
+ pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3] * 2 - 90;
/* pCoexSta->btInfoC2h[rspSource][3]*2+10; */
pCoexSta->btInfoExt = pCoexSta->btInfoC2h[rspSource][4];
- pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40);
+ pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2] & 0x40);
pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask);
if (!pCoexSta->bBtTxRxMask) {
@@ -3628,7 +3626,7 @@ void EXhalbtc8723b1ant_BtInfoNotify(
pCoexSta->bC2hBtInquiryPage = false;
/* set link exist status */
- if (!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION)) {
+ if (!(btInfo & BT_INFO_8723B_1ANT_B_CONNECTION)) {
pCoexSta->bBtLinkExist = false;
pCoexSta->bPanExist = false;
pCoexSta->bA2dpExist = false;
@@ -3661,7 +3659,7 @@ void EXhalbtc8723b1ant_BtInfoNotify(
btInfo = btInfo & 0x1f; /* mask profile bit for connect-ilde identification (for CSR case: A2DP idle --> 0x41) */
- if (!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION)) {
+ if (!(btInfo & BT_INFO_8723B_1ANT_B_CONNECTION)) {
pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));
} else if (btInfo == BT_INFO_8723B_1ANT_B_CONNECTION) {
@@ -3669,12 +3667,12 @@ void EXhalbtc8723b1ant_BtInfoNotify(
pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
} else if (
- (btInfo&BT_INFO_8723B_1ANT_B_SCO_ESCO) ||
- (btInfo&BT_INFO_8723B_1ANT_B_SCO_BUSY)
+ (btInfo & BT_INFO_8723B_1ANT_B_SCO_ESCO) ||
+ (btInfo & BT_INFO_8723B_1ANT_B_SCO_BUSY)
) {
pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_SCO_BUSY;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));
- } else if (btInfo&BT_INFO_8723B_1ANT_B_ACL_BUSY) {
+ } else if (btInfo & BT_INFO_8723B_1ANT_B_ACL_BUSY) {
if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus)
pCoexDm->bAutoTdmaAdjust = false;
@@ -3698,7 +3696,7 @@ void EXhalbtc8723b1ant_BtInfoNotify(
halbtc8723b1ant_RunCoexistMechanism(pBtCoexist);
}
-void EXhalbtc8723b1ant_HaltNotify(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b1ant_HaltNotify(struct btc_coexist *pBtCoexist)
{
BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
@@ -3713,7 +3711,7 @@ void EXhalbtc8723b1ant_HaltNotify(PBTC_COEXIST pBtCoexist)
pBtCoexist->bStopCoexDm = true;
}
-void EXhalbtc8723b1ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
+void EXhalbtc8723b1ant_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState)
{
BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
@@ -3735,7 +3733,7 @@ void EXhalbtc8723b1ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
}
}
-void EXhalbtc8723b1ant_Periodical(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b1ant_Periodical(struct btc_coexist *pBtCoexist)
{
static u8 disVerInfoCnt;
u32 fwVer = 0, btPatchVer = 0;
diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h
index cdffa391bd9d..719e19420a3b 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h
+++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h
@@ -15,20 +15,20 @@
#define BT_INFO_8723B_1ANT_B_CONNECTION BIT0
#define BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \
- (((_BT_INFO_EXT_&BIT0)) ? true : false)
+ (((_BT_INFO_EXT_ & BIT0)) ? true : false)
#define BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT 2
#define BT_8723B_1ANT_WIFI_NOISY_THRESH 30 /* max: 255 */
-typedef enum _BT_INFO_SRC_8723B_1ANT {
+enum {
BT_INFO_SRC_8723B_1ANT_WIFI_FW = 0x0,
BT_INFO_SRC_8723B_1ANT_BT_RSP = 0x1,
BT_INFO_SRC_8723B_1ANT_BT_ACTIVE_SEND = 0x2,
BT_INFO_SRC_8723B_1ANT_MAX
-} BT_INFO_SRC_8723B_1ANT, *PBT_INFO_SRC_8723B_1ANT;
+};
-typedef enum _BT_8723B_1ANT_BT_STATUS {
+enum {
BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0,
BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
BT_8723B_1ANT_BT_STATUS_INQ_PAGE = 0x2,
@@ -36,9 +36,9 @@ typedef enum _BT_8723B_1ANT_BT_STATUS {
BT_8723B_1ANT_BT_STATUS_SCO_BUSY = 0x4,
BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5,
BT_8723B_1ANT_BT_STATUS_MAX
-} BT_8723B_1ANT_BT_STATUS, *PBT_8723B_1ANT_BT_STATUS;
+};
-typedef enum _BT_8723B_1ANT_WIFI_STATUS {
+enum {
BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0,
BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1,
BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2,
@@ -46,9 +46,9 @@ typedef enum _BT_8723B_1ANT_WIFI_STATUS {
BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4,
BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5,
BT_8723B_1ANT_WIFI_STATUS_MAX
-} BT_8723B_1ANT_WIFI_STATUS, *PBT_8723B_1ANT_WIFI_STATUS;
+};
-typedef enum _BT_8723B_1ANT_COEX_ALGO {
+enum {
BT_8723B_1ANT_COEX_ALGO_UNDEFINED = 0x0,
BT_8723B_1ANT_COEX_ALGO_SCO = 0x1,
BT_8723B_1ANT_COEX_ALGO_HID = 0x2,
@@ -61,9 +61,9 @@ typedef enum _BT_8723B_1ANT_COEX_ALGO {
BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9,
BT_8723B_1ANT_COEX_ALGO_HID_A2DP = 0xa,
BT_8723B_1ANT_COEX_ALGO_MAX = 0xb,
-} BT_8723B_1ANT_COEX_ALGO, *PBT_8723B_1ANT_COEX_ALGO;
+};
-typedef struct _COEX_DM_8723B_1ANT {
+struct coex_dm_8723b_1ant {
/* fw mechanism */
bool bCurIgnoreWlanAct;
bool bPreIgnoreWlanAct;
@@ -116,9 +116,9 @@ typedef struct _COEX_DM_8723B_1ANT {
u32 nArpCnt;
u8 errorCondition;
-} COEX_DM_8723B_1ANT, *PCOEX_DM_8723B_1ANT;
+};
-typedef struct _COEX_STA_8723B_1ANT {
+struct coex_sta_8723b_1ant {
bool bBtLinkExist;
bool bScoExist;
bool bA2dpExist;
@@ -162,24 +162,24 @@ typedef struct _COEX_STA_8723B_1ANT {
u8 nCoexTableType;
bool bForceLpsOn;
-} COEX_STA_8723B_1ANT, *PCOEX_STA_8723B_1ANT;
+};
/* */
/* The following is interface which will notify coex module. */
/* */
-void EXhalbtc8723b1ant_PowerOnSetting(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b1ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly);
-void EXhalbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b1ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b1ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b1ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b1ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b1ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b1ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type);
+void EXhalbtc8723b1ant_PowerOnSetting(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b1ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bWifiOnly);
+void EXhalbtc8723b1ant_InitCoexDm(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b1ant_IpsNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b1ant_LpsNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b1ant_ScanNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b1ant_ConnectNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b1ant_MediaStatusNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b1ant_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 type);
void EXhalbtc8723b1ant_BtInfoNotify(
- PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
+ struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
);
-void EXhalbtc8723b1ant_HaltNotify(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b1ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState);
-void EXhalbtc8723b1ant_Periodical(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist);
+void EXhalbtc8723b1ant_HaltNotify(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b1ant_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState);
+void EXhalbtc8723b1ant_Periodical(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b1ant_DisplayCoexInfo(struct btc_coexist *pBtCoexist);
diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
index 2779dba92bab..4b570ec75e67 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
+++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c
@@ -15,10 +15,10 @@ do { \
} while (0)
/* Global variables, these are static variables */
-static COEX_DM_8723B_2ANT GLCoexDm8723b2Ant;
-static PCOEX_DM_8723B_2ANT pCoexDm = &GLCoexDm8723b2Ant;
-static COEX_STA_8723B_2ANT GLCoexSta8723b2Ant;
-static PCOEX_STA_8723B_2ANT pCoexSta = &GLCoexSta8723b2Ant;
+static struct coex_dm_8723b_2ant GLCoexDm8723b2Ant;
+static struct coex_dm_8723b_2ant *pCoexDm = &GLCoexDm8723b2Ant;
+static struct coex_sta_8723b_2ant GLCoexSta8723b2Ant;
+static struct coex_sta_8723b_2ant *pCoexSta = &GLCoexSta8723b2Ant;
static const char *const GLBtInfoSrc8723b2Ant[] = {
"BT Info[wifi fw]",
@@ -44,7 +44,7 @@ static u8 halbtc8723b2ant_BtRssiState(
(pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
(pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
) {
- if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
+ if (btRssi >= (rssiThresh + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
btRssiState = BTC_RSSI_STATE_HIGH;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
} else {
@@ -70,7 +70,7 @@ static u8 halbtc8723b2ant_BtRssiState(
(pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
(pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)
) {
- if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
+ if (btRssi >= (rssiThresh + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
btRssiState = BTC_RSSI_STATE_MEDIUM;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
} else {
@@ -81,7 +81,7 @@ static u8 halbtc8723b2ant_BtRssiState(
(pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
(pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)
) {
- if (btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
+ if (btRssi >= (rssiThresh1 + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
btRssiState = BTC_RSSI_STATE_HIGH;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
} else if (btRssi < rssiThresh) {
@@ -108,7 +108,7 @@ static u8 halbtc8723b2ant_BtRssiState(
}
static u8 halbtc8723b2ant_WifiRssiState(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
u8 index,
u8 levelNum,
u8 rssiThresh,
@@ -125,7 +125,7 @@ static u8 halbtc8723b2ant_WifiRssiState(
(pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
(pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)
) {
- if (wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
+ if (wifiRssi >= (rssiThresh + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
wifiRssiState = BTC_RSSI_STATE_HIGH;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
} else {
@@ -151,7 +151,7 @@ static u8 halbtc8723b2ant_WifiRssiState(
(pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
(pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)
) {
- if (wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
+ if (wifiRssi >= (rssiThresh + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
wifiRssiState = BTC_RSSI_STATE_MEDIUM;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
} else {
@@ -162,7 +162,7 @@ static u8 halbtc8723b2ant_WifiRssiState(
(pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
(pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)
) {
- if (wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
+ if (wifiRssi >= (rssiThresh1 + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) {
wifiRssiState = BTC_RSSI_STATE_HIGH;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
} else if (wifiRssi < rssiThresh) {
@@ -189,7 +189,7 @@ static u8 halbtc8723b2ant_WifiRssiState(
}
static void halbtc8723b2ant_LimitedRx(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
bool bForceExec,
bool bRejApAggPkt,
bool bBtCtrlAggBufSize,
@@ -212,7 +212,7 @@ static void halbtc8723b2ant_LimitedRx(
pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
}
-static void halbtc8723b2ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_MonitorBtCtr(struct btc_coexist *pBtCoexist)
{
u32 regHPTxRx, regLPTxRx, u4Tmp;
u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0;
@@ -222,11 +222,11 @@ static void halbtc8723b2ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);
regHPTx = u4Tmp & bMaskLWord;
- regHPRx = (u4Tmp & bMaskHWord)>>16;
+ regHPRx = (u4Tmp & bMaskHWord) >> 16;
u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);
regLPTx = u4Tmp & bMaskLWord;
- regLPRx = (u4Tmp & bMaskHWord)>>16;
+ regLPRx = (u4Tmp & bMaskHWord) >> 16;
pCoexSta->highPriorityTx = regHPTx;
pCoexSta->highPriorityRx = regHPRx;
@@ -262,7 +262,7 @@ static void halbtc8723b2ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist)
pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);
}
-static void halbtc8723b2ant_QueryBtInfo(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_QueryBtInfo(struct btc_coexist *pBtCoexist)
{
u8 H2C_Parameter[1] = {0};
@@ -279,7 +279,7 @@ static void halbtc8723b2ant_QueryBtInfo(PBTC_COEXIST pBtCoexist)
pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);
}
-static bool halbtc8723b2ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist)
+static bool halbtc8723b2ant_IsWifiStatusChanged(struct btc_coexist *pBtCoexist)
{
static bool bPreWifiBusy, bPreUnder4way, bPreBtHsOn;
bool bWifiBusy = false, bUnder4way = false, bBtHsOn = false;
@@ -310,9 +310,9 @@ static bool halbtc8723b2ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist)
return false;
}
-static void halbtc8723b2ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_UpdateBtLinkInfo(struct btc_coexist *pBtCoexist)
{
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
bool bBtHsOn = false;
pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
@@ -374,9 +374,9 @@ static void halbtc8723b2ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist)
pBtLinkInfo->bHidOnly = false;
}
-static u8 halbtc8723b2ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist)
+static u8 halbtc8723b2ant_ActionAlgorithm(struct btc_coexist *pBtCoexist)
{
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
bool bBtHsOn = false;
u8 algorithm = BT_8723B_2ANT_COEX_ALGO_UNDEFINED;
u8 numOfDiffProfile = 0;
@@ -549,7 +549,7 @@ static u8 halbtc8723b2ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist)
}
static void halbtc8723b2ant_SetFwDacSwingLevel(
- PBTC_COEXIST pBtCoexist, u8 dacSwingLvl
+ struct btc_coexist *pBtCoexist, u8 dacSwingLvl
)
{
u8 H2C_Parameter[1] = {0};
@@ -573,7 +573,7 @@ static void halbtc8723b2ant_SetFwDacSwingLevel(
}
static void halbtc8723b2ant_SetFwDecBtPwr(
- PBTC_COEXIST pBtCoexist, u8 decBtPwrLvl
+ struct btc_coexist *pBtCoexist, u8 decBtPwrLvl
)
{
u8 H2C_Parameter[1] = {0};
@@ -594,7 +594,7 @@ static void halbtc8723b2ant_SetFwDecBtPwr(
}
static void halbtc8723b2ant_DecBtPwr(
- PBTC_COEXIST pBtCoexist, bool bForceExec, u8 decBtPwrLvl
+ struct btc_coexist *pBtCoexist, bool bForceExec, u8 decBtPwrLvl
)
{
BTC_PRINT(
@@ -628,7 +628,7 @@ static void halbtc8723b2ant_DecBtPwr(
}
static void halbtc8723b2ant_FwDacSwingLvl(
- PBTC_COEXIST pBtCoexist, bool bForceExec, u8 fwDacSwingLvl
+ struct btc_coexist *pBtCoexist, bool bForceExec, u8 fwDacSwingLvl
)
{
BTC_PRINT(
@@ -663,7 +663,7 @@ static void halbtc8723b2ant_FwDacSwingLvl(
}
static void halbtc8723b2ant_SetSwRfRxLpfCorner(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
bool bRxRfShrinkOn
)
{
@@ -686,7 +686,7 @@ static void halbtc8723b2ant_SetSwRfRxLpfCorner(
}
static void halbtc8723b2ant_RfShrink(
- PBTC_COEXIST pBtCoexist, bool bForceExec, bool bRxRfShrinkOn
+ struct btc_coexist *pBtCoexist, bool bForceExec, bool bRxRfShrinkOn
)
{
BTC_PRINT(
@@ -720,7 +720,7 @@ static void halbtc8723b2ant_RfShrink(
}
static void halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(
- PBTC_COEXIST pBtCoexist, bool bLowPenaltyRa
+ struct btc_coexist *pBtCoexist, bool bLowPenaltyRa
)
{
u8 H2C_Parameter[6] = {0};
@@ -748,7 +748,7 @@ static void halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(
}
static void halbtc8723b2ant_LowPenaltyRa(
- PBTC_COEXIST pBtCoexist, bool bForceExec, bool bLowPenaltyRa
+ struct btc_coexist *pBtCoexist, bool bForceExec, bool bLowPenaltyRa
)
{
/* return; */
@@ -782,7 +782,7 @@ static void halbtc8723b2ant_LowPenaltyRa(
pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
}
-static void halbtc8723b2ant_SetDacSwingReg(PBTC_COEXIST pBtCoexist, u32 level)
+static void halbtc8723b2ant_SetDacSwingReg(struct btc_coexist *pBtCoexist, u32 level)
{
u8 val = (u8)level;
@@ -795,7 +795,7 @@ static void halbtc8723b2ant_SetDacSwingReg(PBTC_COEXIST pBtCoexist, u32 level)
}
static void halbtc8723b2ant_SetSwFullTimeDacSwing(
- PBTC_COEXIST pBtCoexist, bool bSwDacSwingOn, u32 swDacSwingLvl
+ struct btc_coexist *pBtCoexist, bool bSwDacSwingOn, u32 swDacSwingLvl
)
{
if (bSwDacSwingOn)
@@ -806,7 +806,7 @@ static void halbtc8723b2ant_SetSwFullTimeDacSwing(
static void halbtc8723b2ant_DacSwing(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
bool bForceExec,
bool bDacSwingOn,
u32 dacSwingLvl
@@ -850,7 +850,7 @@ static void halbtc8723b2ant_DacSwing(
}
static void halbtc8723b2ant_SetAgcTable(
- PBTC_COEXIST pBtCoexist, bool bAgcTableEn
+ struct btc_coexist *pBtCoexist, bool bAgcTableEn
)
{
u8 rssiAdjustVal = 0;
@@ -910,7 +910,7 @@ static void halbtc8723b2ant_SetAgcTable(
}
static void halbtc8723b2ant_AgcTable(
- PBTC_COEXIST pBtCoexist, bool bForceExec, bool bAgcTableEn
+ struct btc_coexist *pBtCoexist, bool bForceExec, bool bAgcTableEn
)
{
BTC_PRINT(
@@ -944,7 +944,7 @@ static void halbtc8723b2ant_AgcTable(
}
static void halbtc8723b2ant_SetCoexTable(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
u32 val0x6c0,
u32 val0x6c4,
u32 val0x6c8,
@@ -981,7 +981,7 @@ static void halbtc8723b2ant_SetCoexTable(
}
static void halbtc8723b2ant_CoexTable(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
bool bForceExec,
u32 val0x6c0,
u32 val0x6c4,
@@ -1047,7 +1047,7 @@ static void halbtc8723b2ant_CoexTable(
}
static void halbtc8723b2ant_CoexTableWithType(
- PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type
+ struct btc_coexist *pBtCoexist, bool bForceExec, u8 type
)
{
switch (type) {
@@ -1096,7 +1096,7 @@ static void halbtc8723b2ant_CoexTableWithType(
}
static void halbtc8723b2ant_SetFwIgnoreWlanAct(
- PBTC_COEXIST pBtCoexist, bool bEnable
+ struct btc_coexist *pBtCoexist, bool bEnable
)
{
u8 H2C_Parameter[1] = {0};
@@ -1117,7 +1117,7 @@ static void halbtc8723b2ant_SetFwIgnoreWlanAct(
}
static void halbtc8723b2ant_IgnoreWlanAct(
- PBTC_COEXIST pBtCoexist, bool bForceExec, bool bEnable
+ struct btc_coexist *pBtCoexist, bool bForceExec, bool bEnable
)
{
BTC_PRINT(
@@ -1145,7 +1145,7 @@ static void halbtc8723b2ant_IgnoreWlanAct(
}
static void halbtc8723b2ant_SetFwPstdma(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
u8 byte1,
u8 byte2,
u8 byte3,
@@ -1173,9 +1173,9 @@ static void halbtc8723b2ant_SetFwPstdma(
(
"[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n",
H2C_Parameter[0],
- H2C_Parameter[1]<<24|
- H2C_Parameter[2]<<16|
- H2C_Parameter[3]<<8|
+ H2C_Parameter[1] << 24 |
+ H2C_Parameter[2] << 16 |
+ H2C_Parameter[3] << 8 |
H2C_Parameter[4]
)
);
@@ -1184,7 +1184,7 @@ static void halbtc8723b2ant_SetFwPstdma(
}
static void halbtc8723b2ant_SwMechanism1(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
bool bShrinkRxLPF,
bool bLowPenaltyRA,
bool bLimitedDIG,
@@ -1196,7 +1196,7 @@ static void halbtc8723b2ant_SwMechanism1(
}
static void halbtc8723b2ant_SwMechanism2(
- PBTC_COEXIST pBtCoexist,
+ struct btc_coexist *pBtCoexist,
bool bAGCTableShift,
bool bADCBackOff,
bool bSWDACSwing,
@@ -1208,10 +1208,10 @@ static void halbtc8723b2ant_SwMechanism2(
}
static void halbtc8723b2ant_SetAntPath(
- PBTC_COEXIST pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
+ struct btc_coexist *pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff
)
{
- PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
+ struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
u32 fwVer = 0, u4Tmp = 0;
bool bPgExtSwitch = false;
bool bUseExtSwitch = false;
@@ -1302,7 +1302,7 @@ static void halbtc8723b2ant_SetAntPath(
}
static void halbtc8723b2ant_PsTdma(
- PBTC_COEXIST pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
+ struct btc_coexist *pBtCoexist, bool bForceExec, bool bTurnOn, u8 type
)
{
BTC_PRINT(
@@ -1434,7 +1434,7 @@ static void halbtc8723b2ant_PsTdma(
pCoexDm->prePsTdma = pCoexDm->curPsTdma;
}
-static void halbtc8723b2ant_CoexAllOff(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_CoexAllOff(struct btc_coexist *pBtCoexist)
{
/* fw all off */
halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1);
@@ -1450,7 +1450,7 @@ static void halbtc8723b2ant_CoexAllOff(PBTC_COEXIST pBtCoexist)
halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
}
-static void halbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_InitCoexDm(struct btc_coexist *pBtCoexist)
{
/* force to reset coex mechanism */
@@ -1462,7 +1462,7 @@ static void halbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18);
}
-static void halbtc8723b2ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionBtInquiry(struct btc_coexist *pBtCoexist)
{
bool bWifiConnected = false;
bool bLowPwrDisable = true;
@@ -1490,7 +1490,7 @@ static void halbtc8723b2ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist)
halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_AUX, false, false);
}
-static bool halbtc8723b2ant_IsCommonAction(PBTC_COEXIST pBtCoexist)
+static bool halbtc8723b2ant_IsCommonAction(struct btc_coexist *pBtCoexist)
{
u8 btRssiState = BTC_RSSI_STATE_HIGH;
bool bCommon = false, bWifiConnected = false, bWifiBusy = false;
@@ -1591,7 +1591,7 @@ static bool halbtc8723b2ant_IsCommonAction(PBTC_COEXIST pBtCoexist)
}
static void halbtc8723b2ant_TdmaDurationAdjust(
- PBTC_COEXIST pBtCoexist, bool bScoHid, bool bTxPause, u8 maxInterval
+ struct btc_coexist *pBtCoexist, bool bScoHid, bool bTxPause, u8 maxInterval
)
{
static s32 up, dn, m, n, WaitCount;
@@ -1691,7 +1691,7 @@ static void halbtc8723b2ant_TdmaDurationAdjust(
if (m >= 20) /* m 最大值 = 20 ' 最大120秒 recheck是否調整 WiFi duration. */
m = 20;
- n = 3*m;
+ n = 3 * m;
up = 0;
dn = 0;
WaitCount = 0;
@@ -1707,7 +1707,7 @@ static void halbtc8723b2ant_TdmaDurationAdjust(
if (m >= 20) /* m 最大值 = 20 ' 最大120秒 recheck是否調整 WiFi duration. */
m = 20;
- n = 3*m;
+ n = 3 * m;
up = 0;
dn = 0;
WaitCount = 0;
@@ -2041,7 +2041,7 @@ static void halbtc8723b2ant_TdmaDurationAdjust(
}
/* SCO only or SCO+PAN(HS) */
-static void halbtc8723b2ant_ActionSco(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionSco(struct btc_coexist *pBtCoexist)
{
u8 wifiRssiState, btRssiState;
u32 wifiBw;
@@ -2096,7 +2096,7 @@ static void halbtc8723b2ant_ActionSco(PBTC_COEXIST pBtCoexist)
}
-static void halbtc8723b2ant_ActionHid(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionHid(struct btc_coexist *pBtCoexist)
{
u8 wifiRssiState, btRssiState;
u32 wifiBw;
@@ -2157,7 +2157,7 @@ static void halbtc8723b2ant_ActionHid(PBTC_COEXIST pBtCoexist)
}
/* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
-static void halbtc8723b2ant_ActionA2dp(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionA2dp(struct btc_coexist *pBtCoexist)
{
u8 wifiRssiState, wifiRssiState1, btRssiState;
u32 wifiBw;
@@ -2238,7 +2238,7 @@ static void halbtc8723b2ant_ActionA2dp(PBTC_COEXIST pBtCoexist)
}
}
-static void halbtc8723b2ant_ActionA2dpPanHs(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionA2dpPanHs(struct btc_coexist *pBtCoexist)
{
u8 wifiRssiState, btRssiState;
u32 wifiBw;
@@ -2288,7 +2288,7 @@ static void halbtc8723b2ant_ActionA2dpPanHs(PBTC_COEXIST pBtCoexist)
}
}
-static void halbtc8723b2ant_ActionPanEdr(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionPanEdr(struct btc_coexist *pBtCoexist)
{
u8 wifiRssiState, btRssiState;
u32 wifiBw;
@@ -2346,7 +2346,7 @@ static void halbtc8723b2ant_ActionPanEdr(PBTC_COEXIST pBtCoexist)
/* PAN(HS) only */
-static void halbtc8723b2ant_ActionPanHs(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionPanHs(struct btc_coexist *pBtCoexist)
{
u8 wifiRssiState, btRssiState;
u32 wifiBw;
@@ -2396,7 +2396,7 @@ static void halbtc8723b2ant_ActionPanHs(PBTC_COEXIST pBtCoexist)
}
/* PAN(EDR)+A2DP */
-static void halbtc8723b2ant_ActionPanEdrA2dp(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionPanEdrA2dp(struct btc_coexist *pBtCoexist)
{
u8 wifiRssiState, btRssiState;
u32 wifiBw;
@@ -2457,7 +2457,7 @@ static void halbtc8723b2ant_ActionPanEdrA2dp(PBTC_COEXIST pBtCoexist)
}
}
-static void halbtc8723b2ant_ActionPanEdrHid(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionPanEdrHid(struct btc_coexist *pBtCoexist)
{
u8 wifiRssiState, btRssiState;
u32 wifiBw;
@@ -2521,7 +2521,7 @@ static void halbtc8723b2ant_ActionPanEdrHid(PBTC_COEXIST pBtCoexist)
}
/* HID+A2DP+PAN(EDR) */
-static void halbtc8723b2ant_ActionHidA2dpPanEdr(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionHidA2dpPanEdr(struct btc_coexist *pBtCoexist)
{
u8 wifiRssiState, btRssiState;
u32 wifiBw;
@@ -2581,7 +2581,7 @@ static void halbtc8723b2ant_ActionHidA2dpPanEdr(PBTC_COEXIST pBtCoexist)
}
}
-static void halbtc8723b2ant_ActionHidA2dp(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_ActionHidA2dp(struct btc_coexist *pBtCoexist)
{
u8 wifiRssiState, btRssiState;
u32 wifiBw;
@@ -2656,7 +2656,7 @@ static void halbtc8723b2ant_ActionHidA2dp(PBTC_COEXIST pBtCoexist)
}
}
-static void halbtc8723b2ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_RunCoexistMechanism(struct btc_coexist *pBtCoexist)
{
u8 algorithm = 0;
@@ -2755,7 +2755,7 @@ static void halbtc8723b2ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist)
}
}
-static void halbtc8723b2ant_WifiOffHwCfg(PBTC_COEXIST pBtCoexist)
+static void halbtc8723b2ant_WifiOffHwCfg(struct btc_coexist *pBtCoexist)
{
bool bIsInMpMode = false;
u8 H2C_Parameter[2] = {0};
@@ -2780,7 +2780,7 @@ static void halbtc8723b2ant_WifiOffHwCfg(PBTC_COEXIST pBtCoexist)
pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); /* BT select s0/s1 is controlled by WiFi */
}
-static void halbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bBackUp)
+static void halbtc8723b2ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bBackUp)
{
u8 u1Tmp = 0;
@@ -2814,9 +2814,9 @@ static void halbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bBackUp)
/* */
/* extern function start with EXhalbtc8723b2ant_ */
/* */
-void EXhalbtc8723b2ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b2ant_PowerOnSetting(struct btc_coexist *pBtCoexist)
{
- PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
+ struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
u8 u1Tmp = 0x4; /* Set BIT2 by default since it's 2ant case */
u16 u2Tmp = 0x0;
@@ -2824,7 +2824,7 @@ void EXhalbtc8723b2ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
/* enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. */
u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2);
- pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1);
+ pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp | BIT0 | BIT1);
/* set GRAN_BT = 1 */
pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);
@@ -2866,23 +2866,23 @@ void EXhalbtc8723b2ant_PowerOnSetting(PBTC_COEXIST pBtCoexist)
}
}
-void EXhalbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly)
+void EXhalbtc8723b2ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bWifiOnly)
{
halbtc8723b2ant_InitHwConfig(pBtCoexist, true);
}
-void EXhalbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b2ant_InitCoexDm(struct btc_coexist *pBtCoexist)
{
BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
halbtc8723b2ant_InitCoexDm(pBtCoexist);
}
-void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b2ant_DisplayCoexInfo(struct btc_coexist *pBtCoexist)
{
- PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo;
- PBTC_STACK_INFO pStackInfo = &pBtCoexist->stackInfo;
- PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo;
+ struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo;
+ struct btc_stack_info *pStackInfo = &pBtCoexist->stackInfo;
+ struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo;
u8 *cliBuf = pBtCoexist->cliBuf;
u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0;
u32 u4Tmp[4];
@@ -3019,7 +3019,7 @@ void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = %s", "BT Info A2DP rate", \
- (btInfoExt&BIT0) ? "Basic rate" : "EDR rate"
+ (btInfoExt & BIT0) ? "Basic rate" : "EDR rate"
);
CL_PRINTF(cliBuf);
@@ -3126,7 +3126,7 @@ void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
BT_TMP_BUF_SIZE,
"\r\n %-35s = 0x%x/ 0x%x", "0x778/0x880[29:25]", \
u1Tmp[0],
- (u4Tmp[0]&0x3e000000) >> 25
+ (u4Tmp[0] & 0x3e000000) >> 25
);
CL_PRINTF(cliBuf);
@@ -3139,7 +3139,7 @@ void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
BT_TMP_BUF_SIZE,
"\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x765", \
u4Tmp[0],
- ((u1Tmp[0]&0x20)>>5),
+ ((u1Tmp[0] & 0x20) >> 5),
u1Tmp[1]
);
CL_PRINTF(cliBuf);
@@ -3151,9 +3151,9 @@ void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \
- u4Tmp[0]&0x3,
- u4Tmp[1]&0xff,
- u4Tmp[2]&0x3
+ u4Tmp[0] & 0x3,
+ u4Tmp[1] & 0xff,
+ u4Tmp[2] & 0x3
);
CL_PRINTF(cliBuf);
@@ -3166,10 +3166,10 @@ void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \
- ((u1Tmp[0] & 0x8)>>3),
+ ((u1Tmp[0] & 0x8) >> 3),
u1Tmp[1],
- ((u4Tmp[0]&0x01800000)>>23),
- u1Tmp[2]&0x1
+ ((u4Tmp[0] & 0x01800000) >> 23),
+ u1Tmp[2] & 0x1
);
CL_PRINTF(cliBuf);
@@ -3190,7 +3190,7 @@ void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \
- u4Tmp[0]&0xff,
+ u4Tmp[0] & 0xff,
u1Tmp[0]
);
CL_PRINTF(cliBuf);
@@ -3204,10 +3204,10 @@ void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c);
faOfdm =
- ((u4Tmp[0]&0xffff0000) >> 16) +
- ((u4Tmp[1]&0xffff0000) >> 16) +
+ ((u4Tmp[0] & 0xffff0000) >> 16) +
+ ((u4Tmp[1] & 0xffff0000) >> 16) +
(u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \
- ((u4Tmp[3]&0xffff0000) >> 16) +
+ ((u4Tmp[3] & 0xffff0000) >> 16) +
(u4Tmp[3] & 0xffff);
faCck = (u1Tmp[0] << 8) + u1Tmp[1];
@@ -3216,7 +3216,7 @@ void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
cliBuf,
BT_TMP_BUF_SIZE,
"\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \
- u4Tmp[0]&0xffff,
+ u4Tmp[0] & 0xffff,
faOfdm,
faCck
);
@@ -3259,7 +3259,7 @@ void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist)
}
-void EXhalbtc8723b2ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b2ant_IpsNotify(struct btc_coexist *pBtCoexist, u8 type)
{
if (BTC_IPS_ENTER == type) {
BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
@@ -3276,7 +3276,7 @@ void EXhalbtc8723b2ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
}
}
-void EXhalbtc8723b2ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b2ant_LpsNotify(struct btc_coexist *pBtCoexist, u8 type)
{
if (BTC_LPS_ENABLE == type) {
BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
@@ -3287,7 +3287,7 @@ void EXhalbtc8723b2ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
}
}
-void EXhalbtc8723b2ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b2ant_ScanNotify(struct btc_coexist *pBtCoexist, u8 type)
{
if (BTC_SCAN_START == type) {
BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
@@ -3296,7 +3296,7 @@ void EXhalbtc8723b2ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
}
}
-void EXhalbtc8723b2ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b2ant_ConnectNotify(struct btc_coexist *pBtCoexist, u8 type)
{
if (BTC_ASSOCIATE_START == type) {
BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
@@ -3305,7 +3305,7 @@ void EXhalbtc8723b2ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type)
}
}
-void EXhalbtc8723b2ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b2ant_MediaStatusNotify(struct btc_coexist *pBtCoexist, u8 type)
{
u8 H2C_Parameter[3] = {0};
u32 wifiBw;
@@ -3344,14 +3344,14 @@ void EXhalbtc8723b2ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type)
ALGO_TRACE_FW_EXEC,
(
"[BTCoex], FW write 0x66 = 0x%x\n",
- H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]
+ H2C_Parameter[0] << 16 | H2C_Parameter[1] << 8 | H2C_Parameter[2]
)
);
pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);
}
-void EXhalbtc8723b2ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtc8723b2ant_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 type)
{
if (type == BTC_PACKET_DHCP) {
BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], DHCP Packet notify\n"));
@@ -3359,7 +3359,7 @@ void EXhalbtc8723b2ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type)
}
void EXhalbtc8723b2ant_BtInfoNotify(
- PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
+ struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
)
{
u8 btInfo = 0;
@@ -3369,7 +3369,7 @@ void EXhalbtc8723b2ant_BtInfoNotify(
pCoexSta->bC2hBtInfoReqSent = false;
- rspSource = tmpBuf[0]&0xf;
+ rspSource = tmpBuf[0] & 0xf;
if (rspSource >= BT_INFO_SRC_8723B_2ANT_MAX)
rspSource = BT_INFO_SRC_8723B_2ANT_WIFI_FW;
@@ -3381,7 +3381,7 @@ void EXhalbtc8723b2ant_BtInfoNotify(
if (i == 1)
btInfo = tmpBuf[i];
- if (i == length-1) {
+ if (i == length - 1) {
BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
} else {
BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
@@ -3394,13 +3394,13 @@ void EXhalbtc8723b2ant_BtInfoNotify(
}
if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) {
- pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2]&0xf; /* [3:0] */
+ pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2] & 0xf; /* [3:0] */
- pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3]*2+10;
+ pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3] * 2 + 10;
pCoexSta->btInfoExt = pCoexSta->btInfoC2h[rspSource][4];
- pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40);
+ pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2] & 0x40);
pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask);
if (pCoexSta->bBtTxRxMask) {
/* BT into is responded by BT FW and BT RF REG 0x3C != 0x01 => Need to switch BT TRx Mask */
@@ -3435,7 +3435,7 @@ void EXhalbtc8723b2ant_BtInfoNotify(
pCoexSta->bC2hBtInquiryPage = false;
/* set link exist status */
- if (!(btInfo&BT_INFO_8723B_2ANT_B_CONNECTION)) {
+ if (!(btInfo & BT_INFO_8723B_2ANT_B_CONNECTION)) {
pCoexSta->bBtLinkExist = false;
pCoexSta->bPanExist = false;
pCoexSta->bA2dpExist = false;
@@ -3463,19 +3463,19 @@ void EXhalbtc8723b2ant_BtInfoNotify(
halbtc8723b2ant_UpdateBtLinkInfo(pBtCoexist);
- if (!(btInfo&BT_INFO_8723B_2ANT_B_CONNECTION)) {
+ if (!(btInfo & BT_INFO_8723B_2ANT_B_CONNECTION)) {
pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));
} else if (btInfo == BT_INFO_8723B_2ANT_B_CONNECTION) { /* connection exists but no busy */
pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));
} else if (
- (btInfo&BT_INFO_8723B_2ANT_B_SCO_ESCO) ||
- (btInfo&BT_INFO_8723B_2ANT_B_SCO_BUSY)
+ (btInfo & BT_INFO_8723B_2ANT_B_SCO_ESCO) ||
+ (btInfo & BT_INFO_8723B_2ANT_B_SCO_BUSY)
) {
pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_SCO_BUSY;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));
- } else if (btInfo&BT_INFO_8723B_2ANT_B_ACL_BUSY) {
+ } else if (btInfo & BT_INFO_8723B_2ANT_B_ACL_BUSY) {
pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_ACL_BUSY;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"));
} else {
@@ -3503,7 +3503,7 @@ void EXhalbtc8723b2ant_BtInfoNotify(
halbtc8723b2ant_RunCoexistMechanism(pBtCoexist);
}
-void EXhalbtc8723b2ant_HaltNotify(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b2ant_HaltNotify(struct btc_coexist *pBtCoexist)
{
BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
@@ -3514,7 +3514,7 @@ void EXhalbtc8723b2ant_HaltNotify(PBTC_COEXIST pBtCoexist)
EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
}
-void EXhalbtc8723b2ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
+void EXhalbtc8723b2ant_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState)
{
BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
@@ -3528,7 +3528,7 @@ void EXhalbtc8723b2ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
}
}
-void EXhalbtc8723b2ant_Periodical(PBTC_COEXIST pBtCoexist)
+void EXhalbtc8723b2ant_Periodical(struct btc_coexist *pBtCoexist)
{
static u8 disVerInfoCnt;
u32 fwVer = 0, btPatchVer = 0;
diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h
index df973fcda48c..80db3ba34a3f 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h
+++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h
@@ -16,14 +16,14 @@
#define BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT 2
-typedef enum _BT_INFO_SRC_8723B_2ANT {
+enum {
BT_INFO_SRC_8723B_2ANT_WIFI_FW = 0x0,
BT_INFO_SRC_8723B_2ANT_BT_RSP = 0x1,
BT_INFO_SRC_8723B_2ANT_BT_ACTIVE_SEND = 0x2,
BT_INFO_SRC_8723B_2ANT_MAX
-} BT_INFO_SRC_8723B_2ANT, *PBT_INFO_SRC_8723B_2ANT;
+};
-typedef enum _BT_8723B_2ANT_BT_STATUS {
+enum {
BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0,
BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
BT_8723B_2ANT_BT_STATUS_INQ_PAGE = 0x2,
@@ -31,9 +31,9 @@ typedef enum _BT_8723B_2ANT_BT_STATUS {
BT_8723B_2ANT_BT_STATUS_SCO_BUSY = 0x4,
BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5,
BT_8723B_2ANT_BT_STATUS_MAX
-} BT_8723B_2ANT_BT_STATUS, *PBT_8723B_2ANT_BT_STATUS;
+};
-typedef enum _BT_8723B_2ANT_COEX_ALGO {
+enum {
BT_8723B_2ANT_COEX_ALGO_UNDEFINED = 0x0,
BT_8723B_2ANT_COEX_ALGO_SCO = 0x1,
BT_8723B_2ANT_COEX_ALGO_HID = 0x2,
@@ -46,9 +46,9 @@ typedef enum _BT_8723B_2ANT_COEX_ALGO {
BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9,
BT_8723B_2ANT_COEX_ALGO_HID_A2DP = 0xa,
BT_8723B_2ANT_COEX_ALGO_MAX = 0xb,
-} BT_8723B_2ANT_COEX_ALGO, *PBT_8723B_2ANT_COEX_ALGO;
+};
-typedef struct _COEX_DM_8723B_2ANT {
+struct coex_dm_8723b_2ant {
/* fw mechanism */
u8 preBtDecPwrLvl;
u8 curBtDecPwrLvl;
@@ -99,9 +99,9 @@ typedef struct _COEX_DM_8723B_2ANT {
bool bNeedRecover0x948;
u32 backup0x948;
-} COEX_DM_8723B_2ANT, *PCOEX_DM_8723B_2ANT;
+};
-typedef struct _COEX_STA_8723B_2ANT {
+struct coex_sta_8723b_2ant {
bool bBtLinkExist;
bool bScoExist;
bool bA2dpExist;
@@ -124,24 +124,24 @@ typedef struct _COEX_STA_8723B_2ANT {
bool bC2hBtInquiryPage;
u8 btRetryCnt;
u8 btInfoExt;
-} COEX_STA_8723B_2ANT, *PCOEX_STA_8723B_2ANT;
+};
/* */
/* The following is interface which will notify coex module. */
/* */
-void EXhalbtc8723b2ant_PowerOnSetting(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly);
-void EXhalbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b2ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b2ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b2ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b2ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b2ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtc8723b2ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type);
+void EXhalbtc8723b2ant_PowerOnSetting(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b2ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bWifiOnly);
+void EXhalbtc8723b2ant_InitCoexDm(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b2ant_IpsNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b2ant_LpsNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b2ant_ScanNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b2ant_ConnectNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b2ant_MediaStatusNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtc8723b2ant_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 type);
void EXhalbtc8723b2ant_BtInfoNotify(
- PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
+ struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
);
-void EXhalbtc8723b2ant_HaltNotify(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b2ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState);
-void EXhalbtc8723b2ant_Periodical(PBTC_COEXIST pBtCoexist);
-void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist);
+void EXhalbtc8723b2ant_HaltNotify(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b2ant_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState);
+void EXhalbtc8723b2ant_Periodical(struct btc_coexist *pBtCoexist);
+void EXhalbtc8723b2ant_DisplayCoexInfo(struct btc_coexist *pBtCoexist);
diff --git a/drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h b/drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h
index c758d143c57f..7b2d94a33d9c 100644
--- a/drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h
+++ b/drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h
@@ -44,31 +44,31 @@
#define BTC_ANT_WIFI_AT_CPL_MAIN 0
#define BTC_ANT_WIFI_AT_CPL_AUX 1
-typedef enum _BTC_POWERSAVE_TYPE {
+enum {
BTC_PS_WIFI_NATIVE = 0, /* wifi original power save behavior */
BTC_PS_LPS_ON = 1,
BTC_PS_LPS_OFF = 2,
BTC_PS_MAX
-} BTC_POWERSAVE_TYPE, *PBTC_POWERSAVE_TYPE;
+};
-typedef enum _BTC_BT_REG_TYPE {
+enum {
BTC_BT_REG_RF = 0,
BTC_BT_REG_MODEM = 1,
BTC_BT_REG_BLUEWIZE = 2,
BTC_BT_REG_VENDOR = 3,
BTC_BT_REG_LE = 4,
BTC_BT_REG_MAX
-} BTC_BT_REG_TYPE, *PBTC_BT_REG_TYPE;
+};
-typedef enum _BTC_CHIP_INTERFACE {
+enum btc_chip_interface {
BTC_INTF_UNKNOWN = 0,
BTC_INTF_PCI = 1,
BTC_INTF_USB = 2,
BTC_INTF_SDIO = 3,
BTC_INTF_MAX
-} BTC_CHIP_INTERFACE, *PBTC_CHIP_INTERFACE;
+};
-typedef enum _BTC_CHIP_TYPE {
+enum {
BTC_CHIP_UNDEF = 0,
BTC_CHIP_CSR_BC4 = 1,
BTC_CHIP_CSR_BC8 = 2,
@@ -76,13 +76,13 @@ typedef enum _BTC_CHIP_TYPE {
BTC_CHIP_RTL8821 = 4,
BTC_CHIP_RTL8723B = 5,
BTC_CHIP_MAX
-} BTC_CHIP_TYPE, *PBTC_CHIP_TYPE;
+};
-typedef enum _BTC_MSG_TYPE {
+enum {
BTC_MSG_INTERFACE = 0x0,
BTC_MSG_ALGORITHM = 0x1,
BTC_MSG_MAX
-} BTC_MSG_TYPE;
+};
extern u32 GLBtcDbgType[];
/* following is for BTC_MSG_INTERFACE */
@@ -120,14 +120,6 @@ extern u32 GLBtcDbgType[];
DbgPrint printstr;\
}
-#define BTC_PRINT_F(dbgtype, dbgflag, printstr)\
-{\
- if (GLBtcDbgType[dbgtype] & dbgflag) {\
- DbgPrint("%s(): ", __func__);\
- DbgPrint printstr;\
- } \
-}
-
#define BTC_PRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr)\
{\
if (GLBtcDbgType[dbgtype] & dbgflag) {\
@@ -164,7 +156,7 @@ extern u32 GLBtcDbgType[];
no_printk("%s %p %zu", _TitleString, _HexData, _HexDataLen)
#endif
-typedef struct _BTC_BOARD_INFO {
+struct btc_board_info {
/* The following is some board information */
u8 btChipType;
u8 pgAntNum; /* pg ant number */
@@ -172,19 +164,9 @@ typedef struct _BTC_BOARD_INFO {
u8 btdmAntPos; /* Bryant Add to indicate Antenna Position for (pgAntNum = 2) && (btdmAntNum = 1) (DPDT+1Ant case) */
u8 singleAntPath; /* current used for 8723b only, 1 =>s0, 0 =>s1 */
/* bool bBtExist; */
-} BTC_BOARD_INFO, *PBTC_BOARD_INFO;
-
-typedef enum _BTC_DBG_OPCODE {
- BTC_DBG_SET_COEX_NORMAL = 0x0,
- BTC_DBG_SET_COEX_WIFI_ONLY = 0x1,
- BTC_DBG_SET_COEX_BT_ONLY = 0x2,
- BTC_DBG_SET_COEX_DEC_BT_PWR = 0x3,
- BTC_DBG_SET_COEX_BT_AFH_MAP = 0x4,
- BTC_DBG_SET_COEX_BT_IGNORE_WLAN_ACT = 0x5,
- BTC_DBG_MAX
-} BTC_DBG_OPCODE, *PBTC_DBG_OPCODE;
-
-typedef enum _BTC_RSSI_STATE {
+};
+
+enum {
BTC_RSSI_STATE_HIGH = 0x0,
BTC_RSSI_STATE_MEDIUM = 0x1,
BTC_RSSI_STATE_LOW = 0x2,
@@ -192,51 +174,32 @@ typedef enum _BTC_RSSI_STATE {
BTC_RSSI_STATE_STAY_MEDIUM = 0x4,
BTC_RSSI_STATE_STAY_LOW = 0x5,
BTC_RSSI_MAX
-} BTC_RSSI_STATE, *PBTC_RSSI_STATE;
+};
#define BTC_RSSI_HIGH(_rssi_) ((_rssi_ == BTC_RSSI_STATE_HIGH || _rssi_ == BTC_RSSI_STATE_STAY_HIGH) ? true : false)
#define BTC_RSSI_MEDIUM(_rssi_) ((_rssi_ == BTC_RSSI_STATE_MEDIUM || _rssi_ == BTC_RSSI_STATE_STAY_MEDIUM) ? true : false)
#define BTC_RSSI_LOW(_rssi_) ((_rssi_ == BTC_RSSI_STATE_LOW || _rssi_ == BTC_RSSI_STATE_STAY_LOW) ? true : false)
-typedef enum _BTC_WIFI_ROLE {
- BTC_ROLE_STATION = 0x0,
- BTC_ROLE_AP = 0x1,
- BTC_ROLE_IBSS = 0x2,
- BTC_ROLE_HS_MODE = 0x3,
- BTC_ROLE_MAX
-} BTC_WIFI_ROLE, *PBTC_WIFI_ROLE;
-
-typedef enum _BTC_WIFI_BW_MODE {
+enum {
BTC_WIFI_BW_LEGACY = 0x0,
BTC_WIFI_BW_HT20 = 0x1,
BTC_WIFI_BW_HT40 = 0x2,
BTC_WIFI_BW_MAX
-} BTC_WIFI_BW_MODE, *PBTC_WIFI_BW_MODE;
+};
-typedef enum _BTC_WIFI_TRAFFIC_DIR {
+enum {
BTC_WIFI_TRAFFIC_TX = 0x0,
BTC_WIFI_TRAFFIC_RX = 0x1,
BTC_WIFI_TRAFFIC_MAX
-} BTC_WIFI_TRAFFIC_DIR, *PBTC_WIFI_TRAFFIC_DIR;
+};
-typedef enum _BTC_WIFI_PNP {
+enum {
BTC_WIFI_PNP_WAKE_UP = 0x0,
BTC_WIFI_PNP_SLEEP = 0x1,
BTC_WIFI_PNP_MAX
-} BTC_WIFI_PNP, *PBTC_WIFI_PNP;
-
-/* for 8723b-d cut large current issue */
-typedef enum _BT_WIFI_COEX_STATE {
- BTC_WIFI_STAT_INIT,
- BTC_WIFI_STAT_IQK,
- BTC_WIFI_STAT_NORMAL_OFF,
- BTC_WIFI_STAT_MP_OFF,
- BTC_WIFI_STAT_NORMAL,
- BTC_WIFI_STAT_ANT_DIV,
- BTC_WIFI_STAT_MAX
-} BT_WIFI_COEX_STATE, *PBT_WIFI_COEX_STATE;
+};
/* defined for BFP_BTC_GET */
-typedef enum _BTC_GET_TYPE {
+enum {
/* type bool */
BTC_GET_BL_HS_OPERATION,
BTC_GET_BL_HS_CONNECTING,
@@ -275,10 +238,10 @@ typedef enum _BTC_GET_TYPE {
BTC_GET_U1_LPS_MODE,
BTC_GET_MAX
-} BTC_GET_TYPE, *PBTC_GET_TYPE;
+};
/* defined for BFP_BTC_SET */
-typedef enum _BTC_SET_TYPE {
+enum {
/* type bool */
BTC_SET_BL_BT_DISABLE,
BTC_SET_BL_BT_TRAFFIC_BUSY,
@@ -316,65 +279,58 @@ typedef enum _BTC_SET_TYPE {
BTC_SET_ACT_CTRL_8723B_ANT,
/* */
BTC_SET_MAX
-} BTC_SET_TYPE, *PBTC_SET_TYPE;
+};
-typedef enum _BTC_DBG_DISP_TYPE {
+enum {
BTC_DBG_DISP_COEX_STATISTICS = 0x0,
BTC_DBG_DISP_BT_LINK_INFO = 0x1,
BTC_DBG_DISP_FW_PWR_MODE_CMD = 0x2,
BTC_DBG_DISP_MAX
-} BTC_DBG_DISP_TYPE, *PBTC_DBG_DISP_TYPE;
+};
-typedef enum _BTC_NOTIFY_TYPE_IPS {
+enum {
BTC_IPS_LEAVE = 0x0,
BTC_IPS_ENTER = 0x1,
BTC_IPS_MAX
-} BTC_NOTIFY_TYPE_IPS, *PBTC_NOTIFY_TYPE_IPS;
+};
-typedef enum _BTC_NOTIFY_TYPE_LPS {
+enum {
BTC_LPS_DISABLE = 0x0,
BTC_LPS_ENABLE = 0x1,
BTC_LPS_MAX
-} BTC_NOTIFY_TYPE_LPS, *PBTC_NOTIFY_TYPE_LPS;
+};
-typedef enum _BTC_NOTIFY_TYPE_SCAN {
+enum {
BTC_SCAN_FINISH = 0x0,
BTC_SCAN_START = 0x1,
BTC_SCAN_MAX
-} BTC_NOTIFY_TYPE_SCAN, *PBTC_NOTIFY_TYPE_SCAN;
+};
-typedef enum _BTC_NOTIFY_TYPE_ASSOCIATE {
+enum {
BTC_ASSOCIATE_FINISH = 0x0,
BTC_ASSOCIATE_START = 0x1,
BTC_ASSOCIATE_MAX
-} BTC_NOTIFY_TYPE_ASSOCIATE, *PBTC_NOTIFY_TYPE_ASSOCIATE;
+};
-typedef enum _BTC_NOTIFY_TYPE_MEDIA_STATUS {
+enum {
BTC_MEDIA_DISCONNECT = 0x0,
BTC_MEDIA_CONNECT = 0x1,
BTC_MEDIA_MAX
-} BTC_NOTIFY_TYPE_MEDIA_STATUS, *PBTC_NOTIFY_TYPE_MEDIA_STATUS;
+};
-typedef enum _BTC_NOTIFY_TYPE_SPECIAL_PACKET {
+enum {
BTC_PACKET_UNKNOWN = 0x0,
BTC_PACKET_DHCP = 0x1,
BTC_PACKET_ARP = 0x2,
BTC_PACKET_EAPOL = 0x3,
BTC_PACKET_MAX
-} BTC_NOTIFY_TYPE_SPECIAL_PACKET, *PBTC_NOTIFY_TYPE_SPECIAL_PACKET;
-
-typedef enum _BTC_NOTIFY_TYPE_STACK_OPERATION {
- BTC_STACK_OP_NONE = 0x0,
- BTC_STACK_OP_INQ_PAGE_PAIR_START = 0x1,
- BTC_STACK_OP_INQ_PAGE_PAIR_FINISH = 0x2,
- BTC_STACK_OP_MAX
-} BTC_NOTIFY_TYPE_STACK_OPERATION, *PBTC_NOTIFY_TYPE_STACK_OPERATION;
+};
/* Bryant Add */
-typedef enum _BTC_ANTENNA_POS {
+enum {
BTC_ANTENNA_AT_MAIN_PORT = 0x1,
BTC_ANTENNA_AT_AUX_PORT = 0x2,
-} BTC_ANTENNA_POS, *PBTC_ANTENNA_POS;
+};
typedef u8 (*BFP_BTC_R1)(void *pBtcContext, u32 RegAddr);
typedef u16(*BFP_BTC_R2)(void *pBtcContext, u32 RegAddr);
@@ -409,7 +365,7 @@ typedef void (*BFP_BTC_SET_BT_REG)(
typedef u32 (*BFP_BTC_GET_BT_REG)(void *pBtcContext, u8 regType, u32 offset);
typedef void (*BFP_BTC_DISP_DBG_MSG)(void *pBtCoexist, u8 dispType);
-typedef struct _BTC_BT_INFO {
+struct btc_bt_info {
bool bBtDisabled;
u8 rssiAdjustForAgcTableOn;
u8 rssiAdjustFor1AntCoexType;
@@ -435,9 +391,9 @@ typedef struct _BTC_BT_INFO {
u8 lpsVal;
u8 rpwmVal;
u32 raMask;
-} BTC_BT_INFO, *PBTC_BT_INFO;
+};
-typedef struct _BTC_STACK_INFO {
+struct btc_stack_info {
bool bProfileNotified;
u16 hciVersion; /* stack hci version */
u8 numOfLink;
@@ -450,9 +406,9 @@ typedef struct _BTC_STACK_INFO {
bool bPanExist;
bool bUnknownAclExist;
s8 minBtRssi;
-} BTC_STACK_INFO, *PBTC_STACK_INFO;
+};
-typedef struct _BTC_BT_LINK_INFO {
+struct btc_bt_link_info {
bool bBtLinkExist;
bool bScoExist;
bool bScoOnly;
@@ -463,9 +419,9 @@ typedef struct _BTC_BT_LINK_INFO {
bool bPanExist;
bool bPanOnly;
bool bSlaveRole;
-} BTC_BT_LINK_INFO, *PBTC_BT_LINK_INFO;
+};
-typedef struct _BTC_STATISTICS {
+struct btc_statistics {
u32 cntBind;
u32 cntPowerOn;
u32 cntInitHwConfig;
@@ -482,22 +438,22 @@ typedef struct _BTC_STATISTICS {
u32 cntCoexDmSwitch;
u32 cntStackOperationNotify;
u32 cntDbgCtrl;
-} BTC_STATISTICS, *PBTC_STATISTICS;
+};
-typedef struct _BTC_COEXIST {
+struct btc_coexist {
bool bBinded; /* make sure only one adapter can bind the data context */
void *Adapter; /* default adapter */
- BTC_BOARD_INFO boardInfo;
- BTC_BT_INFO btInfo; /* some bt info referenced by non-bt module */
- BTC_STACK_INFO stackInfo;
- BTC_BT_LINK_INFO btLinkInfo;
- BTC_CHIP_INTERFACE chipInterface;
+ struct btc_board_info boardInfo;
+ struct btc_bt_info btInfo; /* some bt info referenced by non-bt module */
+ struct btc_stack_info stackInfo;
+ struct btc_bt_link_info btLinkInfo;
+ enum btc_chip_interface chipInterface;
bool bInitilized;
bool bStopCoexDm;
bool bManualControl;
u8 *cliBuf;
- BTC_STATISTICS statistics;
+ struct btc_statistics statistics;
u8 pwrModeVal[10];
/* function pointers */
@@ -528,30 +484,30 @@ typedef struct _BTC_COEXIST {
BFP_BTC_GET_BT_REG fBtcGetBtReg;
BFP_BTC_SET_BT_REG fBtcSetBtReg;
-} BTC_COEXIST, *PBTC_COEXIST;
+};
-extern BTC_COEXIST GLBtCoexist;
+extern struct btc_coexist GLBtCoexist;
-void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist);
-void EXhalbtcoutsrc_InitHwConfig(PBTC_COEXIST pBtCoexist, u8 bWifiOnly);
-void EXhalbtcoutsrc_InitCoexDm(PBTC_COEXIST pBtCoexist);
-void EXhalbtcoutsrc_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtcoutsrc_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtcoutsrc_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type);
-void EXhalbtcoutsrc_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 action);
+void EXhalbtcoutsrc_PowerOnSetting(struct btc_coexist *pBtCoexist);
+void EXhalbtcoutsrc_InitHwConfig(struct btc_coexist *pBtCoexist, u8 bWifiOnly);
+void EXhalbtcoutsrc_InitCoexDm(struct btc_coexist *pBtCoexist);
+void EXhalbtcoutsrc_IpsNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtcoutsrc_LpsNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtcoutsrc_ScanNotify(struct btc_coexist *pBtCoexist, u8 type);
+void EXhalbtcoutsrc_ConnectNotify(struct btc_coexist *pBtCoexist, u8 action);
void EXhalbtcoutsrc_MediaStatusNotify(
- PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS mediaStatus
+ struct btc_coexist *pBtCoexist, enum rt_media_status mediaStatus
);
-void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType);
+void EXhalbtcoutsrc_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 pktType);
void EXhalbtcoutsrc_BtInfoNotify(
- PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length
+ struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
);
-void EXhalbtcoutsrc_HaltNotify(PBTC_COEXIST pBtCoexist);
-void EXhalbtcoutsrc_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState);
-void EXhalbtcoutsrc_Periodical(PBTC_COEXIST pBtCoexist);
+void EXhalbtcoutsrc_HaltNotify(struct btc_coexist *pBtCoexist);
+void EXhalbtcoutsrc_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState);
+void EXhalbtcoutsrc_Periodical(struct btc_coexist *pBtCoexist);
void EXhalbtcoutsrc_SetChipType(u8 chipType);
void EXhalbtcoutsrc_SetAntNum(u8 type, u8 antNum);
void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath);
-void EXhalbtcoutsrc_DisplayBtCoexInfo(PBTC_COEXIST pBtCoexist);
+void EXhalbtcoutsrc_DisplayBtCoexInfo(struct btc_coexist *pBtCoexist);
#endif
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
index 19856e806b1f..016d257b90a0 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
@@ -9,7 +9,7 @@
#include "odm_precomp.h"
static bool CheckPositive(
- PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
+ struct dm_odm_t *pDM_Odm, const u32 Condition1, const u32 Condition2
)
{
u8 _BoardType =
@@ -112,7 +112,7 @@ static bool CheckPositive(
}
static bool CheckNegative(
- PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
+ struct dm_odm_t *pDM_Odm, const u32 Condition1, const u32 Condition2
)
{
return true;
@@ -257,7 +257,7 @@ static u32 Array_MP_8723B_AGC_TAB[] = {
};
-void ODM_ReadAndConfig_MP_8723B_AGC_TAB(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_AGC_TAB(struct dm_odm_t *pDM_Odm)
{
u32 i = 0;
u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_AGC_TAB);
@@ -526,7 +526,7 @@ static u32 Array_MP_8723B_PHY_REG[] = {
};
-void ODM_ReadAndConfig_MP_8723B_PHY_REG(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_PHY_REG(struct dm_odm_t *pDM_Odm)
{
u32 i = 0;
u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_PHY_REG);
@@ -606,7 +606,7 @@ static u32 Array_MP_8723B_PHY_REG_PG[] = {
0, 0, 0, 0x00000e14, 0xffffffff, 0x26303436
};
-void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(struct dm_odm_t *pDM_Odm)
{
u32 i = 0;
u32 *Array = Array_MP_8723B_PHY_REG_PG;
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.h b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.h
index c1fbe91cd4f3..186007ce57d5 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.h
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.h
@@ -15,7 +15,7 @@
void
ODM_ReadAndConfig_MP_8723B_AGC_TAB(/* TC: Test Chip, MP: MP Chip */
- PDM_ODM_T pDM_Odm
+ struct dm_odm_t *pDM_Odm
);
/******************************************************************************
@@ -24,7 +24,7 @@ ODM_ReadAndConfig_MP_8723B_AGC_TAB(/* TC: Test Chip, MP: MP Chip */
void
ODM_ReadAndConfig_MP_8723B_PHY_REG(/* TC: Test Chip, MP: MP Chip */
- PDM_ODM_T pDM_Odm
+ struct dm_odm_t *pDM_Odm
);
/******************************************************************************
@@ -33,7 +33,7 @@ ODM_ReadAndConfig_MP_8723B_PHY_REG(/* TC: Test Chip, MP: MP Chip */
void
ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(/* TC: Test Chip, MP: MP Chip */
- PDM_ODM_T pDM_Odm
+ struct dm_odm_t *pDM_Odm
);
u32 ODM_GetVersion_MP_8723B_PHY_REG_PG(void);
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
index b80c5b11796b..677bcfa10b0d 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
@@ -9,7 +9,7 @@
#include "odm_precomp.h"
static bool CheckPositive(
- PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
+ struct dm_odm_t *pDM_Odm, const u32 Condition1, const u32 Condition2
)
{
u8 _BoardType =
@@ -111,7 +111,7 @@ static bool CheckPositive(
}
static bool CheckNegative(
- PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
+ struct dm_odm_t *pDM_Odm, const u32 Condition1, const u32 Condition2
)
{
return true;
@@ -228,7 +228,7 @@ static u32 Array_MP_8723B_MAC_REG[] = {
};
-void ODM_ReadAndConfig_MP_8723B_MAC_REG(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_MAC_REG(struct dm_odm_t *pDM_Odm)
{
u32 i = 0;
u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_MAC_REG);
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.h b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.h
index 788fdca1337b..50429c159fee 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.h
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.h
@@ -15,6 +15,6 @@
void
ODM_ReadAndConfig_MP_8723B_MAC_REG(/* TC: Test Chip, MP: MP Chip */
- PDM_ODM_T pDM_Odm
+ struct dm_odm_t *pDM_Odm
);
#endif
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
index 426f68b8f0d2..2c450c1ce7e7 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
@@ -9,7 +9,7 @@
#include "odm_precomp.h"
static bool CheckPositive(
- PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
+ struct dm_odm_t *pDM_Odm, const u32 Condition1, const u32 Condition2
)
{
u8 _BoardType =
@@ -121,7 +121,7 @@ static bool CheckPositive(
}
static bool CheckNegative(
- PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
+ struct dm_odm_t *pDM_Odm, const u32 Condition1, const u32 Condition2
)
{
return true;
@@ -259,7 +259,7 @@ static u32 Array_MP_8723B_RadioA[] = {
};
-void ODM_ReadAndConfig_MP_8723B_RadioA(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_RadioA(struct dm_odm_t *pDM_Odm)
{
u32 i = 0;
u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_RadioA);
@@ -420,9 +420,9 @@ static u8 gDeltaSwingTableIdx_MP_2GCCKA_P_TxPowerTrack_SDIO_8723B[] = {
8, 8, 9, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 15
};
-void ODM_ReadAndConfig_MP_8723B_TxPowerTrack_SDIO(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_TxPowerTrack_SDIO(struct dm_odm_t *pDM_Odm)
{
- PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
+ struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo;
ODM_RT_TRACE(
pDM_Odm,
@@ -755,7 +755,7 @@ static u8 *Array_MP_8723B_TXPWR_LMT[] = {
"MKK", "2.4G", "40M", "HT", "2T", "14", "63"
};
-void ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(PDM_ODM_T pDM_Odm)
+void ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(struct dm_odm_t *pDM_Odm)
{
u32 i = 0;
u8 **Array = Array_MP_8723B_TXPWR_LMT;
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.h b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.h
index 36a47437f974..acf5679d188c 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.h
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.h
@@ -15,7 +15,7 @@
void
ODM_ReadAndConfig_MP_8723B_RadioA(/* TC: Test Chip, MP: MP Chip */
- PDM_ODM_T pDM_Odm
+ struct dm_odm_t *pDM_Odm
);
/******************************************************************************
@@ -24,7 +24,7 @@ ODM_ReadAndConfig_MP_8723B_RadioA(/* TC: Test Chip, MP: MP Chip */
void
ODM_ReadAndConfig_MP_8723B_TxPowerTrack_SDIO(/* TC: Test Chip, MP: MP Chip */
- PDM_ODM_T pDM_Odm
+ struct dm_odm_t *pDM_Odm
);
u32 ODM_GetVersion_MP_8723B_TxPowerTrack_SDIO(void);
@@ -34,7 +34,7 @@ u32 ODM_GetVersion_MP_8723B_TxPowerTrack_SDIO(void);
void
ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(/* TC: Test Chip, MP: MP Chip */
- PDM_ODM_T pDM_Odm
+ struct dm_odm_t *pDM_Odm
);
u32 ODM_GetVersion_MP_8723B_TXPWR_LMT(void);
diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf.c b/drivers/staging/rtl8723bs/hal/HalPhyRf.c
index 7b435840746d..14426151faae 100644
--- a/drivers/staging/rtl8723bs/hal/HalPhyRf.c
+++ b/drivers/staging/rtl8723bs/hal/HalPhyRf.c
@@ -23,7 +23,7 @@
} while (0)
-void ConfigureTxpowerTrack(PDM_ODM_T pDM_Odm, PTXPWRTRACK_CFG pConfig)
+void ConfigureTxpowerTrack(struct dm_odm_t *pDM_Odm, struct txpwrtrack_cfg *pConfig)
{
ConfigureTxpowerTrack_8723B(pConfig);
}
@@ -36,7 +36,7 @@ void ConfigureTxpowerTrack(PDM_ODM_T pDM_Odm, PTXPWRTRACK_CFG pConfig)
/* NOTE: If Tx BB swing or Tx scaling is varified during run-time, still */
/* need to call this function. */
/* */
-void ODM_ClearTxPowerTrackingState(PDM_ODM_T pDM_Odm)
+void ODM_ClearTxPowerTrackingState(struct dm_odm_t *pDM_Odm)
{
struct hal_com_data *pHalData = GET_HAL_DATA(pDM_Odm->Adapter);
u8 p = 0;
@@ -74,7 +74,7 @@ void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter)
{
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
u8 ThermalValue = 0, delta, delta_LCK, delta_IQK, p = 0, i = 0;
u8 ThermalValue_AVG_count = 0;
@@ -83,7 +83,7 @@ void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter)
u8 OFDM_min_index = 0; /* OFDM BB Swing should be less than +3.0dB, which is required by Arthur */
u8 Indexforchannel = 0; /* GetRightChnlPlaceforIQK(pHalData->CurrentChannel) */
- TXPWRTRACK_CFG c;
+ struct txpwrtrack_cfg c;
/* 4 1. The following TWO tables decide the final index of OFDM/CCK swing table. */
diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf.h b/drivers/staging/rtl8723bs/hal/HalPhyRf.h
index 643fcf37c9ad..fdbdd68edf2a 100644
--- a/drivers/staging/rtl8723bs/hal/HalPhyRf.h
+++ b/drivers/staging/rtl8723bs/hal/HalPhyRf.h
@@ -8,23 +8,18 @@
#ifndef __HAL_PHY_RF_H__
#define __HAL_PHY_RF_H__
-typedef enum _SPUR_CAL_METHOD {
- PLL_RESET,
- AFE_PHASE_SEL
-} SPUR_CAL_METHOD;
-
-typedef enum _PWRTRACK_CONTROL_METHOD {
+enum pwrtrack_method {
BBSWING,
TXAGC,
MIX_MODE
-} PWRTRACK_METHOD;
+};
-typedef void (*FuncSetPwr)(PDM_ODM_T, PWRTRACK_METHOD, u8, u8);
-typedef void (*FuncIQK)(PDM_ODM_T, u8, u8, u8);
-typedef void (*FuncLCK)(PDM_ODM_T);
-typedef void (*FuncSwing)(PDM_ODM_T, u8 **, u8 **, u8 **, u8 **);
+typedef void (*FuncSetPwr)(struct dm_odm_t *, enum pwrtrack_method, u8, u8);
+typedef void (*FuncIQK)(struct dm_odm_t *, u8, u8, u8);
+typedef void (*FuncLCK)(struct dm_odm_t *);
+typedef void (*FuncSwing)(struct dm_odm_t *, u8 **, u8 **, u8 **, u8 **);
-typedef struct _TXPWRTRACK_CFG {
+struct txpwrtrack_cfg {
u8 SwingTableSize_CCK;
u8 SwingTableSize_OFDM;
u8 Threshold_IQK;
@@ -35,12 +30,12 @@ typedef struct _TXPWRTRACK_CFG {
FuncIQK DoIQK;
FuncLCK PHY_LCCalibrate;
FuncSwing GetDeltaSwingTable;
-} TXPWRTRACK_CFG, *PTXPWRTRACK_CFG;
+};
-void ConfigureTxpowerTrack(PDM_ODM_T pDM_Odm, PTXPWRTRACK_CFG pConfig);
+void ConfigureTxpowerTrack(struct dm_odm_t *pDM_Odm, struct txpwrtrack_cfg *pConfig);
-void ODM_ClearTxPowerTrackingState(PDM_ODM_T pDM_Odm);
+void ODM_ClearTxPowerTrackingState(struct dm_odm_t *pDM_Odm);
void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter);
diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c
index 645f4f2a835e..c70b9cf2da32 100644
--- a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c
+++ b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c
@@ -54,7 +54,7 @@ static u8 DeltaSwingTableIdx_2GA_P_8188E[] = {
static void setIqkMatrix_8723B(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u8 OFDM_index,
u8 RFPath,
s32 IqkResult_X,
@@ -135,7 +135,7 @@ static void setIqkMatrix_8723B(
}
-static void setCCKFilterCoefficient(PDM_ODM_T pDM_Odm, u8 CCKSwingIndex)
+static void setCCKFilterCoefficient(struct dm_odm_t *pDM_Odm, u8 CCKSwingIndex)
{
if (!pDM_Odm->RFCalibrateInfo.bCCKinCH14) {
rtw_write8(pDM_Odm->Adapter, 0xa22, CCKSwingTable_Ch1_Ch13_New[CCKSwingIndex][0]);
@@ -159,7 +159,7 @@ static void setCCKFilterCoefficient(PDM_ODM_T pDM_Odm, u8 CCKSwingIndex)
}
void DoIQK_8723B(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u8 DeltaThermalIndex,
u8 ThermalValue,
u8 Threshold
@@ -185,8 +185,8 @@ void DoIQK_8723B(
*
*---------------------------------------------------------------------------*/
void ODM_TxPwrTrackSetPwr_8723B(
- PDM_ODM_T pDM_Odm,
- PWRTRACK_METHOD Method,
+ struct dm_odm_t *pDM_Odm,
+ enum pwrtrack_method Method,
u8 RFPath,
u8 ChannelMappedIndex
)
@@ -360,7 +360,7 @@ void ODM_TxPwrTrackSetPwr_8723B(
}
static void GetDeltaSwingTable_8723B(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u8 **TemperatureUP_A,
u8 **TemperatureDOWN_A,
u8 **TemperatureUP_B,
@@ -368,7 +368,7 @@ static void GetDeltaSwingTable_8723B(
)
{
struct adapter *Adapter = pDM_Odm->Adapter;
- PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
+ struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo;
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
u16 rate = *(pDM_Odm->pForcedDataRate);
u8 channel = pHalData->CurrentChannel;
@@ -409,7 +409,7 @@ static void GetDeltaSwingTable_8723B(
}
-void ConfigureTxpowerTrack_8723B(PTXPWRTRACK_CFG pConfig)
+void ConfigureTxpowerTrack_8723B(struct txpwrtrack_cfg *pConfig)
{
pConfig->SwingTableSize_CCK = CCK_TABLE_SIZE;
pConfig->SwingTableSize_OFDM = OFDM_TABLE_SIZE;
@@ -437,7 +437,7 @@ static u8 phy_PathA_IQK_8723B(
u8 result = 0x00;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
/* Save RF Path */
Path_SEL_BB = PHY_QueryBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord);
@@ -548,7 +548,7 @@ static u8 phy_PathA_RxIQK8723B(
u32 regEAC, regE94, regE9C, regEA4, u4tmp, tmp, Path_SEL_BB;
u8 result = 0x00;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
/* ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK!\n")); */
@@ -762,7 +762,7 @@ static u8 phy_PathB_IQK_8723B(struct adapter *padapter)
u32 regEAC, regE94, regE9C, tmp, Path_SEL_BB/*, regEC4, regECC, Path_SEL_BB*/;
u8 result = 0x00;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK!\n"));
@@ -869,7 +869,7 @@ static u8 phy_PathB_RxIQK8723B(struct adapter *padapter, bool configPathB)
u32 regE94, regE9C, regEA4, regEAC, u4tmp, tmp, Path_SEL_BB;
u8 result = 0x00;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
/* ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B Rx IQK!\n")); */
@@ -1092,9 +1092,9 @@ static void _PHY_PathAFillIQKMatrix8723B(
u32 Oldval_0, X, TX0_A, reg;
s32 Y, TX0_C;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
- PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
+ struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo;
ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A IQ Calibration %s !\n", (bIQKOK)?"Success":"Failed"));
@@ -1172,9 +1172,9 @@ static void _PHY_PathBFillIQKMatrix8723B(
u32 Oldval_1, X, TX1_A, reg;
s32 Y, TX1_C;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
- PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
+ struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo;
ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQ Calibration %s !\n", (bIQKOK)?"Success":"Failed"));
@@ -1247,10 +1247,10 @@ static void _PHY_PathBFillIQKMatrix8723B(
/* */
/* MP Already declare in odm.c */
-void ODM_SetIQCbyRFpath(PDM_ODM_T pDM_Odm, u32 RFpath)
+void ODM_SetIQCbyRFpath(struct dm_odm_t *pDM_Odm, u32 RFpath)
{
- PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
+ struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo;
if (
(pRFCalibrateInfo->TxIQC_8723B[PATH_S0][IDX_0xC80][VAL] != 0x0) &&
@@ -1292,7 +1292,7 @@ static void _PHY_SaveADDARegisters8723B(
{
u32 i;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
if (!ODM_CheckPowerStatus(padapter))
return;
@@ -1310,7 +1310,7 @@ static void _PHY_SaveMACRegisters8723B(
{
u32 i;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save MAC parameters.\n"));
for (i = 0 ; i < (IQK_MAC_REG_NUM - 1); i++) {
@@ -1330,7 +1330,7 @@ static void _PHY_ReloadADDARegisters8723B(
{
u32 i;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Reload ADDA power saving parameters !\n"));
for (i = 0 ; i < RegiesterNum; i++) {
@@ -1360,7 +1360,7 @@ static void _PHY_PathADDAOn8723B(
u32 pathOn;
u32 i;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("ADDA ON.\n"));
@@ -1384,7 +1384,7 @@ static void _PHY_MACSettingCalibration8723B(
{
u32 i = 0;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("MAC settings for Calibration.\n"));
@@ -1489,7 +1489,7 @@ static void phy_IQCalibrate_8723B(
)
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
u32 i;
u8 PathAOK, PathBOK;
@@ -1697,7 +1697,7 @@ static void phy_IQCalibrate_8723B(
}
-static void phy_LCCalibrate_8723B(PDM_ODM_T pDM_Odm, bool is2T)
+static void phy_LCCalibrate_8723B(struct dm_odm_t *pDM_Odm, bool is2T)
{
u8 tmpReg;
u32 RF_Amode = 0, RF_Bmode = 0, LC_Cal;
@@ -1784,7 +1784,7 @@ void PHY_IQCalibrate_8723B(
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
s32 result[4][8]; /* last is final result */
u8 i, final_candidate;
@@ -1830,7 +1830,7 @@ void PHY_IQCalibrate_8723B(
if (bRestore) {
u32 offset, data;
u8 path, bResult = SUCCESS;
- PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo);
+ struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo;
path = (PHY_QueryBBReg(pDM_Odm->Adapter, rS0S1_PathSwitch, bMaskByte0) == 0x00) ? ODM_RF_PATH_A : ODM_RF_PATH_B;
@@ -1839,15 +1839,9 @@ void PHY_IQCalibrate_8723B(
offset = pRFCalibrateInfo->TxIQC_8723B[path][i][0];
data = pRFCalibrateInfo->TxIQC_8723B[path][i][1];
if ((offset == 0) || (data == 0)) {
- DBG_871X(
- "%s =>path:%s Restore TX IQK result failed\n",
- __func__,
- (path == ODM_RF_PATH_A)?"A":"B"
- );
bResult = FAIL;
break;
}
- /* RT_TRACE(_module_mp_, _drv_notice_, ("Switch to S1 TxIQC(offset, data) = (0x%X, 0x%X)\n", offset, data)); */
PHY_SetBBReg(pDM_Odm->Adapter, offset, bMaskDWord, data);
}
@@ -1856,20 +1850,13 @@ void PHY_IQCalibrate_8723B(
offset = pRFCalibrateInfo->RxIQC_8723B[path][i][0];
data = pRFCalibrateInfo->RxIQC_8723B[path][i][1];
if ((offset == 0) || (data == 0)) {
- DBG_871X(
- "%s =>path:%s Restore RX IQK result failed\n",
- __func__,
- (path == ODM_RF_PATH_A)?"A":"B"
- );
bResult = FAIL;
break;
}
- /* RT_TRACE(_module_mp_, _drv_notice_, ("Switch to S1 RxIQC (offset, data) = (0x%X, 0x%X)\n", offset, data)); */
PHY_SetBBReg(pDM_Odm->Adapter, offset, bMaskDWord, data);
}
if (pDM_Odm->RFCalibrateInfo.TxLOK[ODM_RF_PATH_A] == 0) {
- DBG_871X("%s => Restore Path-A TxLOK result failed\n", __func__);
bResult = FAIL;
} else {
PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXM_IDAC, bRFRegOffsetMask, pDM_Odm->RFCalibrateInfo.TxLOK[ODM_RF_PATH_A]);
@@ -1950,7 +1937,6 @@ void PHY_IQCalibrate_8723B(
}
}
}
-/* RT_TRACE(COMP_INIT, DBG_LOUD, ("Release Mutex in IQCalibrate\n")); */
for (i = 0; i < 4; i++) {
RegE94 = result[i][0];
@@ -2038,7 +2024,7 @@ void PHY_IQCalibrate_8723B(
}
-void PHY_LCCalibrate_8723B(PDM_ODM_T pDM_Odm)
+void PHY_LCCalibrate_8723B(struct dm_odm_t *pDM_Odm)
{
bool bSingleTone = false, bCarrierSuppression = false;
u32 timeout = 2000, timecount = 0;
diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.h b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.h
index a4d5150007be..775095ad0921 100644
--- a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.h
+++ b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.h
@@ -16,18 +16,18 @@
#define RF_T_METER_8723B 0x42 /* */
-void ConfigureTxpowerTrack_8723B(PTXPWRTRACK_CFG pConfig);
+void ConfigureTxpowerTrack_8723B(struct txpwrtrack_cfg *pConfig);
void DoIQK_8723B(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u8 DeltaThermalIndex,
u8 ThermalValue,
u8 Threshold
);
void ODM_TxPwrTrackSetPwr_8723B(
- PDM_ODM_T pDM_Odm,
- PWRTRACK_METHOD Method,
+ struct dm_odm_t *pDM_Odm,
+ enum pwrtrack_method Method,
u8 RFPath,
u8 ChannelMappedIndex
);
@@ -41,12 +41,12 @@ void PHY_IQCalibrate_8723B(
u8 RF_Path
);
-void ODM_SetIQCbyRFpath(PDM_ODM_T pDM_Odm, u32 RFpath);
+void ODM_SetIQCbyRFpath(struct dm_odm_t *pDM_Odm, u32 RFpath);
/* */
/* LC calibrate */
/* */
-void PHY_LCCalibrate_8723B(PDM_ODM_T pDM_Odm);
+void PHY_LCCalibrate_8723B(struct dm_odm_t *pDM_Odm);
/* */
/* AP calibrate */
diff --git a/drivers/staging/rtl8723bs/hal/HalPwrSeqCmd.c b/drivers/staging/rtl8723bs/hal/HalPwrSeqCmd.c
index 3b34a516075f..5f9e94a7e6ad 100644
--- a/drivers/staging/rtl8723bs/hal/HalPwrSeqCmd.c
+++ b/drivers/staging/rtl8723bs/hal/HalPwrSeqCmd.c
@@ -39,10 +39,10 @@ u8 HalPwrSeqCmdParsing(
u8 CutVersion,
u8 FabVersion,
u8 InterfaceType,
- WLAN_PWR_CFG PwrSeqCmd[]
+ struct wlan_pwr_cfg PwrSeqCmd[]
)
{
- WLAN_PWR_CFG PwrCfgCmd;
+ struct wlan_pwr_cfg PwrCfgCmd;
u8 bPollingBit = false;
u32 AryIdx = 0;
u8 value = 0;
@@ -53,22 +53,6 @@ u8 HalPwrSeqCmdParsing(
do {
PwrCfgCmd = PwrSeqCmd[AryIdx];
- RT_TRACE(
- _module_hal_init_c_,
- _drv_info_,
- (
- "HalPwrSeqCmdParsing: 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 */
if (
(GET_PWR_CFG_FAB_MASK(PwrCfgCmd) & FabVersion) &&
@@ -77,19 +61,9 @@ u8 HalPwrSeqCmdParsing(
) {
switch (GET_PWR_CFG_CMD(PwrCfgCmd)) {
case PWR_CMD_READ:
- RT_TRACE(
- _module_hal_init_c_,
- _drv_info_,
- ("HalPwrSeqCmdParsing: PWR_CMD_READ\n")
- );
break;
case PWR_CMD_WRITE:
- RT_TRACE(
- _module_hal_init_c_,
- _drv_info_,
- ("HalPwrSeqCmdParsing: PWR_CMD_WRITE\n")
- );
offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);
/* */
@@ -124,11 +98,6 @@ u8 HalPwrSeqCmdParsing(
break;
case PWR_CMD_POLLING:
- RT_TRACE(
- _module_hal_init_c_,
- _drv_info_,
- ("HalPwrSeqCmdParsing: PWR_CMD_POLLING\n")
- );
bPollingBit = false;
offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);
@@ -147,24 +116,14 @@ u8 HalPwrSeqCmdParsing(
else
udelay(10);
- if (pollingCount++ > maxPollingCnt) {
- DBG_871X(
- "Fail to polling Offset[%#x]=%02x\n",
- offset,
- value
- );
+ if (pollingCount++ > maxPollingCnt)
return false;
- }
+
} while (!bPollingBit);
break;
case PWR_CMD_DELAY:
- RT_TRACE(
- _module_hal_init_c_,
- _drv_info_,
- ("HalPwrSeqCmdParsing: PWR_CMD_DELAY\n")
- );
if (GET_PWR_CFG_VALUE(PwrCfgCmd) == PWRSEQ_DELAY_US)
udelay(GET_PWR_CFG_OFFSET(PwrCfgCmd));
else
@@ -173,19 +132,9 @@ u8 HalPwrSeqCmdParsing(
case PWR_CMD_END:
/* When this command is parsed, end the process */
- RT_TRACE(
- _module_hal_init_c_,
- _drv_info_,
- ("HalPwrSeqCmdParsing: PWR_CMD_END\n")
- );
return true;
default:
- RT_TRACE(
- _module_hal_init_c_,
- _drv_err_,
- ("HalPwrSeqCmdParsing: Unknown CMD!!\n")
- );
break;
}
}
diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c
index 3705a60a0546..5802ed4c6f82 100644
--- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c
+++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c
@@ -13,29 +13,29 @@
/* Global variables */
-BTC_COEXIST GLBtCoexist;
+struct btc_coexist GLBtCoexist;
static u8 GLBtcWiFiInScanState;
static u8 GLBtcWiFiInIQKState;
u32 GLBtcDbgType[BTC_MSG_MAX];
static u8 GLBtcDbgBuf[BT_TMP_BUF_SIZE];
-typedef struct _btcoexdbginfo {
+struct btcdbginfo { /* _btcoexdbginfo */
u8 *info;
u32 size; /* buffer total size */
u32 len; /* now used length */
-} BTCDBGINFO, *PBTCDBGINFO;
+};
-static BTCDBGINFO GLBtcDbgInfo;
+static struct btcdbginfo GLBtcDbgInfo;
#define BT_Operation(Adapter) false
-static void DBG_BT_INFO_INIT(PBTCDBGINFO pinfo, u8 *pbuf, u32 size)
+static void DBG_BT_INFO_INIT(struct btcdbginfo *pinfo, u8 *pbuf, u32 size)
{
if (!pinfo)
return;
- memset(pinfo, 0, sizeof(BTCDBGINFO));
+ memset(pinfo, 0, sizeof(struct btcdbginfo));
if (pbuf && size) {
pinfo->info = pbuf;
@@ -45,7 +45,7 @@ static void DBG_BT_INFO_INIT(PBTCDBGINFO pinfo, u8 *pbuf, u32 size)
void DBG_BT_INFO(u8 *dbgmsg)
{
- PBTCDBGINFO pinfo;
+ struct btcdbginfo *pinfo;
u32 msglen;
u8 *pbuf;
@@ -67,7 +67,7 @@ void DBG_BT_INFO(u8 *dbgmsg)
/* */
/* Debug related function */
/* */
-static u8 halbtcoutsrc_IsBtCoexistAvailable(PBTC_COEXIST pBtCoexist)
+static u8 halbtcoutsrc_IsBtCoexistAvailable(struct btc_coexist *pBtCoexist)
{
if (!pBtCoexist->bBinded || !pBtCoexist->Adapter)
return false;
@@ -101,7 +101,7 @@ static void halbtcoutsrc_DbgInit(void)
0;
}
-static void halbtcoutsrc_LeaveLps(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_LeaveLps(struct btc_coexist *pBtCoexist)
{
struct adapter *padapter;
@@ -114,7 +114,7 @@ static void halbtcoutsrc_LeaveLps(PBTC_COEXIST pBtCoexist)
rtw_btcoex_LPS_Leave(padapter);
}
-static void halbtcoutsrc_EnterLps(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_EnterLps(struct btc_coexist *pBtCoexist)
{
struct adapter *padapter;
@@ -127,7 +127,7 @@ static void halbtcoutsrc_EnterLps(PBTC_COEXIST pBtCoexist)
rtw_btcoex_LPS_Enter(padapter);
}
-static void halbtcoutsrc_NormalLps(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_NormalLps(struct btc_coexist *pBtCoexist)
{
struct adapter *padapter;
@@ -149,7 +149,7 @@ static void halbtcoutsrc_NormalLps(PBTC_COEXIST pBtCoexist)
* Constraint:
* 1. this function will request pwrctrl->lock
*/
-static void halbtcoutsrc_LeaveLowPower(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_LeaveLowPower(struct btc_coexist *pBtCoexist)
{
struct adapter *padapter;
s32 ready;
@@ -184,7 +184,7 @@ static void halbtcoutsrc_LeaveLowPower(PBTC_COEXIST pBtCoexist)
* Constraint:
* 1. this function will request pwrctrl->lock
*/
-static void halbtcoutsrc_NormalLowPower(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_NormalLowPower(struct btc_coexist *pBtCoexist)
{
struct adapter *padapter;
@@ -193,7 +193,7 @@ static void halbtcoutsrc_NormalLowPower(PBTC_COEXIST pBtCoexist)
rtw_unregister_task_alive(padapter, BTCOEX_ALIVE);
}
-static void halbtcoutsrc_DisableLowPower(PBTC_COEXIST pBtCoexist, u8 bLowPwrDisable)
+static void halbtcoutsrc_DisableLowPower(struct btc_coexist *pBtCoexist, u8 bLowPwrDisable)
{
pBtCoexist->btInfo.bBtDisableLowPwr = bLowPwrDisable;
if (bLowPwrDisable)
@@ -202,7 +202,7 @@ static void halbtcoutsrc_DisableLowPower(PBTC_COEXIST pBtCoexist, u8 bLowPwrDisa
halbtcoutsrc_NormalLowPower(pBtCoexist); /* original 32k low power behavior. */
}
-static void halbtcoutsrc_AggregationCheck(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_AggregationCheck(struct btc_coexist *pBtCoexist)
{
struct adapter *padapter;
bool bNeedToAct;
@@ -280,7 +280,7 @@ static u32 _halbtcoutsrc_GetWifiLinkStatus(struct adapter *padapter)
return portConnectedStatus;
}
-static u32 halbtcoutsrc_GetWifiLinkStatus(PBTC_COEXIST pBtCoexist)
+static u32 halbtcoutsrc_GetWifiLinkStatus(struct btc_coexist *pBtCoexist)
{
/* */
/* return value: */
@@ -308,7 +308,7 @@ static u32 halbtcoutsrc_GetWifiLinkStatus(PBTC_COEXIST pBtCoexist)
return retVal;
}
-static u32 halbtcoutsrc_GetBtPatchVer(PBTC_COEXIST pBtCoexist)
+static u32 halbtcoutsrc_GetBtPatchVer(struct btc_coexist *pBtCoexist)
{
return pBtCoexist->btInfo.btRealFwVer;
}
@@ -339,7 +339,7 @@ static u8 halbtcoutsrc_GetWifiScanAPNum(struct adapter *padapter)
static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
struct hal_com_data *pHalData;
struct mlme_ext_priv *mlmeext;
@@ -349,7 +349,7 @@ static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
u8 ret;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
return false;
@@ -445,7 +445,7 @@ static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
{
- PRT_LINK_DETECT_T plinkinfo;
+ struct rt_link_detect_t *plinkinfo;
plinkinfo = &padapter->mlmepriv.LinkDetectInfo;
if (plinkinfo->NumTxOkInPeriod > plinkinfo->NumRxOkInPeriod)
@@ -507,14 +507,14 @@ static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
u8 *pu8;
u32 *pU4Tmp;
u8 ret;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
pu8 = pInBuf;
pU4Tmp = pInBuf;
@@ -642,7 +642,7 @@ static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf)
return ret;
}
-static void halbtcoutsrc_DisplayFwPwrModeCmd(PBTC_COEXIST pBtCoexist)
+static void halbtcoutsrc_DisplayFwPwrModeCmd(struct btc_coexist *pBtCoexist)
{
u8 *cliBuf = pBtCoexist->cliBuf;
@@ -658,11 +658,11 @@ static void halbtcoutsrc_DisplayFwPwrModeCmd(PBTC_COEXIST pBtCoexist)
/* */
static u8 halbtcoutsrc_Read1Byte(void *pBtcContext, u32 RegAddr)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
return rtw_read8(padapter, RegAddr);
@@ -670,11 +670,11 @@ static u8 halbtcoutsrc_Read1Byte(void *pBtcContext, u32 RegAddr)
static u16 halbtcoutsrc_Read2Byte(void *pBtcContext, u32 RegAddr)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
return rtw_read16(padapter, RegAddr);
@@ -682,11 +682,11 @@ static u16 halbtcoutsrc_Read2Byte(void *pBtcContext, u32 RegAddr)
static u32 halbtcoutsrc_Read4Byte(void *pBtcContext, u32 RegAddr)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
return rtw_read32(padapter, RegAddr);
@@ -694,11 +694,11 @@ static u32 halbtcoutsrc_Read4Byte(void *pBtcContext, u32 RegAddr)
static void halbtcoutsrc_Write1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
rtw_write8(padapter, RegAddr, Data);
@@ -706,13 +706,13 @@ static void halbtcoutsrc_Write1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
static void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bitMask, u8 data1b)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
u8 originalValue, bitShift;
u8 i;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
originalValue = 0;
bitShift = 0;
@@ -721,7 +721,7 @@ static void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bi
originalValue = rtw_read8(padapter, regAddr);
for (i = 0; i <= 7; i++) {
- if ((bitMask>>i)&0x1)
+ if ((bitMask >> i) & 0x1)
break;
}
bitShift = i;
@@ -734,11 +734,11 @@ static void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bi
static void halbtcoutsrc_Write2Byte(void *pBtcContext, u32 RegAddr, u16 Data)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
rtw_write16(padapter, RegAddr, Data);
@@ -746,11 +746,11 @@ static void halbtcoutsrc_Write2Byte(void *pBtcContext, u32 RegAddr, u16 Data)
static void halbtcoutsrc_Write4Byte(void *pBtcContext, u32 RegAddr, u32 Data)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
rtw_write32(padapter, RegAddr, Data);
@@ -758,7 +758,7 @@ static void halbtcoutsrc_Write4Byte(void *pBtcContext, u32 RegAddr, u32 Data)
static void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
{
- PBTC_COEXIST pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
struct adapter *Adapter = pBtCoexist->Adapter;
if (BTC_INTF_SDIO == pBtCoexist->chipInterface)
@@ -769,11 +769,11 @@ static void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 D
static void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u32 Data)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
PHY_SetBBReg(padapter, RegAddr, BitMask, Data);
@@ -782,11 +782,11 @@ static void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u
static u32 halbtcoutsrc_GetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
return PHY_QueryBBReg(padapter, RegAddr, BitMask);
@@ -794,11 +794,11 @@ static u32 halbtcoutsrc_GetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask)
static void halbtcoutsrc_SetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
PHY_SetRFReg(padapter, eRFPath, RegAddr, BitMask, Data);
@@ -806,11 +806,11 @@ static void halbtcoutsrc_SetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u3
static u32 halbtcoutsrc_GetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
return PHY_QueryRFReg(padapter, eRFPath, RegAddr, BitMask);
@@ -818,7 +818,7 @@ static u32 halbtcoutsrc_GetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32
static void halbtcoutsrc_SetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u32 Data)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
u8 CmdBuffer1[4] = {0};
u8 CmdBuffer2[4] = {0};
@@ -827,7 +827,7 @@ static void halbtcoutsrc_SetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u3
u8 OperVer = 0;
u8 ReqNum = 0;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
CmdBuffer1[0] |= (OperVer & 0x0f); /* Set OperVer */
@@ -854,11 +854,11 @@ static u32 halbtcoutsrc_GetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr)
static void halbtcoutsrc_FillH2cCmd(void *pBtcContext, u8 elementId, u32 cmdLen, u8 *pCmdBuffer)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
struct adapter *padapter;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
padapter = pBtCoexist->Adapter;
rtw_hal_fill_h2c_cmd(padapter, elementId, cmdLen, pCmdBuffer);
@@ -866,10 +866,10 @@ static void halbtcoutsrc_FillH2cCmd(void *pBtcContext, u8 elementId, u32 cmdLen,
static void halbtcoutsrc_DisplayDbgMsg(void *pBtcContext, u8 dispType)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
- pBtCoexist = (PBTC_COEXIST)pBtcContext;
+ pBtCoexist = (struct btc_coexist *)pBtcContext;
switch (dispType) {
case BTC_DBG_DISP_COEX_STATISTICS:
break;
@@ -888,7 +888,7 @@ static void halbtcoutsrc_DisplayDbgMsg(void *pBtcContext, u8 dispType)
/* */
static u8 EXhalbtcoutsrc_BindBtCoexWithAdapter(void *padapter)
{
- PBTC_COEXIST pBtCoexist = &GLBtCoexist;
+ struct btc_coexist *pBtCoexist = &GLBtCoexist;
if (pBtCoexist->bBinded)
return false;
@@ -914,7 +914,7 @@ static u8 EXhalbtcoutsrc_BindBtCoexWithAdapter(void *padapter)
void hal_btcoex_Initialize(void *padapter)
{
- PBTC_COEXIST pBtCoexist;
+ struct btc_coexist *pBtCoexist;
memset(&GLBtCoexist, 0, sizeof(GLBtCoexist));
@@ -960,7 +960,7 @@ void hal_btcoex_Initialize(void *padapter)
GLBtcWiFiInIQKState = false;
}
-void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist)
+void EXhalbtcoutsrc_PowerOnSetting(struct btc_coexist *pBtCoexist)
{
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
return;
@@ -972,7 +972,7 @@ void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist)
EXhalbtc8723b1ant_PowerOnSetting(pBtCoexist);
}
-void EXhalbtcoutsrc_InitHwConfig(PBTC_COEXIST pBtCoexist, u8 bWifiOnly)
+void EXhalbtcoutsrc_InitHwConfig(struct btc_coexist *pBtCoexist, u8 bWifiOnly)
{
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
return;
@@ -985,7 +985,7 @@ void EXhalbtcoutsrc_InitHwConfig(PBTC_COEXIST pBtCoexist, u8 bWifiOnly)
EXhalbtc8723b1ant_InitHwConfig(pBtCoexist, bWifiOnly);
}
-void EXhalbtcoutsrc_InitCoexDm(PBTC_COEXIST pBtCoexist)
+void EXhalbtcoutsrc_InitCoexDm(struct btc_coexist *pBtCoexist)
{
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
return;
@@ -1000,7 +1000,7 @@ void EXhalbtcoutsrc_InitCoexDm(PBTC_COEXIST pBtCoexist)
pBtCoexist->bInitilized = true;
}
-void EXhalbtcoutsrc_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtcoutsrc_IpsNotify(struct btc_coexist *pBtCoexist, u8 type)
{
u8 ipsType;
@@ -1027,7 +1027,7 @@ void EXhalbtcoutsrc_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
}
-void EXhalbtcoutsrc_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtcoutsrc_LpsNotify(struct btc_coexist *pBtCoexist, u8 type)
{
u8 lpsType;
@@ -1050,7 +1050,7 @@ void EXhalbtcoutsrc_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type)
EXhalbtc8723b1ant_LpsNotify(pBtCoexist, lpsType);
}
-void EXhalbtcoutsrc_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
+void EXhalbtcoutsrc_ScanNotify(struct btc_coexist *pBtCoexist, u8 type)
{
u8 scanType;
@@ -1079,7 +1079,7 @@ void EXhalbtcoutsrc_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type)
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
}
-void EXhalbtcoutsrc_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 action)
+void EXhalbtcoutsrc_ConnectNotify(struct btc_coexist *pBtCoexist, u8 action)
{
u8 assoType;
@@ -1105,7 +1105,8 @@ void EXhalbtcoutsrc_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 action)
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
}
-void EXhalbtcoutsrc_MediaStatusNotify(PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS mediaStatus)
+void EXhalbtcoutsrc_MediaStatusNotify(struct btc_coexist *pBtCoexist, enum
+ rt_media_status mediaStatus)
{
u8 mStatus;
@@ -1132,7 +1133,7 @@ void EXhalbtcoutsrc_MediaStatusNotify(PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS m
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
}
-void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType)
+void EXhalbtcoutsrc_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 pktType)
{
u8 packetType;
@@ -1163,7 +1164,7 @@ void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType)
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
}
-void EXhalbtcoutsrc_BtInfoNotify(PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length)
+void EXhalbtcoutsrc_BtInfoNotify(struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length)
{
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
return;
@@ -1181,7 +1182,7 @@ void EXhalbtcoutsrc_BtInfoNotify(PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length)
/* halbtcoutsrc_NormalLowPower(pBtCoexist); */
}
-void EXhalbtcoutsrc_HaltNotify(PBTC_COEXIST pBtCoexist)
+void EXhalbtcoutsrc_HaltNotify(struct btc_coexist *pBtCoexist)
{
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
return;
@@ -1194,7 +1195,7 @@ void EXhalbtcoutsrc_HaltNotify(PBTC_COEXIST pBtCoexist)
pBtCoexist->bBinded = false;
}
-void EXhalbtcoutsrc_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
+void EXhalbtcoutsrc_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState)
{
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
return;
@@ -1210,7 +1211,7 @@ void EXhalbtcoutsrc_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState)
EXhalbtc8723b2ant_PnpNotify(pBtCoexist, pnpState);
}
-void EXhalbtcoutsrc_Periodical(PBTC_COEXIST pBtCoexist)
+void EXhalbtcoutsrc_Periodical(struct btc_coexist *pBtCoexist)
{
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
return;
@@ -1255,7 +1256,7 @@ void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath)
GLBtCoexist.boardInfo.singleAntPath = singleAntPath;
}
-void EXhalbtcoutsrc_DisplayBtCoexInfo(PBTC_COEXIST pBtCoexist)
+void EXhalbtcoutsrc_DisplayBtCoexInfo(struct btc_coexist *pBtCoexist)
{
if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
return;
@@ -1481,15 +1482,15 @@ u32 hal_btcoex_GetRaMask(struct adapter *padapter)
void hal_btcoex_RecordPwrMode(struct adapter *padapter, u8 *pCmdBuf, u8 cmdLen)
{
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write pwrModeCmd = 0x%04x%08x\n",
- pCmdBuf[0]<<8|pCmdBuf[1],
- pCmdBuf[2]<<24|pCmdBuf[3]<<16|pCmdBuf[4]<<8|pCmdBuf[5]));
+ pCmdBuf[0] << 8 | pCmdBuf[1],
+ pCmdBuf[2] << 24 | pCmdBuf[3] << 16 | pCmdBuf[4] << 8 | pCmdBuf[5]));
memcpy(GLBtCoexist.pwrModeVal, pCmdBuf, cmdLen);
}
void hal_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize)
{
- PBTCDBGINFO pinfo;
+ struct btcdbginfo *pinfo;
pinfo = &GLBtcDbgInfo;
@@ -1522,7 +1523,6 @@ u32 hal_btcoex_GetDBG(struct adapter *padapter, u8 *pStrBuf, u32 bufSize)
pstr = pStrBuf;
leftSize = bufSize;
-/* DBG_871X(FUNC_ADPT_FMT ": bufsize =%d\n", FUNC_ADPT_ARG(padapter), bufSize); */
count = rtw_sprintf(pstr, leftSize, "#define DBG\t%d\n", DBG);
if ((count < 0) || (count >= leftSize))
@@ -1551,13 +1551,13 @@ u32 hal_btcoex_GetDBG(struct adapter *padapter, u8 *pStrBuf, u32 bufSize)
pstr += count;
leftSize -= count;
count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for INTF_INIT\n",
- (GLBtcDbgType[BTC_MSG_INTERFACE]&INTF_INIT)?1:0);
+ (GLBtcDbgType[BTC_MSG_INTERFACE] & INTF_INIT) ? 1 : 0);
if ((count < 0) || (count >= leftSize))
goto exit;
pstr += count;
leftSize -= count;
count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for INTF_NOTIFY\n\n",
- (GLBtcDbgType[BTC_MSG_INTERFACE]&INTF_NOTIFY)?1:0);
+ (GLBtcDbgType[BTC_MSG_INTERFACE] & INTF_NOTIFY) ? 1 : 0);
if ((count < 0) || (count >= leftSize))
goto exit;
pstr += count;
@@ -1569,61 +1569,61 @@ u32 hal_btcoex_GetDBG(struct adapter *padapter, u8 *pStrBuf, u32 bufSize)
pstr += count;
leftSize -= count;
count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for BT_RSSI_STATE\n",
- (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_BT_RSSI_STATE)?1:0);
+ (GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_BT_RSSI_STATE) ? 1 : 0);
if ((count < 0) || (count >= leftSize))
goto exit;
pstr += count;
leftSize -= count;
count = rtw_sprintf(pstr, leftSize, "\tbit[1]=%d for WIFI_RSSI_STATE\n",
- (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_WIFI_RSSI_STATE)?1:0);
+ (GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_WIFI_RSSI_STATE) ? 1 : 0);
if ((count < 0) || (count >= leftSize))
goto exit;
pstr += count;
leftSize -= count;
count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for BT_MONITOR\n",
- (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_BT_MONITOR)?1:0);
+ (GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_BT_MONITOR) ? 1 : 0);
if ((count < 0) || (count >= leftSize))
goto exit;
pstr += count;
leftSize -= count;
count = rtw_sprintf(pstr, leftSize, "\tbit[3]=%d for TRACE\n",
- (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE)?1:0);
+ (GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE) ? 1 : 0);
if ((count < 0) || (count >= leftSize))
goto exit;
pstr += count;
leftSize -= count;
count = rtw_sprintf(pstr, leftSize, "\tbit[4]=%d for TRACE_FW\n",
- (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW)?1:0);
+ (GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_FW) ? 1 : 0);
if ((count < 0) || (count >= leftSize))
goto exit;
pstr += count;
leftSize -= count;
count = rtw_sprintf(pstr, leftSize, "\tbit[5]=%d for TRACE_FW_DETAIL\n",
- (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW_DETAIL)?1:0);
+ (GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_FW_DETAIL) ? 1 : 0);
if ((count < 0) || (count >= leftSize))
goto exit;
pstr += count;
leftSize -= count;
count = rtw_sprintf(pstr, leftSize, "\tbit[6]=%d for TRACE_FW_EXEC\n",
- (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW_EXEC)?1:0);
+ (GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_FW_EXEC) ? 1 : 0);
if ((count < 0) || (count >= leftSize))
goto exit;
pstr += count;
leftSize -= count;
count = rtw_sprintf(pstr, leftSize, "\tbit[7]=%d for TRACE_SW\n",
- (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW)?1:0);
+ (GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_SW) ? 1 : 0);
if ((count < 0) || (count >= leftSize))
goto exit;
pstr += count;
leftSize -= count;
count = rtw_sprintf(pstr, leftSize, "\tbit[8]=%d for TRACE_SW_DETAIL\n",
- (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW_DETAIL)?1:0);
+ (GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_SW_DETAIL) ? 1 : 0);
if ((count < 0) || (count >= leftSize))
goto exit;
pstr += count;
leftSize -= count;
count = rtw_sprintf(pstr, leftSize, "\tbit[9]=%d for TRACE_SW_EXEC\n",
- (GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW_EXEC)?1:0);
+ (GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_SW_EXEC) ? 1 : 0);
if ((count < 0) || (count >= leftSize))
goto exit;
pstr += count;
@@ -1631,7 +1631,6 @@ u32 hal_btcoex_GetDBG(struct adapter *padapter, u8 *pStrBuf, u32 bufSize)
exit:
count = pstr - pStrBuf;
-/* DBG_871X(FUNC_ADPT_FMT ": usedsize =%d\n", FUNC_ADPT_ARG(padapter), count); */
return count;
}
diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c
index 16b259acbe1a..e82f59fc5e9b 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com.c
@@ -18,10 +18,8 @@ u8 rtw_hal_data_init(struct adapter *padapter)
if (is_primary_adapter(padapter)) { /* if (padapter->isprimary) */
padapter->hal_data_sz = sizeof(struct hal_com_data);
padapter->HalData = vzalloc(padapter->hal_data_sz);
- if (!padapter->HalData) {
- DBG_8192C("cannot alloc memory for HAL DATA\n");
+ if (!padapter->HalData)
return _FAIL;
- }
}
return _SUCCESS;
}
@@ -38,51 +36,52 @@ void rtw_hal_data_deinit(struct adapter *padapter)
}
-void dump_chip_info(HAL_VERSION ChipVersion)
+void dump_chip_info(struct hal_version ChipVersion)
{
- int cnt = 0;
- u8 buf[128];
+ char buf[128];
+ size_t cnt = 0;
+
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "Chip Version Info: CHIP_8723B_%s_",
+ IS_NORMAL_CHIP(ChipVersion) ? "Normal_Chip" : "Test_Chip");
- cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8723B_");
- cnt += sprintf((buf+cnt), "%s_", IS_NORMAL_CHIP(ChipVersion) ? "Normal_Chip" : "Test_Chip");
if (IS_CHIP_VENDOR_TSMC(ChipVersion))
- cnt += sprintf((buf+cnt), "%s_", "TSMC");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "TSMC_");
else if (IS_CHIP_VENDOR_UMC(ChipVersion))
- cnt += sprintf((buf+cnt), "%s_", "UMC");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "UMC_");
else if (IS_CHIP_VENDOR_SMIC(ChipVersion))
- cnt += sprintf((buf+cnt), "%s_", "SMIC");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "SMIC_");
if (IS_A_CUT(ChipVersion))
- cnt += sprintf((buf+cnt), "A_CUT_");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "A_CUT_");
else if (IS_B_CUT(ChipVersion))
- cnt += sprintf((buf+cnt), "B_CUT_");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "B_CUT_");
else if (IS_C_CUT(ChipVersion))
- cnt += sprintf((buf+cnt), "C_CUT_");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "C_CUT_");
else if (IS_D_CUT(ChipVersion))
- cnt += sprintf((buf+cnt), "D_CUT_");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "D_CUT_");
else if (IS_E_CUT(ChipVersion))
- cnt += sprintf((buf+cnt), "E_CUT_");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "E_CUT_");
else if (IS_I_CUT(ChipVersion))
- cnt += sprintf((buf+cnt), "I_CUT_");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "I_CUT_");
else if (IS_J_CUT(ChipVersion))
- cnt += sprintf((buf+cnt), "J_CUT_");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "J_CUT_");
else if (IS_K_CUT(ChipVersion))
- cnt += sprintf((buf+cnt), "K_CUT_");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "K_CUT_");
else
- cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_", ChipVersion.CUTVersion);
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt,
+ "UNKNOWN_CUT(%d)_", ChipVersion.CUTVersion);
if (IS_1T1R(ChipVersion))
- cnt += sprintf((buf+cnt), "1T1R_");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "1T1R_");
else if (IS_1T2R(ChipVersion))
- cnt += sprintf((buf+cnt), "1T2R_");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "1T2R_");
else if (IS_2T2R(ChipVersion))
- cnt += sprintf((buf+cnt), "2T2R_");
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "2T2R_");
else
- cnt += sprintf((buf+cnt), "UNKNOWN_RFTYPE(%d)_", ChipVersion.RFType);
-
- cnt += sprintf((buf+cnt), "RomVer(%d)\n", ChipVersion.ROMVer);
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt,
+ "UNKNOWN_RFTYPE(%d)_", ChipVersion.RFType);
- DBG_871X("%s", buf);
+ cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "RomVer(%d)\n", ChipVersion.ROMVer);
}
@@ -129,10 +128,8 @@ u8 hal_com_config_channel_plan(
hw_chnlPlan = hw_channel_plan & (~EEPROM_CHANNEL_PLAN_BY_HW_MASK);
if (rtw_is_channel_plan_valid(hw_chnlPlan)) {
-#ifndef CONFIG_SW_CHANNEL_PLAN
if (hw_channel_plan & EEPROM_CHANNEL_PLAN_BY_HW_MASK)
pHalData->bDisableSWChannelPlan = true;
-#endif /* !CONFIG_SW_CHANNEL_PLAN */
chnlPlan = hw_chnlPlan;
}
@@ -152,13 +149,10 @@ bool HAL_IsLegalChannel(struct adapter *Adapter, u32 Channel)
bool bLegalChannel = true;
if ((Channel <= 14) && (Channel >= 1)) {
- if (IsSupported24G(Adapter->registrypriv.wireless_mode) == false) {
+ if (IsSupported24G(Adapter->registrypriv.wireless_mode) == false)
bLegalChannel = false;
- DBG_871X("(Channel <= 14) && (Channel >= 1) but wireless_mode do not support 2.4G\n");
- }
} else {
bLegalChannel = false;
- DBG_871X("Channel is Invalid !!!\n");
}
return bLegalChannel;
@@ -687,7 +681,6 @@ u8 HwRateToMRate(u8 rate)
break;
default:
- DBG_871X("HwRateToMRate(): Non supported Rate [%x]!!!\n", rate);
break;
}
@@ -923,29 +916,15 @@ s32 c2h_evt_read_88xx(struct adapter *adapter, u8 *buf)
c2h_evt->seq = rtw_read8(adapter, REG_C2HEVT_CMD_SEQ_88XX);
c2h_evt->plen = rtw_read8(adapter, REG_C2HEVT_CMD_LEN_88XX);
- RT_PRINT_DATA(
- _module_hal_init_c_,
- _drv_info_,
- "c2h_evt_read(): ",
- &c2h_evt,
- sizeof(c2h_evt)
- );
-
- DBG_871X(
- "%s id:%u, len:%u, seq:%u, trigger:0x%02x\n",
- __func__,
- c2h_evt->id,
- c2h_evt->plen,
- c2h_evt->seq,
- trigger
- );
+ print_hex_dump_debug(DRIVER_PREFIX ": c2h_evt_read(): ", DUMP_PREFIX_NONE,
+ 16, 1, &c2h_evt, sizeof(c2h_evt), false);
/* Read the content */
for (i = 0; i < c2h_evt->plen; i++)
c2h_evt->payload[i] = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 2 + i);
- RT_PRINT_DATA(_module_hal_init_c_, _drv_info_, "c2h_evt_read(): Command Content:\n",
- c2h_evt->payload, c2h_evt->plen);
+ print_hex_dump_debug(DRIVER_PREFIX ": c2h_evt_read(): Command Content:\n",
+ DUMP_PREFIX_NONE, 16, 1, c2h_evt->payload, c2h_evt->plen, false);
ret = _SUCCESS;
@@ -1005,7 +984,7 @@ void hw_var_port_switch(struct adapter *adapter)
void SetHwReg(struct adapter *adapter, u8 variable, u8 *val)
{
struct hal_com_data *hal_data = GET_HAL_DATA(adapter);
- DM_ODM_T *odm = &(hal_data->odmpriv);
+ struct dm_odm_t *odm = &(hal_data->odmpriv);
switch (variable) {
case HW_VAR_PORT_SWITCH:
@@ -1072,12 +1051,9 @@ void SetHwReg(struct adapter *adapter, u8 variable, u8 *val)
/* TODO - Is something needed here? */
break;
default:
- DBG_871X_LEVEL(
- _drv_always_,
- FUNC_ADPT_FMT" variable(%d) not defined!\n",
- FUNC_ADPT_ARG(adapter),
- variable
- );
+ netdev_dbg(adapter->pnetdev,
+ FUNC_ADPT_FMT " variable(%d) not defined!\n",
+ FUNC_ADPT_ARG(adapter), variable);
break;
}
}
@@ -1085,7 +1061,7 @@ void SetHwReg(struct adapter *adapter, u8 variable, u8 *val)
void GetHwReg(struct adapter *adapter, u8 variable, u8 *val)
{
struct hal_com_data *hal_data = GET_HAL_DATA(adapter);
- DM_ODM_T *odm = &(hal_data->odmpriv);
+ struct dm_odm_t *odm = &(hal_data->odmpriv);
switch (variable) {
case HW_VAR_BASIC_RATE:
@@ -1098,12 +1074,9 @@ void GetHwReg(struct adapter *adapter, u8 variable, u8 *val)
*((u8 *)val) = hal_data->rf_type;
break;
default:
- DBG_871X_LEVEL(
- _drv_always_,
- FUNC_ADPT_FMT" variable(%d) not defined!\n",
- FUNC_ADPT_ARG(adapter),
- variable
- );
+ netdev_dbg(adapter->pnetdev,
+ FUNC_ADPT_FMT " variable(%d) not defined!\n",
+ FUNC_ADPT_ARG(adapter), variable);
break;
}
}
@@ -1112,11 +1085,11 @@ void GetHwReg(struct adapter *adapter, u8 variable, u8 *val)
u8 SetHalDefVar(
- struct adapter *adapter, enum HAL_DEF_VARIABLE variable, void *value
+ struct adapter *adapter, enum hal_def_variable variable, void *value
)
{
struct hal_com_data *hal_data = GET_HAL_DATA(adapter);
- DM_ODM_T *odm = &(hal_data->odmpriv);
+ struct dm_odm_t *odm = &(hal_data->odmpriv);
u8 bResult = _SUCCESS;
switch (variable) {
@@ -1128,14 +1101,8 @@ u8 SetHalDefVar(
odm->DebugComponents &= ~(ODM_COMP_DIG | ODM_COMP_FA_CNT);
break;
case HAL_DEF_DBG_RX_INFO_DUMP:
- DBG_871X("============ Rx Info dump ===================\n");
- DBG_871X("bLinked = %d, RSSI_Min = %d(%%)\n",
- odm->bLinked, odm->RSSI_Min);
if (odm->bLinked) {
- DBG_871X("RxRate = %s, RSSI_A = %d(%%), RSSI_B = %d(%%)\n",
- HDATA_RATE(odm->RxRate), odm->RSSI_A, odm->RSSI_B);
-
#ifdef DBG_RX_SIGNAL_DISPLAY_RAW_DATA
rtw_dump_raw_rssi_info(adapter);
#endif
@@ -1154,27 +1121,23 @@ u8 SetHalDefVar(
if (dm_func == 0) { /* disable all dynamic func */
odm->SupportAbility = DYNAMIC_FUNC_DISABLE;
- DBG_8192C("==> Disable all dynamic function...\n");
} else if (dm_func == 1) {/* disable DIG */
odm->SupportAbility &= (~DYNAMIC_BB_DIG);
- DBG_8192C("==> Disable DIG...\n");
} else if (dm_func == 2) {/* disable High power */
odm->SupportAbility &= (~DYNAMIC_BB_DYNAMIC_TXPWR);
} else if (dm_func == 3) {/* disable tx power tracking */
odm->SupportAbility &= (~DYNAMIC_RF_CALIBRATION);
- DBG_8192C("==> Disable tx power tracking...\n");
} else if (dm_func == 4) {/* disable BT coexistence */
dm->DMFlag &= (~DYNAMIC_FUNC_BT);
} else if (dm_func == 5) {/* disable antenna diversity */
odm->SupportAbility &= (~DYNAMIC_BB_ANT_DIV);
} else if (dm_func == 6) {/* turn on all dynamic func */
if (!(odm->SupportAbility & DYNAMIC_BB_DIG)) {
- DIG_T *pDigTable = &odm->DM_DigTable;
+ struct dig_t *pDigTable = &odm->DM_DigTable;
pDigTable->CurIGValue = rtw_read8(adapter, 0xc50);
}
dm->DMFlag |= DYNAMIC_FUNC_BT;
odm->SupportAbility = DYNAMIC_ALL_FUNC_ENABLE;
- DBG_8192C("==> Turn on all dynamic function...\n");
}
}
break;
@@ -1188,7 +1151,9 @@ u8 SetHalDefVar(
hal_data->AntDetection = *((u8 *)value);
break;
default:
- DBG_871X_LEVEL(_drv_always_, "%s: [WARNING] HAL_DEF_VARIABLE(%d) not defined!\n", __func__, variable);
+ netdev_dbg(adapter->pnetdev,
+ "%s: [WARNING] HAL_DEF_VARIABLE(%d) not defined!\n",
+ __func__, variable);
bResult = _FAIL;
break;
}
@@ -1197,11 +1162,11 @@ u8 SetHalDefVar(
}
u8 GetHalDefVar(
- struct adapter *adapter, enum HAL_DEF_VARIABLE variable, void *value
+ struct adapter *adapter, enum hal_def_variable variable, void *value
)
{
struct hal_com_data *hal_data = GET_HAL_DATA(adapter);
- DM_ODM_T *odm = &(hal_data->odmpriv);
+ struct dm_odm_t *odm = &(hal_data->odmpriv);
u8 bResult = _SUCCESS;
switch (variable) {
@@ -1243,7 +1208,9 @@ u8 GetHalDefVar(
*((u32 *)value) = PAGE_SIZE_128;
break;
default:
- DBG_871X_LEVEL(_drv_always_, "%s: [WARNING] HAL_DEF_VARIABLE(%d) not defined!\n", __func__, variable);
+ netdev_dbg(adapter->pnetdev,
+ "%s: [WARNING] HAL_DEF_VARIABLE(%d) not defined!\n",
+ __func__, variable);
bResult = _FAIL;
break;
}
@@ -1253,26 +1220,12 @@ u8 GetHalDefVar(
void GetHalODMVar(
struct adapter *Adapter,
- enum HAL_ODM_VARIABLE eVariable,
+ enum hal_odm_variable eVariable,
void *pValue1,
void *pValue2
)
{
switch (eVariable) {
-#if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
- case HAL_ODM_NOISE_MONITOR:
- {
- struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- u8 chan = *(u8 *)pValue1;
- *(s16 *)pValue2 = pHalData->noise[chan];
- #ifdef DBG_NOISE_MONITOR
- DBG_8192C("### Noise monitor chan(%d)-noise:%d (dBm) ###\n",
- chan, pHalData->noise[chan]);
- #endif
-
- }
- break;
-#endif/* ifdef CONFIG_BACKGROUND_NOISE_MONITOR */
default:
break;
}
@@ -1280,23 +1233,21 @@ void GetHalODMVar(
void SetHalODMVar(
struct adapter *Adapter,
- enum HAL_ODM_VARIABLE eVariable,
+ enum hal_odm_variable eVariable,
void *pValue1,
bool bSet
)
{
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T podmpriv = &pHalData->odmpriv;
+ struct dm_odm_t *podmpriv = &pHalData->odmpriv;
/* _irqL irqL; */
switch (eVariable) {
case HAL_ODM_STA_INFO:
{
struct sta_info *psta = pValue1;
if (bSet) {
- DBG_8192C("### Set STA_(%d) info ###\n", psta->mac_id);
ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, psta);
} else {
- DBG_8192C("### Clean STA_(%d) info ###\n", psta->mac_id);
/* spin_lock_bh(&pHalData->odm_stainfo_lock); */
ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, NULL);
@@ -1310,27 +1261,6 @@ void SetHalODMVar(
case HAL_ODM_WIFI_DISPLAY_STATE:
ODM_CmnInfoUpdate(podmpriv, ODM_CMNINFO_WIFI_DISPLAY, bSet);
break;
- #if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
- case HAL_ODM_NOISE_MONITOR:
- {
- struct noise_info *pinfo = pValue1;
-
- #ifdef DBG_NOISE_MONITOR
- DBG_8192C("### Noise monitor chan(%d)-bPauseDIG:%d, IGIValue:0x%02x, max_time:%d (ms) ###\n",
- pinfo->chan, pinfo->bPauseDIG, pinfo->IGIValue, pinfo->max_time);
- #endif
-
- pHalData->noise[pinfo->chan] = ODM_InbandNoise_Monitor(podmpriv, pinfo->bPauseDIG, pinfo->IGIValue, pinfo->max_time);
- DBG_871X("chan_%d, noise = %d (dBm)\n", pinfo->chan, pHalData->noise[pinfo->chan]);
- #ifdef DBG_NOISE_MONITOR
- DBG_871X("noise_a = %d, noise_b = %d noise_all:%d\n",
- podmpriv->noise_level.noise[ODM_RF_PATH_A],
- podmpriv->noise_level.noise[ODM_RF_PATH_B],
- podmpriv->noise_level.noise_all);
- #endif
- }
- break;
- #endif/* ifdef CONFIG_BACKGROUND_NOISE_MONITOR */
default:
break;
@@ -1394,11 +1324,8 @@ bool GetHexValueFromString(char *szStr, u32 *pu4bVal, u32 *pu4bMove)
char *szScan = szStr;
/* Check input parameter. */
- if (!szStr || !pu4bVal || !pu4bMove) {
- DBG_871X("GetHexValueFromString(): Invalid input arguments! szStr: %p, pu4bVal: %p, pu4bMove: %p\n",
- szStr, pu4bVal, pu4bMove);
+ if (!szStr || !pu4bVal || !pu4bMove)
return false;
- }
/* Initialize output. */
*pu4bMove = 0;
@@ -1572,8 +1499,6 @@ void linked_info_dump(struct adapter *padapter, u8 benable)
if (padapter->bLinkInfoDump == benable)
return;
- DBG_871X("%s %s\n", __func__, (benable) ? "enable" : "disable");
-
if (benable) {
pwrctrlpriv->org_power_mgnt = pwrctrlpriv->power_mgnt;/* keep org value */
rtw_pm_set_lps(padapter, PS_MODE_ACTIVE);
@@ -1595,12 +1520,10 @@ void rtw_get_raw_rssi_info(void *sel, struct adapter *padapter)
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
struct rx_raw_rssi *psample_pkt_rssi = &padapter->recvpriv.raw_rssi_info;
- DBG_871X_SEL_NL(
- sel,
- "RxRate = %s, PWDBALL = %d(%%), rx_pwr_all = %d(dBm)\n",
- HDATA_RATE(psample_pkt_rssi->data_rate),
- psample_pkt_rssi->pwdball, psample_pkt_rssi->pwr_all
- );
+ netdev_dbg(padapter->pnetdev,
+ "RxRate = %s, PWDBALL = %d(%%), rx_pwr_all = %d(dBm)\n",
+ HDATA_RATE(psample_pkt_rssi->data_rate),
+ psample_pkt_rssi->pwdball, psample_pkt_rssi->pwr_all);
isCCKrate = psample_pkt_rssi->data_rate <= DESC_RATE11M;
@@ -1608,20 +1531,17 @@ void rtw_get_raw_rssi_info(void *sel, struct adapter *padapter)
psample_pkt_rssi->mimo_signal_strength[0] = psample_pkt_rssi->pwdball;
for (rf_path = 0; rf_path < pHalData->NumTotalRFPath; rf_path++) {
- DBG_871X_SEL_NL(
- sel,
- "RF_PATH_%d =>signal_strength:%d(%%), signal_quality:%d(%%)\n",
- rf_path, psample_pkt_rssi->mimo_signal_strength[rf_path],
- psample_pkt_rssi->mimo_signal_quality[rf_path]
- );
+ netdev_dbg(padapter->pnetdev,
+ "RF_PATH_%d =>signal_strength:%d(%%), signal_quality:%d(%%)\n",
+ rf_path,
+ psample_pkt_rssi->mimo_signal_strength[rf_path],
+ psample_pkt_rssi->mimo_signal_quality[rf_path]);
if (!isCCKrate) {
- DBG_871X_SEL_NL(
- sel,
- "\trx_ofdm_pwr:%d(dBm), rx_ofdm_snr:%d(dB)\n",
- psample_pkt_rssi->ofdm_pwr[rf_path],
- psample_pkt_rssi->ofdm_snr[rf_path]
- );
+ netdev_dbg(padapter->pnetdev,
+ "\trx_ofdm_pwr:%d(dBm), rx_ofdm_snr:%d(dB)\n",
+ psample_pkt_rssi->ofdm_pwr[rf_path],
+ psample_pkt_rssi->ofdm_snr[rf_path]);
}
}
}
@@ -1631,9 +1551,6 @@ void rtw_dump_raw_rssi_info(struct adapter *padapter)
u8 isCCKrate, rf_path;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
struct rx_raw_rssi *psample_pkt_rssi = &padapter->recvpriv.raw_rssi_info;
- DBG_871X("============ RAW Rx Info dump ===================\n");
- DBG_871X("RxRate = %s, PWDBALL = %d(%%), rx_pwr_all = %d(dBm)\n",
- HDATA_RATE(psample_pkt_rssi->data_rate), psample_pkt_rssi->pwdball, psample_pkt_rssi->pwr_all);
isCCKrate = psample_pkt_rssi->data_rate <= DESC_RATE11M;
@@ -1641,9 +1558,6 @@ void rtw_dump_raw_rssi_info(struct adapter *padapter)
psample_pkt_rssi->mimo_signal_strength[0] = psample_pkt_rssi->pwdball;
for (rf_path = 0; rf_path < pHalData->NumTotalRFPath; rf_path++) {
- DBG_871X("RF_PATH_%d =>signal_strength:%d(%%), signal_quality:%d(%%)"
- , rf_path, psample_pkt_rssi->mimo_signal_strength[rf_path], psample_pkt_rssi->mimo_signal_quality[rf_path]);
-
if (!isCCKrate) {
printk(", rx_ofdm_pwr:%d(dBm), rx_ofdm_snr:%d(dB)\n",
psample_pkt_rssi->ofdm_pwr[rf_path], psample_pkt_rssi->ofdm_snr[rf_path]);
@@ -1698,34 +1612,25 @@ void rtw_bb_rf_gain_offset(struct adapter *padapter)
u32 res, i = 0;
u32 *Array = Array_kfreemap;
u32 v1 = 0, v2 = 0, target = 0;
- /* DBG_871X("+%s value: 0x%02x+\n", __func__, value); */
if (value & BIT4) {
- DBG_871X("Offset RF Gain.\n");
- DBG_871X("Offset RF Gain. padapter->eeprompriv.EEPROMRFGainVal = 0x%x\n", padapter->eeprompriv.EEPROMRFGainVal);
if (padapter->eeprompriv.EEPROMRFGainVal != 0xff) {
res = rtw_hal_read_rfreg(padapter, RF_PATH_A, 0x7f, 0xffffffff);
res &= 0xfff87fff;
- DBG_871X("Offset RF Gain. before reg 0x7f = 0x%08x\n", res);
/* res &= 0xfff87fff; */
for (i = 0; i < ARRAY_SIZE(Array_kfreemap); i += 2) {
v1 = Array[i];
v2 = Array[i+1];
if (v1 == padapter->eeprompriv.EEPROMRFGainVal) {
- DBG_871X("Offset RF Gain. got v1 = 0x%x , v2 = 0x%x\n", v1, v2);
target = v2;
break;
}
}
- DBG_871X("padapter->eeprompriv.EEPROMRFGainVal = 0x%x , Gain offset Target Value = 0x%x\n", padapter->eeprompriv.EEPROMRFGainVal, target);
PHY_SetRFReg(padapter, RF_PATH_A, REG_RF_BB_GAIN_OFFSET, BIT18|BIT17|BIT16|BIT15, target);
/* res |= (padapter->eeprompriv.EEPROMRFGainVal & 0x0f)<< 15; */
/* rtw_hal_write_rfreg(padapter, RF_PATH_A, REG_RF_BB_GAIN_OFFSET, RF_GAIN_OFFSET_MASK, res); */
res = rtw_hal_read_rfreg(padapter, RF_PATH_A, 0x7f, 0xffffffff);
- DBG_871X("Offset RF Gain. After reg 0x7f = 0x%08x\n", res);
- } else
- DBG_871X("Offset RF Gain. padapter->eeprompriv.EEPROMRFGainVal = 0x%x != 0xff, didn't run Kfree\n", padapter->eeprompriv.EEPROMRFGainVal);
- } else
- DBG_871X("Using the default RF gain.\n");
+ }
+ }
}
diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 10250642d30a..94d11689b4ac 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -12,15 +12,13 @@
#include <linux/kernel.h>
u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 Band, u8 RfPath,
- u8 TxNum, enum RATE_SECTION RateSection)
+ u8 TxNum, enum rate_section RateSection)
{
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
u8 value = 0;
- if (RfPath > ODM_RF_PATH_D) {
- DBG_871X("Invalid Rf Path %d in PHY_GetTxPowerByRateBase()\n", RfPath);
+ if (RfPath > ODM_RF_PATH_D)
return 0;
- }
if (Band == BAND_ON_2_4G) {
switch (RateSection) {
@@ -55,8 +53,6 @@ u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 Band, u8 RfPath,
value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][9];
break;
default:
- DBG_871X("Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in PHY_GetTxPowerByRateBase()\n",
- RateSection, RfPath, TxNum);
break;
}
} else if (Band == BAND_ON_5G) {
@@ -89,12 +85,9 @@ u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 Band, u8 RfPath,
value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][8];
break;
default:
- DBG_871X("Invalid RateSection %d in Band 5G, Rf Path %d, %dTx in PHY_GetTxPowerByRateBase()\n",
- RateSection, RfPath, TxNum);
break;
}
- } else
- DBG_871X("Invalid Band %d in PHY_GetTxPowerByRateBase()\n", Band);
+ }
return value;
}
@@ -104,17 +97,15 @@ phy_SetTxPowerByRateBase(
struct adapter *Adapter,
u8 Band,
u8 RfPath,
- enum RATE_SECTION RateSection,
+ enum rate_section RateSection,
u8 TxNum,
u8 Value
)
{
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- if (RfPath > ODM_RF_PATH_D) {
- DBG_871X("Invalid Rf Path %d in phy_SetTxPowerByRatBase()\n", RfPath);
+ if (RfPath > ODM_RF_PATH_D)
return;
- }
if (Band == BAND_ON_2_4G) {
switch (RateSection) {
@@ -149,8 +140,6 @@ phy_SetTxPowerByRateBase(
pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][9] = Value;
break;
default:
- DBG_871X("Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in phy_SetTxPowerByRateBase()\n",
- RateSection, RfPath, TxNum);
break;
}
} else if (Band == BAND_ON_5G) {
@@ -183,12 +172,9 @@ phy_SetTxPowerByRateBase(
pHalData->TxPwrByRateBase5G[RfPath][TxNum][8] = Value;
break;
default:
- DBG_871X("Invalid RateSection %d in Band 5G, Rf Path %d, %dTx in phy_SetTxPowerByRateBase()\n",
- RateSection, RfPath, TxNum);
break;
}
- } else
- DBG_871X("Invalid Band %d in phy_SetTxPowerByRateBase()\n", Band);
+ }
}
static void
@@ -198,71 +184,52 @@ struct adapter *padapter
{
u8 path, base;
- /* DBG_871X("===>%s\n", __func__); */
-
for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_B; ++path) {
base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_1TX, MGN_11M);
phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, CCK, RF_1TX, base);
- /* DBG_871X("Power index base of 2.4G path %d 1Tx CCK = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_1TX, MGN_54M);
phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, OFDM, RF_1TX, base);
- /* DBG_871X("Power index base of 2.4G path %d 1Tx OFDM = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_1TX, MGN_MCS7);
phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, HT_MCS0_MCS7, RF_1TX, base);
- /* DBG_871X("Power index base of 2.4G path %d 1Tx MCS0-7 = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_2TX, MGN_MCS15);
phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, HT_MCS8_MCS15, RF_2TX, base);
- /* DBG_871X("Power index base of 2.4G path %d 2Tx MCS8-15 = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_3TX, MGN_MCS23);
phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, HT_MCS16_MCS23, RF_3TX, base);
- /* DBG_871X("Power index base of 2.4G path %d 3Tx MCS16-23 = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_1TX, MGN_VHT1SS_MCS7);
phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, VHT_1SSMCS0_1SSMCS9, RF_1TX, base);
- /* DBG_871X("Power index base of 2.4G path %d 1Tx VHT1SS = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_2TX, MGN_VHT2SS_MCS7);
phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, VHT_2SSMCS0_2SSMCS9, RF_2TX, base);
- /* DBG_871X("Power index base of 2.4G path %d 2Tx VHT2SS = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_3TX, MGN_VHT3SS_MCS7);
phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, VHT_3SSMCS0_3SSMCS9, RF_3TX, base);
- /* DBG_871X("Power index base of 2.4G path %d 3Tx VHT3SS = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_1TX, MGN_54M);
phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, OFDM, RF_1TX, base);
- /* DBG_871X("Power index base of 5G path %d 1Tx OFDM = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_1TX, MGN_MCS7);
phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, HT_MCS0_MCS7, RF_1TX, base);
- /* DBG_871X("Power index base of 5G path %d 1Tx MCS0~7 = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_2TX, MGN_MCS15);
phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, HT_MCS8_MCS15, RF_2TX, base);
- /* DBG_871X("Power index base of 5G path %d 2Tx MCS8~15 = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_3TX, MGN_MCS23);
phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, HT_MCS16_MCS23, RF_3TX, base);
- /* DBG_871X("Power index base of 5G path %d 3Tx MCS16~23 = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_1TX, MGN_VHT1SS_MCS7);
phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, VHT_1SSMCS0_1SSMCS9, RF_1TX, base);
- /* DBG_871X("Power index base of 5G path %d 1Tx VHT1SS = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_2TX, MGN_VHT2SS_MCS7);
phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, VHT_2SSMCS0_2SSMCS9, RF_2TX, base);
- /* DBG_871X("Power index base of 5G path %d 2Tx VHT2SS = > 0x%x\n", path, base); */
base = PHY_GetTxPowerByRate(padapter, BAND_ON_5G, path, RF_3TX, MGN_VHT2SS_MCS7);
phy_SetTxPowerByRateBase(padapter, BAND_ON_5G, path, VHT_3SSMCS0_3SSMCS9, RF_3TX, base);
- /* DBG_871X("Power index base of 5G path %d 3Tx VHT3SS = > 0x%x\n", path, base); */
}
-
- /* DBG_871X("<===%s\n", __func__); */
}
u8 PHY_GetRateSectionIndexOfTxPowerByRate(
@@ -270,7 +237,7 @@ u8 PHY_GetRateSectionIndexOfTxPowerByRate(
)
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
u8 index = 0;
if (pDM_Odm->PhyRegPgVersion == 0) {
@@ -325,7 +292,6 @@ u8 PHY_GetRateSectionIndexOfTxPowerByRate(
index = 13;
break;
default:
- DBG_871X("Invalid RegAddr 0x3%x in PHY_GetRateSectionIndexOfTxPowerByRate()", RegAddr);
break;
}
}
@@ -715,7 +681,6 @@ PHY_GetRateValuesOfTxPowerByRate(
break;
default:
- DBG_871X("Invalid RegAddr 0x%x in %s()\n", RegAddr, __func__);
break;
}
}
@@ -736,20 +701,14 @@ static void PHY_StoreTxPowerByRateNew(
PHY_GetRateValuesOfTxPowerByRate(padapter, RegAddr, BitMask, Data, rateIndex, PwrByRateVal, &rateNum);
- if (Band != BAND_ON_2_4G && Band != BAND_ON_5G) {
- DBG_871X("Invalid Band %d\n", Band);
+ if (Band != BAND_ON_2_4G && Band != BAND_ON_5G)
return;
- }
- if (RfPath > ODM_RF_PATH_D) {
- DBG_871X("Invalid RfPath %d\n", RfPath);
+ if (RfPath > ODM_RF_PATH_D)
return;
- }
- if (TxNum > ODM_RF_PATH_D) {
- DBG_871X("Invalid TxNum %d\n", TxNum);
+ if (TxNum > ODM_RF_PATH_D)
return;
- }
for (i = 0; i < rateNum; ++i) {
if (rateIndex[i] == PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS0) ||
@@ -768,8 +727,6 @@ static void PHY_StoreTxPowerByRateOld(
u8 index = PHY_GetRateSectionIndexOfTxPowerByRate(padapter, RegAddr, BitMask);
pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][index] = Data;
- /* DBG_871X("MCSTxPowerLevelOriginalOffset[%d][0] = 0x%x\n", pHalData->pwrGroupCnt, */
- /* pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][0]); */
}
void PHY_InitTxPowerByRate(struct adapter *padapter)
@@ -795,7 +752,7 @@ void PHY_StoreTxPowerByRate(
)
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
if (pDM_Odm->PhyRegPgVersion > 0)
PHY_StoreTxPowerByRateNew(padapter, Band, RfPath, TxNum, RegAddr, BitMask, Data);
@@ -806,9 +763,7 @@ void PHY_StoreTxPowerByRate(
pHalData->pwrGroupCnt++;
else if (RegAddr == rTxAGC_B_Mcs15_Mcs12 && pHalData->rf_type != RF_1T1R)
pHalData->pwrGroupCnt++;
- } else
- DBG_871X("Invalid PHY_REG_PG.txt version %d\n", pDM_Odm->PhyRegPgVersion);
-
+ }
}
static void
@@ -845,8 +800,6 @@ struct adapter *padapter
MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7, MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9
};
- /* DBG_871X("===>PHY_ConvertTxPowerByRateInDbmToRelativeValues()\n"); */
-
for (band = BAND_ON_2_4G; band <= BAND_ON_5G; ++band) {
for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_D; ++path) {
for (txNum = RF_1TX; txNum < RF_MAX_TX_NUM; ++txNum) {
@@ -908,8 +861,6 @@ struct adapter *padapter
}
}
}
-
- /* DBG_871X("<===PHY_ConvertTxPowerByRateInDbmToRelativeValues()\n"); */
}
/*
@@ -1003,8 +954,7 @@ void PHY_SetTxPowerIndexByRateSection(
pHalData->CurrentChannelBW,
Channel, vhtRates4T,
ARRAY_SIZE(vhtRates4T));
- } else
- DBG_871X("Invalid RateSection %d in %s", RateSection, __func__);
+ }
}
static bool phy_GetChnlIndex(u8 Channel, u8 *ChannelIdx)
@@ -1039,7 +989,7 @@ u8 PHY_GetTxPowerIndexBase(
struct adapter *padapter,
u8 RFPath,
u8 Rate,
- enum CHANNEL_WIDTH BandWidth,
+ enum channel_width BandWidth,
u8 Channel,
bool *bIn24G
)
@@ -1049,31 +999,21 @@ u8 PHY_GetTxPowerIndexBase(
u8 txPower = 0;
u8 chnlIdx = (Channel-1);
- if (HAL_IsLegalChannel(padapter, Channel) == false) {
+ if (HAL_IsLegalChannel(padapter, Channel) == false)
chnlIdx = 0;
- DBG_871X("Illegal channel!!\n");
- }
*bIn24G = phy_GetChnlIndex(Channel, &chnlIdx);
- /* DBG_871X("[%s] Channel Index: %d\n", (*bIn24G?"2.4G":"5G"), chnlIdx); */
-
if (*bIn24G) { /* 3 ============================== 2.4 G ============================== */
if (IS_CCK_RATE(Rate))
txPower = pHalData->Index24G_CCK_Base[RFPath][chnlIdx];
else if (MGN_6M <= Rate)
txPower = pHalData->Index24G_BW40_Base[RFPath][chnlIdx];
- else
- DBG_871X("PHY_GetTxPowerIndexBase: INVALID Rate.\n");
-
- /* DBG_871X("Base Tx power(RF-%c, Rate #%d, Channel Index %d) = 0x%X\n", */
- /* ((RFPath == 0)?'A':'B'), Rate, chnlIdx, txPower); */
/* OFDM-1T */
- if ((MGN_6M <= Rate && Rate <= MGN_54M) && !IS_CCK_RATE(Rate)) {
+ if ((MGN_6M <= Rate && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
- /* DBG_871X("+PowerDiff 2.4G (RF-%c): (OFDM-1T) = (%d)\n", ((RFPath == 0)?'A':'B'), pHalData->OFDM_24G_Diff[RFPath][TX_1S]); */
- }
+
if (BandWidth == CHANNEL_WIDTH_20) { /* BW20-1S, BW20-2S */
if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S];
@@ -1084,9 +1024,6 @@ u8 PHY_GetTxPowerIndexBase(
if ((MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
txPower += pHalData->BW20_24G_Diff[RFPath][TX_4S];
- /* DBG_871X("+PowerDiff 2.4G (RF-%c): (BW20-1S, BW20-2S, BW20-3S, BW20-4S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */
- /* pHalData->BW20_24G_Diff[RFPath][TX_1S], pHalData->BW20_24G_Diff[RFPath][TX_2S], */
- /* pHalData->BW20_24G_Diff[RFPath][TX_3S], pHalData->BW20_24G_Diff[RFPath][TX_4S]); */
} else if (BandWidth == CHANNEL_WIDTH_40) { /* BW40-1S, BW40-2S */
if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];
@@ -1097,9 +1034,6 @@ u8 PHY_GetTxPowerIndexBase(
if ((MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
txPower += pHalData->BW40_24G_Diff[RFPath][TX_4S];
- /* DBG_871X("+PowerDiff 2.4G (RF-%c): (BW40-1S, BW40-2S, BW40-3S, BW40-4S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */
- /* pHalData->BW40_24G_Diff[RFPath][TX_1S], pHalData->BW40_24G_Diff[RFPath][TX_2S], */
- /* pHalData->BW40_24G_Diff[RFPath][TX_3S], pHalData->BW40_24G_Diff[RFPath][TX_4S]); */
}
/* Willis suggest adopt BW 40M power index while in BW 80 mode */
else if (BandWidth == CHANNEL_WIDTH_80) {
@@ -1112,24 +1046,14 @@ u8 PHY_GetTxPowerIndexBase(
if ((MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
txPower += pHalData->BW40_24G_Diff[RFPath][TX_4S];
- /* DBG_871X("+PowerDiff 2.4G (RF-%c): (BW40-1S, BW40-2S, BW40-3S, BW40-4T) = (%d, %d, %d, %d) P.S. Current is in BW 80MHz\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */
- /* pHalData->BW40_24G_Diff[RFPath][TX_1S], pHalData->BW40_24G_Diff[RFPath][TX_2S], */
- /* pHalData->BW40_24G_Diff[RFPath][TX_3S], pHalData->BW40_24G_Diff[RFPath][TX_4S]); */
}
} else {/* 3 ============================== 5 G ============================== */
if (MGN_6M <= Rate)
txPower = pHalData->Index5G_BW40_Base[RFPath][chnlIdx];
- else
- DBG_871X("===> mpt_ProQueryCalTxPower_Jaguar: INVALID Rate.\n");
-
- /* DBG_871X("Base Tx power(RF-%c, Rate #%d, Channel Index %d) = 0x%X\n", */
- /* ((RFPath == 0)?'A':'B'), Rate, chnlIdx, txPower); */
/* OFDM-1T */
- if ((MGN_6M <= Rate && Rate <= MGN_54M) && !IS_CCK_RATE(Rate)) {
+ if ((MGN_6M <= Rate && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
txPower += pHalData->OFDM_5G_Diff[RFPath][TX_1S];
- /* DBG_871X("+PowerDiff 5G (RF-%c): (OFDM-1T) = (%d)\n", ((RFPath == 0)?'A':'B'), pHalData->OFDM_5G_Diff[RFPath][TX_1S]); */
- }
/* BW20-1S, BW20-2S */
if (BandWidth == CHANNEL_WIDTH_20) {
@@ -1142,9 +1066,6 @@ u8 PHY_GetTxPowerIndexBase(
if ((MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
txPower += pHalData->BW20_5G_Diff[RFPath][TX_4S];
- /* DBG_871X("+PowerDiff 5G (RF-%c): (BW20-1S, BW20-2S, BW20-3S, BW20-4S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */
- /* pHalData->BW20_5G_Diff[RFPath][TX_1S], pHalData->BW20_5G_Diff[RFPath][TX_2S], */
- /* pHalData->BW20_5G_Diff[RFPath][TX_3S], pHalData->BW20_5G_Diff[RFPath][TX_4S]); */
} else if (BandWidth == CHANNEL_WIDTH_40) { /* BW40-1S, BW40-2S */
if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
txPower += pHalData->BW40_5G_Diff[RFPath][TX_1S];
@@ -1155,9 +1076,6 @@ u8 PHY_GetTxPowerIndexBase(
if ((MGN_MCS24 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
txPower += pHalData->BW40_5G_Diff[RFPath][TX_4S];
- /* DBG_871X("+PowerDiff 5G(RF-%c): (BW40-1S, BW40-2S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */
- /* pHalData->BW40_5G_Diff[RFPath][TX_1S], pHalData->BW40_5G_Diff[RFPath][TX_2S], */
- /* pHalData->BW40_5G_Diff[RFPath][TX_3S], pHalData->BW40_5G_Diff[RFPath][TX_4S]); */
} else if (BandWidth == CHANNEL_WIDTH_80) { /* BW80-1S, BW80-2S */
/* <20121220, Kordan> Get the index of array "Index5G_BW80_Base". */
u8 channel5G_80M[CHANNEL_MAX_NUMBER_5G_80M] = {42, 58, 106, 122, 138, 155, 171};
@@ -1175,10 +1093,6 @@ u8 PHY_GetTxPowerIndexBase(
txPower += pHalData->BW80_5G_Diff[RFPath][TX_3S];
if ((MGN_MCS23 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT4SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9))
txPower += pHalData->BW80_5G_Diff[RFPath][TX_4S];
-
- /* DBG_871X("+PowerDiff 5G(RF-%c): (BW80-1S, BW80-2S, BW80-3S, BW80-4S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */
- /* pHalData->BW80_5G_Diff[RFPath][TX_1S], pHalData->BW80_5G_Diff[RFPath][TX_2S], */
- /* pHalData->BW80_5G_Diff[RFPath][TX_3S], pHalData->BW80_5G_Diff[RFPath][TX_4S]); */
}
}
@@ -1188,20 +1102,16 @@ u8 PHY_GetTxPowerIndexBase(
s8 PHY_GetTxPowerTrackingOffset(struct adapter *padapter, u8 RFPath, u8 Rate)
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
s8 offset = 0;
if (pDM_Odm->RFCalibrateInfo.TxPowerTrackControl == false)
return offset;
- if ((Rate == MGN_1M) || (Rate == MGN_2M) || (Rate == MGN_5_5M) || (Rate == MGN_11M)) {
+ if ((Rate == MGN_1M) || (Rate == MGN_2M) || (Rate == MGN_5_5M) || (Rate == MGN_11M))
offset = pDM_Odm->Remnant_CCKSwingIdx;
- /* DBG_871X("+Remnant_CCKSwingIdx = 0x%x\n", RFPath, Rate, pDM_Odm->Remnant_CCKSwingIdx); */
- } else {
+ else
offset = pDM_Odm->Remnant_OFDMSwingIdx[RFPath];
- /* DBG_871X("+Remanant_OFDMSwingIdx[RFPath %u][Rate 0x%x] = 0x%x\n", RFPath, Rate, pDM_Odm->Remnant_OFDMSwingIdx[RFPath]); */
-
- }
return offset;
}
@@ -1463,7 +1373,6 @@ u8 PHY_GetRateIndexOfTxPowerByRate(u8 Rate)
index = 83;
break;
default:
- DBG_871X("Invalid rate 0x%x in %s\n", Rate, __func__);
break;
}
return index;
@@ -1481,22 +1390,17 @@ s8 PHY_GetTxPowerByRate(
padapter->registrypriv.RegEnableTxPowerByRate == 0)
return 0;
- if (Band != BAND_ON_2_4G && Band != BAND_ON_5G) {
- DBG_871X("Invalid band %d in %s\n", Band, __func__);
+ if (Band != BAND_ON_2_4G && Band != BAND_ON_5G)
return value;
- }
- if (RFPath > ODM_RF_PATH_D) {
- DBG_871X("Invalid RfPath %d in %s\n", RFPath, __func__);
+
+ if (RFPath > ODM_RF_PATH_D)
return value;
- }
- if (TxNum >= RF_MAX_TX_NUM) {
- DBG_871X("Invalid TxNum %d in %s\n", TxNum, __func__);
+
+ if (TxNum >= RF_MAX_TX_NUM)
return value;
- }
- if (rateIndex >= TX_PWR_BY_RATE_NUM_RATE) {
- DBG_871X("Invalid RateIndex %d in %s\n", rateIndex, __func__);
+
+ if (rateIndex >= TX_PWR_BY_RATE_NUM_RATE)
return value;
- }
return pHalData->TxPwrByRateOffset[Band][RFPath][TxNum][rateIndex];
@@ -1514,22 +1418,17 @@ void PHY_SetTxPowerByRate(
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
u8 rateIndex = PHY_GetRateIndexOfTxPowerByRate(Rate);
- if (Band != BAND_ON_2_4G && Band != BAND_ON_5G) {
- DBG_871X("Invalid band %d in %s\n", Band, __func__);
+ if (Band != BAND_ON_2_4G && Band != BAND_ON_5G)
return;
- }
- if (RFPath > ODM_RF_PATH_D) {
- DBG_871X("Invalid RfPath %d in %s\n", RFPath, __func__);
+
+ if (RFPath > ODM_RF_PATH_D)
return;
- }
- if (TxNum >= RF_MAX_TX_NUM) {
- DBG_871X("Invalid TxNum %d in %s\n", TxNum, __func__);
+
+ if (TxNum >= RF_MAX_TX_NUM)
return;
- }
- if (rateIndex >= TX_PWR_BY_RATE_NUM_RATE) {
- DBG_871X("Invalid RateIndex %d in %s\n", rateIndex, __func__);
+
+ if (rateIndex >= TX_PWR_BY_RATE_NUM_RATE)
return;
- }
pHalData->TxPwrByRateOffset[Band][RFPath][TxNum][rateIndex] = Value;
}
@@ -1556,7 +1455,7 @@ void PHY_SetTxPowerLevelByPath(struct adapter *Adapter, u8 channel, u8 path)
void PHY_SetTxPowerIndexByRateArray(
struct adapter *padapter,
u8 RFPath,
- enum CHANNEL_WIDTH BandWidth,
+ enum channel_width BandWidth,
u8 Channel,
u8 *Rates,
u8 RateArraySize
@@ -1601,16 +1500,12 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel)
if (channel5G[i] == Channel)
channelIndex = i;
}
- } else
- DBG_871X("Invalid Band %d in %s", Band, __func__);
-
- if (channelIndex == -1)
- DBG_871X("Invalid Channel %d of Band %d in %s", Channel, Band, __func__);
+ }
return channelIndex;
}
-static s16 get_bandwidth_idx(const enum CHANNEL_WIDTH bandwidth)
+static s16 get_bandwidth_idx(const enum channel_width bandwidth)
{
switch (bandwidth) {
case CHANNEL_WIDTH_20:
@@ -1667,13 +1562,12 @@ static s16 get_rate_sctn_idx(const u8 rate)
case MGN_VHT4SS_MCS9:
return 9;
default:
- DBG_871X("Wrong rate 0x%x\n", rate);
return -1;
}
}
s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
- enum BAND_TYPE band_type, enum CHANNEL_WIDTH bandwidth,
+ enum band_type band_type, enum channel_width bandwidth,
u8 rf_path, u8 data_rate, u8 channel)
{
s16 idx_band = -1;
@@ -1709,9 +1603,6 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
break;
}
- /* DBG_871X("pMgntInfo->RegPwrTblSel %d, final regulation %d\n", */
- /* adapter->registrypriv.RegPwrTblSel, idx_regulation); */
-
if (band_type == BAND_ON_2_4G)
idx_band = 0;
else if (band_type == BAND_ON_5G)
@@ -1720,9 +1611,6 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
idx_bandwidth = get_bandwidth_idx(bandwidth);
idx_rate_sctn = get_rate_sctn_idx(data_rate);
- if (band_type == BAND_ON_5G && idx_rate_sctn == 0)
- DBG_871X("Wrong rate 0x%x: No CCK in 5G Band\n", DataRate);
-
/* workaround for wrong index combination to obtain tx power limit, */
/* OFDM only exists in BW 20M */
/* CCK table will only be given in BW 20M */
@@ -1737,13 +1625,8 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
channel = phy_GetChannelIndexOfTxPowerLimit(band_type, channel);
if (idx_band == -1 || idx_regulation == -1 || idx_bandwidth == -1 ||
- idx_rate_sctn == -1 || idx_channel == -1) {
- /* DBG_871X("Wrong index value to access power limit table [band %d][regulation %d][bandwidth %d][rf_path %d][rate_section %d][chnlGroup %d]\n", */
- /* idx_band, idx_regulation, idx_bandwidth, rf_path, */
- /* idx_rate_sctn, channel); */
-
+ idx_rate_sctn == -1 || idx_channel == -1)
return MAX_POWER_INDEX;
- }
if (band_type == BAND_ON_2_4G) {
s8 limits[10] = {0}; u8 i = 0;
@@ -1780,32 +1663,8 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
[idx_rate_sctn]
[idx_channel]
[rf_path];
- } else {
- DBG_871X("No power limit table of the specified band\n");
}
- /* combine 5G VHT & HT rate */
- /* 5G 20M and 40M HT and VHT can cross reference */
- /*
- if (band_type == BAND_ON_5G && pwr_lmt == MAX_POWER_INDEX) {
- if (idx_bandwidth == 0 || idx_bandwidth == 1) {
- RT_TRACE(COMP_INIT, DBG_LOUD, ("No power limit table of the specified band %d, bandwidth %d, ratesection %d, rf path %d\n",
- idx_band, idx_bandwidth,
- idx_rate_sctn, rf_path));
- if (idx_rate_sctn == 2)
- pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][4][idx_channel][rf_path];
- else if (idx_rate_sctn == 4)
- pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][2][idx_channel][rf_path];
- else if (idx_rate_sctn == 3)
- pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][5][idx_channel][rf_path];
- else if (idx_rate_sctn == 5)
- pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][3][idx_channel][rf_path];
- }
- }
- */
-
- /* DBG_871X("TxPwrLmt[Regulation %d][Band %d][BW %d][RFPath %d][Rate 0x%x][Chnl %d] = %d\n", */
- /* idx_regulation, hal_data->CurrentBandType, bandwidth, rf_path, data_rate, channel, pwr_lmt); */
return pwr_lmt;
}
@@ -1823,7 +1682,6 @@ static void phy_CrossReferenceHTAndVHTTxPowerLimit(struct adapter *padapter)
if (tempPwrLmt == MAX_POWER_INDEX) {
u8 baseSection = 2, refSection = 6;
if (bw == 0 || bw == 1) { /* 5G 20M 40M VHT and HT can cross reference */
- /* DBG_871X("No power limit table of the specified band %d, bandwidth %d, ratesection %d, channel %d, rf path %d\n", */
/* 1, bw, rateSection, channel, ODM_RF_PATH_A); */
if (rateSection >= 2 && rateSection <= 9) {
if (rateSection == 2) {
@@ -1854,8 +1712,6 @@ static void phy_CrossReferenceHTAndVHTTxPowerLimit(struct adapter *padapter)
pHalData->TxPwrLimit_5G[regulation][bw][baseSection][channel][ODM_RF_PATH_A] =
pHalData->TxPwrLimit_5G[regulation][bw][refSection][channel][ODM_RF_PATH_A];
}
-
- /* DBG_871X("use other value %d", tempPwrLmt); */
}
}
}
@@ -1872,8 +1728,6 @@ void PHY_ConvertTxPowerLimitToPowerIndex(struct adapter *Adapter)
s8 tempValue = 0, tempPwrLmt = 0;
u8 rfPath = 0;
- /* DBG_871X("=====> PHY_ConvertTxPowerLimitToPowerIndex()\n"); */
-
phy_CrossReferenceHTAndVHTTxPowerLimit(Adapter);
for (regulation = 0; regulation < MAX_REGULATION_NUM; ++regulation) {
@@ -1908,8 +1762,6 @@ void PHY_ConvertTxPowerLimitToPowerIndex(struct adapter *Adapter)
}
}
}
-
- /* DBG_871X("<===== PHY_ConvertTxPowerLimitToPowerIndex()\n"); */
}
void PHY_InitTxPowerLimit(struct adapter *Adapter)
@@ -1917,8 +1769,6 @@ void PHY_InitTxPowerLimit(struct adapter *Adapter)
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
u8 i, j, k, l, m;
- /* DBG_871X("=====> PHY_InitTxPowerLimit()!\n"); */
-
for (i = 0; i < MAX_REGULATION_NUM; ++i) {
for (j = 0; j < MAX_2_4G_BANDWIDTH_NUM; ++j)
for (k = 0; k < MAX_RATE_SECTION_NUM; ++k)
@@ -1934,8 +1784,6 @@ void PHY_InitTxPowerLimit(struct adapter *Adapter)
for (l = 0; l < MAX_RF_PATH_NUM; ++l)
pHalData->TxPwrLimit_5G[i][j][k][m][l] = MAX_POWER_INDEX;
}
-
- /* DBG_871X("<===== PHY_InitTxPowerLimit()!\n"); */
}
void PHY_SetTxPowerLimit(
@@ -1953,12 +1801,8 @@ void PHY_SetTxPowerLimit(
u8 regulation = 0, bandwidth = 0, rateSection = 0, channel;
s8 powerLimit = 0, prevPowerLimit, channelIndex;
- /* DBG_871X("Index of power limit table [band %s][regulation %s][bw %s][rate section %s][rf path %s][chnl %s][val %s]\n", */
- /* Band, Regulation, Bandwidth, RateSection, RfPath, Channel, PowerLimit); */
-
- if (!GetU1ByteIntegerFromStringInDecimal((s8 *)Channel, &channel) ||
- !GetU1ByteIntegerFromStringInDecimal((s8 *)PowerLimit, &powerLimit))
- DBG_871X("Illegal index of power limit table [chnl %s][val %s]\n", Channel, PowerLimit);
+ GetU1ByteIntegerFromStringInDecimal((s8 *)Channel, &channel);
+ GetU1ByteIntegerFromStringInDecimal((s8 *)PowerLimit, &powerLimit);
powerLimit = powerLimit > MAX_POWER_INDEX ? MAX_POWER_INDEX : powerLimit;
@@ -1991,11 +1835,8 @@ void PHY_SetTxPowerLimit(
rateSection = 8;
else if (eqNByte(RateSection, (u8 *)("VHT"), 3) && eqNByte(RfPath, (u8 *)("4T"), 2))
rateSection = 9;
- else {
- DBG_871X("Wrong rate section!\n");
+ else
return;
- }
-
if (eqNByte(Bandwidth, (u8 *)("20M"), 3))
bandwidth = 0;
@@ -2017,8 +1858,6 @@ void PHY_SetTxPowerLimit(
if (powerLimit < prevPowerLimit)
pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A] = powerLimit;
- /* DBG_871X("2.4G Band value : [regulation %d][bw %d][rate_section %d][chnl %d][val %d]\n", */
- /* regulation, bandwidth, rateSection, channelIndex, pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A]); */
} else if (eqNByte(Band, (u8 *)("5G"), 2)) {
channelIndex = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G, channel);
@@ -2030,10 +1869,7 @@ void PHY_SetTxPowerLimit(
if (powerLimit < prevPowerLimit)
pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A] = powerLimit;
- /* DBG_871X("5G Band value : [regulation %d][bw %d][rate_section %d][chnl %d][val %d]\n", */
- /* regulation, bandwidth, rateSection, channel, pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A]); */
} else {
- DBG_871X("Cannot recognize the band info in %s\n", Band);
return;
}
}
diff --git a/drivers/staging/rtl8723bs/hal/hal_intf.c b/drivers/staging/rtl8723bs/hal/hal_intf.c
index ac3066a91c84..8dc4dd8c6d4c 100644
--- a/drivers/staging/rtl8723bs/hal/hal_intf.c
+++ b/drivers/staging/rtl8723bs/hal/hal_intf.c
@@ -63,9 +63,9 @@ void rtw_hal_dm_deinit(struct adapter *padapter)
static void rtw_hal_init_opmode(struct adapter *padapter)
{
- enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType = Ndis802_11InfrastructureMax;
+ enum ndis_802_11_network_infrastructure networkType = Ndis802_11InfrastructureMax;
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
- sint fw_state;
+ signed int fw_state;
fw_state = get_fwstate(pmlmepriv);
@@ -105,18 +105,14 @@ uint rtw_hal_init(struct adapter *padapter)
rtw_bb_rf_gain_offset(padapter);
} else {
dvobj->padapters->hw_init_completed = false;
- DBG_871X("rtw_hal_init: hal__init fail\n");
}
- RT_TRACE(_module_hal_init_c_, _drv_err_, ("-rtl871x_hal_init:status = 0x%x\n", status));
-
return status;
-
}
uint rtw_hal_deinit(struct adapter *padapter)
{
- uint status = _SUCCESS;
+ uint status = _SUCCESS;
struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
status = padapter->HalFunc.hal_deinit(padapter);
@@ -124,9 +120,8 @@ uint rtw_hal_deinit(struct adapter *padapter)
if (status == _SUCCESS) {
padapter = dvobj->padapters;
padapter->hw_init_completed = false;
- } else {
- DBG_871X("\n rtw_hal_deinit: hal_init fail\n");
}
+
return status;
}
@@ -148,27 +143,27 @@ void rtw_hal_set_hwreg_with_buf(struct adapter *padapter, u8 variable, u8 *pbuf,
padapter->HalFunc.SetHwRegHandlerWithBuf(padapter, variable, pbuf, len);
}
-u8 rtw_hal_set_def_var(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue)
+u8 rtw_hal_set_def_var(struct adapter *padapter, enum hal_def_variable eVariable, void *pValue)
{
if (padapter->HalFunc.SetHalDefVarHandler)
return padapter->HalFunc.SetHalDefVarHandler(padapter, eVariable, pValue);
return _FAIL;
}
-u8 rtw_hal_get_def_var(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue)
+u8 rtw_hal_get_def_var(struct adapter *padapter, enum hal_def_variable eVariable, void *pValue)
{
if (padapter->HalFunc.GetHalDefVarHandler)
return padapter->HalFunc.GetHalDefVarHandler(padapter, eVariable, pValue);
return _FAIL;
}
-void rtw_hal_set_odm_var(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, bool bSet)
+void rtw_hal_set_odm_var(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet)
{
if (padapter->HalFunc.SetHalODMVarHandler)
padapter->HalFunc.SetHalODMVarHandler(padapter, eVariable, pValue1, bSet);
}
-void rtw_hal_get_odm_var(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, void *pValue2)
+void rtw_hal_get_odm_var(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, void *pValue2)
{
if (padapter->HalFunc.GetHalODMVarHandler)
padapter->HalFunc.GetHalODMVarHandler(padapter, eVariable, pValue1, pValue2);
@@ -178,18 +173,12 @@ void rtw_hal_enable_interrupt(struct adapter *padapter)
{
if (padapter->HalFunc.enable_interrupt)
padapter->HalFunc.enable_interrupt(padapter);
- else
- DBG_871X("%s: HalFunc.enable_interrupt is NULL!\n", __func__);
-
}
void rtw_hal_disable_interrupt(struct adapter *padapter)
{
if (padapter->HalFunc.disable_interrupt)
padapter->HalFunc.disable_interrupt(padapter);
- else
- DBG_871X("%s: HalFunc.disable_interrupt is NULL!\n", __func__);
-
}
u8 rtw_hal_check_ips_status(struct adapter *padapter)
@@ -197,8 +186,6 @@ u8 rtw_hal_check_ips_status(struct adapter *padapter)
u8 val = false;
if (padapter->HalFunc.check_ips_status)
val = padapter->HalFunc.check_ips_status(padapter);
- else
- DBG_871X("%s: HalFunc.check_ips_status is NULL!\n", __func__);
return val;
}
@@ -269,7 +256,6 @@ s32 rtw_hal_init_recv_priv(struct adapter *padapter)
void rtw_hal_free_recv_priv(struct adapter *padapter)
{
-
if (padapter->HalFunc.free_recv_priv)
padapter->HalFunc.free_recv_priv(padapter);
}
@@ -346,7 +332,7 @@ void rtw_hal_set_chan(struct adapter *padapter, u8 channel)
}
void rtw_hal_set_chnl_bw(struct adapter *padapter, u8 channel,
- enum CHANNEL_WIDTH Bandwidth, u8 Offset40, u8 Offset80)
+ enum channel_width Bandwidth, u8 Offset40, u8 Offset80)
{
if (padapter->HalFunc.set_chnl_bw_handler)
padapter->HalFunc.set_chnl_bw_handler(padapter, channel,
@@ -358,12 +344,11 @@ void rtw_hal_dm_watchdog(struct adapter *padapter)
{
if (padapter->HalFunc.hal_dm_watchdog)
padapter->HalFunc.hal_dm_watchdog(padapter);
-
}
void rtw_hal_dm_watchdog_in_lps(struct adapter *padapter)
{
- if (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode == true) {
+ if (adapter_to_pwrctl(padapter)->fw_current_in_ps_mode) {
if (padapter->HalFunc.hal_dm_watchdog_in_lps)
padapter->HalFunc.hal_dm_watchdog_in_lps(padapter); /* this function caller is in interrupt context */
}
@@ -422,7 +407,6 @@ s32 rtw_hal_macid_sleep(struct adapter *padapter, u32 macid)
{
u8 support;
-
support = false;
rtw_hal_get_def_var(padapter, HAL_DEF_MACID_SLEEP, &support);
if (false == support)
@@ -437,7 +421,6 @@ s32 rtw_hal_macid_wakeup(struct adapter *padapter, u32 macid)
{
u8 support;
-
support = false;
rtw_hal_get_def_var(padapter, HAL_DEF_MACID_SLEEP, &support);
if (false == support)
@@ -454,8 +437,6 @@ s32 rtw_hal_fill_h2c_cmd(struct adapter *padapter, u8 ElementID, u32 CmdLen, u8
if (padapter->HalFunc.fill_h2c_cmd)
ret = padapter->HalFunc.fill_h2c_cmd(padapter, ElementID, CmdLen, pCmdBuffer);
- else
- DBG_871X("%s: func[fill_h2c_cmd] not defined!\n", __func__);
return ret;
}
diff --git a/drivers/staging/rtl8723bs/hal/hal_pwr_seq.c b/drivers/staging/rtl8723bs/hal/hal_pwr_seq.c
index 589e7aae7bbd..fba67a7c069c 100644
--- a/drivers/staging/rtl8723bs/hal/hal_pwr_seq.c
+++ b/drivers/staging/rtl8723bs/hal/hal_pwr_seq.c
@@ -21,7 +21,7 @@ Major Change History:
/* drivers should parse below arrays and do the corresponding actions */
/* 3 Power on Array */
-WLAN_PWR_CFG rtl8723B_power_on_flow[
+struct wlan_pwr_cfg rtl8723B_power_on_flow[
RTL8723B_TRANS_CARDEMU_TO_ACT_STEPS+
RTL8723B_TRANS_END_STEPS
] = {
@@ -30,7 +30,7 @@ WLAN_PWR_CFG rtl8723B_power_on_flow[
};
/* 3Radio off GPIO Array */
-WLAN_PWR_CFG rtl8723B_radio_off_flow[
+struct wlan_pwr_cfg rtl8723B_radio_off_flow[
RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+
RTL8723B_TRANS_END_STEPS
] = {
@@ -39,7 +39,7 @@ WLAN_PWR_CFG rtl8723B_radio_off_flow[
};
/* 3Card Disable Array */
-WLAN_PWR_CFG rtl8723B_card_disable_flow[
+struct wlan_pwr_cfg rtl8723B_card_disable_flow[
RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+
RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+
RTL8723B_TRANS_END_STEPS
@@ -50,7 +50,7 @@ WLAN_PWR_CFG rtl8723B_card_disable_flow[
};
/* 3 Card Enable Array */
-WLAN_PWR_CFG rtl8723B_card_enable_flow[
+struct wlan_pwr_cfg rtl8723B_card_enable_flow[
RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+
RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+
RTL8723B_TRANS_END_STEPS
@@ -61,7 +61,7 @@ WLAN_PWR_CFG rtl8723B_card_enable_flow[
};
/* 3Suspend Array */
-WLAN_PWR_CFG rtl8723B_suspend_flow[
+struct wlan_pwr_cfg rtl8723B_suspend_flow[
RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+
RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+
RTL8723B_TRANS_END_STEPS
@@ -72,7 +72,7 @@ WLAN_PWR_CFG rtl8723B_suspend_flow[
};
/* 3 Resume Array */
-WLAN_PWR_CFG rtl8723B_resume_flow[
+struct wlan_pwr_cfg rtl8723B_resume_flow[
RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+
RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+
RTL8723B_TRANS_END_STEPS
@@ -83,7 +83,7 @@ WLAN_PWR_CFG rtl8723B_resume_flow[
};
/* 3HWPDN Array */
-WLAN_PWR_CFG rtl8723B_hwpdn_flow[
+struct wlan_pwr_cfg rtl8723B_hwpdn_flow[
RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+
RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+
RTL8723B_TRANS_END_STEPS
@@ -94,7 +94,7 @@ WLAN_PWR_CFG rtl8723B_hwpdn_flow[
};
/* 3 Enter LPS */
-WLAN_PWR_CFG rtl8723B_enter_lps_flow[
+struct wlan_pwr_cfg rtl8723B_enter_lps_flow[
RTL8723B_TRANS_ACT_TO_LPS_STEPS+RTL8723B_TRANS_END_STEPS
] = {
/* FW behavior */
@@ -103,7 +103,7 @@ WLAN_PWR_CFG rtl8723B_enter_lps_flow[
};
/* 3 Leave LPS */
-WLAN_PWR_CFG rtl8723B_leave_lps_flow[
+struct wlan_pwr_cfg rtl8723B_leave_lps_flow[
RTL8723B_TRANS_LPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS
] = {
/* FW behavior */
@@ -112,7 +112,7 @@ WLAN_PWR_CFG rtl8723B_leave_lps_flow[
};
/* 3 Enter SW LPS */
-WLAN_PWR_CFG rtl8723B_enter_swlps_flow[
+struct wlan_pwr_cfg rtl8723B_enter_swlps_flow[
RTL8723B_TRANS_ACT_TO_SWLPS_STEPS+RTL8723B_TRANS_END_STEPS
] = {
/* SW behavior */
@@ -121,7 +121,7 @@ WLAN_PWR_CFG rtl8723B_enter_swlps_flow[
};
/* 3 Leave SW LPS */
-WLAN_PWR_CFG rtl8723B_leave_swlps_flow[
+struct wlan_pwr_cfg rtl8723B_leave_swlps_flow[
RTL8723B_TRANS_SWLPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS
] = {
/* SW behavior */
diff --git a/drivers/staging/rtl8723bs/hal/odm.c b/drivers/staging/rtl8723bs/hal/odm.c
index f2a9e95a1563..092b32c41ff3 100644
--- a/drivers/staging/rtl8723bs/hal/odm.c
+++ b/drivers/staging/rtl8723bs/hal/odm.c
@@ -279,79 +279,541 @@ u32 TxScalingTable_Jaguar[TXSCALE_TABLE_SIZE] = {
0x3FE /* 36, +6.0dB */
};
-/* Local Function predefine. */
+/* Remove Edca by Yu Chen */
-/* START------------COMMON INFO RELATED--------------- */
-void odm_CommonInfoSelfInit(PDM_ODM_T pDM_Odm);
-void odm_CommonInfoSelfUpdate(PDM_ODM_T pDM_Odm);
+#define RxDefaultAnt1 0x65a9
+#define RxDefaultAnt2 0x569a
-void odm_CmnInfoInit_Debug(PDM_ODM_T pDM_Odm);
+static void odm_CommonInfoSelfInit(struct dm_odm_t *pDM_Odm)
+{
+ pDM_Odm->bCckHighPower = (bool) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(CCK_RPT_FORMAT, pDM_Odm), ODM_BIT(CCK_RPT_FORMAT, pDM_Odm));
+ pDM_Odm->RFPathRxEnable = (u8) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(BB_RX_PATH, pDM_Odm), ODM_BIT(BB_RX_PATH, pDM_Odm));
-void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm);
+ ODM_InitDebugSetting(pDM_Odm);
-/* END------------COMMON INFO RELATED--------------- */
+ pDM_Odm->TxRate = 0xFF;
+}
-/* START---------------DIG--------------------------- */
+static void odm_CommonInfoSelfUpdate(struct dm_odm_t *pDM_Odm)
+{
+ u8 EntryCnt = 0;
+ u8 i;
+ PSTA_INFO_T pEntry;
-/* Remove by Yuchen */
+ if (*(pDM_Odm->pBandWidth) == ODM_BW40M) {
+ if (*(pDM_Odm->pSecChOffset) == 1)
+ pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)-2;
+ else if (*(pDM_Odm->pSecChOffset) == 2)
+ pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)+2;
+ } else
+ pDM_Odm->ControlChannel = *(pDM_Odm->pChannel);
-/* END---------------DIG--------------------------- */
+ for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
+ pEntry = pDM_Odm->pODM_StaInfo[i];
+ if (IS_STA_VALID(pEntry))
+ EntryCnt++;
+ }
-/* START-------BB POWER SAVE----------------------- */
-/* Remove BB power Saving by YuChen */
-/* END---------BB POWER SAVE----------------------- */
+ if (EntryCnt == 1)
+ pDM_Odm->bOneEntryOnly = true;
+ else
+ pDM_Odm->bOneEntryOnly = false;
+}
-void odm_RefreshRateAdaptiveMaskCE(PDM_ODM_T pDM_Odm);
+static void odm_CmnInfoInit_Debug(struct dm_odm_t *pDM_Odm)
+{
+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug ==>\n"));
+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportPlatform =%d\n", pDM_Odm->SupportPlatform));
+ 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));
-/* Remove by YuChen */
+}
-void odm_RSSIMonitorInit(PDM_ODM_T pDM_Odm);
+static void odm_BasicDbgMessage(struct dm_odm_t *pDM_Odm)
+{
+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_BasicDbgMsg ==>\n"));
+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked = %d, RSSI_Min = %d,\n",
+ pDM_Odm->bLinked, pDM_Odm->RSSI_Min));
+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RxRate = 0x%x, RSSI_A = %d, RSSI_B = %d\n",
+ pDM_Odm->RxRate, pDM_Odm->RSSI_A, pDM_Odm->RSSI_B));
+}
-void odm_RSSIMonitorCheckCE(PDM_ODM_T pDM_Odm);
+/* 3 ============================================================ */
+/* 3 RATR MASK */
+/* 3 ============================================================ */
+/* 3 ============================================================ */
+/* 3 Rate Adaptive */
+/* 3 ============================================================ */
-void odm_RSSIMonitorCheck(PDM_ODM_T pDM_Odm);
+static void odm_RateAdaptiveMaskInit(struct dm_odm_t *pDM_Odm)
+{
+ struct odm_rate_adaptive *pOdmRA = &pDM_Odm->RateAdaptive;
-void odm_SwAntDetectInit(PDM_ODM_T pDM_Odm);
+ pOdmRA->Type = DM_Type_ByDriver;
+ if (pOdmRA->Type == DM_Type_ByDriver)
+ pDM_Odm->bUseRAMask = true;
+ else
+ pDM_Odm->bUseRAMask = false;
-void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext);
+ pOdmRA->RATRState = DM_RATR_STA_INIT;
+ pOdmRA->LdpcThres = 35;
+ pOdmRA->bUseLdpc = false;
+ pOdmRA->HighRSSIThresh = 50;
+ pOdmRA->LowRSSIThresh = 20;
+}
+u32 ODM_Get_Rate_Bitmap(
+ struct dm_odm_t *pDM_Odm,
+ u32 macid,
+ u32 ra_mask,
+ u8 rssi_level
+)
+{
+ PSTA_INFO_T pEntry;
+ u32 rate_bitmap = 0;
+ u8 WirelessMode;
+ pEntry = pDM_Odm->pODM_StaInfo[macid];
+ if (!IS_STA_VALID(pEntry))
+ return ra_mask;
-void odm_GlobalAdapterCheck(void);
+ WirelessMode = pEntry->wireless_mode;
-void odm_RefreshRateAdaptiveMask(PDM_ODM_T pDM_Odm);
+ switch (WirelessMode) {
+ case ODM_WM_B:
+ if (ra_mask & 0x0000000c) /* 11M or 5.5M enable */
+ rate_bitmap = 0x0000000d;
+ else
+ rate_bitmap = 0x0000000f;
+ break;
-void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm);
+ case (ODM_WM_G):
+ case (ODM_WM_A):
+ if (rssi_level == DM_RATR_STA_HIGH)
+ rate_bitmap = 0x00000f00;
+ else
+ rate_bitmap = 0x00000ff0;
+ break;
-void odm_RateAdaptiveMaskInit(PDM_ODM_T pDM_Odm);
+ case (ODM_WM_B|ODM_WM_G):
+ if (rssi_level == DM_RATR_STA_HIGH)
+ rate_bitmap = 0x00000f00;
+ else if (rssi_level == DM_RATR_STA_MIDDLE)
+ rate_bitmap = 0x00000ff0;
+ else
+ rate_bitmap = 0x00000ff5;
+ break;
+ case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G):
+ case (ODM_WM_B|ODM_WM_N24G):
+ case (ODM_WM_G|ODM_WM_N24G):
+ case (ODM_WM_A|ODM_WM_N5G):
+ if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) {
+ if (rssi_level == DM_RATR_STA_HIGH)
+ rate_bitmap = 0x000f0000;
+ else if (rssi_level == DM_RATR_STA_MIDDLE)
+ rate_bitmap = 0x000ff000;
+ else {
+ if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
+ rate_bitmap = 0x000ff015;
+ else
+ rate_bitmap = 0x000ff005;
+ }
+ } else {
+ if (rssi_level == DM_RATR_STA_HIGH)
+ rate_bitmap = 0x0f8f0000;
+ else if (rssi_level == DM_RATR_STA_MIDDLE)
+ rate_bitmap = 0x0f8ff000;
+ else {
+ if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
+ rate_bitmap = 0x0f8ff015;
+ else
+ rate_bitmap = 0x0f8ff005;
+ }
+ }
+ break;
-void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm);
+ case (ODM_WM_AC|ODM_WM_G):
+ if (rssi_level == 1)
+ rate_bitmap = 0xfc3f0000;
+ else if (rssi_level == 2)
+ rate_bitmap = 0xfffff000;
+ else
+ rate_bitmap = 0xffffffff;
+ break;
-/* Remove Edca by Yu Chen */
+ case (ODM_WM_AC|ODM_WM_A):
+
+ if (pDM_Odm->RFType == RF_1T1R) {
+ if (rssi_level == 1) /* add by Gary for ac-series */
+ rate_bitmap = 0x003f8000;
+ else if (rssi_level == 2)
+ rate_bitmap = 0x003ff000;
+ else
+ rate_bitmap = 0x003ff010;
+ } else {
+ if (rssi_level == 1) /* add by Gary for ac-series */
+ rate_bitmap = 0xfe3f8000; /* VHT 2SS MCS3~9 */
+ else if (rssi_level == 2)
+ rate_bitmap = 0xfffff000; /* VHT 2SS MCS0~9 */
+ else
+ rate_bitmap = 0xfffff010; /* All */
+ }
+ break;
+ default:
+ if (pDM_Odm->RFType == RF_1T2R)
+ rate_bitmap = 0x000fffff;
+ else
+ rate_bitmap = 0x0fffffff;
+ break;
+ }
-#define RxDefaultAnt1 0x65a9
-#define RxDefaultAnt2 0x569a
+ /* 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));
+
+ return ra_mask & rate_bitmap;
+
+}
+
+static void odm_RefreshRateAdaptiveMaskCE(struct dm_odm_t *pDM_Odm)
+{
+ u8 i;
+ struct adapter *padapter = pDM_Odm->Adapter;
+
+ if (padapter->bDriverStopped) {
+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n"));
+ return;
+ }
+
+ if (!pDM_Odm->bUseRAMask) {
+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n"));
+ return;
+ }
+
+ for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
+ PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i];
+
+ if (IS_STA_VALID(pstat)) {
+ if (IS_MCAST(pstat->hwaddr)) /* if (psta->mac_id == 1) */
+ continue;
+
+ if (true == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, 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));
+ /* printk("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level); */
+ rtw_hal_update_ra_mask(pstat, pstat->rssi_level);
+ }
+
+ }
+ }
+}
+
+/*-----------------------------------------------------------------------------
+* Function: odm_RefreshRateAdaptiveMask()
+*
+* Overview: Update rate table mask according to rssi
+*
+* Input: NONE
+*
+* Output: NONE
+*
+* Return: NONE
+*
+* Revised History:
+*When Who Remark
+*05/27/2009 hpfan Create Version 0.
+*
+* --------------------------------------------------------------------------
+*/
+static void odm_RefreshRateAdaptiveMask(struct dm_odm_t *pDM_Odm)
+{
+
+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask()---------->\n"));
+ if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) {
+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask(): Return cos not supported\n"));
+ return;
+ }
+ odm_RefreshRateAdaptiveMaskCE(pDM_Odm);
+}
+
+/* Return Value: bool */
+/* - true: RATRState is changed. */
+bool ODM_RAStateCheck(
+ struct dm_odm_t *pDM_Odm,
+ s32 RSSI,
+ bool bForceUpdate,
+ u8 *pRATRState
+)
+{
+ struct odm_rate_adaptive *pRA = &pDM_Odm->RateAdaptive;
+ const u8 GoUpGap = 5;
+ u8 HighRSSIThreshForRA = pRA->HighRSSIThresh;
+ u8 LowRSSIThreshForRA = pRA->LowRSSIThresh;
+ u8 RATRState;
-void odm_InitHybridAntDiv(PDM_ODM_T pDM_Odm);
+ /* Threshold Adjustment: */
+ /* when RSSI state trends to go up one or two levels, make sure RSSI is high enough. */
+ /* Here GoUpGap is added to solve the boundary's level alternation issue. */
+ switch (*pRATRState) {
+ case DM_RATR_STA_INIT:
+ case DM_RATR_STA_HIGH:
+ break;
-bool odm_StaDefAntSel(
- PDM_ODM_T pDM_Odm,
- u32 OFDM_Ant1_Cnt,
- u32 OFDM_Ant2_Cnt,
- u32 CCK_Ant1_Cnt,
- u32 CCK_Ant2_Cnt,
- u8 *pDefAnt
-);
+ case DM_RATR_STA_MIDDLE:
+ HighRSSIThreshForRA += GoUpGap;
+ break;
-void odm_SetRxIdleAnt(PDM_ODM_T pDM_Odm, u8 Ant, bool bDualPath);
+ case DM_RATR_STA_LOW:
+ HighRSSIThreshForRA += GoUpGap;
+ LowRSSIThreshForRA += GoUpGap;
+ break;
+ default:
+ ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState));
+ break;
+ }
+ /* Decide RATRState by RSSI. */
+ if (RSSI > HighRSSIThreshForRA)
+ RATRState = DM_RATR_STA_HIGH;
+ else if (RSSI > LowRSSIThreshForRA)
+ RATRState = DM_RATR_STA_MIDDLE;
+ else
+ RATRState = DM_RATR_STA_LOW;
+ /* printk("==>%s, RATRState:0x%02x , RSSI:%d\n", __func__, RATRState, RSSI); */
-void odm_HwAntDiv(PDM_ODM_T pDM_Odm);
+ if (*pRATRState != RATRState || bForceUpdate) {
+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI Level %d -> %d\n", *pRATRState, RATRState));
+ *pRATRState = RATRState;
+ return true;
+ }
+ return false;
+}
+
+/* */
+
+/* 3 ============================================================ */
+/* 3 RSSI Monitor */
+/* 3 ============================================================ */
+
+static void odm_RSSIMonitorInit(struct dm_odm_t *pDM_Odm)
+{
+ struct ra_t *pRA_Table = &pDM_Odm->DM_RA_Table;
+
+ pRA_Table->firstconnect = false;
+
+}
+
+static void FindMinimumRSSI(struct adapter *padapter)
+{
+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
+ struct dm_priv *pdmpriv = &pHalData->dmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
+
+ /* 1 1.Determine the minimum RSSI */
+
+ if (
+ (pDM_Odm->bLinked != true) &&
+ (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)
+ ) {
+ pdmpriv->MinUndecoratedPWDBForDM = 0;
+ /* ODM_RT_TRACE(pDM_Odm, COMP_BB_POWERSAVING, DBG_LOUD, ("Not connected to any\n")); */
+ } else
+ pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
+
+ /* ODM_RT_TRACE(pDM_Odm, COMP_DIG, DBG_LOUD, ("MinUndecoratedPWDBForDM =%d\n", pHalData->MinUndecoratedPWDBForDM)); */
+}
+
+static void odm_RSSIMonitorCheckCE(struct dm_odm_t *pDM_Odm)
+{
+ struct adapter *Adapter = pDM_Odm->Adapter;
+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
+ struct dm_priv *pdmpriv = &pHalData->dmpriv;
+ int i;
+ int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff;
+ u8 sta_cnt = 0;
+ u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */
+ struct ra_t *pRA_Table = &pDM_Odm->DM_RA_Table;
+
+ if (pDM_Odm->bLinked != true)
+ return;
+
+ pRA_Table->firstconnect = pDM_Odm->bLinked;
+
+ /* if (check_fwstate(&Adapter->mlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true) */
+ {
+ struct sta_info *psta;
+
+ for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
+ psta = pDM_Odm->pODM_StaInfo[i];
+ if (IS_STA_VALID(psta)) {
+ if (IS_MCAST(psta->hwaddr)) /* if (psta->mac_id == 1) */
+ continue;
+
+ if (psta->rssi_stat.UndecoratedSmoothedPWDB == (-1))
+ continue;
+
+ if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
+ tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
+
+ if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
+ tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
+
+ if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1))
+ PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16));
+ }
+ }
+
+ /* printk("%s ==> sta_cnt(%d)\n", __func__, sta_cnt); */
+
+ for (i = 0; i < sta_cnt; i++) {
+ if (PWDB_rssi[i] != (0)) {
+ if (pHalData->fw_ractrl == true)/* Report every sta's RSSI to FW */
+ rtl8723b_set_rssi_cmd(Adapter, (u8 *)(&PWDB_rssi[i]));
+ }
+ }
+ }
+
+
+
+ if (tmpEntryMaxPWDB != 0) /* If associated entry is found */
+ pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB;
+ else
+ pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0;
+
+ if (tmpEntryMinPWDB != 0xff) /* If associated entry is found */
+ pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
+ else
+ pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0;
+
+ FindMinimumRSSI(Adapter);/* get pdmpriv->MinUndecoratedPWDBForDM */
+
+ pDM_Odm->RSSI_Min = pdmpriv->MinUndecoratedPWDBForDM;
+ /* ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); */
+}
+
+static void odm_RSSIMonitorCheck(struct dm_odm_t *pDM_Odm)
+{
+ if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR))
+ return;
+
+ odm_RSSIMonitorCheckCE(pDM_Odm);
+
+} /* odm_RSSIMonitorCheck */
+
+/* 3 ============================================================ */
+/* 3 SW Antenna Diversity */
+/* 3 ============================================================ */
+static void odm_SwAntDetectInit(struct dm_odm_t *pDM_Odm)
+{
+ struct swat_t *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
+
+ pDM_SWAT_Table->SWAS_NoLink_BK_Reg92c = rtw_read32(pDM_Odm->Adapter, rDPDT_control);
+ pDM_SWAT_Table->PreAntenna = MAIN_ANT;
+ pDM_SWAT_Table->CurAntenna = MAIN_ANT;
+ pDM_SWAT_Table->SWAS_NoLink_State = 0;
+}
+
+/* 3 ============================================================ */
+/* 3 Tx Power Tracking */
+/* 3 ============================================================ */
+
+static u8 getSwingIndex(struct dm_odm_t *pDM_Odm)
+{
+ struct adapter *Adapter = pDM_Odm->Adapter;
+ u8 i = 0;
+ u32 bbSwing;
+ u32 swingTableSize;
+ u32 *pSwingTable;
+
+ bbSwing = PHY_QueryBBReg(Adapter, rOFDM0_XATxIQImbalance, 0xFFC00000);
+
+ pSwingTable = OFDMSwingTable_New;
+ swingTableSize = OFDM_TABLE_SIZE;
+
+ for (i = 0; i < swingTableSize; ++i) {
+ u32 tableValue = pSwingTable[i];
+
+ if (tableValue >= 0x100000)
+ tableValue >>= 22;
+ if (bbSwing == tableValue)
+ break;
+ }
+ return i;
+}
+
+void odm_TXPowerTrackingInit(struct dm_odm_t *pDM_Odm)
+{
+ u8 defaultSwingIndex = getSwingIndex(pDM_Odm);
+ u8 p = 0;
+ struct adapter *Adapter = pDM_Odm->Adapter;
+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
+
+
+ struct dm_priv *pdmpriv = &pHalData->dmpriv;
+
+ pdmpriv->bTXPowerTracking = true;
+ pdmpriv->TXPowercount = 0;
+ pdmpriv->bTXPowerTrackingInit = false;
+
+ if (*(pDM_Odm->mp_mode) != 1)
+ pdmpriv->TxPowerTrackControl = true;
+ else
+ pdmpriv->TxPowerTrackControl = false;
+
+ /* pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; */
+ pDM_Odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter;
+ pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = pHalData->EEPROMThermalMeter;
+ pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = pHalData->EEPROMThermalMeter;
+
+ /* The index of "0 dB" in SwingTable. */
+ pDM_Odm->DefaultOfdmIndex = (defaultSwingIndex >= OFDM_TABLE_SIZE) ? 30 : defaultSwingIndex;
+ pDM_Odm->DefaultCckIndex = 20;
+
+ pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex;
+ pDM_Odm->RFCalibrateInfo.CCK_index = pDM_Odm->DefaultCckIndex;
+
+ for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) {
+ pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex;
+ pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex;
+ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] = 0;
+ pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] = 0;
+ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
+ }
+
+}
+
+void ODM_TXPowerTrackingCheck(struct dm_odm_t *pDM_Odm)
+{
+ struct adapter *Adapter = pDM_Odm->Adapter;
+
+ if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK))
+ return;
+
+ if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { /* at least delay 1 sec */
+ PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_T_METER_NEW, (BIT17 | BIT16), 0x03);
+
+ pDM_Odm->RFCalibrateInfo.TM_Trigger = 1;
+ return;
+ } else {
+ ODM_TXPowerTrackingCallback_ThermalMeter(Adapter);
+ pDM_Odm->RFCalibrateInfo.TM_Trigger = 0;
+ }
+}
/* */
/* 3 Export Interface */
@@ -360,7 +822,7 @@ void odm_HwAntDiv(PDM_ODM_T pDM_Odm);
/* */
/* 2011/09/21 MH Add to describe different team necessary resource allocate?? */
/* */
-void ODM_DMInit(PDM_ODM_T pDM_Odm)
+void ODM_DMInit(struct dm_odm_t *pDM_Odm)
{
odm_CommonInfoSelfInit(pDM_Odm);
@@ -390,7 +852,7 @@ void ODM_DMInit(PDM_ODM_T pDM_Odm)
/* You can not add any dummy function here, be care, you can only use DM structure */
/* to perform any new ODM_DM. */
/* */
-void ODM_DMWatchdog(PDM_ODM_T pDM_Odm)
+void ODM_DMWatchdog(struct dm_odm_t *pDM_Odm)
{
odm_CommonInfoSelfUpdate(pDM_Odm);
odm_BasicDbgMessage(pDM_Odm);
@@ -417,7 +879,7 @@ void ODM_DMWatchdog(PDM_ODM_T pDM_Odm)
odm_DIG(pDM_Odm);
{
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
+ struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
odm_Adaptivity(pDM_Odm, pDM_DigTable->CurIGValue);
}
@@ -445,7 +907,7 @@ void ODM_DMWatchdog(PDM_ODM_T pDM_Odm)
/* */
/* Init /.. Fixed HW value. Only init time. */
/* */
-void ODM_CmnInfoInit(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, u32 Value)
+void ODM_CmnInfoInit(struct dm_odm_t *pDM_Odm, enum odm_cmninfo_e CmnInfo, u32 Value)
{
/* */
/* This section is used for init value */
@@ -519,16 +981,16 @@ void ODM_CmnInfoInit(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, u32 Value)
break;
case ODM_CMNINFO_GPA:
- pDM_Odm->TypeGPA = (ODM_TYPE_GPA_E)Value;
+ pDM_Odm->TypeGPA = (enum odm_type_gpa_e)Value;
break;
case ODM_CMNINFO_APA:
- pDM_Odm->TypeAPA = (ODM_TYPE_APA_E)Value;
+ pDM_Odm->TypeAPA = (enum odm_type_apa_e)Value;
break;
case ODM_CMNINFO_GLNA:
- pDM_Odm->TypeGLNA = (ODM_TYPE_GLNA_E)Value;
+ pDM_Odm->TypeGLNA = (enum odm_type_glna_e)Value;
break;
case ODM_CMNINFO_ALNA:
- pDM_Odm->TypeALNA = (ODM_TYPE_ALNA_E)Value;
+ pDM_Odm->TypeALNA = (enum odm_type_alna_e)Value;
break;
case ODM_CMNINFO_EXT_TRSW:
@@ -557,7 +1019,7 @@ void ODM_CmnInfoInit(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, u32 Value)
}
-void ODM_CmnInfoHook(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, void *pValue)
+void ODM_CmnInfoHook(struct dm_odm_t *pDM_Odm, enum odm_cmninfo_e CmnInfo, void *pValue)
{
/* */
/* Hook call by reference pointer. */
@@ -686,8 +1148,8 @@ void ODM_CmnInfoHook(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, void *pValue)
void ODM_CmnInfoPtrArrayHook(
- PDM_ODM_T pDM_Odm,
- ODM_CMNINFO_E CmnInfo,
+ struct dm_odm_t *pDM_Odm,
+ enum odm_cmninfo_e CmnInfo,
u16 Index,
void *pValue
)
@@ -714,7 +1176,7 @@ void ODM_CmnInfoPtrArrayHook(
/* */
/* Update Band/CHannel/.. The values are dynamic but non-per-packet. */
/* */
-void ODM_CmnInfoUpdate(PDM_ODM_T pDM_Odm, u32 CmnInfo, u64 Value)
+void ODM_CmnInfoUpdate(struct dm_odm_t *pDM_Odm, u32 CmnInfo, u64 Value)
{
/* */
/* This init variable may be changed in run time. */
@@ -828,72 +1290,6 @@ void ODM_CmnInfoUpdate(PDM_ODM_T pDM_Odm, u32 CmnInfo, u64 Value)
}
-void odm_CommonInfoSelfInit(PDM_ODM_T pDM_Odm)
-{
- pDM_Odm->bCckHighPower = (bool) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(CCK_RPT_FORMAT, pDM_Odm), ODM_BIT(CCK_RPT_FORMAT, pDM_Odm));
- pDM_Odm->RFPathRxEnable = (u8) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(BB_RX_PATH, pDM_Odm), ODM_BIT(BB_RX_PATH, pDM_Odm));
-
- ODM_InitDebugSetting(pDM_Odm);
-
- pDM_Odm->TxRate = 0xFF;
-}
-
-void odm_CommonInfoSelfUpdate(PDM_ODM_T pDM_Odm)
-{
- u8 EntryCnt = 0;
- u8 i;
- PSTA_INFO_T pEntry;
-
- if (*(pDM_Odm->pBandWidth) == ODM_BW40M) {
- if (*(pDM_Odm->pSecChOffset) == 1)
- pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)-2;
- else if (*(pDM_Odm->pSecChOffset) == 2)
- pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)+2;
- } else
- pDM_Odm->ControlChannel = *(pDM_Odm->pChannel);
-
- for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
- pEntry = pDM_Odm->pODM_StaInfo[i];
- if (IS_STA_VALID(pEntry))
- EntryCnt++;
- }
-
- if (EntryCnt == 1)
- pDM_Odm->bOneEntryOnly = true;
- else
- pDM_Odm->bOneEntryOnly = false;
-}
-
-void odm_CmnInfoInit_Debug(PDM_ODM_T pDM_Odm)
-{
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug ==>\n"));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportPlatform =%d\n", pDM_Odm->SupportPlatform));
- 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));
-
-}
-
-void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm)
-{
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_BasicDbgMsg ==>\n"));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked = %d, RSSI_Min = %d,\n",
- pDM_Odm->bLinked, pDM_Odm->RSSI_Min));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RxRate = 0x%x, RSSI_A = %d, RSSI_B = %d\n",
- pDM_Odm->RxRate, pDM_Odm->RSSI_A, pDM_Odm->RSSI_B));
-}
-
/* 3 ============================================================ */
/* 3 DIG */
/* 3 ============================================================ */
@@ -918,7 +1314,6 @@ void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm)
/* Remove DIG and FA check by Yu Chen */
-
/* 3 ============================================================ */
/* 3 BB Power Save */
/* 3 ============================================================ */
@@ -926,483 +1321,8 @@ void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm)
/* Remove BB power saving by Yuchen */
/* 3 ============================================================ */
-/* 3 RATR MASK */
-/* 3 ============================================================ */
-/* 3 ============================================================ */
-/* 3 Rate Adaptive */
-/* 3 ============================================================ */
-
-void odm_RateAdaptiveMaskInit(PDM_ODM_T pDM_Odm)
-{
- PODM_RATE_ADAPTIVE 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->LdpcThres = 35;
- pOdmRA->bUseLdpc = false;
- pOdmRA->HighRSSIThresh = 50;
- pOdmRA->LowRSSIThresh = 20;
-}
-
-u32 ODM_Get_Rate_Bitmap(
- PDM_ODM_T pDM_Odm,
- u32 macid,
- u32 ra_mask,
- u8 rssi_level
-)
-{
- PSTA_INFO_T pEntry;
- u32 rate_bitmap = 0;
- u8 WirelessMode;
-
- pEntry = pDM_Odm->pODM_StaInfo[macid];
- if (!IS_STA_VALID(pEntry))
- return ra_mask;
-
- WirelessMode = pEntry->wireless_mode;
-
- switch (WirelessMode) {
- case ODM_WM_B:
- if (ra_mask & 0x0000000c) /* 11M or 5.5M enable */
- rate_bitmap = 0x0000000d;
- else
- rate_bitmap = 0x0000000f;
- break;
-
- case (ODM_WM_G):
- case (ODM_WM_A):
- if (rssi_level == DM_RATR_STA_HIGH)
- rate_bitmap = 0x00000f00;
- else
- rate_bitmap = 0x00000ff0;
- break;
-
- case (ODM_WM_B|ODM_WM_G):
- if (rssi_level == DM_RATR_STA_HIGH)
- rate_bitmap = 0x00000f00;
- else if (rssi_level == DM_RATR_STA_MIDDLE)
- rate_bitmap = 0x00000ff0;
- else
- rate_bitmap = 0x00000ff5;
- break;
-
- case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G):
- case (ODM_WM_B|ODM_WM_N24G):
- case (ODM_WM_G|ODM_WM_N24G):
- case (ODM_WM_A|ODM_WM_N5G):
- if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) {
- if (rssi_level == DM_RATR_STA_HIGH)
- rate_bitmap = 0x000f0000;
- else if (rssi_level == DM_RATR_STA_MIDDLE)
- rate_bitmap = 0x000ff000;
- else {
- if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
- rate_bitmap = 0x000ff015;
- else
- rate_bitmap = 0x000ff005;
- }
- } else {
- if (rssi_level == DM_RATR_STA_HIGH)
- rate_bitmap = 0x0f8f0000;
- else if (rssi_level == DM_RATR_STA_MIDDLE)
- rate_bitmap = 0x0f8ff000;
- else {
- if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
- rate_bitmap = 0x0f8ff015;
- else
- rate_bitmap = 0x0f8ff005;
- }
- }
- break;
-
- case (ODM_WM_AC|ODM_WM_G):
- if (rssi_level == 1)
- rate_bitmap = 0xfc3f0000;
- else if (rssi_level == 2)
- rate_bitmap = 0xfffff000;
- else
- rate_bitmap = 0xffffffff;
- break;
-
- case (ODM_WM_AC|ODM_WM_A):
-
- if (pDM_Odm->RFType == RF_1T1R) {
- if (rssi_level == 1) /* add by Gary for ac-series */
- rate_bitmap = 0x003f8000;
- else if (rssi_level == 2)
- rate_bitmap = 0x003ff000;
- else
- rate_bitmap = 0x003ff010;
- } else {
- if (rssi_level == 1) /* add by Gary for ac-series */
- rate_bitmap = 0xfe3f8000; /* VHT 2SS MCS3~9 */
- else if (rssi_level == 2)
- rate_bitmap = 0xfffff000; /* VHT 2SS MCS0~9 */
- else
- rate_bitmap = 0xfffff010; /* All */
- }
- break;
-
- default:
- if (pDM_Odm->RFType == 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));
-
- return ra_mask & rate_bitmap;
-
-}
-
-/*-----------------------------------------------------------------------------
-* Function: odm_RefreshRateAdaptiveMask()
-*
-* Overview: Update rate table mask according to rssi
-*
-* Input: NONE
-*
-* Output: NONE
-*
-* Return: NONE
-*
-* Revised History:
-*When Who Remark
-*05/27/2009 hpfan Create Version 0.
-*
-* --------------------------------------------------------------------------
-*/
-void odm_RefreshRateAdaptiveMask(PDM_ODM_T pDM_Odm)
-{
-
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask()---------->\n"));
- if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask(): Return cos not supported\n"));
- return;
- }
- odm_RefreshRateAdaptiveMaskCE(pDM_Odm);
-}
-
-void odm_RefreshRateAdaptiveMaskCE(PDM_ODM_T pDM_Odm)
-{
- u8 i;
- struct adapter *padapter = pDM_Odm->Adapter;
-
- if (padapter->bDriverStopped) {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n"));
- return;
- }
-
- if (!pDM_Odm->bUseRAMask) {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n"));
- return;
- }
-
- /* printk("==> %s\n", __func__); */
-
- for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
- PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i];
-
- if (IS_STA_VALID(pstat)) {
- if (IS_MCAST(pstat->hwaddr)) /* if (psta->mac_id == 1) */
- continue;
- if (IS_MCAST(pstat->hwaddr))
- continue;
-
- if (true == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, 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));
- /* printk("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level); */
- rtw_hal_update_ra_mask(pstat, pstat->rssi_level);
- }
-
- }
- }
-}
-
-/* Return Value: bool */
-/* - true: RATRState is changed. */
-bool ODM_RAStateCheck(
- PDM_ODM_T pDM_Odm,
- s32 RSSI,
- bool bForceUpdate,
- u8 *pRATRState
-)
-{
- PODM_RATE_ADAPTIVE pRA = &pDM_Odm->RateAdaptive;
- const u8 GoUpGap = 5;
- u8 HighRSSIThreshForRA = pRA->HighRSSIThresh;
- u8 LowRSSIThreshForRA = pRA->LowRSSIThresh;
- u8 RATRState;
-
- /* Threshold Adjustment: */
- /* when RSSI state trends to go up one or two levels, make sure RSSI is high enough. */
- /* Here GoUpGap is added to solve the boundary's level alternation issue. */
- switch (*pRATRState) {
- case DM_RATR_STA_INIT:
- case DM_RATR_STA_HIGH:
- break;
-
- case DM_RATR_STA_MIDDLE:
- HighRSSIThreshForRA += GoUpGap;
- break;
-
- case DM_RATR_STA_LOW:
- HighRSSIThreshForRA += GoUpGap;
- LowRSSIThreshForRA += GoUpGap;
- break;
-
- default:
- ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState));
- break;
- }
-
- /* Decide RATRState by RSSI. */
- if (RSSI > HighRSSIThreshForRA)
- RATRState = DM_RATR_STA_HIGH;
- else if (RSSI > LowRSSIThreshForRA)
- RATRState = DM_RATR_STA_MIDDLE;
- else
- RATRState = DM_RATR_STA_LOW;
- /* printk("==>%s, RATRState:0x%02x , RSSI:%d\n", __func__, RATRState, RSSI); */
-
- if (*pRATRState != RATRState || bForceUpdate) {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI Level %d -> %d\n", *pRATRState, RATRState));
- *pRATRState = RATRState;
- return true;
- }
-
- return false;
-}
-
-
-/* */
-
-/* 3 ============================================================ */
/* 3 Dynamic Tx Power */
/* 3 ============================================================ */
/* Remove BY YuChen */
-/* 3 ============================================================ */
-/* 3 RSSI Monitor */
-/* 3 ============================================================ */
-
-void odm_RSSIMonitorInit(PDM_ODM_T pDM_Odm)
-{
- pRA_T pRA_Table = &pDM_Odm->DM_RA_Table;
-
- pRA_Table->firstconnect = false;
-
-}
-
-void odm_RSSIMonitorCheck(PDM_ODM_T pDM_Odm)
-{
- if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR))
- return;
-
- odm_RSSIMonitorCheckCE(pDM_Odm);
-
-} /* odm_RSSIMonitorCheck */
-
-static void FindMinimumRSSI(struct adapter *padapter)
-{
- struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
-
- /* 1 1.Determine the minimum RSSI */
-
- if (
- (pDM_Odm->bLinked != true) &&
- (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)
- ) {
- pdmpriv->MinUndecoratedPWDBForDM = 0;
- /* ODM_RT_TRACE(pDM_Odm, COMP_BB_POWERSAVING, DBG_LOUD, ("Not connected to any\n")); */
- } else
- pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
-
- /* DBG_8192C("%s =>MinUndecoratedPWDBForDM(%d)\n", __func__, pdmpriv->MinUndecoratedPWDBForDM); */
- /* ODM_RT_TRACE(pDM_Odm, COMP_DIG, DBG_LOUD, ("MinUndecoratedPWDBForDM =%d\n", pHalData->MinUndecoratedPWDBForDM)); */
-}
-
-void odm_RSSIMonitorCheckCE(PDM_ODM_T pDM_Odm)
-{
- struct adapter *Adapter = pDM_Odm->Adapter;
- struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- int i;
- int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff;
- u8 sta_cnt = 0;
- u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */
- pRA_T pRA_Table = &pDM_Odm->DM_RA_Table;
-
- if (pDM_Odm->bLinked != true)
- return;
-
- pRA_Table->firstconnect = pDM_Odm->bLinked;
-
- /* if (check_fwstate(&Adapter->mlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true) */
- {
- struct sta_info *psta;
-
- for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
- psta = pDM_Odm->pODM_StaInfo[i];
- if (IS_STA_VALID(psta)) {
- if (IS_MCAST(psta->hwaddr)) /* if (psta->mac_id == 1) */
- continue;
-
- if (psta->rssi_stat.UndecoratedSmoothedPWDB == (-1))
- continue;
-
- if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
- tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
-
- if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
- tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
-
- if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1))
- PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16));
- }
- }
-
- /* printk("%s ==> sta_cnt(%d)\n", __func__, sta_cnt); */
-
- for (i = 0; i < sta_cnt; i++) {
- if (PWDB_rssi[i] != (0)) {
- if (pHalData->fw_ractrl == true)/* Report every sta's RSSI to FW */
- rtl8723b_set_rssi_cmd(Adapter, (u8 *)(&PWDB_rssi[i]));
- }
- }
- }
-
-
-
- if (tmpEntryMaxPWDB != 0) /* If associated entry is found */
- pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB;
- else
- pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0;
-
- if (tmpEntryMinPWDB != 0xff) /* If associated entry is found */
- pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
- else
- pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0;
-
- FindMinimumRSSI(Adapter);/* get pdmpriv->MinUndecoratedPWDBForDM */
-
- pDM_Odm->RSSI_Min = pdmpriv->MinUndecoratedPWDBForDM;
- /* ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); */
-}
-
-/* 3 ============================================================ */
-/* 3 Tx Power Tracking */
-/* 3 ============================================================ */
-
-static u8 getSwingIndex(PDM_ODM_T pDM_Odm)
-{
- struct adapter *Adapter = pDM_Odm->Adapter;
- u8 i = 0;
- u32 bbSwing;
- u32 swingTableSize;
- u32 *pSwingTable;
-
- bbSwing = PHY_QueryBBReg(Adapter, rOFDM0_XATxIQImbalance, 0xFFC00000);
-
- pSwingTable = OFDMSwingTable_New;
- swingTableSize = OFDM_TABLE_SIZE;
-
- for (i = 0; i < swingTableSize; ++i) {
- u32 tableValue = pSwingTable[i];
-
- if (tableValue >= 0x100000)
- tableValue >>= 22;
- if (bbSwing == tableValue)
- break;
- }
- return i;
-}
-
-void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm)
-{
- u8 defaultSwingIndex = getSwingIndex(pDM_Odm);
- u8 p = 0;
- struct adapter *Adapter = pDM_Odm->Adapter;
- struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-
-
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
-
- pdmpriv->bTXPowerTracking = true;
- pdmpriv->TXPowercount = 0;
- pdmpriv->bTXPowerTrackingInit = false;
-
- if (*(pDM_Odm->mp_mode) != 1)
- pdmpriv->TxPowerTrackControl = true;
- else
- pdmpriv->TxPowerTrackControl = false;
-
-
- /* MSG_8192C("pdmpriv->TxPowerTrackControl = %d\n", pdmpriv->TxPowerTrackControl); */
-
- /* pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; */
- pDM_Odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter;
- pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = pHalData->EEPROMThermalMeter;
- pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = pHalData->EEPROMThermalMeter;
-
- /* The index of "0 dB" in SwingTable. */
- pDM_Odm->DefaultOfdmIndex = (defaultSwingIndex >= OFDM_TABLE_SIZE) ? 30 : defaultSwingIndex;
- pDM_Odm->DefaultCckIndex = 20;
-
- pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex;
- pDM_Odm->RFCalibrateInfo.CCK_index = pDM_Odm->DefaultCckIndex;
-
- for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) {
- pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex;
- pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex;
- pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] = 0;
- pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] = 0;
- pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
- }
-
-}
-
-void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm)
-{
- struct adapter *Adapter = pDM_Odm->Adapter;
-
- if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK))
- return;
-
- if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { /* at least delay 1 sec */
- PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_T_METER_NEW, (BIT17 | BIT16), 0x03);
-
- /* DBG_871X("Trigger Thermal Meter!!\n"); */
-
- pDM_Odm->RFCalibrateInfo.TM_Trigger = 1;
- return;
- } else {
- /* DBG_871X("Schedule TxPowerTracking direct call!!\n"); */
- ODM_TXPowerTrackingCallback_ThermalMeter(Adapter);
- pDM_Odm->RFCalibrateInfo.TM_Trigger = 0;
- }
-}
-
-/* 3 ============================================================ */
-/* 3 SW Antenna Diversity */
-/* 3 ============================================================ */
-void odm_SwAntDetectInit(PDM_ODM_T pDM_Odm)
-{
- pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
-
- pDM_SWAT_Table->SWAS_NoLink_BK_Reg92c = rtw_read32(pDM_Odm->Adapter, rDPDT_control);
- pDM_SWAT_Table->PreAntenna = MAIN_ANT;
- pDM_SWAT_Table->CurAntenna = MAIN_ANT;
- pDM_SWAT_Table->SWAS_NoLink_State = 0;
-}
diff --git a/drivers/staging/rtl8723bs/hal/odm.h b/drivers/staging/rtl8723bs/hal/odm.h
index 16e8f66a3171..ff21343fbe0b 100644
--- a/drivers/staging/rtl8723bs/hal/odm.h
+++ b/drivers/staging/rtl8723bs/hal/odm.h
@@ -92,11 +92,11 @@ struct dynamic_primary_CCA {
u8 MF_state;
};
-typedef struct _Rate_Adaptive_Table_ {
+struct ra_t {
u8 firstconnect;
-} RA_T, *pRA_T;
+};
-typedef struct _RX_High_Power_ {
+struct rxhp_t {
u8 RXHP_flag;
u8 PSD_func_trigger;
u8 PSD_bitmap_RXHP[80];
@@ -107,8 +107,8 @@ typedef struct _RX_High_Power_ {
bool First_time_enter;
bool RXHP_enable;
u8 TP_Mode;
- RT_TIMER PSDTimer;
-} RXHP_T, *pRXHP_T;
+ struct timer_list PSDTimer;
+};
#define ASSOCIATE_ENTRY_NUM 32 /* Max size of AsocEntry[]. */
#define ODM_ASSOCIATE_ENTRY_NUM ASSOCIATE_ENTRY_NUM
@@ -126,7 +126,7 @@ typedef struct _RX_High_Power_ {
#define TRAFFIC_HIGH 1
#define TRAFFIC_UltraLOW 2
-typedef struct _SW_Antenna_Switch_ {
+struct swat_t { /* _SW_Antenna_Switch_ */
u8 Double_chk_flag;
u8 try_flag;
s32 PreRSSI;
@@ -169,16 +169,16 @@ typedef struct _SW_Antenna_Switch_ {
u8 TrafficLoad;
u8 Train_time;
u8 Train_time_flag;
- RT_TIMER SwAntennaSwitchTimer;
- RT_TIMER SwAntennaSwitchTimer_8723B;
+ struct timer_list SwAntennaSwitchTimer;
+ struct timer_list SwAntennaSwitchTimer_8723B;
u32 PktCnt_SWAntDivByCtrlFrame;
bool bSWAntDivByCtrlFrame;
-} SWAT_T, *pSWAT_T;
+};
/* Remove Edca by YuChen */
-typedef struct _ODM_RATE_ADAPTIVE {
+struct odm_rate_adaptive {
u8 Type; /* DM_Type_ByFW/DM_Type_ByDriver */
u8 LdpcThres; /* if RSSI > LdpcThres => switch from LPDC to BCC */
bool bUseLdpc;
@@ -187,7 +187,7 @@ typedef struct _ODM_RATE_ADAPTIVE {
u8 LowRSSIThresh; /* if RSSI <= LowRSSIThresh => RATRState is DM_RATR_STA_LOW */
u8 RATRState; /* Current RSSI level, DM_RATR_STA_HIGH/DM_RATR_STA_MIDDLE/DM_RATR_STA_LOW */
-} ODM_RATE_ADAPTIVE, *PODM_RATE_ADAPTIVE;
+};
#define IQK_MAC_REG_NUM 4
#define IQK_ADDA_REG_NUM 16
@@ -277,55 +277,10 @@ struct odm_mac_status_info {
u8 test;
};
-typedef enum tag_Dynamic_ODM_Support_Ability_Type {
- /* BB Team */
- ODM_DIG = 0x00000001,
- ODM_HIGH_POWER = 0x00000002,
- ODM_CCK_CCA_TH = 0x00000004,
- ODM_FA_STATISTICS = 0x00000008,
- ODM_RAMASK = 0x00000010,
- ODM_RSSI_MONITOR = 0x00000020,
- ODM_SW_ANTDIV = 0x00000040,
- ODM_HW_ANTDIV = 0x00000080,
- ODM_BB_PWRSV = 0x00000100,
- ODM_2TPATHDIV = 0x00000200,
- ODM_1TPATHDIV = 0x00000400,
- ODM_PSD2AFH = 0x00000800
-} ODM_Ability_E;
-
-/* */
-/* 2011/20/20 MH For MP driver RT_WLAN_STA = STA_INFO_T */
-/* Please declare below ODM relative info in your STA info structure. */
-/* */
-typedef struct _ODM_STA_INFO {
- /* Driver Write */
- bool bUsed; /* record the sta status link or not? */
- /* u8 WirelessMode; */
- u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */
-
- /* ODM Write */
- /* 1 PHY_STATUS_INFO */
- u8 RSSI_Path[4]; /* */
- u8 RSSI_Ave;
- u8 RXEVM[4];
- u8 RXSNR[4];
-
- /* ODM Write */
- /* 1 TX_INFO (may changed by IC) */
- /* TX_INFO_T pTxInfo; Define in IC folder. Move lower layer. */
-
- /* */
- /* Please use compile flag to disabe the strcutrue for other IC except 88E. */
- /* Move To lower layer. */
- /* */
- /* ODM Write Wilson will handle this part(said by Luke.Lee) */
- /* TX_RPT_T pTxRpt; Define in IC folder. Move lower layer. */
-} ODM_STA_INFO_T, *PODM_STA_INFO_T;
-
/* */
/* 2011/10/20 MH Define Common info enum for all team. */
/* */
-typedef enum _ODM_Common_Info_Definition {
+enum odm_cmninfo_e {
/* Fixed value: */
/* HOOK BEFORE REG INIT----------- */
@@ -412,10 +367,10 @@ typedef enum _ODM_Common_Info_Definition {
ODM_CMNINFO_MAC_STATUS,
ODM_CMNINFO_MAX,
-} ODM_CMNINFO_E;
+};
/* 2011/10/20 MH Define ODM support ability. ODM_CMNINFO_ABILITY */
-typedef enum _ODM_Support_Ability_Definition {
+enum { /* _ODM_Support_Ability_Definition */
/* */
/* BB ODM section BIT 0-15 */
/* */
@@ -443,21 +398,21 @@ typedef enum _ODM_Support_Ability_Definition {
ODM_RF_TX_PWR_TRACK = BIT24,
ODM_RF_RX_GAIN_TRACK = BIT25,
ODM_RF_CALIBRATION = BIT26,
-} ODM_ABILITY_E;
+};
/* ODM_CMNINFO_INTERFACE */
-typedef enum tag_ODM_Support_Interface_Definition {
+enum { /* tag_ODM_Support_Interface_Definition */
ODM_ITRF_SDIO = 0x4,
ODM_ITRF_ALL = 0x7,
-} ODM_INTERFACE_E;
+};
/* ODM_CMNINFO_IC_TYPE */
-typedef enum tag_ODM_Support_IC_Type_Definition {
+enum { /* tag_ODM_Support_IC_Type_Definition */
ODM_RTL8723B = BIT8,
-} ODM_IC_TYPE_E;
+};
/* ODM_CMNINFO_CUT_VER */
-typedef enum tag_ODM_Cut_Version_Definition {
+enum { /* tag_ODM_Cut_Version_Definition */
ODM_CUT_A = 0,
ODM_CUT_B = 1,
ODM_CUT_C = 2,
@@ -469,30 +424,19 @@ typedef enum tag_ODM_Cut_Version_Definition {
ODM_CUT_J = 9,
ODM_CUT_K = 10,
ODM_CUT_TEST = 15,
-} ODM_CUT_VERSION_E;
+};
/* ODM_CMNINFO_FAB_VER */
-typedef enum tag_ODM_Fab_Version_Definition {
+enum { /* tag_ODM_Fab_Version_Definition */
ODM_TSMC = 0,
ODM_UMC = 1,
-} ODM_FAB_E;
+};
/* ODM_CMNINFO_RF_TYPE */
/* */
/* For example 1T2R (A+AB = BIT0|BIT4|BIT5) */
/* */
-typedef enum tag_ODM_RF_Path_Bit_Definition {
- ODM_RF_TX_A = BIT0,
- ODM_RF_TX_B = BIT1,
- ODM_RF_TX_C = BIT2,
- ODM_RF_TX_D = BIT3,
- ODM_RF_RX_A = BIT4,
- ODM_RF_RX_B = BIT5,
- ODM_RF_RX_C = BIT6,
- ODM_RF_RX_D = BIT7,
-} ODM_RF_PATH_E;
-
-typedef enum tag_ODM_RF_Type_Definition {
+enum { /* tag_ODM_RF_Type_Definition */
ODM_1T1R = 0,
ODM_1T2R = 1,
ODM_2T2R = 2,
@@ -501,46 +445,14 @@ typedef enum tag_ODM_RF_Type_Definition {
ODM_3T3R = 5,
ODM_3T4R = 6,
ODM_4T4R = 7,
-} ODM_RF_TYPE_E;
+};
/* */
/* ODM Dynamic common info value definition */
/* */
-/* typedef enum _MACPHY_MODE_8192D{ */
-/* SINGLEMAC_SINGLEPHY, */
-/* DUALMAC_DUALPHY, */
-/* DUALMAC_SINGLEPHY, */
-/* MACPHY_MODE_8192D,*PMACPHY_MODE_8192D; */
-/* Above is the original define in MP driver. Please use the same define. THX. */
-typedef enum tag_ODM_MAC_PHY_Mode_Definition {
- ODM_SMSP = 0,
- ODM_DMSP = 1,
- ODM_DMDP = 2,
-} ODM_MAC_PHY_MODE_E;
-
-typedef enum tag_BT_Coexist_Definition {
- ODM_BT_BUSY = 1,
- ODM_BT_ON = 2,
- ODM_BT_OFF = 3,
- ODM_BT_NONE = 4,
-} ODM_BT_COEXIST_E;
-
-/* ODM_CMNINFO_OP_MODE */
-typedef enum tag_Operation_Mode_Definition {
- ODM_NO_LINK = BIT0,
- ODM_LINK = BIT1,
- ODM_SCAN = BIT2,
- ODM_POWERSAVE = BIT3,
- ODM_AP_MODE = BIT4,
- ODM_CLIENT_MODE = BIT5,
- ODM_AD_HOC = BIT6,
- ODM_WIFI_DIRECT = BIT7,
- ODM_WIFI_DISPLAY = BIT8,
-} ODM_OPERATION_MODE_E;
-
/* ODM_CMNINFO_WM_MODE */
-typedef enum tag_Wireless_Mode_Definition {
+enum { /* tag_Wireless_Mode_Definition */
ODM_WM_UNKNOWN = 0x0,
ODM_WM_B = BIT0,
ODM_WM_G = BIT1,
@@ -549,138 +461,62 @@ typedef enum tag_Wireless_Mode_Definition {
ODM_WM_N5G = BIT4,
ODM_WM_AUTO = BIT5,
ODM_WM_AC = BIT6,
-} ODM_WIRELESS_MODE_E;
+};
/* ODM_CMNINFO_BAND */
-typedef enum tag_Band_Type_Definition {
+enum { /* tag_Band_Type_Definition */
ODM_BAND_2_4G = 0,
ODM_BAND_5G,
ODM_BAND_ON_BOTH,
ODM_BANDMAX
-} ODM_BAND_TYPE_E;
-
-/* ODM_CMNINFO_SEC_CHNL_OFFSET */
-typedef enum tag_Secondary_Channel_Offset_Definition {
- ODM_DONT_CARE = 0,
- ODM_BELOW = 1,
- ODM_ABOVE = 2
-} ODM_SEC_CHNL_OFFSET_E;
-
-/* ODM_CMNINFO_SEC_MODE */
-typedef enum tag_Security_Definition {
- ODM_SEC_OPEN = 0,
- ODM_SEC_WEP40 = 1,
- ODM_SEC_TKIP = 2,
- ODM_SEC_RESERVE = 3,
- ODM_SEC_AESCCMP = 4,
- ODM_SEC_WEP104 = 5,
- ODM_WEP_WPA_MIXED = 6, /* WEP + WPA */
- ODM_SEC_SMS4 = 7,
-} ODM_SECURITY_E;
+};
/* ODM_CMNINFO_BW */
-typedef enum tag_Bandwidth_Definition {
+enum { /* tag_Bandwidth_Definition */
ODM_BW20M = 0,
ODM_BW40M = 1,
ODM_BW80M = 2,
ODM_BW160M = 3,
ODM_BW10M = 4,
-} ODM_BW_E;
+};
/* ODM_CMNINFO_BOARD_TYPE */
/* For non-AC-series IC , ODM_BOARD_5G_EXT_PA and ODM_BOARD_5G_EXT_LNA are ignored */
/* For AC-series IC, external PA & LNA can be indivisuallly added on 2.4G and/or 5G */
-typedef enum tag_Board_Definition {
- ODM_BOARD_DEFAULT = 0, /* The DEFAULT case. */
- ODM_BOARD_MINICARD = BIT(0), /* 0 = non-mini card, 1 = mini card. */
- ODM_BOARD_SLIM = BIT(1), /* 0 = non-slim card, 1 = slim card */
- ODM_BOARD_BT = BIT(2), /* 0 = without BT card, 1 = with BT */
- ODM_BOARD_EXT_PA = BIT(3), /* 0 = no 2G ext-PA, 1 = existing 2G ext-PA */
- ODM_BOARD_EXT_LNA = BIT(4), /* 0 = no 2G ext-LNA, 1 = existing 2G ext-LNA */
- ODM_BOARD_EXT_TRSW = BIT(5), /* 0 = no ext-TRSW, 1 = existing ext-TRSW */
- ODM_BOARD_EXT_PA_5G = BIT(6), /* 0 = no 5G ext-PA, 1 = existing 5G ext-PA */
- ODM_BOARD_EXT_LNA_5G = BIT(7), /* 0 = no 5G ext-LNA, 1 = existing 5G ext-LNA */
-} ODM_BOARD_TYPE_E;
-
-typedef enum tag_ODM_Package_Definition {
- ODM_PACKAGE_DEFAULT = 0,
- ODM_PACKAGE_QFN68 = BIT(0),
- ODM_PACKAGE_TFBGA90 = BIT(1),
- ODM_PACKAGE_TFBGA79 = BIT(2),
-} ODM_Package_TYPE_E;
-
-typedef enum tag_ODM_TYPE_GPA_Definition {
+
+enum odm_type_gpa_e { /* tag_ODM_TYPE_GPA_Definition */
TYPE_GPA0 = 0,
TYPE_GPA1 = BIT(1)|BIT(0)
-} ODM_TYPE_GPA_E;
+};
-typedef enum tag_ODM_TYPE_APA_Definition {
+enum odm_type_apa_e { /* tag_ODM_TYPE_APA_Definition */
TYPE_APA0 = 0,
TYPE_APA1 = BIT(1)|BIT(0)
-} ODM_TYPE_APA_E;
+};
-typedef enum tag_ODM_TYPE_GLNA_Definition {
+enum odm_type_glna_e { /* tag_ODM_TYPE_GLNA_Definition */
TYPE_GLNA0 = 0,
TYPE_GLNA1 = BIT(2)|BIT(0),
TYPE_GLNA2 = BIT(3)|BIT(1),
TYPE_GLNA3 = BIT(3)|BIT(2)|BIT(1)|BIT(0)
-} ODM_TYPE_GLNA_E;
+};
-typedef enum tag_ODM_TYPE_ALNA_Definition {
+enum odm_type_alna_e { /* tag_ODM_TYPE_ALNA_Definition */
TYPE_ALNA0 = 0,
TYPE_ALNA1 = BIT(2)|BIT(0),
TYPE_ALNA2 = BIT(3)|BIT(1),
TYPE_ALNA3 = BIT(3)|BIT(2)|BIT(1)|BIT(0)
-} ODM_TYPE_ALNA_E;
-
-/* ODM_CMNINFO_ONE_PATH_CCA */
-typedef enum tag_CCA_Path {
- ODM_CCA_2R = 0,
- ODM_CCA_1R_A = 1,
- ODM_CCA_1R_B = 2,
-} ODM_CCA_PATH_E;
-
-typedef struct _ODM_RA_Info_ {
- u8 RateID;
- u32 RateMask;
- u32 RAUseRate;
- u8 RateSGI;
- u8 RssiStaRA;
- u8 PreRssiStaRA;
- u8 SGIEnable;
- u8 DecisionRate;
- u8 PreRate;
- u8 HighestRate;
- u8 LowestRate;
- u32 NscUp;
- u32 NscDown;
- u16 RTY[5];
- u32 TOTAL;
- u16 DROP;
- u8 Active;
- u16 RptTime;
- u8 RAWaitingCounter;
- u8 RAPendingCounter;
- u8 PTActive; /* on or off */
- u8 PTTryState; /* 0 trying state, 1 for decision state */
- u8 PTStage; /* 0~6 */
- u8 PTStopCount; /* Stop PT counter */
- u8 PTPreRate; /* if rate change do PT */
- u8 PTPreRssi; /* if RSSI change 5% do PT */
- u8 PTModeSS; /* decide whitch rate should do PT */
- u8 RAstage; /* StageRA, decide how many times RA will be done between PT */
- u8 PTSmoothFactor;
-} ODM_RA_INFO_T, *PODM_RA_INFO_T;
-
-typedef struct _IQK_MATRIX_REGS_SETTING {
+};
+
+struct iqk_matrix_regs_setting { /* _IQK_MATRIX_REGS_SETTING */
bool bIQKDone;
s32 Value[3][IQK_Matrix_REG_NUM];
bool bBWIqkResultSaved[3];
-} IQK_MATRIX_REGS_SETTING, *PIQK_MATRIX_REGS_SETTING;
+};
/* Remove PATHDIV_PARA struct to odm_PathDiv.h */
-typedef struct ODM_RF_Calibration_Structure {
+struct odm_rf_cal_t { /* ODM_RF_Calibration_Structure */
/* for tx power tracking */
u32 RegA24; /* for TempCCK */
@@ -724,7 +560,7 @@ typedef struct ODM_RF_Calibration_Structure {
u8 ThermalValue_HP[HP_THERMAL_NUM];
u8 ThermalValue_HP_index;
- IQK_MATRIX_REGS_SETTING IQKMatrixRegSetting[IQK_Matrix_Settings_NUM];
+ struct iqk_matrix_regs_setting IQKMatrixRegSetting[IQK_Matrix_Settings_NUM];
bool bNeedIQK;
bool bIQKInProgress;
u8 Delta_IQK;
@@ -780,12 +616,12 @@ typedef struct ODM_RF_Calibration_Structure {
u32 TxLOK[2];
-} ODM_RF_CAL_T, *PODM_RF_CAL_T;
+};
/* */
/* ODM Dynamic common info value definition */
/* */
-typedef struct _FAST_ANTENNA_TRAINNING_ {
+struct fat_t { /* _FAST_ANTENNA_TRAINNING_ */
u8 Bssid[6];
u8 antsel_rx_keep_0;
u8 antsel_rx_keep_1;
@@ -823,14 +659,9 @@ typedef struct _FAST_ANTENNA_TRAINNING_ {
u32 MainAnt_CtrlFrame_Cnt;
u32 AuxAnt_CtrlFrame_Cnt;
-} FAT_T, *pFAT_T;
-
-typedef enum _FAT_STATE {
- FAT_NORMAL_STATE = 0,
- FAT_TRAINING_STATE = 1,
-} FAT_STATE_E, *PFAT_STATE_E;
+};
-typedef enum _ANT_DIV_TYPE {
+enum {
NO_ANTDIV = 0xFF,
CG_TRX_HW_ANTDIV = 0x01,
CGCS_RX_HW_ANTDIV = 0x02,
@@ -838,37 +669,37 @@ typedef enum _ANT_DIV_TYPE {
CG_TRX_SMART_ANTDIV = 0x04,
CGCS_RX_SW_ANTDIV = 0x05,
S0S1_SW_ANTDIV = 0x06 /* 8723B intrnal switch S0 S1 */
-} ANT_DIV_TYPE_E, *PANT_DIV_TYPE_E;
+};
-typedef struct _ODM_PATH_DIVERSITY_ {
+struct pathdiv_t { /* _ODM_PATH_DIVERSITY_ */
u8 RespTxPath;
u8 PathSel[ODM_ASSOCIATE_ENTRY_NUM];
u32 PathA_Sum[ODM_ASSOCIATE_ENTRY_NUM];
u32 PathB_Sum[ODM_ASSOCIATE_ENTRY_NUM];
u32 PathA_Cnt[ODM_ASSOCIATE_ENTRY_NUM];
u32 PathB_Cnt[ODM_ASSOCIATE_ENTRY_NUM];
-} PATHDIV_T, *pPATHDIV_T;
+};
-typedef enum _BASEBAND_CONFIG_PHY_REG_PG_VALUE_TYPE {
+enum phy_reg_pg_type { /* _BASEBAND_CONFIG_PHY_REG_PG_VALUE_TYPE */
PHY_REG_PG_RELATIVE_VALUE = 0,
PHY_REG_PG_EXACT_VALUE = 1
-} PHY_REG_PG_TYPE;
+};
/* */
/* Antenna detection information from single tone mechanism, added by Roger, 2012.11.27. */
/* */
-typedef struct _ANT_DETECTED_INFO {
+struct ant_detected_info {
bool bAntDetected;
u32 dBForAntA;
u32 dBForAntB;
u32 dBForAntO;
-} ANT_DETECTED_INFO, *PANT_DETECTED_INFO;
+};
/* */
/* 2011/09/22 MH Copy from SD4 defined structure. We use to support PHY DM integration. */
/* */
-typedef struct DM_Out_Source_Dynamic_Mechanism_Structure {
- /* RT_TIMER FastAntTrainingTimer; */
+struct dm_odm_t { /* DM_Out_Source_Dynamic_Mechanism_Structure */
+ /* struct timer_list FastAntTrainingTimer; */
/* */
/* Add for different team use temporarily */
/* */
@@ -876,7 +707,7 @@ typedef struct DM_Out_Source_Dynamic_Mechanism_Structure {
/* WHen you use Adapter or priv pointer, you must make sure the pointer is ready. */
bool odm_ready;
- PHY_REG_PG_TYPE PhyRegPgValueType;
+ enum phy_reg_pg_type PhyRegPgValueType;
u8 PhyRegPgVersion;
u64 DebugComponents;
@@ -1076,7 +907,7 @@ typedef struct DM_Out_Source_Dynamic_Mechanism_Structure {
u8 Adaptivity_IGI_upper;
u8 NHM_cnt_0;
- ODM_NOISE_MONITOR noise_level;/* ODM_MAX_CHANNEL_NUM]; */
+ struct odm_noise_monitor noise_level;/* ODM_MAX_CHANNEL_NUM]; */
/* */
/* 2 Define STA info. */
/* _ODM_STA_INFO */
@@ -1109,21 +940,21 @@ typedef struct DM_Out_Source_Dynamic_Mechanism_Structure {
/* */
/* ODM Structure */
/* */
- FAT_T DM_FatTable;
- DIG_T DM_DigTable;
- PS_T DM_PSTable;
+ struct fat_t DM_FatTable;
+ struct dig_t DM_DigTable;
+ struct ps_t DM_PSTable;
struct dynamic_primary_CCA DM_PriCCA;
- RXHP_T DM_RXHP_Table;
- RA_T DM_RA_Table;
- false_ALARM_STATISTICS FalseAlmCnt;
- false_ALARM_STATISTICS FlaseAlmCntBuddyAdapter;
- SWAT_T DM_SWAT_Table;
+ struct rxhp_t dM_RXHP_Table;
+ struct ra_t DM_RA_Table;
+ struct false_ALARM_STATISTICS FalseAlmCnt;
+ struct false_ALARM_STATISTICS FlaseAlmCntBuddyAdapter;
+ struct swat_t DM_SWAT_Table;
bool RSSI_test;
- CFO_TRACKING DM_CfoTrack;
+ struct cfo_tracking DM_CfoTrack;
- EDCA_T DM_EDCA_Table;
+ struct edca_t DM_EDCA_Table;
u32 WMMEDCA_BE;
- PATHDIV_T DM_PathDiv;
+ struct pathdiv_t DM_PathDiv;
/* Copy from SD4 structure */
/* */
/* ================================================== */
@@ -1146,23 +977,23 @@ typedef struct DM_Out_Source_Dynamic_Mechanism_Structure {
/* PSD */
bool bUserAssignLevel;
- RT_TIMER PSDTimer;
+ struct timer_list PSDTimer;
u8 RSSI_BT; /* come from BT */
bool bPSDinProcess;
bool bPSDactive;
bool bDMInitialGainEnable;
/* MPT DIG */
- RT_TIMER MPT_DIGTimer;
+ struct timer_list MPT_DIGTimer;
/* for rate adaptive, in fact, 88c/92c fw will handle this */
u8 bUseRAMask;
- ODM_RATE_ADAPTIVE RateAdaptive;
+ struct odm_rate_adaptive RateAdaptive;
- ANT_DETECTED_INFO AntDetectedInfo; /* Antenna detected information for RSSI tool */
+ struct ant_detected_info AntDetectedInfo; /* Antenna detected information for RSSI tool */
- ODM_RF_CAL_T RFCalibrateInfo;
+ struct odm_rf_cal_t RFCalibrateInfo;
/* */
/* TX power tracking */
@@ -1194,21 +1025,21 @@ typedef struct DM_Out_Source_Dynamic_Mechanism_Structure {
/* */
/* ODM relative time. */
- RT_TIMER PathDivSwitchTimer;
+ struct timer_list PathDivSwitchTimer;
/* 2011.09.27 add for Path Diversity */
- RT_TIMER CCKPathDiversityTimer;
- RT_TIMER FastAntTrainingTimer;
+ struct timer_list CCKPathDiversityTimer;
+ struct timer_list FastAntTrainingTimer;
/* ODM relative workitem. */
#if (BEAMFORMING_SUPPORT == 1)
RT_BEAMFORMING_INFO BeamformingInfo;
#endif
-} DM_ODM_T, *PDM_ODM_T; /* DM_Dynamic_Mechanism_Structure */
+};
#define ODM_RF_PATH_MAX 2
-typedef enum _ODM_RF_RADIO_PATH {
+enum odm_rf_radio_path_e {
ODM_RF_PATH_A = 0, /* Radio Path A */
ODM_RF_PATH_B = 1, /* Radio Path B */
ODM_RF_PATH_C = 2, /* Radio Path C */
@@ -1224,16 +1055,16 @@ typedef enum _ODM_RF_RADIO_PATH {
ODM_RF_PATH_BCD,
ODM_RF_PATH_ABCD,
/* ODM_RF_PATH_MAX, Max RF number 90 support */
-} ODM_RF_RADIO_PATH_E, *PODM_RF_RADIO_PATH_E;
+};
- typedef enum _ODM_RF_CONTENT {
+ enum odm_rf_content {
odm_radioa_txt = 0x1000,
odm_radiob_txt = 0x1001,
odm_radioc_txt = 0x1002,
odm_radiod_txt = 0x1003
-} ODM_RF_CONTENT;
+};
-typedef enum _ODM_BB_Config_Type {
+enum ODM_BB_Config_Type {
CONFIG_BB_PHY_REG,
CONFIG_BB_AGC_TAB,
CONFIG_BB_AGC_TAB_2G,
@@ -1241,14 +1072,14 @@ typedef enum _ODM_BB_Config_Type {
CONFIG_BB_PHY_REG_PG,
CONFIG_BB_PHY_REG_MP,
CONFIG_BB_AGC_TAB_DIFF,
-} ODM_BB_Config_Type, *PODM_BB_Config_Type;
+};
-typedef enum _ODM_RF_Config_Type {
+enum ODM_RF_Config_Type {
CONFIG_RF_RADIO,
CONFIG_RF_TXPWR_LMT,
-} ODM_RF_Config_Type, *PODM_RF_Config_Type;
+};
-typedef enum _ODM_FW_Config_Type {
+enum ODM_FW_Config_Type {
CONFIG_FW_NIC,
CONFIG_FW_NIC_2,
CONFIG_FW_AP,
@@ -1256,19 +1087,7 @@ typedef enum _ODM_FW_Config_Type {
CONFIG_FW_WoWLAN_2,
CONFIG_FW_AP_WoWLAN,
CONFIG_FW_BT,
-} ODM_FW_Config_Type;
-
-/* Status code */
-typedef enum _RT_STATUS {
- RT_STATUS_SUCCESS,
- RT_STATUS_FAILURE,
- RT_STATUS_PENDING,
- RT_STATUS_RESOURCE,
- RT_STATUS_INVALID_CONTEXT,
- RT_STATUS_INVALID_PARAMETER,
- RT_STATUS_NOT_SUPPORT,
- RT_STATUS_OS_API_FAILED,
-} RT_STATUS, *PRT_STATUS;
+};
#ifdef REMOVE_PACK
#pragma pack()
@@ -1316,26 +1135,17 @@ typedef enum _RT_STATUS {
/* 3 BB Power Save */
/* 3 =========================================================== */
-typedef enum tag_1R_CCA_Type_Definition {
+enum { /* tag_1R_CCA_Type_Definition */
CCA_1R = 0,
CCA_2R = 1,
CCA_MAX = 2,
-} DM_1R_CCA_E;
+};
-typedef enum tag_RF_Type_Definition {
+enum { /* tag_RF_Type_Definition */
RF_Save = 0,
RF_Normal = 1,
RF_MAX = 2,
-} DM_RF_E;
-
-/* 3 =========================================================== */
-/* 3 Antenna Diversity */
-/* 3 =========================================================== */
-typedef enum tag_SW_Antenna_Switch_Definition {
- Antenna_A = 1,
- Antenna_B = 2,
- Antenna_MAX = 3,
-} DM_SWAS_E;
+};
/* Maximal number of antenna detection mechanism needs to perform, added by Roger, 2011.12.28. */
#define MAX_ANTENNA_DETECTION_CNT 10
@@ -1368,10 +1178,10 @@ extern u32 TxScalingTable_Jaguar[TXSCALE_TABLE_SIZE];
/* Remove BB power saving by Yuchen */
#define dm_CheckTXPowerTracking ODM_TXPowerTrackingCheck
-void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm);
+void ODM_TXPowerTrackingCheck(struct dm_odm_t *pDM_Odm);
bool ODM_RAStateCheck(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
s32 RSSI,
bool bForceUpdate,
u8 *pRATRState
@@ -1379,13 +1189,13 @@ bool ODM_RAStateCheck(
#define dm_SWAW_RSSI_Check ODM_SwAntDivChkPerPktRssi
void ODM_SwAntDivChkPerPktRssi(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u8 StationID,
struct odm_phy_info *pPhyInfo
);
u32 ODM_Get_Rate_Bitmap(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u32 macid,
u32 ra_mask,
u8 rssi_level
@@ -1395,38 +1205,38 @@ u32 ODM_Get_Rate_Bitmap(
BEAMFORMING_CAP Beamforming_GetEntryBeamCapByMacId(PMGNT_INFO pMgntInfo, u8 MacId);
#endif
-void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm);
+void odm_TXPowerTrackingInit(struct dm_odm_t *pDM_Odm);
-void ODM_DMInit(PDM_ODM_T pDM_Odm);
+void ODM_DMInit(struct dm_odm_t *pDM_Odm);
-void ODM_DMWatchdog(PDM_ODM_T pDM_Odm); /* For common use in the future */
+void ODM_DMWatchdog(struct dm_odm_t *pDM_Odm); /* For common use in the future */
-void ODM_CmnInfoInit(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, u32 Value);
+void ODM_CmnInfoInit(struct dm_odm_t *pDM_Odm, enum odm_cmninfo_e CmnInfo, u32 Value);
-void ODM_CmnInfoHook(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, void *pValue);
+void ODM_CmnInfoHook(struct dm_odm_t *pDM_Odm, enum odm_cmninfo_e CmnInfo, void *pValue);
void ODM_CmnInfoPtrArrayHook(
- PDM_ODM_T pDM_Odm,
- ODM_CMNINFO_E CmnInfo,
+ struct dm_odm_t *pDM_Odm,
+ enum odm_cmninfo_e CmnInfo,
u16 Index,
void *pValue
);
-void ODM_CmnInfoUpdate(PDM_ODM_T pDM_Odm, u32 CmnInfo, u64 Value);
+void ODM_CmnInfoUpdate(struct dm_odm_t *pDM_Odm, u32 CmnInfo, u64 Value);
-void ODM_InitAllTimers(PDM_ODM_T pDM_Odm);
+void ODM_InitAllTimers(struct dm_odm_t *pDM_Odm);
-void ODM_CancelAllTimers(PDM_ODM_T pDM_Odm);
+void ODM_CancelAllTimers(struct dm_odm_t *pDM_Odm);
-void ODM_ReleaseAllTimers(PDM_ODM_T pDM_Odm);
+void ODM_ReleaseAllTimers(struct dm_odm_t *pDM_Odm);
void ODM_AntselStatistics_88C(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u8 MacId,
u32 PWDBAll,
bool isCCKrate
);
-void ODM_DynamicARFBSelect(PDM_ODM_T pDM_Odm, u8 rate, bool Collision_State);
+void ODM_DynamicARFBSelect(struct dm_odm_t *pDM_Odm, u8 rate, bool Collision_State);
#endif
diff --git a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c
index 3ea1972545e5..75471c6c168e 100644
--- a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c
+++ b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c
@@ -9,8 +9,8 @@
static void odm_SetCrystalCap(void *pDM_VOID, u8 CrystalCap)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack;
if (pCfoTrack->CrystalCap == CrystalCap)
return;
@@ -39,7 +39,7 @@ static void odm_SetCrystalCap(void *pDM_VOID, u8 CrystalCap)
static u8 odm_GetDefaultCrytaltalCap(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
struct adapter *Adapter = pDM_Odm->Adapter;
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
@@ -49,8 +49,8 @@ static u8 odm_GetDefaultCrytaltalCap(void *pDM_VOID)
static void odm_SetATCStatus(void *pDM_VOID, bool ATCStatus)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack;
if (pCfoTrack->bATCStatus == ATCStatus)
return;
@@ -67,7 +67,7 @@ static void odm_SetATCStatus(void *pDM_VOID, bool ATCStatus)
static bool odm_GetATCStatus(void *pDM_VOID)
{
bool ATCStatus;
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
ATCStatus = (bool)PHY_QueryBBReg(
pDM_Odm->Adapter,
@@ -79,8 +79,8 @@ static bool odm_GetATCStatus(void *pDM_VOID)
void ODM_CfoTrackingReset(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack;
pCfoTrack->DefXCap = odm_GetDefaultCrytaltalCap(pDM_Odm);
pCfoTrack->bAdjust = true;
@@ -91,8 +91,8 @@ void ODM_CfoTrackingReset(void *pDM_VOID)
void ODM_CfoTrackingInit(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack;
pCfoTrack->DefXCap =
pCfoTrack->CrystalCap = odm_GetDefaultCrytaltalCap(pDM_Odm);
@@ -118,8 +118,8 @@ void ODM_CfoTrackingInit(void *pDM_VOID)
void ODM_CfoTracking(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack;
int CFO_kHz_A, CFO_kHz_B, CFO_ave = 0;
int CFO_ave_diff;
int CrystalCap = (int)pCfoTrack->CrystalCap;
@@ -297,9 +297,9 @@ void ODM_CfoTracking(void *pDM_VOID)
void ODM_ParsingCFO(void *pDM_VOID, void *pPktinfo_VOID, s8 *pcfotail)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
struct odm_packet_info *pPktinfo = pPktinfo_VOID;
- PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack;
+ struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack;
u8 i;
if (!(pDM_Odm->SupportAbility & ODM_BB_CFO_TRACKING))
diff --git a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.h b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.h
index 81db63efe286..bb00d8c893bd 100644
--- a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.h
+++ b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.h
@@ -12,7 +12,7 @@
#define CFO_TH_XTAL_LOW 10 /* kHz */
#define CFO_TH_ATC 80 /* kHz */
-typedef struct _CFO_TRACKING_ {
+struct cfo_tracking {
bool bATCStatus;
bool largeCFOHit;
bool bAdjust;
@@ -25,7 +25,7 @@ typedef struct _CFO_TRACKING_ {
bool bForceXtalCap;
bool bReset;
-} CFO_TRACKING, *PCFO_TRACKING;
+};
void ODM_CfoTrackingReset(void *pDM_VOID
);
diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.c b/drivers/staging/rtl8723bs/hal/odm_DIG.c
index 40fe43c62c45..dcef7fb17389 100644
--- a/drivers/staging/rtl8723bs/hal/odm_DIG.c
+++ b/drivers/staging/rtl8723bs/hal/odm_DIG.c
@@ -11,7 +11,7 @@
void odm_NHMCounterStatisticsInit(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
/* PHY parameters initialize for n series */
rtw_write16(pDM_Odm->Adapter, ODM_REG_NHM_TIMER_11N+2, 0x2710); /* 0x894[31:16]= 0x2710 Time duration for NHM unit: 4us, 0x2710 =40ms */
@@ -27,7 +27,7 @@ void odm_NHMCounterStatisticsInit(void *pDM_VOID)
void odm_NHMCounterStatistics(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
/* Get NHM report */
odm_GetNHMCounterStatistics(pDM_Odm);
@@ -38,7 +38,7 @@ void odm_NHMCounterStatistics(void *pDM_VOID)
void odm_GetNHMCounterStatistics(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
u32 value32 = 0;
value32 = PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG_NHM_CNT_11N, bMaskDWord);
@@ -48,7 +48,7 @@ void odm_GetNHMCounterStatistics(void *pDM_VOID)
void odm_NHMCounterStatisticsReset(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_NHM_TH9_TH10_11N, BIT1, 0);
PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_NHM_TH9_TH10_11N, BIT1, 1);
@@ -56,7 +56,7 @@ void odm_NHMCounterStatisticsReset(void *pDM_VOID)
void odm_NHMBBInit(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
pDM_Odm->adaptivity_flag = 0;
pDM_Odm->tolerance_cnt = 3;
@@ -69,9 +69,9 @@ void odm_NHMBBInit(void *pDM_VOID)
/* */
void odm_NHMBB(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
/* u8 test_status; */
- /* Pfalse_ALARM_STATISTICS pFalseAlmCnt = &(pDM_Odm->FalseAlmCnt); */
+ /* struct false_ALARM_STATISTICS *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; */
pDM_Odm->NHMCurTxOkcnt =
*(pDM_Odm->pNumTxBytesUnicast)-pDM_Odm->NHMLastTxOkcnt;
@@ -133,7 +133,7 @@ void odm_NHMBB(void *pDM_VOID)
void odm_SearchPwdBLowerBound(void *pDM_VOID, u8 IGI_target)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
u32 value32 = 0;
u8 cnt, IGI;
bool bAdjust = true;
@@ -205,7 +205,7 @@ void odm_SearchPwdBLowerBound(void *pDM_VOID, u8 IGI_target)
void odm_AdaptivityInit(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
if (pDM_Odm->Carrier_Sense_enable == false)
pDM_Odm->TH_L2H_ini = 0xf7; /* -7 */
@@ -233,7 +233,7 @@ void odm_AdaptivityInit(void *pDM_VOID)
void odm_Adaptivity(void *pDM_VOID, u8 IGI)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
s8 TH_L2H_dmc, TH_H2L_dmc;
s8 Diff, IGI_target;
bool EDCCA_State = false;
@@ -322,8 +322,8 @@ void odm_Adaptivity(void *pDM_VOID, u8 IGI)
void ODM_Write_DIG(void *pDM_VOID, u8 CurrentIGI)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
if (pDM_DigTable->bStopDIG) {
ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("Stop Writing IGI\n"));
@@ -358,12 +358,12 @@ void ODM_Write_DIG(void *pDM_VOID, u8 CurrentIGI)
void odm_PauseDIG(
void *pDM_VOID,
- ODM_Pause_DIG_TYPE PauseType,
+ enum ODM_Pause_DIG_TYPE PauseType,
u8 IGIValue
)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
static bool bPaused;
ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG() =========>\n"));
@@ -435,7 +435,7 @@ void odm_PauseDIG(
bool odm_DigAbort(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
/* SupportAbility */
if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT)) {
@@ -466,8 +466,8 @@ bool odm_DigAbort(void *pDM_VOID)
void odm_DIGInit(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
pDM_DigTable->bStopDIG = false;
pDM_DigTable->bPSDInProgress = false;
@@ -504,11 +504,11 @@ void odm_DIGInit(void *pDM_VOID)
void odm_DIG(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
/* Common parameters */
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
- Pfalse_ALARM_STATISTICS pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
+ struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
+ struct false_ALARM_STATISTICS *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
bool FirstConnect, FirstDisConnect;
u8 DIG_MaxOfMin, DIG_Dynamic_MIN;
u8 dm_dig_max, dm_dig_min;
@@ -823,8 +823,8 @@ void odm_DIG(void *pDM_VOID)
void odm_DIGbyRSSI_LPS(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- Pfalse_ALARM_STATISTICS pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct false_ALARM_STATISTICS *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
u8 RSSI_Lower = DM_DIG_MIN_NIC; /* 0x1E or 0x1C */
u8 CurrentIGI = pDM_Odm->RSSI_Min;
@@ -892,8 +892,8 @@ void odm_DIGbyRSSI_LPS(void *pDM_VOID)
void odm_FalseAlarmCounterStatistics(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- Pfalse_ALARM_STATISTICS FalseAlmCnt = &(pDM_Odm->FalseAlmCnt);
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct false_ALARM_STATISTICS *FalseAlmCnt = &pDM_Odm->FalseAlmCnt;
u32 ret_value;
if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT))
@@ -1062,7 +1062,7 @@ void odm_FAThresholdCheck(
u32 *dm_FA_thres
)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
if (pDM_Odm->bLinked && (bPerformance || bDFSBand)) {
/* For NIC */
@@ -1078,9 +1078,9 @@ void odm_FAThresholdCheck(
u8 odm_ForbiddenIGICheck(void *pDM_VOID, u8 DIG_Dynamic_MIN, u8 CurrentIGI)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
- Pfalse_ALARM_STATISTICS pFalseAlmCnt = &(pDM_Odm->FalseAlmCnt);
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
+ struct false_ALARM_STATISTICS *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
u8 rx_gain_range_min = pDM_DigTable->rx_gain_range_min;
if (pFalseAlmCnt->Cnt_all > 10000) {
@@ -1134,8 +1134,8 @@ u8 odm_ForbiddenIGICheck(void *pDM_VOID, u8 DIG_Dynamic_MIN, u8 CurrentIGI)
void odm_CCKPacketDetectionThresh(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- Pfalse_ALARM_STATISTICS FalseAlmCnt = &(pDM_Odm->FalseAlmCnt);
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct false_ALARM_STATISTICS *FalseAlmCnt = &pDM_Odm->FalseAlmCnt;
u8 CurCCK_CCAThres;
@@ -1195,8 +1195,8 @@ void odm_CCKPacketDetectionThresh(void *pDM_VOID)
void ODM_Write_CCK_CCA_Thres(void *pDM_VOID, u8 CurCCK_CCAThres)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
/* modify by Guo.Mingzhi 2012-01-03 */
if (pDM_DigTable->CurCCK_CCAThres != CurCCK_CCAThres)
diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.h b/drivers/staging/rtl8723bs/hal/odm_DIG.h
index f6777e97a24a..88cfd542df16 100644
--- a/drivers/staging/rtl8723bs/hal/odm_DIG.h
+++ b/drivers/staging/rtl8723bs/hal/odm_DIG.h
@@ -8,7 +8,7 @@
#ifndef __ODMDIG_H__
#define __ODMDIG_H__
-typedef struct _Dynamic_Initial_Gain_Threshold_ {
+struct dig_t { /* _Dynamic_Initial_Gain_Threshold_ */
bool bStopDIG;
bool bPSDInProgress;
@@ -57,9 +57,9 @@ typedef struct _Dynamic_Initial_Gain_Threshold_ {
u32 RSSI_max;
u8 *pbP2pLinkInProgress;
-} DIG_T, *pDIG_T;
+};
-typedef struct false_ALARM_STATISTICS {
+struct false_ALARM_STATISTICS {
u32 Cnt_Parity_Fail;
u32 Cnt_Rate_Illegal;
u32 Cnt_Crc8_fail;
@@ -75,28 +75,12 @@ typedef struct false_ALARM_STATISTICS {
u32 Cnt_CCA_all;
u32 Cnt_BW_USC; /* Gary */
u32 Cnt_BW_LSC; /* Gary */
-} false_ALARM_STATISTICS, *Pfalse_ALARM_STATISTICS;
-
-typedef enum tag_Dynamic_Init_Gain_Operation_Type_Definition {
- DIG_TYPE_THRESH_HIGH = 0,
- DIG_TYPE_THRESH_LOW = 1,
- DIG_TYPE_BACKOFF = 2,
- DIG_TYPE_RX_GAIN_MIN = 3,
- DIG_TYPE_RX_GAIN_MAX = 4,
- DIG_TYPE_ENABLE = 5,
- DIG_TYPE_DISABLE = 6,
- DIG_OP_TYPE_MAX
-} DM_DIG_OP_E;
-
-typedef enum tag_ODM_PauseDIG_Type {
+};
+
+enum ODM_Pause_DIG_TYPE {
ODM_PAUSE_DIG = BIT0,
ODM_RESUME_DIG = BIT1
-} ODM_Pause_DIG_TYPE;
-
-typedef enum tag_ODM_PauseCCKPD_Type {
- ODM_PAUSE_CCKPD = BIT0,
- ODM_RESUME_CCKPD = BIT1
-} ODM_Pause_CCKPD_TYPE;
+};
#define DM_DIG_THRESH_HIGH 40
#define DM_DIG_THRESH_LOW 35
@@ -157,7 +141,7 @@ void odm_Adaptivity(void *pDM_VOID, u8 IGI);
void ODM_Write_DIG(void *pDM_VOID, u8 CurrentIGI);
-void odm_PauseDIG(void *pDM_VOID, ODM_Pause_DIG_TYPE PauseType, u8 IGIValue);
+void odm_PauseDIG(void *pDM_VOID, enum ODM_Pause_DIG_TYPE PauseType, u8 IGIValue);
void odm_DIGInit(void *pDM_VOID);
diff --git a/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.c b/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.c
index e18c9d65eee2..57c5736527d2 100644
--- a/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.c
+++ b/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.c
@@ -9,8 +9,8 @@
void odm_DynamicBBPowerSavingInit(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct ps_t *pDM_PSTable = &pDM_Odm->DM_PSTable;
pDM_PSTable->PreCCAState = CCA_MAX;
pDM_PSTable->CurCCAState = CCA_MAX;
@@ -22,8 +22,8 @@ void odm_DynamicBBPowerSavingInit(void *pDM_VOID)
void ODM_RF_Saving(void *pDM_VOID, u8 bForceInNormal)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
- pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
+ struct ps_t *pDM_PSTable = &pDM_Odm->DM_PSTable;
u8 Rssi_Up_bound = 30;
u8 Rssi_Low_bound = 25;
diff --git a/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.h b/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.h
index dba19271d526..3ebbbfd1dd1f 100644
--- a/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.h
+++ b/drivers/staging/rtl8723bs/hal/odm_DynamicBBPowerSaving.h
@@ -8,7 +8,7 @@
#ifndef __ODMDYNAMICBBPOWERSAVING_H__
#define __ODMDYNAMICBBPOWERSAVING_H__
-typedef struct _Dynamic_Power_Saving_ {
+struct ps_t { /* _Dynamic_Power_Saving_ */
u8 PreCCAState;
u8 CurCCAState;
@@ -20,7 +20,7 @@ typedef struct _Dynamic_Power_Saving_ {
u8 initialize;
u32 Reg874, RegC70, Reg85C, RegA74;
-} PS_T, *pPS_T;
+};
#define dm_RF_Saving ODM_RF_Saving
diff --git a/drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.c b/drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.c
index 17f90f4cc1ad..398dfa13449d 100644
--- a/drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.c
+++ b/drivers/staging/rtl8723bs/hal/odm_DynamicTxPower.c
@@ -9,7 +9,7 @@
void odm_DynamicTxPowerInit(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
struct adapter *Adapter = pDM_Odm->Adapter;
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
diff --git a/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c b/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c
index b7ebce7a6ff9..12b37c17ea0c 100644
--- a/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c
+++ b/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c
@@ -31,7 +31,7 @@ static u32 edca_setting_DL[HT_IOT_PEER_MAX] = {
void ODM_EdcaTurboInit(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
struct adapter *Adapter = pDM_Odm->Adapter;
pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false;
@@ -58,7 +58,7 @@ void odm_EdcaTurboCheck(void *pDM_VOID)
* operate at the same time. In stage2/3, we need to prove universal
* interface and merge all HW dynamic mechanism.
*/
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD,
("odm_EdcaTurboCheck ========================>\n"));
@@ -73,7 +73,7 @@ void odm_EdcaTurboCheck(void *pDM_VOID)
void odm_EdcaTurboCheckCE(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
struct adapter *Adapter = pDM_Odm->Adapter;
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(Adapter);
struct recv_priv *precvpriv = &(Adapter->recvpriv);
diff --git a/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.h b/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.h
index bc574d2ad065..e9f9f07221f2 100644
--- a/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.h
+++ b/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.h
@@ -8,12 +8,12 @@
#ifndef __ODMEDCATURBOCHECK_H__
#define __ODMEDCATURBOCHECK_H__
-typedef struct _EDCA_TURBO_ {
+struct edca_t { /* _EDCA_TURBO_ */
bool bCurrentTurboEDCA;
bool bIsCurRDLState;
u32 prv_traffic_idx; /* edca turbo */
-} EDCA_T, *pEDCA_T;
+};
void odm_EdcaTurboCheck(void *pDM_VOID);
void ODM_EdcaTurboInit(void *pDM_VOID);
diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
index 9c190b1024d8..638c16f5c668 100644
--- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
+++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
@@ -23,7 +23,7 @@ static u8 odm_QueryRxPwrPercentage(s8 AntPower)
}
-s32 odm_SignalScaleMapping(PDM_ODM_T pDM_Odm, s32 CurrSig)
+s32 odm_SignalScaleMapping(struct dm_odm_t *pDM_Odm, s32 CurrSig)
{
s32 RetSig = 0;
@@ -77,7 +77,7 @@ static u8 odm_EVMdbToPercentage(s8 Value)
}
static void odm_RxPhyStatus92CSeries_Parsing(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
struct odm_phy_info *pPhyInfo,
u8 *pPhyStatus,
struct odm_packet_info *pPktinfo
@@ -90,7 +90,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(
bool isCCKrate = false;
u8 rf_rx_num = 0;
u8 LNA_idx, VGA_idx;
- PPHY_STATUS_RPT_8192CD_T pPhyStaRpt = (PPHY_STATUS_RPT_8192CD_T)pPhyStatus;
+ struct phy_status_rpt_8192cd_t *pPhyStaRpt = (struct phy_status_rpt_8192cd_t *)pPhyStatus;
isCCKrate = pPktinfo->data_rate <= DESC_RATE11M;
pPhyInfo->rx_mimo_signal_quality[ODM_RF_PATH_A] = -1;
@@ -226,19 +226,10 @@ static void odm_RxPhyStatus92CSeries_Parsing(
/* UI BSS List signal strength(in percentage), make it good looking, from 0~100. */
/* It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). */
if (isCCKrate) {
-#ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
- pPhyInfo->SignalStrength = (u8)PWDB_ALL;
-#else
pPhyInfo->signal_strength = (u8)(odm_SignalScaleMapping(pDM_Odm, PWDB_ALL));/* PWDB_ALL; */
-#endif
} else {
if (rf_rx_num != 0) {
-#ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
- total_rssi /= rf_rx_num;
- pPhyInfo->signal_strength = (u8)total_rssi;
-#else
pPhyInfo->signal_strength = (u8)(odm_SignalScaleMapping(pDM_Odm, total_rssi /= rf_rx_num));
-#endif
}
}
@@ -247,7 +238,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(
}
static void odm_Process_RSSIForDM(
- PDM_ODM_T pDM_Odm, struct odm_phy_info *pPhyInfo, struct odm_packet_info *pPktinfo
+ struct dm_odm_t *pDM_Odm, struct odm_phy_info *pPhyInfo, struct odm_packet_info *pPktinfo
)
{
@@ -401,7 +392,7 @@ static void odm_Process_RSSIForDM(
/* Endianness before calling this API */
/* */
static void ODM_PhyStatusQuery_92CSeries(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
struct odm_phy_info *pPhyInfo,
u8 *pPhyStatus,
struct odm_packet_info *pPktinfo
@@ -415,7 +406,7 @@ static void ODM_PhyStatusQuery_92CSeries(
}
void ODM_PhyStatusQuery(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
struct odm_phy_info *pPhyInfo,
u8 *pPhyStatus,
struct odm_packet_info *pPktinfo
@@ -430,10 +421,10 @@ void ODM_PhyStatusQuery(
/* */
/* */
-HAL_STATUS ODM_ConfigRFWithHeaderFile(
- PDM_ODM_T pDM_Odm,
- ODM_RF_Config_Type ConfigType,
- ODM_RF_RADIO_PATH_E eRFPath
+enum hal_status ODM_ConfigRFWithHeaderFile(
+ struct dm_odm_t *pDM_Odm,
+ enum ODM_RF_Config_Type ConfigType,
+ enum odm_rf_radio_path_e eRFPath
)
{
ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
@@ -450,7 +441,7 @@ HAL_STATUS ODM_ConfigRFWithHeaderFile(
return HAL_STATUS_SUCCESS;
}
-HAL_STATUS ODM_ConfigRFWithTxPwrTrackHeaderFile(PDM_ODM_T pDM_Odm)
+enum hal_status ODM_ConfigRFWithTxPwrTrackHeaderFile(struct dm_odm_t *pDM_Odm)
{
ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
("===>ODM_ConfigRFWithTxPwrTrackHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip"));
@@ -464,8 +455,8 @@ HAL_STATUS ODM_ConfigRFWithTxPwrTrackHeaderFile(PDM_ODM_T pDM_Odm)
return HAL_STATUS_SUCCESS;
}
-HAL_STATUS ODM_ConfigBBWithHeaderFile(
- PDM_ODM_T pDM_Odm, ODM_BB_Config_Type ConfigType
+enum hal_status ODM_ConfigBBWithHeaderFile(
+ struct dm_odm_t *pDM_Odm, enum ODM_BB_Config_Type ConfigType
)
{
ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h
index 945366bc37ce..574f9cfe8190 100644
--- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h
+++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h
@@ -30,16 +30,16 @@
/* structure and define */
/* */
-typedef struct _Phy_Rx_AGC_Info {
+struct phy_rx_agc_info_t {
#if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
u8 gain:7, trsw:1;
#else
u8 trsw:1, gain:7;
#endif
-} PHY_RX_AGC_INFO_T, *pPHY_RX_AGC_INFO_T;
+};
-typedef struct _Phy_Status_Rpt_8192cd {
- PHY_RX_AGC_INFO_T path_agc[2];
+struct phy_status_rpt_8192cd_t {
+ struct phy_rx_agc_info_t path_agc[2];
u8 ch_corr[2];
u8 cck_sig_qual_ofdm_pwdb_all;
u8 cck_agc_rpt_ofdm_cfosho_a;
@@ -74,79 +74,34 @@ typedef struct _Phy_Status_Rpt_8192cd {
u8 sgi_en:1;
u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */
#endif
-} PHY_STATUS_RPT_8192CD_T, *PPHY_STATUS_RPT_8192CD_T;
-
-
-typedef struct _Phy_Status_Rpt_8812 {
- /* 2012.05.24 LukeLee: This structure should take big/little endian in consideration later..... */
-
- /* DWORD 0 */
- u8 gain_trsw[2];
-#if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
- u16 chl_num:10;
- u16 sub_chnl:4;
- u16 r_RFMOD:2;
-#else /* _BIG_ENDIAN_ */
- u16 r_RFMOD:2;
- u16 sub_chnl:4;
- u16 chl_num:10;
-#endif
-
- /* DWORD 1 */
- u8 pwdb_all;
- u8 cfosho[4]; /* DW 1 byte 1 DW 2 byte 0 */
-
- /* DWORD 2 */
- s8 cfotail[4]; /* DW 2 byte 1 DW 3 byte 0 */
-
- /* DWORD 3 */
- s8 rxevm[2]; /* DW 3 byte 1 DW 3 byte 2 */
- s8 rxsnr[2]; /* DW 3 byte 3 DW 4 byte 0 */
-
- /* DWORD 4 */
- u8 PCTS_MSK_RPT[2];
- u8 pdsnr[2]; /* DW 4 byte 3 DW 5 Byte 0 */
-
- /* DWORD 5 */
- u8 csi_current[2];
- u8 rx_gain_c;
-
- /* DWORD 6 */
- u8 rx_gain_d;
- s8 sigevm;
- u8 resvd_0;
- u8 antidx_anta:3;
- u8 antidx_antb:3;
- u8 resvd_1:2;
-} PHY_STATUS_RPT_8812_T, *PPHY_STATUS_RPT_8812_T;
-
+};
void ODM_PhyStatusQuery(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
struct odm_phy_info *pPhyInfo,
u8 *pPhyStatus,
struct odm_packet_info *pPktinfo
);
-HAL_STATUS ODM_ConfigRFWithTxPwrTrackHeaderFile(PDM_ODM_T pDM_Odm);
+enum hal_status ODM_ConfigRFWithTxPwrTrackHeaderFile(struct dm_odm_t *pDM_Odm);
-HAL_STATUS ODM_ConfigRFWithHeaderFile(
- PDM_ODM_T pDM_Odm,
- ODM_RF_Config_Type ConfigType,
- ODM_RF_RADIO_PATH_E eRFPath
+enum hal_status ODM_ConfigRFWithHeaderFile(
+ struct dm_odm_t *pDM_Odm,
+ enum ODM_RF_Config_Type ConfigType,
+ enum odm_rf_radio_path_e eRFPath
);
-HAL_STATUS ODM_ConfigBBWithHeaderFile(
- PDM_ODM_T pDM_Odm, ODM_BB_Config_Type ConfigType
+enum hal_status ODM_ConfigBBWithHeaderFile(
+ struct dm_odm_t *pDM_Odm, enum ODM_BB_Config_Type ConfigType
);
-HAL_STATUS ODM_ConfigFWWithHeaderFile(
- PDM_ODM_T pDM_Odm,
- ODM_FW_Config_Type ConfigType,
+enum hal_status ODM_ConfigFWWithHeaderFile(
+ struct dm_odm_t *pDM_Odm,
+ enum ODM_FW_Config_Type ConfigType,
u8 *pFirmware,
u32 *pSize
);
-s32 odm_SignalScaleMapping(PDM_ODM_T pDM_Odm, s32 CurrSig);
+s32 odm_SignalScaleMapping(struct dm_odm_t *pDM_Odm, s32 CurrSig);
#endif
diff --git a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c
index 6ca799816c08..c3de123e2a48 100644
--- a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c
+++ b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c
@@ -19,7 +19,7 @@
#define ValidCnt 5
static s16 odm_InbandNoise_Monitor_NSeries(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u8 bPauseDIG,
u8 IGIValue,
u32 max_time
diff --git a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h
index a7f13a85559c..ab114543f39c 100644
--- a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h
+++ b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h
@@ -24,10 +24,10 @@ struct noise_level {
};
-typedef struct _ODM_NOISE_MONITOR_ {
+struct odm_noise_monitor {
s8 noise[MAX_RF_PATH];
s16 noise_all;
-} ODM_NOISE_MONITOR;
+};
s16 ODM_InbandNoise_Monitor(
void *pDM_VOID,
diff --git a/drivers/staging/rtl8723bs/hal/odm_PathDiv.c b/drivers/staging/rtl8723bs/hal/odm_PathDiv.c
index 4d22360934f6..92b708265d47 100644
--- a/drivers/staging/rtl8723bs/hal/odm_PathDiv.c
+++ b/drivers/staging/rtl8723bs/hal/odm_PathDiv.c
@@ -9,7 +9,7 @@
void odm_PathDiversityInit(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
if (!(pDM_Odm->SupportAbility & ODM_BB_PATH_DIV))
ODM_RT_TRACE(
@@ -22,7 +22,7 @@ void odm_PathDiversityInit(void *pDM_VOID)
void odm_PathDiversity(void *pDM_VOID)
{
- PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID;
+ struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID;
if (!(pDM_Odm->SupportAbility & ODM_BB_PATH_DIV))
ODM_RT_TRACE(
diff --git a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c
index 39f989bf3410..63bf5ba3e0d5 100644
--- a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c
+++ b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c
@@ -8,10 +8,10 @@
#include "odm_precomp.h"
void odm_ConfigRFReg_8723B(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u32 Addr,
u32 Data,
- ODM_RF_RADIO_PATH_E RF_PATH,
+ enum odm_rf_radio_path_e RF_PATH,
u32 RegAddr
)
{
@@ -106,7 +106,7 @@ void odm_ConfigRFReg_8723B(
}
-void odm_ConfigRF_RadioA_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u32 Data)
+void odm_ConfigRF_RadioA_8723B(struct dm_odm_t *pDM_Odm, u32 Addr, u32 Data)
{
u32 content = 0x1000; /* RF_Content: radioa_txt */
u32 maskforPhySet = (u32)(content&0xE000);
@@ -131,7 +131,7 @@ void odm_ConfigRF_RadioA_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u32 Data)
);
}
-void odm_ConfigMAC_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u8 Data)
+void odm_ConfigMAC_8723B(struct dm_odm_t *pDM_Odm, u32 Addr, u8 Data)
{
rtw_write8(pDM_Odm->Adapter, Addr, Data);
ODM_RT_TRACE(
@@ -147,7 +147,7 @@ void odm_ConfigMAC_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u8 Data)
}
void odm_ConfigBB_AGC_8723B(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u32 Addr,
u32 Bitmask,
u32 Data
@@ -170,7 +170,7 @@ void odm_ConfigBB_AGC_8723B(
}
void odm_ConfigBB_PHY_REG_PG_8723B(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u32 Band,
u32 RfPath,
u32 TxNum,
@@ -198,7 +198,7 @@ void odm_ConfigBB_PHY_REG_PG_8723B(
}
void odm_ConfigBB_PHY_8723B(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u32 Addr,
u32 Bitmask,
u32 Data
@@ -226,7 +226,7 @@ void odm_ConfigBB_PHY_8723B(
}
void odm_ConfigBB_TXPWR_LMT_8723B(
- PDM_ODM_T pDM_Odm,
+ struct dm_odm_t *pDM_Odm,
u8 *Regulation,
u8 *Band,
u8 *Bandwidth,
diff --git a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h
index 07b585950cf9..b392d14c389d 100644
--- a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h
+++ b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h
@@ -7,24 +7,24 @@
#ifndef __INC_ODM_REGCONFIG_H_8723B
#define __INC_ODM_REGCONFIG_H_8723B
-void odm_ConfigRFReg_8723B(PDM_ODM_T pDM_Odm,
+void odm_ConfigRFReg_8723B(struct dm_odm_t *pDM_Odm,
u32 Addr,
u32 Data,
- ODM_RF_RADIO_PATH_E RF_PATH,
+ enum odm_rf_radio_path_e RF_PATH,
u32 RegAddr
);
-void odm_ConfigRF_RadioA_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u32 Data);
+void odm_ConfigRF_RadioA_8723B(struct dm_odm_t *pDM_Odm, u32 Addr, u32 Data);
-void odm_ConfigMAC_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u8 Data);
+void odm_ConfigMAC_8723B(struct dm_odm_t *pDM_Odm, u32 Addr, u8 Data);
-void odm_ConfigBB_AGC_8723B(PDM_ODM_T pDM_Odm,
+void odm_ConfigBB_AGC_8723B(struct dm_odm_t *pDM_Odm,
u32 Addr,
u32 Bitmask,
u32 Data
);
-void odm_ConfigBB_PHY_REG_PG_8723B(PDM_ODM_T pDM_Odm,
+void odm_ConfigBB_PHY_REG_PG_8723B(struct dm_odm_t *pDM_Odm,
u32 Band,
u32 RfPath,
u32 TxNum,
@@ -33,13 +33,13 @@ void odm_ConfigBB_PHY_REG_PG_8723B(PDM_ODM_T pDM_Odm,
u32 Data
);
-void odm_ConfigBB_PHY_8723B(PDM_ODM_T pDM_Odm,
+void odm_ConfigBB_PHY_8723B(struct dm_odm_t *pDM_Odm,
u32 Addr,
u32 Bitmask,
u32 Data
);
-void odm_ConfigBB_TXPWR_LMT_8723B(PDM_ODM_T pDM_Odm,
+void odm_ConfigBB_TXPWR_LMT_8723B(struct dm_odm_t *pDM_Odm,
u8 *Regulation,
u8 *Band,
u8 *Bandwidth,
diff --git a/drivers/staging/rtl8723bs/hal/odm_debug.c b/drivers/staging/rtl8723bs/hal/odm_debug.c
index b92422c8fb8e..b35451bcb437 100644
--- a/drivers/staging/rtl8723bs/hal/odm_debug.c
+++ b/drivers/staging/rtl8723bs/hal/odm_debug.c
@@ -7,7 +7,7 @@
#include "odm_precomp.h"
-void ODM_InitDebugSetting(PDM_ODM_T pDM_Odm)
+void ODM_InitDebugSetting(struct dm_odm_t *pDM_Odm)
{
pDM_Odm->DebugLevel = ODM_DBG_LOUD;
diff --git a/drivers/staging/rtl8723bs/hal/odm_debug.h b/drivers/staging/rtl8723bs/hal/odm_debug.h
index a7381173d1a3..be0d4c49a747 100644
--- a/drivers/staging/rtl8723bs/hal/odm_debug.h
+++ b/drivers/staging/rtl8723bs/hal/odm_debug.h
@@ -131,8 +131,6 @@
ASSERT(false);\
} \
} while (0)
-#define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); }
-#define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); }
#define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); }
#define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr)\
@@ -162,6 +160,6 @@
no_printk("%s %p", title_str, ptr)
#endif
-void ODM_InitDebugSetting(PDM_ODM_T pDM_Odm);
+void ODM_InitDebugSetting(struct dm_odm_t *pDM_Odm);
#endif /* __ODM_DBG_H__ */
diff --git a/drivers/staging/rtl8723bs/hal/odm_interface.h b/drivers/staging/rtl8723bs/hal/odm_interface.h
index 63f374f0bda7..d19347b02890 100644
--- a/drivers/staging/rtl8723bs/hal/odm_interface.h
+++ b/drivers/staging/rtl8723bs/hal/odm_interface.h
@@ -11,8 +11,6 @@
-/* =========== Constant/Structure/Enum/... Define */
-
/* =========== Macro Define */
#define _reg_all(_name) ODM_##_name
@@ -39,13 +37,4 @@ ODM_REG(DIG, _pDM_Odm)
#define ODM_REG(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _reg)
#define ODM_BIT(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _bit)
-typedef enum _ODM_H2C_CMD {
- ODM_H2C_RSSI_REPORT = 0,
- ODM_H2C_PSD_RESULT = 1,
- ODM_H2C_PathDiv = 2,
- ODM_H2C_WIFI_CALIBRATION = 3,
- ODM_MAX_H2CCMD
-} ODM_H2C_CMD;
-
-
#endif /* __ODM_INTERFACE_H__ */
diff --git a/drivers/staging/rtl8723bs/hal/odm_types.h b/drivers/staging/rtl8723bs/hal/odm_types.h
index c79fc1813c3f..8168dc14e879 100644
--- a/drivers/staging/rtl8723bs/hal/odm_types.h
+++ b/drivers/staging/rtl8723bs/hal/odm_types.h
@@ -15,7 +15,7 @@
#define GET_ODM(__padapter) ((PDM_ODM_T)(&((GET_HAL_DATA(__padapter))->odmpriv)))
-typedef enum _HAL_STATUS {
+enum hal_status {
HAL_STATUS_SUCCESS,
HAL_STATUS_FAILURE,
/*RT_STATUS_PENDING,
@@ -24,58 +24,15 @@ typedef enum _HAL_STATUS {
RT_STATUS_INVALID_PARAMETER,
RT_STATUS_NOT_SUPPORT,
RT_STATUS_OS_API_FAILED,*/
-} HAL_STATUS, *PHAL_STATUS;
+};
-/* */
-/* Declare for ODM spin lock definition temporarily from compile pass. */
-/* */
-typedef enum _RT_SPINLOCK_TYPE {
- RT_TX_SPINLOCK = 1,
- RT_RX_SPINLOCK = 2,
- RT_RM_SPINLOCK = 3,
- RT_CAM_SPINLOCK = 4,
- RT_SCAN_SPINLOCK = 5,
- RT_LOG_SPINLOCK = 7,
- RT_BW_SPINLOCK = 8,
- RT_CHNLOP_SPINLOCK = 9,
- RT_RF_OPERATE_SPINLOCK = 10,
- RT_INITIAL_SPINLOCK = 11,
- RT_RF_STATE_SPINLOCK = 12, /* For RF state. Added by Bruce, 2007-10-30. */
- /* Shall we define Ndis 6.2 SpinLock Here ? */
- RT_PORT_SPINLOCK = 16,
- RT_H2C_SPINLOCK = 20, /* For H2C cmd. Added by tynli. 2009.11.09. */
-
- RT_BTData_SPINLOCK = 25,
-
- RT_WAPI_OPTION_SPINLOCK = 26,
- RT_WAPI_RX_SPINLOCK = 27,
-
- /* add for 92D CCK control issue */
- RT_CCK_PAGEA_SPINLOCK = 28,
- RT_BUFFER_SPINLOCK = 29,
- RT_CHANNEL_AND_BANDWIDTH_SPINLOCK = 30,
- RT_GEN_TEMP_BUF_SPINLOCK = 31,
- RT_AWB_SPINLOCK = 32,
- RT_FW_PS_SPINLOCK = 33,
- RT_HW_TIMER_SPIN_LOCK = 34,
- RT_MPT_WI_SPINLOCK = 35,
- RT_P2P_SPIN_LOCK = 36, /* Protect P2P context */
- RT_DBG_SPIN_LOCK = 37,
- RT_IQK_SPINLOCK = 38,
- RT_PENDED_OID_SPINLOCK = 39,
- RT_CHNLLIST_SPINLOCK = 40,
- RT_INDIC_SPINLOCK = 41, /* protect indication */
-} RT_SPINLOCK_TYPE;
-
#if defined(__LITTLE_ENDIAN)
#define ODM_ENDIAN_TYPE ODM_ENDIAN_LITTLE
#else
#define ODM_ENDIAN_TYPE ODM_ENDIAN_BIG
#endif
- typedef struct timer_list RT_TIMER, *PRT_TIMER;
- typedef void *RT_TIMER_CALL_BACK;
#define STA_INFO_T struct sta_info
#define PSTA_INFO_T struct sta_info *
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
index 86f31d98349a..2451875ab3c0 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c
@@ -24,17 +24,11 @@ static u8 _is_fw_read_cmd_down(struct adapter *padapter, u8 msgbox_num)
u8 valid;
- /* DBG_8192C(" _is_fw_read_cmd_down , reg_1cc(%x), msg_box(%d)...\n", rtw_read8(padapter, REG_HMETFR), msgbox_num); */
-
do {
valid = rtw_read8(padapter, REG_HMETFR) & BIT(msgbox_num);
if (0 == valid) {
read_down = true;
}
-#ifdef CONFIG_WOWLAN
- else
- msleep(1);
-#endif
} while ((!read_down) && (retry_cnts--));
return read_down;
@@ -80,12 +74,8 @@ s32 FillH2CCmd8723B(struct adapter *padapter, u8 ElementID, u32 CmdLen, u8 *pCmd
do {
h2c_box_num = pHalData->LastHMEBoxNum;
- if (!_is_fw_read_cmd_down(padapter, h2c_box_num)) {
- DBG_8192C(" fw read cmd failed...\n");
- /* DBG_8192C(" 0x1c0: 0x%8x\n", rtw_read32(padapter, 0x1c0)); */
- /* DBG_8192C(" 0x1c4: 0x%8x\n", rtw_read32(padapter, 0x1c4)); */
+ if (!_is_fw_read_cmd_down(padapter, h2c_box_num))
goto exit;
- }
if (CmdLen <= 3)
memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, CmdLen);
@@ -104,9 +94,6 @@ s32 FillH2CCmd8723B(struct adapter *padapter, u8 ElementID, u32 CmdLen, u8 *pCmd
msgbox_addr = REG_HMEBOX_0 + (h2c_box_num*MESSAGE_BOX_SIZE);
rtw_write32(padapter, msgbox_addr, h2c_cmd);
- /* DBG_8192C("MSG_BOX:%d, CmdLen(%d), CmdID(0x%x), reg:0x%x =>h2c_cmd:0x%.8x, reg:0x%x =>h2c_cmd_ex:0x%.8x\n" */
- /* , pHalData->LastHMEBoxNum , CmdLen, ElementID, msgbox_addr, h2c_cmd, msgbox_ex_addr, h2c_cmd_ex); */
-
pHalData->LastHMEBoxNum = (h2c_box_num+1) % MAX_H2C_BOX_NUMS;
} while (0);
@@ -129,9 +116,6 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength)
struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
- /* DBG_871X("%s\n", __func__); */
-
pwlanhdr = (struct ieee80211_hdr *)pframe;
fctrl = &(pwlanhdr->frame_control);
@@ -165,7 +149,6 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength)
pktlen += 2;
if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) {
- /* DBG_871X("ie len =%d\n", cur_network->IELength); */
pktlen += cur_network->IELength - sizeof(struct ndis_802_11_fix_ie);
memcpy(pframe, cur_network->IEs+sizeof(struct ndis_802_11_fix_ie), pktlen);
@@ -205,15 +188,11 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength)
_ConstructBeacon:
- if ((pktlen + TXDESC_SIZE) > 512) {
- DBG_871X("beacon frame too large\n");
+ if ((pktlen + TXDESC_SIZE) > 512)
return;
- }
*pLength = pktlen;
- /* DBG_871X("%s bcn_sz =%d\n", __func__, pktlen); */
-
}
static void ConstructPSPoll(struct adapter *padapter, u8 *pframe, u32 *pLength)
@@ -223,8 +202,6 @@ static void ConstructPSPoll(struct adapter *padapter, u8 *pframe, u32 *pLength)
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- /* DBG_871X("%s\n", __func__); */
-
pwlanhdr = (struct ieee80211_hdr *)pframe;
/* Frame control. */
@@ -264,9 +241,6 @@ static void ConstructNullFunctionData(
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
-
- /* DBG_871X("%s:%d\n", __func__, bForcePowerSave); */
-
pwlanhdr = (struct ieee80211_hdr *)pframe;
fctrl = &pwlanhdr->frame_control;
@@ -316,513 +290,6 @@ static void ConstructNullFunctionData(
*pLength = pktlen;
}
-
-#ifdef CONFIG_WOWLAN
-/* */
-/* Description: */
-/* Construct the ARP response packet to support ARP offload. */
-/* */
-static void ConstructARPResponse(
- struct adapter *padapter,
- u8 *pframe,
- u32 *pLength,
- u8 *pIPAddress
-)
-{
- struct ieee80211_hdr *pwlanhdr;
- __le16 *fctrl;
- struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- struct security_priv *psecuritypriv = &padapter->securitypriv;
- static u8 ARPLLCHeader[8] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x08, 0x06};
- u8 *pARPRspPkt = pframe;
- /* for TKIP Cal MIC */
- u8 *payload = pframe;
- u8 EncryptionHeadOverhead = 0;
- /* DBG_871X("%s:%d\n", __func__, bForcePowerSave); */
-
- pwlanhdr = (struct ieee80211_hdr *)pframe;
-
- fctrl = &pwlanhdr->frame_control;
- *(fctrl) = 0;
-
- /* */
- /* MAC Header. */
- /* */
- SetFrameType(fctrl, WIFI_DATA);
- /* SetFrameSubType(fctrl, 0); */
- SetToDs(fctrl);
- memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
- memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN);
- memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
-
- SetSeqNum(pwlanhdr, 0);
- SetDuration(pwlanhdr, 0);
- /* SET_80211_HDR_FRAME_CONTROL(pARPRspPkt, 0); */
- /* SET_80211_HDR_TYPE_AND_SUBTYPE(pARPRspPkt, Type_Data); */
- /* SET_80211_HDR_TO_DS(pARPRspPkt, 1); */
- /* SET_80211_HDR_ADDRESS1(pARPRspPkt, pMgntInfo->Bssid); */
- /* SET_80211_HDR_ADDRESS2(pARPRspPkt, Adapter->CurrentAddress); */
- /* SET_80211_HDR_ADDRESS3(pARPRspPkt, pMgntInfo->Bssid); */
-
- /* SET_80211_HDR_DURATION(pARPRspPkt, 0); */
- /* SET_80211_HDR_FRAGMENT_SEQUENCE(pARPRspPkt, 0); */
- *pLength = 24;
-
- /* */
- /* Security Header: leave space for it if necessary. */
- /* */
-
- switch (psecuritypriv->dot11PrivacyAlgrthm) {
- case _WEP40_:
- case _WEP104_:
- EncryptionHeadOverhead = 4;
- break;
- case _TKIP_:
- EncryptionHeadOverhead = 8;
- break;
- case _AES_:
- EncryptionHeadOverhead = 8;
- break;
- default:
- EncryptionHeadOverhead = 0;
- }
-
- if (EncryptionHeadOverhead > 0) {
- memset(&(pframe[*pLength]), 0, EncryptionHeadOverhead);
- *pLength += EncryptionHeadOverhead;
- SetPrivacy(fctrl);
- }
-
- /* */
- /* Frame Body. */
- /* */
- pARPRspPkt = (u8 *)(pframe + *pLength);
- payload = pARPRspPkt; /* Get Payload pointer */
- /* LLC header */
- memcpy(pARPRspPkt, ARPLLCHeader, 8);
- *pLength += 8;
-
- /* ARP element */
- pARPRspPkt += 8;
- SET_ARP_PKT_HW(pARPRspPkt, 0x0100);
- SET_ARP_PKT_PROTOCOL(pARPRspPkt, 0x0008); /* IP protocol */
- SET_ARP_PKT_HW_ADDR_LEN(pARPRspPkt, 6);
- SET_ARP_PKT_PROTOCOL_ADDR_LEN(pARPRspPkt, 4);
- SET_ARP_PKT_OPERATION(pARPRspPkt, 0x0200); /* ARP response */
- SET_ARP_PKT_SENDER_MAC_ADDR(pARPRspPkt, myid(&(padapter->eeprompriv)));
- SET_ARP_PKT_SENDER_IP_ADDR(pARPRspPkt, pIPAddress);
- {
- SET_ARP_PKT_TARGET_MAC_ADDR(pARPRspPkt, get_my_bssid(&(pmlmeinfo->network)));
- SET_ARP_PKT_TARGET_IP_ADDR(pARPRspPkt, pIPAddress);
- DBG_871X("%s Target Mac Addr:%pM\n", __func__, MAC_ARG(get_my_bssid(&(pmlmeinfo->network))));
- DBG_871X("%s Target IP Addr:%pI4\n", __func__, IP_ARG(pIPAddress));
- }
-
- *pLength += 28;
-
- if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_) {
- u8 mic[8];
- struct mic_data micdata;
- struct sta_info *psta = NULL;
- u8 priority[4] = {
- 0x0, 0x0, 0x0, 0x0
- };
- u8 null_key[16] = {
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
- };
-
- DBG_871X("%s(): Add MIC\n", __func__);
-
- psta = rtw_get_stainfo(&padapter->stapriv, get_my_bssid(&(pmlmeinfo->network)));
- if (psta) {
- if (!memcmp(&psta->dot11tkiptxmickey.skey[0], null_key, 16)) {
- DBG_871X("%s(): STA dot11tkiptxmickey == 0\n", __func__);
- }
- /* start to calculate the mic code */
- rtw_secmicsetkey(&micdata, &psta->dot11tkiptxmickey.skey[0]);
- }
-
- rtw_secmicappend(&micdata, pwlanhdr->addr3, 6); /* DA */
-
- rtw_secmicappend(&micdata, pwlanhdr->addr2, 6); /* SA */
-
- priority[0] = 0;
- rtw_secmicappend(&micdata, &priority[0], 4);
-
- rtw_secmicappend(&micdata, payload, 36); /* payload length = 8 + 28 */
-
- rtw_secgetmic(&micdata, &(mic[0]));
-
- pARPRspPkt += 28;
- memcpy(pARPRspPkt, &(mic[0]), 8);
-
- *pLength += 8;
- }
-}
-
-#ifdef CONFIG_PNO_SUPPORT
-static void ConstructPnoInfo(
- struct adapter *padapter, u8 *pframe, u32 *pLength
-)
-{
-
- struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
-
- u8 *pPnoInfoPkt = pframe;
- pPnoInfoPkt = (u8 *)(pframe + *pLength);
- memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->ssid_num, 4);
-
- *pLength += 4;
- pPnoInfoPkt += 4;
- memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->fast_scan_period, 4);
-
- *pLength += 4;
- pPnoInfoPkt += 4;
- memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->fast_scan_iterations, 4);
-
- *pLength += 4;
- pPnoInfoPkt += 4;
- memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->slow_scan_period, 4);
-
- *pLength += 4;
- pPnoInfoPkt += 4;
- memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->ssid_length,
- MAX_PNO_LIST_COUNT);
-
- *pLength += MAX_PNO_LIST_COUNT;
- pPnoInfoPkt += MAX_PNO_LIST_COUNT;
- memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->ssid_cipher_info,
- MAX_PNO_LIST_COUNT);
-
- *pLength += MAX_PNO_LIST_COUNT;
- pPnoInfoPkt += MAX_PNO_LIST_COUNT;
- memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->ssid_channel_info,
- MAX_PNO_LIST_COUNT);
-
- *pLength += MAX_PNO_LIST_COUNT;
- pPnoInfoPkt += MAX_PNO_LIST_COUNT;
-}
-
-static void ConstructSSIDList(
- struct adapter *padapter, u8 *pframe, u32 *pLength
-)
-{
- int i = 0;
- u8 *pSSIDListPkt = pframe;
- struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
-
- pSSIDListPkt = (u8 *)(pframe + *pLength);
-
- for (i = 0; i < pwrctl->pnlo_info->ssid_num ; i++) {
- memcpy(pSSIDListPkt, &pwrctl->pno_ssid_list->node[i].SSID,
- pwrctl->pnlo_info->ssid_length[i]);
-
- *pLength += WLAN_SSID_MAXLEN;
- pSSIDListPkt += WLAN_SSID_MAXLEN;
- }
-}
-
-static void ConstructScanInfo(
- struct adapter *padapter, u8 *pframe, u32 *pLength
-)
-{
- int i = 0;
- u8 *pScanInfoPkt = pframe;
- struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
-
- pScanInfoPkt = (u8 *)(pframe + *pLength);
-
- memcpy(pScanInfoPkt, &pwrctl->pscan_info->channel_num, 1);
-
- *pLength += 1;
- pScanInfoPkt += 1;
- memcpy(pScanInfoPkt, &pwrctl->pscan_info->orig_ch, 1);
-
-
- *pLength += 1;
- pScanInfoPkt += 1;
- memcpy(pScanInfoPkt, &pwrctl->pscan_info->orig_bw, 1);
-
-
- *pLength += 1;
- pScanInfoPkt += 1;
- memcpy(pScanInfoPkt, &pwrctl->pscan_info->orig_40_offset, 1);
-
- *pLength += 1;
- pScanInfoPkt += 1;
- memcpy(pScanInfoPkt, &pwrctl->pscan_info->orig_80_offset, 1);
-
- *pLength += 1;
- pScanInfoPkt += 1;
- memcpy(pScanInfoPkt, &pwrctl->pscan_info->periodScan, 1);
-
- *pLength += 1;
- pScanInfoPkt += 1;
- memcpy(pScanInfoPkt, &pwrctl->pscan_info->period_scan_time, 1);
-
- *pLength += 1;
- pScanInfoPkt += 1;
- memcpy(pScanInfoPkt, &pwrctl->pscan_info->enableRFE, 1);
-
- *pLength += 1;
- pScanInfoPkt += 1;
- memcpy(pScanInfoPkt, &pwrctl->pscan_info->rfe_type, 8);
-
- *pLength += 8;
- pScanInfoPkt += 8;
-
- for (i = 0; i < MAX_SCAN_LIST_COUNT; i++) {
- memcpy(pScanInfoPkt, &pwrctl->pscan_info->ssid_channel_info[i], 4);
- *pLength += 4;
- pScanInfoPkt += 4;
- }
-}
-#endif
-
-#ifdef CONFIG_GTK_OL
-static void ConstructGTKResponse(
- struct adapter *padapter, u8 *pframe, u32 *pLength
-)
-{
- struct ieee80211_hdr *pwlanhdr;
- u16 *fctrl;
- struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- struct security_priv *psecuritypriv = &padapter->securitypriv;
- static u8 LLCHeader[8] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8E};
- static u8 GTKbody_a[11] = {0x01, 0x03, 0x00, 0x5F, 0x02, 0x03, 0x12, 0x00, 0x10, 0x42, 0x0B};
- u8 *pGTKRspPkt = pframe;
- u8 EncryptionHeadOverhead = 0;
- /* DBG_871X("%s:%d\n", __func__, bForcePowerSave); */
-
- pwlanhdr = (struct ieee80211_hdr *)pframe;
-
- fctrl = &pwlanhdr->frame_control;
- *(fctrl) = 0;
-
- /* */
- /* MAC Header. */
- /* */
- SetFrameType(fctrl, WIFI_DATA);
- /* SetFrameSubType(fctrl, 0); */
- SetToDs(fctrl);
- memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
- memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN);
- memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
-
- SetSeqNum(pwlanhdr, 0);
- SetDuration(pwlanhdr, 0);
-
- *pLength = 24;
-
- /* */
- /* Security Header: leave space for it if necessary. */
- /* */
-
- switch (psecuritypriv->dot11PrivacyAlgrthm) {
- case _WEP40_:
- case _WEP104_:
- EncryptionHeadOverhead = 4;
- break;
- case _TKIP_:
- EncryptionHeadOverhead = 8;
- break;
- case _AES_:
- EncryptionHeadOverhead = 8;
- break;
- default:
- EncryptionHeadOverhead = 0;
- }
-
- if (EncryptionHeadOverhead > 0) {
- memset(&(pframe[*pLength]), 0, EncryptionHeadOverhead);
- *pLength += EncryptionHeadOverhead;
- /* GTK's privacy bit is done by FW */
- /* SetPrivacy(fctrl); */
- }
-
- /* */
- /* Frame Body. */
- /* */
- pGTKRspPkt = (u8 *)(pframe + *pLength);
- /* LLC header */
- memcpy(pGTKRspPkt, LLCHeader, 8);
- *pLength += 8;
-
- /* GTK element */
- pGTKRspPkt += 8;
-
- /* GTK frame body after LLC, part 1 */
- memcpy(pGTKRspPkt, GTKbody_a, 11);
- *pLength += 11;
- pGTKRspPkt += 11;
- /* GTK frame body after LLC, part 2 */
- memset(&(pframe[*pLength]), 0, 88);
- *pLength += 88;
- pGTKRspPkt += 88;
-
-}
-#endif /* CONFIG_GTK_OL */
-
-#ifdef CONFIG_PNO_SUPPORT
-static void ConstructProbeReq(struct adapter *padapter, u8 *pframe, u32 *pLength)
-{
- struct ieee80211_hdr *pwlanhdr;
- u16 *fctrl;
- u32 pktlen;
- unsigned char *mac;
- unsigned char bssrate[NumRates];
- int bssrate_len = 0;
- u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
- pwlanhdr = (struct ieee80211_hdr *)pframe;
- mac = myid(&(padapter->eeprompriv));
-
- fctrl = &(pwlanhdr->frame_control);
- *(fctrl) = 0;
-
- /* broadcast probe request frame */
- memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN);
- memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN);
-
- memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
-
- SetSeqNum(pwlanhdr, 0);
- SetFrameSubType(pframe, WIFI_PROBEREQ);
-
- pktlen = sizeof(struct ieee80211_hdr_3addr);
- pframe += pktlen;
-
- pframe = rtw_set_ie(pframe, WLAN_EID_SSID, 0, NULL, &pktlen);
-
- get_rate_set(padapter, bssrate, &bssrate_len);
-
- if (bssrate_len > 8) {
- pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &pktlen);
- pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (bssrate_len - 8), (bssrate + 8), &pktlen);
- } else
- pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &pktlen);
-
- *pLength = pktlen;
-}
-#endif /* CONFIG_PNO_SUPPORT */
-#endif /* CONFIG_WOWLAN */
-
-#ifdef CONFIG_AP_WOWLAN
-static void ConstructProbeRsp(struct adapter *padapter, u8 *pframe, u32 *pLength, u8 *StaAddr, bool bHideSSID)
-{
- struct ieee80211_hdr *pwlanhdr;
- u16 *fctrl;
- u8 *mac, *bssid;
- u32 pktlen;
- struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
- u8 *pwps_ie;
- uint wps_ielen;
- struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-
- /* DBG_871X("%s\n", __func__); */
-
- pwlanhdr = (struct ieee80211_hdr *)pframe;
-
- mac = myid(&(padapter->eeprompriv));
- bssid = cur_network->MacAddress;
-
- fctrl = &(pwlanhdr->frame_control);
- *(fctrl) = 0;
- memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN);
- memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
- memcpy(pwlanhdr->addr3, bssid, ETH_ALEN);
-
- DBG_871X("%s FW Mac Addr:%pM\n", __func__, MAC_ARG(mac));
- DBG_871X("%s FW IP Addr:%pI4\n", __func__, IP_ARG(StaAddr));
-
- SetSeqNum(pwlanhdr, 0);
- SetFrameSubType(fctrl, WIFI_PROBERSP);
-
- pktlen = sizeof(struct ieee80211_hdr_3addr);
- pframe += pktlen;
-
- if (cur_network->IELength > MAX_IE_SZ)
- return;
-
- pwps_ie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_,
- cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen);
-
- /* inerset & update wps_probe_resp_ie */
- if (pmlmepriv->wps_probe_resp_ie && pwps_ie && (wps_ielen > 0)) {
- uint wps_offset, remainder_ielen;
- u8 *premainder_ie;
-
- wps_offset = (uint)(pwps_ie - cur_network->IEs);
-
- premainder_ie = pwps_ie + wps_ielen;
-
- remainder_ielen = cur_network->IELength - wps_offset - wps_ielen;
-
- memcpy(pframe, cur_network->IEs, wps_offset);
- pframe += wps_offset;
- pktlen += wps_offset;
-
- wps_ielen = (uint)pmlmepriv->wps_probe_resp_ie[1];/* to get ie data len */
- if ((wps_offset+wps_ielen+2) <= MAX_IE_SZ) {
- memcpy(pframe, pmlmepriv->wps_probe_resp_ie, wps_ielen+2);
- pframe += wps_ielen+2;
- pktlen += wps_ielen+2;
- }
-
- if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) {
- memcpy(pframe, premainder_ie, remainder_ielen);
- pframe += remainder_ielen;
- pktlen += remainder_ielen;
- }
- } else {
- memcpy(pframe, cur_network->IEs, cur_network->IELength);
- pframe += cur_network->IELength;
- pktlen += cur_network->IELength;
- }
-
- /* retrieve SSID IE from cur_network->Ssid */
- {
- u8 *ssid_ie;
- sint ssid_ielen;
- sint ssid_ielen_diff;
- u8 buf[MAX_IE_SZ];
- u8 *ies = pframe + sizeof(struct ieee80211_hdr_3addr);
-
- ssid_ie = rtw_get_ie(ies+_FIXED_IE_LENGTH_, WLAN_EID_SSID, &ssid_ielen,
- (pframe-ies)-_FIXED_IE_LENGTH_);
-
- ssid_ielen_diff = cur_network->Ssid.SsidLength - ssid_ielen;
-
- if (ssid_ie && cur_network->Ssid.SsidLength) {
- uint remainder_ielen;
- u8 *remainder_ie;
- remainder_ie = ssid_ie+2;
- remainder_ielen = (pframe-remainder_ie);
-
- if (remainder_ielen > MAX_IE_SZ) {
- DBG_871X_LEVEL(_drv_warning_, FUNC_ADPT_FMT" remainder_ielen > MAX_IE_SZ\n", FUNC_ADPT_ARG(padapter));
- remainder_ielen = MAX_IE_SZ;
- }
-
- memcpy(buf, remainder_ie, remainder_ielen);
- memcpy(remainder_ie+ssid_ielen_diff, buf, remainder_ielen);
- *(ssid_ie+1) = cur_network->Ssid.SsidLength;
- memcpy(ssid_ie+2, cur_network->Ssid.Ssid, cur_network->Ssid.SsidLength);
- pframe += ssid_ielen_diff;
- pktlen += ssid_ielen_diff;
- }
- }
-
- *pLength = pktlen;
-
-}
-#endif /* CONFIG_AP_WOWLAN */
-
/*
* To check if reserved page content is destroyed by beacon because beacon
* is too large.
@@ -832,155 +299,46 @@ void CheckFwRsvdPageContent(struct adapter *Adapter)
{
}
-static void rtl8723b_set_FwRsvdPage_cmd(struct adapter *padapter, PRSVDPAGE_LOC rsvdpageloc)
+static void rtl8723b_set_FwRsvdPage_cmd(struct adapter *padapter, struct rsvdpage_loc *rsvdpageloc)
{
u8 u1H2CRsvdPageParm[H2C_RSVDPAGE_LOC_LEN] = {0};
- DBG_871X("8723BRsvdPageLoc: ProbeRsp =%d PsPoll =%d Null =%d QoSNull =%d BTNull =%d\n",
- rsvdpageloc->LocProbeRsp, rsvdpageloc->LocPsPoll,
- rsvdpageloc->LocNullData, rsvdpageloc->LocQosNull,
- rsvdpageloc->LocBTQosNull);
-
SET_8723B_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1H2CRsvdPageParm, rsvdpageloc->LocProbeRsp);
SET_8723B_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1H2CRsvdPageParm, rsvdpageloc->LocPsPoll);
SET_8723B_H2CCMD_RSVDPAGE_LOC_NULL_DATA(u1H2CRsvdPageParm, rsvdpageloc->LocNullData);
SET_8723B_H2CCMD_RSVDPAGE_LOC_QOS_NULL_DATA(u1H2CRsvdPageParm, rsvdpageloc->LocQosNull);
SET_8723B_H2CCMD_RSVDPAGE_LOC_BT_QOS_NULL_DATA(u1H2CRsvdPageParm, rsvdpageloc->LocBTQosNull);
- RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CRsvdPageParm:", u1H2CRsvdPageParm, H2C_RSVDPAGE_LOC_LEN);
- FillH2CCmd8723B(padapter, H2C_8723B_RSVD_PAGE, H2C_RSVDPAGE_LOC_LEN, u1H2CRsvdPageParm);
-}
-
-static void rtl8723b_set_FwAoacRsvdPage_cmd(struct adapter *padapter, PRSVDPAGE_LOC rsvdpageloc)
-{
-#ifdef CONFIG_WOWLAN
- struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- u8 u1H2CAoacRsvdPageParm[H2C_AOAC_RSVDPAGE_LOC_LEN] = {0};
+ print_hex_dump_debug(DRIVER_PREFIX ": u1H2CRsvdPageParm:", DUMP_PREFIX_NONE,
+ 16, 1, u1H2CRsvdPageParm, H2C_RSVDPAGE_LOC_LEN, false);
- DBG_871X("8723BAOACRsvdPageLoc: RWC =%d ArpRsp =%d NbrAdv =%d GtkRsp =%d GtkInfo =%d ProbeReq =%d NetworkList =%d\n",
- rsvdpageloc->LocRemoteCtrlInfo, rsvdpageloc->LocArpRsp,
- rsvdpageloc->LocNbrAdv, rsvdpageloc->LocGTKRsp,
- rsvdpageloc->LocGTKInfo, rsvdpageloc->LocProbeReq,
- rsvdpageloc->LocNetList);
-
- if (check_fwstate(pmlmepriv, _FW_LINKED)) {
- SET_H2CCMD_AOAC_RSVDPAGE_LOC_REMOTE_WAKE_CTRL_INFO(u1H2CAoacRsvdPageParm, rsvdpageloc->LocRemoteCtrlInfo);
- SET_H2CCMD_AOAC_RSVDPAGE_LOC_ARP_RSP(u1H2CAoacRsvdPageParm, rsvdpageloc->LocArpRsp);
- /* SET_H2CCMD_AOAC_RSVDPAGE_LOC_NEIGHBOR_ADV(u1H2CAoacRsvdPageParm, rsvdpageloc->LocNbrAdv); */
- SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_RSP(u1H2CAoacRsvdPageParm, rsvdpageloc->LocGTKRsp);
- SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_INFO(u1H2CAoacRsvdPageParm, rsvdpageloc->LocGTKInfo);
-#ifdef CONFIG_GTK_OL
- SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_EXT_MEM(u1H2CAoacRsvdPageParm, rsvdpageloc->LocGTKEXTMEM);
-#endif /* CONFIG_GTK_OL */
- RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CAoacRsvdPageParm:", u1H2CAoacRsvdPageParm, H2C_AOAC_RSVDPAGE_LOC_LEN);
- FillH2CCmd8723B(padapter, H2C_8723B_AOAC_RSVD_PAGE, H2C_AOAC_RSVDPAGE_LOC_LEN, u1H2CAoacRsvdPageParm);
- } else {
-#ifdef CONFIG_PNO_SUPPORT
- if (!pwrpriv->pno_in_resume) {
- DBG_871X("NLO_INFO =%d\n", rsvdpageloc->LocPNOInfo);
- memset(&u1H2CAoacRsvdPageParm, 0, sizeof(u1H2CAoacRsvdPageParm));
- SET_H2CCMD_AOAC_RSVDPAGE_LOC_NLO_INFO(u1H2CAoacRsvdPageParm, rsvdpageloc->LocPNOInfo);
- FillH2CCmd8723B(padapter, H2C_AOAC_RSVDPAGE3, H2C_AOAC_RSVDPAGE_LOC_LEN, u1H2CAoacRsvdPageParm);
- msleep(10);
- }
-#endif
- }
-
-#endif /* CONFIG_WOWLAN */
+ FillH2CCmd8723B(padapter, H2C_8723B_RSVD_PAGE, H2C_RSVDPAGE_LOC_LEN, u1H2CRsvdPageParm);
}
-#ifdef CONFIG_AP_WOWLAN
-static void rtl8723b_set_ap_wow_rsvdpage_cmd(
- struct adapter *padapter, PRSVDPAGE_LOC rsvdpageloc
-)
+static void rtl8723b_set_FwAoacRsvdPage_cmd(struct adapter *padapter, struct rsvdpage_loc *rsvdpageloc)
{
- u8 header;
- u8 rsvdparm[H2C_AOAC_RSVDPAGE_LOC_LEN] = {0};
-
- header = rtw_read8(padapter, REG_BCNQ_BDNY);
-
- DBG_871X("%s: beacon: %d, probeRsp: %d, header:0x%02x\n", __func__,
- rsvdpageloc->LocApOffloadBCN,
- rsvdpageloc->LocProbeRsp,
- header);
-
- SET_H2CCMD_AP_WOWLAN_RSVDPAGE_LOC_BCN(rsvdparm,
- rsvdpageloc->LocApOffloadBCN + header);
-
- FillH2CCmd8723B(padapter, H2C_8723B_BCN_RSVDPAGE,
- H2C_BCN_RSVDPAGE_LEN, rsvdparm);
-
- msleep(10);
-
- memset(&rsvdparm, 0, sizeof(rsvdparm));
-
- SET_H2CCMD_AP_WOWLAN_RSVDPAGE_LOC_ProbeRsp(
- rsvdparm,
- rsvdpageloc->LocProbeRsp + header);
-
- FillH2CCmd8723B(padapter, H2C_8723B_PROBERSP_RSVDPAGE,
- H2C_PROBERSP_RSVDPAGE_LEN, rsvdparm);
-
- msleep(10);
}
-#endif /* CONFIG_AP_WOWLAN */
void rtl8723b_set_FwMediaStatusRpt_cmd(struct adapter *padapter, u8 mstatus, u8 macid)
{
u8 u1H2CMediaStatusRptParm[H2C_MEDIA_STATUS_RPT_LEN] = {0};
u8 macid_end = 0;
- DBG_871X("%s(): mstatus = %d macid =%d\n", __func__, mstatus, macid);
-
SET_8723B_H2CCMD_MSRRPT_PARM_OPMODE(u1H2CMediaStatusRptParm, mstatus);
SET_8723B_H2CCMD_MSRRPT_PARM_MACID_IND(u1H2CMediaStatusRptParm, 0);
SET_8723B_H2CCMD_MSRRPT_PARM_MACID(u1H2CMediaStatusRptParm, macid);
SET_8723B_H2CCMD_MSRRPT_PARM_MACID_END(u1H2CMediaStatusRptParm, macid_end);
- RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CMediaStatusRptParm:", u1H2CMediaStatusRptParm, H2C_MEDIA_STATUS_RPT_LEN);
- FillH2CCmd8723B(padapter, H2C_8723B_MEDIA_STATUS_RPT, H2C_MEDIA_STATUS_RPT_LEN, u1H2CMediaStatusRptParm);
-}
-
-#ifdef CONFIG_WOWLAN
-static void rtl8723b_set_FwKeepAlive_cmd(struct adapter *padapter, u8 benable, u8 pkt_type)
-{
- u8 u1H2CKeepAliveParm[H2C_KEEP_ALIVE_CTRL_LEN] = {0};
- u8 adopt = 1, check_period = 5;
-
- DBG_871X("%s(): benable = %d\n", __func__, benable);
- SET_8723B_H2CCMD_KEEPALIVE_PARM_ENABLE(u1H2CKeepAliveParm, benable);
- SET_8723B_H2CCMD_KEEPALIVE_PARM_ADOPT(u1H2CKeepAliveParm, adopt);
- SET_8723B_H2CCMD_KEEPALIVE_PARM_PKT_TYPE(u1H2CKeepAliveParm, pkt_type);
- SET_8723B_H2CCMD_KEEPALIVE_PARM_CHECK_PERIOD(u1H2CKeepAliveParm, check_period);
-
- RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CKeepAliveParm:", u1H2CKeepAliveParm, H2C_KEEP_ALIVE_CTRL_LEN);
+ print_hex_dump_debug(DRIVER_PREFIX ": u1H2CMediaStatusRptParm:", DUMP_PREFIX_NONE,
+ 16, 1, u1H2CMediaStatusRptParm, H2C_MEDIA_STATUS_RPT_LEN, false);
- FillH2CCmd8723B(padapter, H2C_8723B_KEEP_ALIVE, H2C_KEEP_ALIVE_CTRL_LEN, u1H2CKeepAliveParm);
-}
-
-static void rtl8723b_set_FwDisconDecision_cmd(struct adapter *padapter, u8 benable)
-{
- u8 u1H2CDisconDecisionParm[H2C_DISCON_DECISION_LEN] = {0};
- u8 adopt = 1, check_period = 10, trypkt_num = 0;
-
- DBG_871X("%s(): benable = %d\n", __func__, benable);
- SET_8723B_H2CCMD_DISCONDECISION_PARM_ENABLE(u1H2CDisconDecisionParm, benable);
- SET_8723B_H2CCMD_DISCONDECISION_PARM_ADOPT(u1H2CDisconDecisionParm, adopt);
- SET_8723B_H2CCMD_DISCONDECISION_PARM_CHECK_PERIOD(u1H2CDisconDecisionParm, check_period);
- SET_8723B_H2CCMD_DISCONDECISION_PARM_TRY_PKT_NUM(u1H2CDisconDecisionParm, trypkt_num);
-
- RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CDisconDecisionParm:", u1H2CDisconDecisionParm, H2C_DISCON_DECISION_LEN);
-
- FillH2CCmd8723B(padapter, H2C_8723B_DISCON_DECISION, H2C_DISCON_DECISION_LEN, u1H2CDisconDecisionParm);
+ FillH2CCmd8723B(padapter, H2C_8723B_MEDIA_STATUS_RPT, H2C_MEDIA_STATUS_RPT_LEN, u1H2CMediaStatusRptParm);
}
-#endif /* CONFIG_WOWLAN */
void rtl8723b_set_FwMacIdConfig_cmd(struct adapter *padapter, u8 mac_id, u8 raid, u8 bw, u8 sgi, u32 mask)
{
u8 u1H2CMacIdConfigParm[H2C_MACID_CFG_LEN] = {0};
- DBG_871X("%s(): mac_id =%d raid = 0x%x bw =%d mask = 0x%x\n", __func__, mac_id, raid, bw, mask);
-
SET_8723B_H2CCMD_MACID_CFG_MACID(u1H2CMacIdConfigParm, mac_id);
SET_8723B_H2CCMD_MACID_CFG_RAID(u1H2CMacIdConfigParm, raid);
SET_8723B_H2CCMD_MACID_CFG_SGI_EN(u1H2CMacIdConfigParm, sgi ? 1 : 0);
@@ -990,7 +348,9 @@ void rtl8723b_set_FwMacIdConfig_cmd(struct adapter *padapter, u8 mac_id, u8 raid
SET_8723B_H2CCMD_MACID_CFG_RATE_MASK2(u1H2CMacIdConfigParm, (u8)((mask & 0x00ff0000) >> 16));
SET_8723B_H2CCMD_MACID_CFG_RATE_MASK3(u1H2CMacIdConfigParm, (u8)((mask & 0xff000000) >> 24));
- RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CMacIdConfigParm:", u1H2CMacIdConfigParm, H2C_MACID_CFG_LEN);
+ print_hex_dump_debug(DRIVER_PREFIX ": u1H2CMacIdConfigParm:", DUMP_PREFIX_NONE,
+ 16, 1, u1H2CMacIdConfigParm, H2C_MACID_CFG_LEN, false);
+
FillH2CCmd8723B(padapter, H2C_8723B_MACID_CFG, H2C_MACID_CFG_LEN, u1H2CMacIdConfigParm);
}
@@ -1001,14 +361,13 @@ void rtl8723b_set_rssi_cmd(struct adapter *padapter, u8 *param)
u8 rssi = *(param+2);
u8 uldl_state = 0;
- /* DBG_871X("%s(): param =%.2x-%.2x-%.2x\n", __func__, *param, *(param+1), *(param+2)); */
- /* DBG_871X("%s(): mac_id =%d rssi =%d\n", __func__, mac_id, rssi); */
-
SET_8723B_H2CCMD_RSSI_SETTING_MACID(u1H2CRssiSettingParm, mac_id);
SET_8723B_H2CCMD_RSSI_SETTING_RSSI(u1H2CRssiSettingParm, rssi);
SET_8723B_H2CCMD_RSSI_SETTING_ULDL_STATE(u1H2CRssiSettingParm, uldl_state);
- RT_PRINT_DATA(_module_hal_init_c_, _drv_notice_, "u1H2CRssiSettingParm:", u1H2CRssiSettingParm, H2C_RSSI_SETTING_LEN);
+ print_hex_dump_debug(DRIVER_PREFIX ": u1H2CRssiSettingParm:", DUMP_PREFIX_NONE,
+ 16, 1, u1H2CRssiSettingParm, H2C_RSSI_SETTING_LEN, false);
+
FillH2CCmd8723B(padapter, H2C_8723B_RSSI_SETTING, H2C_RSSI_SETTING_LEN, u1H2CRssiSettingParm);
}
@@ -1020,26 +379,12 @@ void rtl8723b_set_FwPwrMode_cmd(struct adapter *padapter, u8 psmode)
u8 u1H2CPwrModeParm[H2C_PWRMODE_LEN] = {0};
u8 PowerState = 0, awake_intvl = 1, byte5 = 0, rlbm = 0;
- if (pwrpriv->dtim > 0)
- DBG_871X("%s(): FW LPS mode = %d, SmartPS =%d, dtim =%d\n", __func__, psmode, pwrpriv->smart_ps, pwrpriv->dtim);
+ if (pwrpriv->dtim > 0 && pwrpriv->dtim < 16)
+ awake_intvl = pwrpriv->dtim+1;/* DTIM = (awake_intvl - 1) */
else
- DBG_871X("%s(): FW LPS mode = %d, SmartPS =%d\n", __func__, psmode, pwrpriv->smart_ps);
-
-#ifdef CONFIG_WOWLAN
- if (psmode == PS_MODE_DTIM) { /* For WOWLAN LPS, DTIM = (awake_intvl - 1) */
awake_intvl = 3;/* DTIM =2 */
- rlbm = 2;
- } else
-#endif /* CONFIG_WOWLAN */
- {
- if (pwrpriv->dtim > 0 && pwrpriv->dtim < 16)
- awake_intvl = pwrpriv->dtim+1;/* DTIM = (awake_intvl - 1) */
- else
- awake_intvl = 3;/* DTIM =2 */
-
- rlbm = 2;
- }
+ rlbm = 2;
if (padapter->registrypriv.wifi_spec == 1) {
awake_intvl = 2;
@@ -1085,32 +430,17 @@ void rtl8723b_set_FwPwrMode_cmd(struct adapter *padapter, u8 psmode)
pmlmeext->DrvBcnEarly = 0xff;
pmlmeext->DrvBcnTimeOut = 0xff;
- DBG_871X("%s(): bcn_cnt = %d\n", __func__, pmlmeext->bcn_cnt);
-
for (i = 0; i < 9; i++) {
pmlmeext->bcn_delay_ratio[i] = (pmlmeext->bcn_delay_cnt[i]*100)/pmlmeext->bcn_cnt;
- DBG_871X(
- "%s(): bcn_delay_cnt[%d]=%d, bcn_delay_ratio[%d] = %d\n",
- __func__,
- i,
- pmlmeext->bcn_delay_cnt[i],
- i,
- pmlmeext->bcn_delay_ratio[i]
- );
-
ratio_20_delay += pmlmeext->bcn_delay_ratio[i];
ratio_80_delay += pmlmeext->bcn_delay_ratio[i];
- if (ratio_20_delay > 20 && pmlmeext->DrvBcnEarly == 0xff) {
+ if (ratio_20_delay > 20 && pmlmeext->DrvBcnEarly == 0xff)
pmlmeext->DrvBcnEarly = i;
- DBG_871X("%s(): DrvBcnEarly = %d\n", __func__, pmlmeext->DrvBcnEarly);
- }
- if (ratio_80_delay > 80 && pmlmeext->DrvBcnTimeOut == 0xff) {
+ if (ratio_80_delay > 80 && pmlmeext->DrvBcnTimeOut == 0xff)
pmlmeext->DrvBcnTimeOut = i;
- DBG_871X("%s(): DrvBcnTimeOut = %d\n", __func__, pmlmeext->DrvBcnTimeOut);
- }
/* reset adaptive_early_32k cnt */
pmlmeext->bcn_delay_cnt[i] = 0;
@@ -1121,9 +451,6 @@ void rtl8723b_set_FwPwrMode_cmd(struct adapter *padapter, u8 psmode)
pmlmeext->bcn_cnt = 0;
pmlmeext->adaptive_tsf_done = true;
- } else {
- DBG_871X("%s(): DrvBcnEarly = %d\n", __func__, pmlmeext->DrvBcnEarly);
- DBG_871X("%s(): DrvBcnTimeOut = %d\n", __func__, pmlmeext->DrvBcnTimeOut);
}
/* offload to FW if fw version > v15.10
@@ -1138,7 +465,8 @@ void rtl8723b_set_FwPwrMode_cmd(struct adapter *padapter, u8 psmode)
hal_btcoex_RecordPwrMode(padapter, u1H2CPwrModeParm, H2C_PWRMODE_LEN);
- RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CPwrModeParm:", u1H2CPwrModeParm, H2C_PWRMODE_LEN);
+ print_hex_dump_debug(DRIVER_PREFIX ": u1H2CPwrModeParm:", DUMP_PREFIX_NONE,
+ 16, 1, u1H2CPwrModeParm, H2C_PWRMODE_LEN, false);
FillH2CCmd8723B(padapter, H2C_8723B_SET_PWR_MODE, H2C_PWRMODE_LEN, u1H2CPwrModeParm);
}
@@ -1151,267 +479,24 @@ void rtl8723b_set_FwPsTuneParam_cmd(struct adapter *padapter)
u8 ps_timeout = 20; /* ms Keep awake when tx */
u8 dtim_period = 3;
- /* DBG_871X("%s(): FW LPS mode = %d\n", __func__, psmode); */
-
SET_8723B_H2CCMD_PSTUNE_PARM_BCN_TO_LIMIT(u1H2CPsTuneParm, bcn_to_limit);
SET_8723B_H2CCMD_PSTUNE_PARM_DTIM_TIMEOUT(u1H2CPsTuneParm, dtim_timeout);
SET_8723B_H2CCMD_PSTUNE_PARM_PS_TIMEOUT(u1H2CPsTuneParm, ps_timeout);
SET_8723B_H2CCMD_PSTUNE_PARM_ADOPT(u1H2CPsTuneParm, 1);
SET_8723B_H2CCMD_PSTUNE_PARM_DTIM_PERIOD(u1H2CPsTuneParm, dtim_period);
- RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CPsTuneParm:", u1H2CPsTuneParm, H2C_PSTUNEPARAM_LEN);
+ print_hex_dump_debug(DRIVER_PREFIX ": u1H2CPsTuneParm:", DUMP_PREFIX_NONE,
+ 16, 1, u1H2CPsTuneParm, H2C_PSTUNEPARAM_LEN, false);
FillH2CCmd8723B(padapter, H2C_8723B_PS_TUNING_PARA, H2C_PSTUNEPARAM_LEN, u1H2CPsTuneParm);
}
void rtl8723b_set_FwPwrModeInIPS_cmd(struct adapter *padapter, u8 cmd_param)
{
- /* BIT0:enable, BIT1:NoConnect32k */
-
- DBG_871X("%s()\n", __func__);
FillH2CCmd8723B(padapter, H2C_8723B_FWLPS_IN_IPS_, 1, &cmd_param);
}
-#ifdef CONFIG_WOWLAN
-static void rtl8723b_set_FwWoWlanCtrl_Cmd(struct adapter *padapter, u8 bFuncEn)
-{
- struct security_priv *psecpriv = &padapter->securitypriv;
- u8 u1H2CWoWlanCtrlParm[H2C_WOWLAN_LEN] = {0};
- u8 discont_wake = 1, gpionum = 0, gpio_dur = 0, hw_unicast = 0;
- u8 sdio_wakeup_enable = 1;
- u8 gpio_high_active = 0; /* 0: low active, 1: high active */
- u8 magic_pkt = 0;
-
-#ifdef CONFIG_GPIO_WAKEUP
- gpionum = WAKEUP_GPIO_IDX;
- sdio_wakeup_enable = 0;
-#endif
-
-#ifdef CONFIG_PNO_SUPPORT
- if (!ppwrpriv->wowlan_pno_enable)
- magic_pkt = 1;
-#endif
-
- if (psecpriv->dot11PrivacyAlgrthm == _WEP40_ || psecpriv->dot11PrivacyAlgrthm == _WEP104_)
- hw_unicast = 1;
-
- DBG_871X("%s(): bFuncEn =%d\n", __func__, bFuncEn);
-
- SET_H2CCMD_WOWLAN_FUNC_ENABLE(u1H2CWoWlanCtrlParm, bFuncEn);
- SET_H2CCMD_WOWLAN_PATTERN_MATCH_ENABLE(u1H2CWoWlanCtrlParm, 0);
- SET_H2CCMD_WOWLAN_MAGIC_PKT_ENABLE(u1H2CWoWlanCtrlParm, magic_pkt);
- SET_H2CCMD_WOWLAN_UNICAST_PKT_ENABLE(u1H2CWoWlanCtrlParm, hw_unicast);
- SET_H2CCMD_WOWLAN_ALL_PKT_DROP(u1H2CWoWlanCtrlParm, 0);
- SET_H2CCMD_WOWLAN_GPIO_ACTIVE(u1H2CWoWlanCtrlParm, gpio_high_active);
- SET_H2CCMD_WOWLAN_DISCONNECT_WAKE_UP(u1H2CWoWlanCtrlParm, discont_wake);
- SET_H2CCMD_WOWLAN_GPIONUM(u1H2CWoWlanCtrlParm, gpionum);
- SET_H2CCMD_WOWLAN_DATAPIN_WAKE_UP(u1H2CWoWlanCtrlParm, sdio_wakeup_enable);
- SET_H2CCMD_WOWLAN_GPIO_DURATION(u1H2CWoWlanCtrlParm, gpio_dur);
- /* SET_H2CCMD_WOWLAN_GPIO_PULSE_EN(u1H2CWoWlanCtrlParm, 1); */
- SET_H2CCMD_WOWLAN_GPIO_PULSE_COUNT(u1H2CWoWlanCtrlParm, 0x09);
-
- RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CWoWlanCtrlParm:", u1H2CWoWlanCtrlParm, H2C_WOWLAN_LEN);
-
- FillH2CCmd8723B(padapter, H2C_8723B_WOWLAN, H2C_WOWLAN_LEN, u1H2CWoWlanCtrlParm);
-}
-
-static void rtl8723b_set_FwRemoteWakeCtrl_Cmd(struct adapter *padapter, u8 benable)
-{
- u8 u1H2CRemoteWakeCtrlParm[H2C_REMOTE_WAKE_CTRL_LEN] = {0};
- struct security_priv *psecuritypriv = &(padapter->securitypriv);
- struct pwrctrl_priv *ppwrpriv = adapter_to_pwrctl(padapter);
-
- DBG_871X("%s(): Enable =%d\n", __func__, benable);
-
- if (!ppwrpriv->wowlan_pno_enable) {
- SET_H2CCMD_REMOTE_WAKECTRL_ENABLE(u1H2CRemoteWakeCtrlParm, benable);
- SET_H2CCMD_REMOTE_WAKE_CTRL_ARP_OFFLOAD_EN(u1H2CRemoteWakeCtrlParm, 1);
-#ifdef CONFIG_GTK_OL
- if (psecuritypriv->binstallKCK_KEK &&
- psecuritypriv->dot11PrivacyAlgrthm == _AES_) {
- SET_H2CCMD_REMOTE_WAKE_CTRL_GTK_OFFLOAD_EN(u1H2CRemoteWakeCtrlParm, 1);
- } else {
- DBG_871X("no kck or security is not AES\n");
- SET_H2CCMD_REMOTE_WAKE_CTRL_GTK_OFFLOAD_EN(u1H2CRemoteWakeCtrlParm, 0);
- }
-#endif /* CONFIG_GTK_OL */
-
- SET_H2CCMD_REMOTE_WAKE_CTRL_FW_UNICAST_EN(u1H2CRemoteWakeCtrlParm, 1);
-
- if ((psecuritypriv->dot11PrivacyAlgrthm == _AES_) ||
- (psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_))
- SET_H2CCMD_REMOTE_WAKE_CTRL_ARP_ACTION(u1H2CRemoteWakeCtrlParm, 0);
- else
- SET_H2CCMD_REMOTE_WAKE_CTRL_ARP_ACTION(u1H2CRemoteWakeCtrlParm, 1);
- }
-#ifdef CONFIG_PNO_SUPPORT
- else {
- SET_H2CCMD_REMOTE_WAKECTRL_ENABLE(u1H2CRemoteWakeCtrlParm, benable);
- SET_H2CCMD_REMOTE_WAKE_CTRL_NLO_OFFLOAD_EN(u1H2CRemoteWakeCtrlParm, benable);
- }
-#endif
- RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CRemoteWakeCtrlParm:", u1H2CRemoteWakeCtrlParm, H2C_REMOTE_WAKE_CTRL_LEN);
- FillH2CCmd8723B(padapter, H2C_8723B_REMOTE_WAKE_CTRL,
- H2C_REMOTE_WAKE_CTRL_LEN, u1H2CRemoteWakeCtrlParm);
-#ifdef CONFIG_PNO_SUPPORT
- if (ppwrpriv->wowlan_pno_enable && !ppwrpriv->pno_in_resume) {
- res = rtw_read8(padapter, REG_PNO_STATUS);
- DBG_871X("cmd: 0x81 REG_PNO_STATUS: 0x%02x\n", res);
- while (!(res&BIT(7)) && count < 25) {
- DBG_871X("[%d] cmd: 0x81 REG_PNO_STATUS: 0x%02x\n", count, res);
- res = rtw_read8(padapter, REG_PNO_STATUS);
- count++;
- msleep(2);
- }
- DBG_871X("cmd: 0x81 REG_PNO_STATUS: 0x%02x\n", res);
- }
-#endif /* CONFIG_PNO_SUPPORT */
-}
-
-static void rtl8723b_set_FwAOACGlobalInfo_Cmd(struct adapter *padapter, u8 group_alg, u8 pairwise_alg)
-{
- u8 u1H2CAOACGlobalInfoParm[H2C_AOAC_GLOBAL_INFO_LEN] = {0};
-
- DBG_871X("%s(): group_alg =%d pairwise_alg =%d\n", __func__, group_alg, pairwise_alg);
-
- SET_H2CCMD_AOAC_GLOBAL_INFO_PAIRWISE_ENC_ALG(u1H2CAOACGlobalInfoParm, pairwise_alg);
- SET_H2CCMD_AOAC_GLOBAL_INFO_GROUP_ENC_ALG(u1H2CAOACGlobalInfoParm, group_alg);
-
- RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CAOACGlobalInfoParm:", u1H2CAOACGlobalInfoParm, H2C_AOAC_GLOBAL_INFO_LEN);
-
- FillH2CCmd8723B(padapter, H2C_8723B_AOAC_GLOBAL_INFO, H2C_AOAC_GLOBAL_INFO_LEN, u1H2CAOACGlobalInfoParm);
-}
-
-#ifdef CONFIG_PNO_SUPPORT
-static void rtl8723b_set_FwScanOffloadInfo_cmd(struct adapter *padapter, PRSVDPAGE_LOC rsvdpageloc, u8 enable)
-{
- u8 u1H2CScanOffloadInfoParm[H2C_SCAN_OFFLOAD_CTRL_LEN] = {0};
-
- DBG_871X("%s: loc_probe_packet:%d, loc_scan_info: %d loc_ssid_info:%d\n",
- __func__, rsvdpageloc->LocProbePacket, rsvdpageloc->LocScanInfo, rsvdpageloc->LocSSIDInfo);
-
- SET_H2CCMD_AOAC_NLO_FUN_EN(u1H2CScanOffloadInfoParm, enable);
- SET_H2CCMD_AOAC_RSVDPAGE_LOC_SCAN_INFO(u1H2CScanOffloadInfoParm, rsvdpageloc->LocScanInfo);
- SET_H2CCMD_AOAC_RSVDPAGE_LOC_PROBE_PACKET(u1H2CScanOffloadInfoParm, rsvdpageloc->LocProbePacket);
- SET_H2CCMD_AOAC_RSVDPAGE_LOC_SSID_INFO(u1H2CScanOffloadInfoParm, rsvdpageloc->LocSSIDInfo);
-
- RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CScanOffloadInfoParm:", u1H2CScanOffloadInfoParm, H2C_SCAN_OFFLOAD_CTRL_LEN);
- FillH2CCmd8723B(padapter, H2C_8723B_D0_SCAN_OFFLOAD_INFO, H2C_SCAN_OFFLOAD_CTRL_LEN, u1H2CScanOffloadInfoParm);
-
- msleep(20);
-}
-#endif /* CONFIG_PNO_SUPPORT */
-
-void rtl8723b_set_wowlan_cmd(struct adapter *padapter, u8 enable)
-{
- struct security_priv *psecpriv = &padapter->securitypriv;
- struct pwrctrl_priv *ppwrpriv = adapter_to_pwrctl(padapter);
- struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- struct sta_info *psta = NULL;
- u8 pkt_type = 0;
-
- DBG_871X_LEVEL(_drv_always_, "+%s()+: enable =%d\n", __func__, enable);
- if (enable) {
- rtl8723b_set_FwAOACGlobalInfo_Cmd(padapter, psecpriv->dot118021XGrpPrivacy, psecpriv->dot11PrivacyAlgrthm);
-
- rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT); /* RT_MEDIA_CONNECT will confuse in the future */
-
- if (!(ppwrpriv->wowlan_pno_enable)) {
- psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(pmlmepriv));
- if (psta)
- rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_CONNECT, psta->mac_id);
- } else
- DBG_871X("%s(): Disconnected, no FwMediaStatusRpt CONNECT\n", __func__);
-
- msleep(2);
-
- if (!(ppwrpriv->wowlan_pno_enable)) {
- rtl8723b_set_FwDisconDecision_cmd(padapter, enable);
- msleep(2);
-
- if ((psecpriv->dot11PrivacyAlgrthm != _WEP40_) || (psecpriv->dot11PrivacyAlgrthm != _WEP104_))
- pkt_type = 1;
-
- rtl8723b_set_FwKeepAlive_cmd(padapter, enable, pkt_type);
- msleep(2);
- }
-
- rtl8723b_set_FwWoWlanCtrl_Cmd(padapter, enable);
- msleep(2);
-
- rtl8723b_set_FwRemoteWakeCtrl_Cmd(padapter, enable);
- } else {
- rtl8723b_set_FwRemoteWakeCtrl_Cmd(padapter, enable);
- msleep(2);
- rtl8723b_set_FwWoWlanCtrl_Cmd(padapter, enable);
- }
-
- DBG_871X_LEVEL(_drv_always_, "-%s()-\n", __func__);
-}
-#endif /* CONFIG_WOWLAN */
-
-#ifdef CONFIG_AP_WOWLAN
-static void rtl8723b_set_FwAPWoWlanCtrl_Cmd(struct adapter *padapter, u8 bFuncEn)
-{
- u8 u1H2CAPWoWlanCtrlParm[H2C_WOWLAN_LEN] = {0};
- u8 gpionum = 0, gpio_dur = 0;
- u8 gpio_high_active = 1; /* 0: low active, 1: high active */
- u8 gpio_pulse = bFuncEn;
-#ifdef CONFIG_GPIO_WAKEUP
- gpionum = WAKEUP_GPIO_IDX;
-#endif
-
- DBG_871X("%s(): bFuncEn =%d\n", __func__, bFuncEn);
-
- if (bFuncEn)
- gpio_dur = 16;
- else
- gpio_dur = 0;
-
- SET_H2CCMD_AP_WOW_GPIO_CTRL_INDEX(u1H2CAPWoWlanCtrlParm,
- gpionum);
- SET_H2CCMD_AP_WOW_GPIO_CTRL_PLUS(u1H2CAPWoWlanCtrlParm,
- gpio_pulse);
- SET_H2CCMD_AP_WOW_GPIO_CTRL_HIGH_ACTIVE(u1H2CAPWoWlanCtrlParm,
- gpio_high_active);
- SET_H2CCMD_AP_WOW_GPIO_CTRL_EN(u1H2CAPWoWlanCtrlParm,
- bFuncEn);
- SET_H2CCMD_AP_WOW_GPIO_CTRL_DURATION(u1H2CAPWoWlanCtrlParm,
- gpio_dur);
-
- FillH2CCmd8723B(padapter, H2C_8723B_AP_WOW_GPIO_CTRL,
- H2C_AP_WOW_GPIO_CTRL_LEN, u1H2CAPWoWlanCtrlParm);
-}
-
-static void rtl8723b_set_Fw_AP_Offload_Cmd(struct adapter *padapter, u8 bFuncEn)
-{
- u8 u1H2CAPOffloadCtrlParm[H2C_WOWLAN_LEN] = {0};
-
- DBG_871X("%s(): bFuncEn =%d\n", __func__, bFuncEn);
-
- SET_H2CCMD_AP_WOWLAN_EN(u1H2CAPOffloadCtrlParm, bFuncEn);
-
- FillH2CCmd8723B(padapter, H2C_8723B_AP_OFFLOAD,
- H2C_AP_OFFLOAD_LEN, u1H2CAPOffloadCtrlParm);
-}
-
-void rtl8723b_set_ap_wowlan_cmd(struct adapter *padapter, u8 enable)
-{
- DBG_871X_LEVEL(_drv_always_, "+%s()+: enable =%d\n", __func__, enable);
- if (enable) {
- rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT);
- issue_beacon(padapter, 0);
- }
-
- rtl8723b_set_FwAPWoWlanCtrl_Cmd(padapter, enable);
- msleep(10);
- rtl8723b_set_Fw_AP_Offload_Cmd(padapter, enable);
- msleep(10);
- DBG_871X_LEVEL(_drv_always_, "-%s()-\n", __func__);
-}
-#endif /* CONFIG_AP_WOWLAN */
-
/*
* Description: Fill the reserved packets that FW will use to RSVD page.
* Now we just send 4 types packet to rsvd page.
@@ -1435,7 +520,6 @@ static void rtl8723b_set_FwRsvdPagePkt(
struct xmit_priv *pxmitpriv;
struct mlme_ext_priv *pmlmeext;
struct mlme_ext_info *pmlmeinfo;
- struct pwrctrl_priv *pwrctl;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
u32 BeaconLength = 0, PSPollLength = 0;
u32 NullDataLength = 0, QosNullLength = 0, BTQosNullLength = 0;
@@ -1444,37 +528,22 @@ static void rtl8723b_set_FwRsvdPagePkt(
u8 TotalPageNum = 0, CurtPktPageNum = 0, RsvdPageNum = 0;
u16 BufIndex, PageSize = 128;
u32 TotalPacketLen, MaxRsvdPageBufSize = 0;
- RSVDPAGE_LOC RsvdPageLoc;
-#ifdef CONFIG_WOWLAN
- u32 ARPLegnth = 0, GTKLegnth = 0;
- u8 currentip[4];
- u8 cur_dot11txpn[8];
-#ifdef CONFIG_GTK_OL
- struct sta_priv *pstapriv = &padapter->stapriv;
- struct sta_info *psta;
- u8 kek[RTW_KEK_LEN];
- u8 kck[RTW_KCK_LEN];
-#endif
-#endif
- /* DBG_871X("%s---->\n", __func__); */
+ struct rsvdpage_loc RsvdPageLoc;
pxmitpriv = &padapter->xmitpriv;
pmlmeext = &padapter->mlmeextpriv;
pmlmeinfo = &pmlmeext->mlmext_info;
- pwrctl = adapter_to_pwrctl(padapter);
RsvdPageNum = BCNQ_PAGE_NUM_8723B + WOWLAN_PAGE_NUM_8723B;
MaxRsvdPageBufSize = RsvdPageNum*PageSize;
pcmdframe = rtw_alloc_cmdxmitframe(pxmitpriv);
- if (!pcmdframe) {
- DBG_871X("%s: alloc ReservedPagePacket fail!\n", __func__);
+ if (!pcmdframe)
return;
- }
ReservedPagePacket = pcmdframe->buf_addr;
- memset(&RsvdPageLoc, 0, sizeof(RSVDPAGE_LOC));
+ memset(&RsvdPageLoc, 0, sizeof(struct rsvdpage_loc));
/* 3 (1) beacon */
BufIndex = TxDescOffset;
@@ -1496,9 +565,6 @@ static void rtl8723b_set_FwRsvdPagePkt(
ConstructPSPoll(padapter, &ReservedPagePacket[BufIndex], &PSPollLength);
rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], PSPollLength, true, false, false);
- /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: PS-POLL %p %d\n", */
- /* __func__, &ReservedPagePacket[BufIndex-TxDescLen], (PSPollLength+TxDescLen)); */
-
CurtPktPageNum = (u8)PageNum_128(TxDescLen + PSPollLength);
TotalPageNum += CurtPktPageNum;
@@ -1516,9 +582,6 @@ static void rtl8723b_set_FwRsvdPagePkt(
);
rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], NullDataLength, false, false, false);
- /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: NULL DATA %p %d\n", */
- /* __func__, &ReservedPagePacket[BufIndex-TxDescLen], (NullDataLength+TxDescLen)); */
-
CurtPktPageNum = (u8)PageNum_128(TxDescLen + NullDataLength);
TotalPageNum += CurtPktPageNum;
@@ -1536,9 +599,6 @@ static void rtl8723b_set_FwRsvdPagePkt(
);
rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], QosNullLength, false, false, false);
- /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: QOS NULL DATA %p %d\n", */
- /* __func__, &ReservedPagePacket[BufIndex-TxDescLen], (QosNullLength+TxDescLen)); */
-
CurtPktPageNum = (u8)PageNum_128(TxDescLen + QosNullLength);
TotalPageNum += CurtPktPageNum;
@@ -1556,215 +616,15 @@ static void rtl8723b_set_FwRsvdPagePkt(
);
rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], BTQosNullLength, false, true, false);
- /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: BT QOS NULL DATA %p %d\n", */
- /* __func__, &ReservedPagePacket[BufIndex-TxDescLen], (BTQosNullLength+TxDescLen)); */
-
CurtPktPageNum = (u8)PageNum_128(TxDescLen + BTQosNullLength);
TotalPageNum += CurtPktPageNum;
BufIndex += (CurtPktPageNum*PageSize);
-#ifdef CONFIG_WOWLAN
- if (check_fwstate(pmlmepriv, _FW_LINKED)) {
- /* if (pwrctl->wowlan_mode == true) { */
- /* BufIndex += (CurtPktPageNum*PageSize); */
-
- /* 3(7) ARP RSP */
- rtw_get_current_ip_address(padapter, currentip);
- RsvdPageLoc.LocArpRsp = TotalPageNum;
- {
- ConstructARPResponse(
- padapter,
- &ReservedPagePacket[BufIndex],
- &ARPLegnth,
- currentip
- );
- rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], ARPLegnth, false, false, true);
-
- /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: ARP RSP %p %d\n", */
- /* __func__, &ReservedPagePacket[BufIndex-TxDescLen], (ARPLegnth+TxDescLen)); */
-
- CurtPktPageNum = (u8)PageNum_128(TxDescLen + ARPLegnth);
- }
- TotalPageNum += CurtPktPageNum;
-
- BufIndex += (CurtPktPageNum*PageSize);
-
- /* 3(8) SEC IV */
- rtw_get_sec_iv(padapter, cur_dot11txpn, get_my_bssid(&pmlmeinfo->network));
- RsvdPageLoc.LocRemoteCtrlInfo = TotalPageNum;
- memcpy(ReservedPagePacket+BufIndex-TxDescLen, cur_dot11txpn, _AES_IV_LEN_);
-
- /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: SEC IV %p %d\n", */
- /* __func__, &ReservedPagePacket[BufIndex-TxDescLen], _AES_IV_LEN_); */
-
- CurtPktPageNum = (u8)PageNum_128(_AES_IV_LEN_);
-
- TotalPageNum += CurtPktPageNum;
-
-#ifdef CONFIG_GTK_OL
- BufIndex += (CurtPktPageNum*PageSize);
-
- /* if the ap station info. exists, get the kek, kck from station info. */
- psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv));
- if (!psta) {
- memset(kek, 0, RTW_KEK_LEN);
- memset(kck, 0, RTW_KCK_LEN);
- DBG_8192C("%s, KEK, KCK download rsvd page all zero\n", __func__);
- } else {
- memcpy(kek, psta->kek, RTW_KEK_LEN);
- memcpy(kck, psta->kck, RTW_KCK_LEN);
- }
-
- /* 3(9) KEK, KCK */
- RsvdPageLoc.LocGTKInfo = TotalPageNum;
- memcpy(ReservedPagePacket+BufIndex-TxDescLen, kck, RTW_KCK_LEN);
- memcpy(ReservedPagePacket+BufIndex-TxDescLen+RTW_KCK_LEN, kek, RTW_KEK_LEN);
-
- /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: KEK KCK %p %d\n", */
- /* __func__, &ReservedPagePacket[BufIndex-TxDescLen], (TxDescLen + RTW_KCK_LEN + RTW_KEK_LEN)); */
-
- CurtPktPageNum = (u8)PageNum_128(TxDescLen + RTW_KCK_LEN + RTW_KEK_LEN);
-
- TotalPageNum += CurtPktPageNum;
-
- BufIndex += (CurtPktPageNum*PageSize);
-
- /* 3(10) GTK Response */
- RsvdPageLoc.LocGTKRsp = TotalPageNum;
- ConstructGTKResponse(
- padapter,
- &ReservedPagePacket[BufIndex],
- &GTKLegnth
- );
-
- rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], GTKLegnth, false, false, true);
- /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: GTK RSP %p %d\n", */
- /* __func__, &ReservedPagePacket[BufIndex-TxDescLen], (TxDescLen + GTKLegnth)); */
-
- CurtPktPageNum = (u8)PageNum_128(TxDescLen + GTKLegnth);
-
- TotalPageNum += CurtPktPageNum;
-
- BufIndex += (CurtPktPageNum*PageSize);
-
- /* below page is empty for GTK extension memory */
- /* 3(11) GTK EXT MEM */
- RsvdPageLoc.LocGTKEXTMEM = TotalPageNum;
-
- CurtPktPageNum = 2;
-
- TotalPageNum += CurtPktPageNum;
-
- TotalPacketLen = BufIndex-TxDescLen + 256; /* extension memory for FW */
-#else
- TotalPacketLen = BufIndex - TxDescLen + sizeof(union pn48); /* IV len */
-#endif /* CONFIG_GTK_OL */
- } else
-#endif /* CONFIG_WOWLAN */
- {
-#ifdef CONFIG_PNO_SUPPORT
- if (!pwrctl->pno_in_resume && pwrctl->pno_inited) {
- /* Probe Request */
- RsvdPageLoc.LocProbePacket = TotalPageNum;
- ConstructProbeReq(
- padapter,
- &ReservedPagePacket[BufIndex],
- &ProbeReqLength);
-
- rtl8723b_fill_fake_txdesc(padapter,
- &ReservedPagePacket[BufIndex-TxDescLen],
- ProbeReqLength, false, false, false);
-#ifdef CONFIG_PNO_SET_DEBUG
- {
- int gj;
- printk("probe req pkt =>\n");
- for (gj = 0; gj < ProbeReqLength+TxDescLen; gj++) {
- printk(" %02x ", ReservedPagePacket[BufIndex-TxDescLen+gj]);
- if ((gj+1)%8 == 0)
- printk("\n");
- }
- printk(" <=end\n");
- }
-#endif
- CurtPktPageNum =
- (u8)PageNum_128(TxDescLen + ProbeReqLength);
-
- TotalPageNum += CurtPktPageNum;
-
- BufIndex += (CurtPktPageNum*PageSize);
-
- /* PNO INFO Page */
- RsvdPageLoc.LocPNOInfo = TotalPageNum;
- ConstructPnoInfo(padapter, &ReservedPagePacket[BufIndex-TxDescLen], &PNOLength);
-#ifdef CONFIG_PNO_SET_DEBUG
- {
- int gj;
- printk("PNO pkt =>\n");
- for (gj = 0; gj < PNOLength; gj++) {
- printk(" %02x ", ReservedPagePacket[BufIndex-TxDescLen+gj]);
- if ((gj + 1)%8 == 0)
- printk("\n");
- }
- printk(" <=end\n");
- }
-#endif
-
- CurtPktPageNum = (u8)PageNum_128(PNOLength);
- TotalPageNum += CurtPktPageNum;
- BufIndex += (CurtPktPageNum*PageSize);
-
- /* SSID List Page */
- RsvdPageLoc.LocSSIDInfo = TotalPageNum;
- ConstructSSIDList(padapter, &ReservedPagePacket[BufIndex-TxDescLen], &SSIDLegnth);
-#ifdef CONFIG_PNO_SET_DEBUG
- {
- int gj;
- printk("SSID list pkt =>\n");
- for (gj = 0; gj < SSIDLegnth; gj++) {
- printk(" %02x ", ReservedPagePacket[BufIndex-TxDescLen+gj]);
- if ((gj + 1)%8 == 0)
- printk("\n");
- }
- printk(" <=end\n");
- }
-#endif
- CurtPktPageNum = (u8)PageNum_128(SSIDLegnth);
- TotalPageNum += CurtPktPageNum;
- BufIndex += (CurtPktPageNum*PageSize);
-
- /* Scan Info Page */
- RsvdPageLoc.LocScanInfo = TotalPageNum;
- ConstructScanInfo(padapter, &ReservedPagePacket[BufIndex-TxDescLen], &ScanInfoLength);
-#ifdef CONFIG_PNO_SET_DEBUG
- {
- int gj;
- printk("Scan info pkt =>\n");
- for (gj = 0; gj < ScanInfoLength; gj++) {
- printk(" %02x ", ReservedPagePacket[BufIndex-TxDescLen+gj]);
- if ((gj + 1)%8 == 0)
- printk("\n");
- }
- printk(" <=end\n");
- }
-#endif
- CurtPktPageNum = (u8)PageNum_128(ScanInfoLength);
- TotalPageNum += CurtPktPageNum;
- BufIndex += (CurtPktPageNum*PageSize);
-
- TotalPacketLen = BufIndex + ScanInfoLength;
- } else {
- TotalPacketLen = BufIndex + BTQosNullLength;
- }
-#else /* CONFIG_PNO_SUPPORT */
- TotalPacketLen = BufIndex + BTQosNullLength;
-#endif
- }
+ TotalPacketLen = BufIndex + BTQosNullLength;
if (TotalPacketLen > MaxRsvdPageBufSize) {
- DBG_871X("%s(): ERROR: The rsvd page size is not enough!!TotalPacketLen %d, MaxRsvdPageBufSize %d\n", __func__,
- TotalPacketLen, MaxRsvdPageBufSize);
goto error;
} else {
/* update attribute */
@@ -1775,20 +635,11 @@ static void rtl8723b_set_FwRsvdPagePkt(
dump_mgntframe_and_wait(padapter, pcmdframe, 100);
}
- DBG_871X("%s: Set RSVD page location to Fw , TotalPacketLen(%d), TotalPageNum(%d)\n", __func__, TotalPacketLen, TotalPageNum);
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
rtl8723b_set_FwRsvdPage_cmd(padapter, &RsvdPageLoc);
rtl8723b_set_FwAoacRsvdPage_cmd(padapter, &RsvdPageLoc);
} else {
rtl8723b_set_FwAoacRsvdPage_cmd(padapter, &RsvdPageLoc);
-#ifdef CONFIG_PNO_SUPPORT
- if (pwrctl->pno_in_resume)
- rtl8723b_set_FwScanOffloadInfo_cmd(padapter,
- &RsvdPageLoc, 0);
- else
- rtl8723b_set_FwScanOffloadInfo_cmd(padapter,
- &RsvdPageLoc, 1);
-#endif
}
return;
@@ -1797,134 +648,9 @@ error:
rtw_free_xmitframe(pxmitpriv, pcmdframe);
}
-#ifdef CONFIG_AP_WOWLAN
-/*
- * Description: Fill the reserved packets that FW will use to RSVD page.
- * Now we just send 2 types packet to rsvd page. (1)Beacon, (2)ProbeRsp.
- *
- * Input: bDLFinished
- *
- * false: At the first time we will send all the packets as a large packet to
- * Hw, so we need to set the packet length to total length.
- *
- * true: At the second time, we should send the first packet (default:beacon)
- * to Hw again and set the length in descriptor to the real beacon length.
- */
-/* 2009.10.15 by tynli. */
-static void rtl8723b_set_AP_FwRsvdPagePkt(
- struct adapter *padapter, bool bDLFinished
-)
-{
- struct hal_com_data *pHalData;
- struct xmit_frame *pcmdframe;
- struct pkt_attrib *pattrib;
- struct xmit_priv *pxmitpriv;
- struct mlme_ext_priv *pmlmeext;
- struct mlme_ext_info *pmlmeinfo;
- struct pwrctrl_priv *pwrctl;
- u32 BeaconLength = 0, ProbeRspLength = 0;
- u8 *ReservedPagePacket;
- u8 TxDescLen = TXDESC_SIZE, TxDescOffset = TXDESC_OFFSET;
- u8 TotalPageNum = 0, CurtPktPageNum = 0, RsvdPageNum = 0;
- u8 currentip[4];
- u16 BufIndex, PageSize = 128;
- u32 TotalPacketLen = 0, MaxRsvdPageBufSize = 0;
- RSVDPAGE_LOC RsvdPageLoc;
-
- /* DBG_871X("%s---->\n", __func__); */
- DBG_8192C("+" FUNC_ADPT_FMT ": iface_type =%d\n",
- FUNC_ADPT_ARG(padapter), get_iface_type(padapter));
-
- pHalData = GET_HAL_DATA(padapter);
- pxmitpriv = &padapter->xmitpriv;
- pmlmeext = &padapter->mlmeextpriv;
- pmlmeinfo = &pmlmeext->mlmext_info;
- pwrctl = adapter_to_pwrctl(padapter);
-
- RsvdPageNum = BCNQ_PAGE_NUM_8723B + AP_WOWLAN_PAGE_NUM_8723B;
- MaxRsvdPageBufSize = RsvdPageNum*PageSize;
-
- pcmdframe = rtw_alloc_cmdxmitframe(pxmitpriv);
- if (!pcmdframe) {
- DBG_871X("%s: alloc ReservedPagePacket fail!\n", __func__);
- return;
- }
-
- ReservedPagePacket = pcmdframe->buf_addr;
- memset(&RsvdPageLoc, 0, sizeof(RSVDPAGE_LOC));
-
- /* 3 (1) beacon */
- BufIndex = TxDescOffset;
- ConstructBeacon(padapter, &ReservedPagePacket[BufIndex], &BeaconLength);
-
- /* When we count the first page size, we need to reserve description size for the RSVD */
- /* packet, it will be filled in front of the packet in TXPKTBUF. */
- CurtPktPageNum = (u8)PageNum_128(TxDescLen + BeaconLength);
- /* If we don't add 1 more page, the WOWLAN function has a problem. Baron thinks it's a bug of firmware */
- if (CurtPktPageNum == 1)
- CurtPktPageNum += 1;
- TotalPageNum += CurtPktPageNum;
-
- BufIndex += (CurtPktPageNum*PageSize);
-
- /* 2 (4) probe response */
- RsvdPageLoc.LocProbeRsp = TotalPageNum;
-
- rtw_get_current_ip_address(padapter, currentip);
-
- ConstructProbeRsp(
- padapter,
- &ReservedPagePacket[BufIndex],
- &ProbeRspLength,
- currentip,
- false);
- rtl8723b_fill_fake_txdesc(padapter,
- &ReservedPagePacket[BufIndex-TxDescLen],
- ProbeRspLength,
- false, false, false);
-
- DBG_871X("%s(): HW_VAR_SET_TX_CMD: PROBE RSP %p %d\n",
- __func__, &ReservedPagePacket[BufIndex-TxDescLen],
- (ProbeRspLength+TxDescLen));
-
- CurtPktPageNum = (u8)PageNum_128(TxDescLen + ProbeRspLength);
-
- TotalPageNum += CurtPktPageNum;
-
- BufIndex += (CurtPktPageNum*PageSize);
-
- TotalPacketLen = BufIndex + ProbeRspLength;
-
- if (TotalPacketLen > MaxRsvdPageBufSize) {
- DBG_871X("%s(): ERROR: The rsvd page size is not enough \
- !!TotalPacketLen %d, MaxRsvdPageBufSize %d\n",
- __func__, TotalPacketLen, MaxRsvdPageBufSize);
- goto error;
- } else {
- /* update attribute */
- pattrib = &pcmdframe->attrib;
- update_mgntframe_attrib(padapter, pattrib);
- pattrib->qsel = 0x10;
- pattrib->pktlen = TotalPacketLen - TxDescOffset;
- pattrib->last_txcmdsz = TotalPacketLen - TxDescOffset;
- dump_mgntframe_and_wait(padapter, pcmdframe, 100);
- }
-
- DBG_871X("%s: Set RSVD page location to Fw , TotalPacketLen(%d), TotalPageNum(%d)\n", __func__, TotalPacketLen, TotalPageNum);
- rtl8723b_set_ap_wow_rsvdpage_cmd(padapter, &RsvdPageLoc);
-
- return;
-error:
- rtw_free_xmitframe(pxmitpriv, pcmdframe);
-}
-#endif /* CONFIG_AP_WOWLAN */
-
void rtl8723b_download_rsvd_page(struct adapter *padapter, u8 mstatus)
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-#ifdef CONFIG_AP_WOWLAN
- struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
-#endif
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
bool bcn_valid = false;
@@ -1932,9 +658,6 @@ void rtl8723b_download_rsvd_page(struct adapter *padapter, u8 mstatus)
u32 poll = 0;
u8 val8;
- DBG_8192C("+" FUNC_ADPT_FMT ": iface_type =%d mstatus(%x)\n",
- FUNC_ADPT_ARG(padapter), get_iface_type(padapter), mstatus);
-
if (mstatus == RT_MEDIA_CONNECT) {
bool bRecover = false;
u8 v8;
@@ -1971,15 +694,8 @@ void rtl8723b_download_rsvd_page(struct adapter *padapter, u8 mstatus)
DLBcnCount = 0;
poll = 0;
do {
-#ifdef CONFIG_AP_WOWLAN
- if (pwrpriv->wowlan_ap_mode)
- rtl8723b_set_AP_FwRsvdPagePkt(padapter, 0);
- else
- rtl8723b_set_FwRsvdPagePkt(padapter, 0);
-#else
/* download rsvd page. */
rtl8723b_set_FwRsvdPagePkt(padapter, 0);
-#endif
DLBcnCount++;
do {
yield();
@@ -1992,14 +708,9 @@ void rtl8723b_download_rsvd_page(struct adapter *padapter, u8 mstatus)
} while (!bcn_valid && DLBcnCount <= 100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped);
if (padapter->bSurpriseRemoved || padapter->bDriverStopped) {
- } else if (!bcn_valid)
- DBG_871X("%s: 1 DL RSVD page failed! DLBcnCount:%u, poll:%u\n",
- ADPT_ARG(padapter), DLBcnCount, poll);
- else {
+ } else {
struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
pwrctl->fw_psmode_iface_id = padapter->iface_id;
- DBG_871X("%s: 1 DL RSVD page success! DLBcnCount:%u, poll:%u\n",
- ADPT_ARG(padapter), DLBcnCount, poll);
}
/* 2010.05.11. Added by tynli. */
@@ -2061,7 +772,6 @@ void rtl8723b_Add_RateATid(
if (rssi_level != DM_RATR_STA_INIT)
mask = ODM_Get_Rate_Bitmap(&pHalData->odmpriv, mac_id, mask, rssi_level);
- DBG_871X("%s(): mac_id =%d raid = 0x%x bw =%d mask = 0x%x\n", __func__, mac_id, raid, bw, mask);
rtl8723b_set_FwMacIdConfig_cmd(padapter, mac_id, raid, bw, shortGI, mask);
}
@@ -2081,10 +791,6 @@ static void ConstructBtNullFunctionData(
u32 pktlen;
u8 bssid[ETH_ALEN];
-
- DBG_871X("+" FUNC_ADPT_FMT ": qos =%d eosp =%d ps =%d\n",
- FUNC_ADPT_ARG(padapter), bQoS, bEosp, bForcePowerSave);
-
pwlanhdr = (struct ieee80211_hdr *)pframe;
if (!StaAddr) {
@@ -2136,10 +842,7 @@ static void SetFwRsvdPagePkt_BTCoex(struct adapter *padapter)
u8 TotalPageNum = 0, CurtPktPageNum = 0, RsvdPageNum = 0;
u16 BufIndex, PageSize;
u32 TotalPacketLen, MaxRsvdPageBufSize = 0;
- RSVDPAGE_LOC RsvdPageLoc;
-
-
-/* DBG_8192C("+" FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); */
+ struct rsvdpage_loc RsvdPageLoc;
pxmitpriv = &padapter->xmitpriv;
TxDescLen = TXDESC_SIZE;
@@ -2150,13 +853,11 @@ static void SetFwRsvdPagePkt_BTCoex(struct adapter *padapter)
MaxRsvdPageBufSize = RsvdPageNum*PageSize;
pcmdframe = rtw_alloc_cmdxmitframe(pxmitpriv);
- if (!pcmdframe) {
- DBG_8192C("%s: alloc ReservedPagePacket fail!\n", __func__);
+ if (!pcmdframe)
return;
- }
ReservedPagePacket = pcmdframe->buf_addr;
- memset(&RsvdPageLoc, 0, sizeof(RSVDPAGE_LOC));
+ memset(&RsvdPageLoc, 0, sizeof(struct rsvdpage_loc));
/* 3 (1) beacon */
BufIndex = TxDescOffset;
@@ -2194,11 +895,8 @@ static void SetFwRsvdPagePkt_BTCoex(struct adapter *padapter)
TotalPageNum += CurtPktPageNum;
TotalPacketLen = BufIndex + BTQosNullLength;
- if (TotalPacketLen > MaxRsvdPageBufSize) {
- DBG_8192C(FUNC_ADPT_FMT ": ERROR: The rsvd page size is not enough!!TotalPacketLen %d, MaxRsvdPageBufSize %d\n",
- FUNC_ADPT_ARG(padapter), TotalPacketLen, MaxRsvdPageBufSize);
+ if (TotalPacketLen > MaxRsvdPageBufSize)
goto error;
- }
/* update attribute */
pattrib = &pcmdframe->attrib;
@@ -2207,8 +905,6 @@ static void SetFwRsvdPagePkt_BTCoex(struct adapter *padapter)
pattrib->pktlen = pattrib->last_txcmdsz = TotalPacketLen - TxDescOffset;
dump_mgntframe_and_wait(padapter, pcmdframe, 100);
-/* DBG_8192C(FUNC_ADPT_FMT ": Set RSVD page location to Fw, TotalPacketLen(%d), TotalPageNum(%d)\n", */
-/* FUNC_ADPT_ARG(padapter), TotalPacketLen, TotalPageNum); */
rtl8723b_set_FwRsvdPage_cmd(padapter, &RsvdPageLoc);
rtl8723b_set_FwAoacRsvdPage_cmd(padapter, &RsvdPageLoc);
@@ -2229,17 +925,6 @@ void rtl8723b_download_BTCoex_AP_mode_rsvd_page(struct adapter *padapter)
u32 poll = 0;
u8 val8;
-
- DBG_8192C("+" FUNC_ADPT_FMT ": iface_type =%d fw_state = 0x%08X\n",
- FUNC_ADPT_ARG(padapter), get_iface_type(padapter), get_fwstate(&padapter->mlmepriv));
-
-#ifdef DEBUG
- if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == false) {
- DBG_8192C(FUNC_ADPT_FMT ": [WARNING] not in AP mode!!\n",
- FUNC_ADPT_ARG(padapter));
- }
-#endif /* DEBUG */
-
pHalData = GET_HAL_DATA(padapter);
pmlmeext = &padapter->mlmeextpriv;
pmlmeinfo = &pmlmeext->mlmext_info;
@@ -2290,15 +975,6 @@ void rtl8723b_download_BTCoex_AP_mode_rsvd_page(struct adapter *padapter)
if (bcn_valid) {
struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
pwrctl->fw_psmode_iface_id = padapter->iface_id;
- DBG_8192C("%s: DL RSVD page success! DLBcnCount:%d, poll:%d\n",
- ADPT_ARG(padapter), DLBcnCount, poll);
- } else {
- DBG_8192C("%s: DL RSVD page fail! DLBcnCount:%d, poll:%d\n",
- ADPT_ARG(padapter), DLBcnCount, poll);
- DBG_8192C("%s: DL RSVD page fail! bSurpriseRemoved =%d\n",
- ADPT_ARG(padapter), padapter->bSurpriseRemoved);
- DBG_8192C("%s: DL RSVD page fail! bDriverStopped =%d\n",
- ADPT_ARG(padapter), padapter->bDriverStopped);
}
/* 2010.05.11. Added by tynli. */
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c
index 650fbedd34e8..23be025ceb5b 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c
@@ -25,7 +25,7 @@ static void Init_ODM_ComInfo_8723b(struct adapter *Adapter)
{
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
struct dm_priv *pdmpriv = &pHalData->dmpriv;
u8 cut_ver, fab_ver;
@@ -44,7 +44,6 @@ static void Init_ODM_ComInfo_8723b(struct adapter *Adapter)
fab_ver = ODM_TSMC;
cut_ver = ODM_CUT_A;
- DBG_871X("%s(): fab_ver =%d cut_ver =%d\n", __func__, fab_ver, cut_ver);
ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_FAB_VER, fab_ver);
ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_CUT_VER, cut_ver);
ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_MP_TEST_CHIP, IS_NORMAL_CHIP(pHalData->VersionID));
@@ -74,7 +73,7 @@ static void Update_ODM_ComInfo_8723b(struct adapter *Adapter)
struct dvobj_priv *dvobj = adapter_to_dvobj(Adapter);
struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(Adapter);
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
struct dm_priv *pdmpriv = &pHalData->dmpriv;
int i;
u8 zero = 0;
@@ -91,9 +90,6 @@ static void Update_ODM_ComInfo_8723b(struct adapter *Adapter)
| ODM_MAC_EDCA_TURBO
| ODM_RF_TX_PWR_TRACK
| ODM_RF_CALIBRATION
-#ifdef CONFIG_ODM_ADAPTIVITY
- | ODM_BB_ADAPTIVITY
-#endif
;
/* */
@@ -129,7 +125,7 @@ void rtl8723b_InitHalDm(struct adapter *Adapter)
{
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
struct dm_priv *pdmpriv = &pHalData->dmpriv;
- PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
pdmpriv->DM_Type = DM_Type_ByDriver;
pdmpriv->DMFlag = DYNAMIC_FUNC_DISABLE;
@@ -145,7 +141,7 @@ void rtl8723b_InitHalDm(struct adapter *Adapter)
void rtl8723b_HalDmWatchDog(struct adapter *Adapter)
{
- bool bFwCurrentInPSMode = false;
+ bool fw_current_in_ps_mode = false;
bool bFwPSAwake = true;
u8 hw_init_completed = false;
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
@@ -155,12 +151,12 @@ void rtl8723b_HalDmWatchDog(struct adapter *Adapter)
if (hw_init_completed == false)
goto skip_dm;
- bFwCurrentInPSMode = adapter_to_pwrctl(Adapter)->bFwCurrentInPSMode;
+ fw_current_in_ps_mode = adapter_to_pwrctl(Adapter)->fw_current_in_ps_mode;
rtw_hal_get_hwreg(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&bFwPSAwake));
if (
(hw_init_completed == true) &&
- ((!bFwCurrentInPSMode) && bFwPSAwake)
+ ((!fw_current_in_ps_mode) && bFwPSAwake)
) {
/* */
/* Calculate Tx/Rx statistics. */
@@ -203,12 +199,10 @@ void rtl8723b_hal_dm_in_lps(struct adapter *padapter)
u32 PWDB_rssi = 0;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
struct sta_priv *pstapriv = &padapter->stapriv;
struct sta_info *psta = NULL;
- DBG_871X("%s, RSSI_Min =%d\n", __func__, pDM_Odm->RSSI_Min);
-
/* update IGI */
ODM_Write_DIG(pDM_Odm, pDM_Odm->RSSI_Min);
@@ -229,8 +223,8 @@ void rtl8723b_HalDmWatchDog_in_LPS(struct adapter *Adapter)
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
struct mlme_priv *pmlmepriv = &Adapter->mlmepriv;
struct dm_priv *pdmpriv = &pHalData->dmpriv;
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
+ struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
struct sta_priv *pstapriv = &Adapter->stapriv;
struct sta_info *psta = NULL;
@@ -260,8 +254,6 @@ void rtl8723b_HalDmWatchDog_in_LPS(struct adapter *Adapter)
pdmpriv->EntryMinUndecoratedSmoothedPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
- DBG_871X("CurIGValue =%d, EntryMinUndecoratedSmoothedPWDB = %d\n", pDM_DigTable->CurIGValue, pdmpriv->EntryMinUndecoratedSmoothedPWDB);
-
if (pdmpriv->EntryMinUndecoratedSmoothedPWDB <= 0)
goto skip_lps_dm;
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
index 84e963909283..082448557b53 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
@@ -33,9 +33,6 @@ static void _FWDownloadEnable(struct adapter *padapter, bool enable)
msleep(1);
} while (count++ < 100);
- if (count > 0)
- DBG_871X("%s: !!!!!!!!Write 0x80 Fail!: count = %d\n", __func__, count);
-
/* 8051 reset */
tmp = rtw_read8(padapter, REG_MCUFWDL+2);
rtw_write8(padapter, REG_MCUFWDL+2, tmp&0xf7);
@@ -64,20 +61,6 @@ static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize)
blockCount_p1 = buffSize / blockSize_p1;
remainSize_p1 = buffSize % blockSize_p1;
- if (blockCount_p1) {
- RT_TRACE(
- _module_hal_init_c_,
- _drv_notice_,
- (
- "_BlockWrite: [P1] buffSize(%d) blockSize_p1(%d) blockCount_p1(%d) remainSize_p1(%d)\n",
- buffSize,
- blockSize_p1,
- blockCount_p1,
- remainSize_p1
- )
- );
- }
-
for (i = 0; i < blockCount_p1; i++) {
ret = rtw_write32(padapter, (FW_8723B_START_ADDRESS + i * blockSize_p1), *((u32 *)(bufferPtr + i * blockSize_p1)));
if (ret == _FAIL) {
@@ -92,21 +75,6 @@ static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize)
blockCount_p2 = remainSize_p1/blockSize_p2;
remainSize_p2 = remainSize_p1%blockSize_p2;
-
- if (blockCount_p2) {
- RT_TRACE(
- _module_hal_init_c_,
- _drv_notice_,
- (
- "_BlockWrite: [P2] buffSize_p2(%d) blockSize_p2(%d) blockCount_p2(%d) remainSize_p2(%d)\n",
- (buffSize-offset),
- blockSize_p2,
- blockCount_p2,
- remainSize_p2
- )
- );
- }
-
}
/* 3 Phase #3 */
@@ -115,10 +83,6 @@ static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize)
blockCount_p3 = remainSize_p2 / blockSize_p3;
- RT_TRACE(_module_hal_init_c_, _drv_notice_,
- ("_BlockWrite: [P3] buffSize_p3(%d) blockSize_p3(%d) blockCount_p3(%d)\n",
- (buffSize-offset), blockSize_p3, blockCount_p3));
-
for (i = 0; i < blockCount_p3; i++) {
ret = rtw_write8(padapter, (FW_8723B_START_ADDRESS + offset + i), *(bufferPtr + offset + i));
@@ -181,7 +145,6 @@ static int _WriteFW(struct adapter *padapter, void *buffer, u32 size)
goto exit;
}
}
- RT_TRACE(_module_hal_init_c_, _drv_info_, ("_WriteFW Done- for Normal chip.\n"));
exit:
return ret;
@@ -213,8 +176,6 @@ void _8051Reset8723(struct adapter *padapter)
cpu_rst = rtw_read8(padapter, REG_SYS_FUNC_EN+1);
cpu_rst |= BIT(2);
rtw_write8(padapter, REG_SYS_FUNC_EN+1, cpu_rst);
-
- DBG_8192C("%s: Finish\n", __func__);
}
u8 g_fwdl_chksum_fail;
@@ -242,7 +203,6 @@ static s32 polling_fwdl_chksum(
}
if (g_fwdl_chksum_fail) {
- DBG_871X("%s: fwdl test case: fwdl_chksum_fail\n", __func__);
g_fwdl_chksum_fail--;
goto exit;
}
@@ -250,14 +210,6 @@ static s32 polling_fwdl_chksum(
ret = _SUCCESS;
exit:
- DBG_871X(
- "%s: Checksum report %s! (%u, %dms), REG_MCUFWDL:0x%08x\n",
- __func__,
- (ret == _SUCCESS) ? "OK" : "Fail",
- cnt,
- jiffies_to_msecs(jiffies-start),
- value32
- );
return ret;
}
@@ -292,7 +244,6 @@ static s32 _FWFreeToGo(struct adapter *adapter, u32 min_cnt, u32 timeout_ms)
}
if (g_fwdl_wintint_rdy_fail) {
- DBG_871X("%s: fwdl test case: wintint_rdy_fail\n", __func__);
g_fwdl_wintint_rdy_fail--;
goto exit;
}
@@ -300,14 +251,6 @@ static s32 _FWFreeToGo(struct adapter *adapter, u32 min_cnt, u32 timeout_ms)
ret = _SUCCESS;
exit:
- DBG_871X(
- "%s: Polling FW ready %s! (%u, %dms), REG_MCUFWDL:0x%08x\n",
- __func__,
- (ret == _SUCCESS) ? "OK" : "Fail",
- cnt,
- jiffies_to_msecs(jiffies-start),
- value32
- );
return ret;
}
@@ -334,10 +277,8 @@ void rtl8723b_FirmwareSelfReset(struct adapter *padapter)
udelay(50);
u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN+1);
}
- RT_TRACE(_module_hal_init_c_, _drv_notice_, ("-%s: 8051 reset success (%d)\n", __func__, Delay));
if (Delay == 0) {
- RT_TRACE(_module_hal_init_c_, _drv_notice_, ("%s: Force 8051 reset!!!\n", __func__));
/* force firmware reset */
u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN+1);
rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp&(~BIT2));
@@ -368,10 +309,6 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)
struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
u8 tmp_ps;
- RT_TRACE(_module_hal_init_c_, _drv_info_, ("+%s\n", __func__));
-#ifdef CONFIG_WOWLAN
- RT_TRACE(_module_hal_init_c_, _drv_notice_, ("+%s, bUsedWoWLANFw:%d\n", __func__, bUsedWoWLANFw));
-#endif
pFirmware = kzalloc(sizeof(struct rt_firmware), GFP_KERNEL);
if (!pFirmware)
return _FAIL;
@@ -388,17 +325,10 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)
/* 2. read power_state = 0xA0[1:0] */
tmp_ps = rtw_read8(padapter, 0xa0);
tmp_ps &= 0x03;
- if (tmp_ps != 0x01) {
- DBG_871X(FUNC_ADPT_FMT" tmp_ps =%x\n", FUNC_ADPT_ARG(padapter), tmp_ps);
+ if (tmp_ps != 0x01)
pdbgpriv->dbg_downloadfw_pwr_state_cnt++;
- }
-#ifdef CONFIG_WOWLAN
- if (bUsedWoWLANFw)
- fwfilepath = "rtlwifi/rtl8723bs_wowlan.bin";
- else
-#endif /* CONFIG_WOWLAN */
- fwfilepath = "rtlwifi/rtl8723bs_nic.bin";
+ fwfilepath = "rtlwifi/rtl8723bs_nic.bin";
pr_info("rtl8723bs: acquire FW from file:%s\n", fwfilepath);
@@ -417,11 +347,6 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)
if (fw->size > FW_8723B_SIZE) {
rtStatus = _FAIL;
- RT_TRACE(
- _module_hal_init_c_,
- _drv_err_,
- ("Firmware size exceed 0x%X. Check it.\n", FW_8188E_SIZE)
- );
goto exit;
}
@@ -435,7 +360,9 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)
release_firmware(fw);
if (pFirmware->fw_length > FW_8723B_SIZE) {
rtStatus = _FAIL;
- DBG_871X_LEVEL(_drv_emerg_, "Firmware size:%u exceed %u\n", pFirmware->fw_length, FW_8723B_SIZE);
+ netdev_emerg(padapter->pnetdev,
+ "Firmware size:%u exceed %u\n",
+ pFirmware->fw_length, FW_8723B_SIZE);
goto release_fw1;
}
@@ -449,20 +376,7 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)
pHalData->FirmwareSubVersion = le16_to_cpu(pFwHdr->subversion);
pHalData->FirmwareSignature = le16_to_cpu(pFwHdr->signature);
- DBG_871X(
- "%s: fw_ver =%x fw_subver =%04x sig = 0x%x, Month =%02x, Date =%02x, Hour =%02x, Minute =%02x\n",
- __func__,
- pHalData->FirmwareVersion,
- pHalData->FirmwareSubVersion,
- pHalData->FirmwareSignature,
- pFwHdr->month,
- pFwHdr->date,
- pFwHdr->hour,
- pFwHdr->minute
- );
-
if (IS_FW_HEADER_EXIST_8723B(pFwHdr)) {
- DBG_871X("%s(): Shift for fw header!\n", __func__);
/* Shift 32 bytes for FW header */
pFirmwareBuf = pFirmwareBuf + 32;
FirmwareLen = FirmwareLen - 32;
@@ -502,19 +416,12 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)
goto fwdl_stat;
fwdl_stat:
- DBG_871X(
- "FWDL %s. write_fw:%u, %dms\n",
- (rtStatus == _SUCCESS)?"success":"fail",
- write_fw,
- jiffies_to_msecs(jiffies - fwdl_start_time)
- );
exit:
kfree(pFirmware->fw_buffer_sz);
kfree(pFirmware);
release_fw1:
kfree(pBTFirmware);
- DBG_871X(" <=== rtl8723b_FirmwareDownload()\n");
return rtStatus;
}
@@ -523,7 +430,7 @@ void rtl8723b_InitializeFirmwareVars(struct adapter *padapter)
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
/* Init Fw LPS related. */
- adapter_to_pwrctl(padapter)->bFwCurrentInPSMode = false;
+ adapter_to_pwrctl(padapter)->fw_current_in_ps_mode = false;
/* Init H2C cmd. */
rtw_write8(padapter, REG_HMETFR, 0x0f);
@@ -535,39 +442,6 @@ void rtl8723b_InitializeFirmwareVars(struct adapter *padapter)
/* pHalData->H2CStopInsertQueue = false; */
}
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-/* */
-
-/* */
-/* Description: Prepare some information to Fw for WoWLAN. */
-/* (1) Download wowlan Fw. */
-/* (2) Download RSVD page packets. */
-/* (3) Enable AP offload if needed. */
-/* */
-/* 2011.04.12 by tynli. */
-/* */
-void SetFwRelatedForWoWLAN8723b(
- struct adapter *padapter, u8 bHostIsGoingtoSleep
-)
-{
- int status = _FAIL;
- /* */
- /* 1. Before WoWLAN we need to re-download WoWLAN Fw. */
- /* */
- status = rtl8723b_FirmwareDownload(padapter, bHostIsGoingtoSleep);
- if (status != _SUCCESS) {
- DBG_871X("SetFwRelatedForWoWLAN8723b(): Re-Download Firmware failed!!\n");
- return;
- } else {
- DBG_871X("SetFwRelatedForWoWLAN8723b(): Re-Download Firmware Success !!\n");
- }
- /* */
- /* 2. Re-Init the variables about Fw related setting. */
- /* */
- rtl8723b_InitializeFirmwareVars(padapter);
-}
-#endif /* CONFIG_WOWLAN */
-
static void rtl8723b_free_hal_data(struct adapter *padapter)
{
}
@@ -583,11 +457,10 @@ static u8 hal_EfuseSwitchToBank(
u32 value32 = 0;
#ifdef HAL_EFUSE_MEMORY
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal;
+ struct efuse_hal *pEfuseHal = &pHalData->EfuseHal;
#endif
- DBG_8192C("%s: Efuse switch bank to %d\n", __func__, bank);
if (bPseudoTest) {
#ifdef HAL_EFUSE_MEMORY
pEfuseHal->fakeEfuseBank = bank;
@@ -807,14 +680,6 @@ static void Hal_EfusePowerSwitch(
mdelay(10);
} while (1);
-
- if (count >= 100) {
- DBG_8192C(FUNC_ADPT_FMT ": Leave SDIO local register suspend fail! Local 0x86 =%#X\n",
- FUNC_ADPT_ARG(padapter), tempval);
- } else {
- DBG_8192C(FUNC_ADPT_FMT ": Leave SDIO local register suspend OK! Local 0x86 =%#X\n",
- FUNC_ADPT_ARG(padapter), tempval);
- }
}
rtw_write8(padapter, REG_EFUSE_ACCESS_8723, EFUSE_ACCESS_ON_8723);
@@ -864,7 +729,7 @@ static void hal_ReadEFuse_WiFi(
{
#ifdef HAL_EFUSE_MEMORY
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal;
+ struct efuse_hal *pEfuseHal = &pHalData->EfuseHal;
#endif
u8 *efuseTbl = NULL;
u16 eFuse_Addr = 0;
@@ -873,57 +738,32 @@ static void hal_ReadEFuse_WiFi(
u16 i, total, used;
u8 efuse_usage = 0;
- /* DBG_871X("YJ: ====>%s():_offset =%d _size_byte =%d bPseudoTest =%d\n", __func__, _offset, _size_byte, bPseudoTest); */
/* */
/* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */
/* */
- if ((_offset+_size_byte) > EFUSE_MAX_MAP_LEN) {
- DBG_8192C("%s: Invalid offset(%#x) with read bytes(%#x)!!\n", __func__, _offset, _size_byte);
+ if ((_offset + _size_byte) > EFUSE_MAX_MAP_LEN)
return;
- }
efuseTbl = rtw_malloc(EFUSE_MAX_MAP_LEN);
- if (!efuseTbl) {
- DBG_8192C("%s: alloc efuseTbl fail!\n", __func__);
+ if (!efuseTbl)
return;
- }
+
/* 0xff will be efuse default value instead of 0x00. */
memset(efuseTbl, 0xFF, EFUSE_MAX_MAP_LEN);
-
-#ifdef DEBUG
-if (0) {
- for (i = 0; i < 256; i++)
- efuse_OneByteRead(padapter, i, &efuseTbl[i], false);
- DBG_871X("Efuse Content:\n");
- for (i = 0; i < 256; i++) {
- if (i % 16 == 0)
- printk("\n");
- printk("%02X ", efuseTbl[i]);
- }
- printk("\n");
-}
-#endif
-
-
/* switch bank back to bank 0 for later BT and wifi use. */
hal_EfuseSwitchToBank(padapter, 0, bPseudoTest);
while (AVAILABLE_EFUSE_ADDR(eFuse_Addr)) {
efuse_OneByteRead(padapter, eFuse_Addr++, &efuseHeader, bPseudoTest);
- if (efuseHeader == 0xFF) {
- DBG_8192C("%s: data end at address =%#x\n", __func__, eFuse_Addr-1);
+ if (efuseHeader == 0xFF)
break;
- }
- /* DBG_8192C("%s: efuse[0x%X]= 0x%02X\n", __func__, eFuse_Addr-1, efuseHeader); */
/* Check PG header for section num. */
if (EXT_HEADER(efuseHeader)) { /* extended header */
offset = GET_HDR_OFFSET_2_0(efuseHeader);
- /* DBG_8192C("%s: extended header offset = 0x%X\n", __func__, offset); */
efuse_OneByteRead(padapter, eFuse_Addr++, &efuseExtHdr, bPseudoTest);
- /* DBG_8192C("%s: efuse[0x%X]= 0x%02X\n", __func__, eFuse_Addr-1, efuseExtHdr); */
if (ALL_WORDS_DISABLED(efuseExtHdr))
continue;
@@ -933,29 +773,24 @@ if (0) {
offset = ((efuseHeader >> 4) & 0x0f);
wden = (efuseHeader & 0x0f);
}
- /* DBG_8192C("%s: Offset =%d Worden = 0x%X\n", __func__, offset, wden); */
if (offset < EFUSE_MAX_SECTION_8723B) {
u16 addr;
/* Get word enable value from PG header */
-/* DBG_8192C("%s: Offset =%d Worden = 0x%X\n", __func__, offset, wden); */
addr = offset * PGPKT_DATA_SIZE;
for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) {
/* Check word enable condition in the section */
if (!(wden & (0x01<<i))) {
efuse_OneByteRead(padapter, eFuse_Addr++, &efuseData, bPseudoTest);
-/* DBG_8192C("%s: efuse[%#X]= 0x%02X\n", __func__, eFuse_Addr-1, efuseData); */
efuseTbl[addr] = efuseData;
efuse_OneByteRead(padapter, eFuse_Addr++, &efuseData, bPseudoTest);
-/* DBG_8192C("%s: efuse[%#X]= 0x%02X\n", __func__, eFuse_Addr-1, efuseData); */
efuseTbl[addr+1] = efuseData;
}
addr += 2;
}
} else {
- DBG_8192C(KERN_ERR "%s: offset(%d) is illegal!!\n", __func__, offset);
eFuse_Addr += Efuse_CalculateWordCnts(wden)*2;
}
}
@@ -964,17 +799,6 @@ if (0) {
for (i = 0; i < _size_byte; i++)
pbuf[i] = efuseTbl[_offset+i];
-#ifdef DEBUG
-if (1) {
- DBG_871X("Efuse Realmap:\n");
- for (i = 0; i < _size_byte; i++) {
- if (i % 16 == 0)
- printk("\n");
- printk("%02X ", pbuf[i]);
- }
- printk("\n");
-}
-#endif
/* Calculate Efuse utilization */
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, &total, bPseudoTest);
used = eFuse_Addr - 1;
@@ -1003,7 +827,7 @@ static void hal_ReadEFuse_BT(
{
#ifdef HAL_EFUSE_MEMORY
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal;
+ struct efuse_hal *pEfuseHal = &pHalData->EfuseHal;
#endif
u8 *efuseTbl;
u8 bank;
@@ -1017,26 +841,21 @@ static void hal_ReadEFuse_BT(
/* */
/* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */
/* */
- if ((_offset+_size_byte) > EFUSE_BT_MAP_LEN) {
- DBG_8192C("%s: Invalid offset(%#x) with read bytes(%#x)!!\n", __func__, _offset, _size_byte);
+ if ((_offset + _size_byte) > EFUSE_BT_MAP_LEN)
return;
- }
efuseTbl = rtw_malloc(EFUSE_BT_MAP_LEN);
- if (!efuseTbl) {
- DBG_8192C("%s: efuseTbl malloc fail!\n", __func__);
+ if (!efuseTbl)
return;
- }
+
/* 0xff will be efuse default value instead of 0x00. */
memset(efuseTbl, 0xFF, EFUSE_BT_MAP_LEN);
EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_BANK, &total, bPseudoTest);
for (bank = 1; bank < 3; bank++) { /* 8723b Max bake 0~2 */
- if (hal_EfuseSwitchToBank(padapter, bank, bPseudoTest) == false) {
- DBG_8192C("%s: hal_EfuseSwitchToBank Fail!!\n", __func__);
+ if (hal_EfuseSwitchToBank(padapter, bank, bPseudoTest) == false)
goto exit;
- }
eFuse_Addr = 0;
@@ -1044,15 +863,12 @@ static void hal_ReadEFuse_BT(
efuse_OneByteRead(padapter, eFuse_Addr++, &efuseHeader, bPseudoTest);
if (efuseHeader == 0xFF)
break;
- DBG_8192C("%s: efuse[%#X]= 0x%02x (header)\n", __func__, (((bank-1)*EFUSE_REAL_CONTENT_LEN_8723B)+eFuse_Addr-1), efuseHeader);
/* Check PG header for section num. */
if (EXT_HEADER(efuseHeader)) { /* extended header */
offset = GET_HDR_OFFSET_2_0(efuseHeader);
- DBG_8192C("%s: extended header offset_2_0 = 0x%X\n", __func__, offset);
efuse_OneByteRead(padapter, eFuse_Addr++, &efuseExtHdr, bPseudoTest);
- DBG_8192C("%s: efuse[%#X]= 0x%02x (ext header)\n", __func__, (((bank-1)*EFUSE_REAL_CONTENT_LEN_8723B)+eFuse_Addr-1), efuseExtHdr);
if (ALL_WORDS_DISABLED(efuseExtHdr))
continue;
@@ -1067,33 +883,26 @@ static void hal_ReadEFuse_BT(
if (offset < EFUSE_BT_MAX_SECTION) {
u16 addr;
- /* Get word enable value from PG header */
- DBG_8192C("%s: Offset =%d Worden =%#X\n", __func__, offset, wden);
-
addr = offset * PGPKT_DATA_SIZE;
for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) {
/* Check word enable condition in the section */
if (!(wden & (0x01<<i))) {
efuse_OneByteRead(padapter, eFuse_Addr++, &efuseData, bPseudoTest);
- DBG_8192C("%s: efuse[%#X]= 0x%02X\n", __func__, eFuse_Addr-1, efuseData);
efuseTbl[addr] = efuseData;
efuse_OneByteRead(padapter, eFuse_Addr++, &efuseData, bPseudoTest);
- DBG_8192C("%s: efuse[%#X]= 0x%02X\n", __func__, eFuse_Addr-1, efuseData);
efuseTbl[addr+1] = efuseData;
}
addr += 2;
}
} else {
- DBG_8192C("%s: offset(%d) is illegal!!\n", __func__, offset);
eFuse_Addr += Efuse_CalculateWordCnts(wden)*2;
}
}
- if ((eFuse_Addr-1) < total) {
- DBG_8192C("%s: bank(%d) data end at %#x\n", __func__, bank, eFuse_Addr-1);
+ if ((eFuse_Addr - 1) < total)
break;
- }
+
}
/* switch bank back to bank 0 for later BT and wifi use. */
@@ -1108,7 +917,6 @@ static void hal_ReadEFuse_BT(
/* */
EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, &total, bPseudoTest);
used = (EFUSE_BT_REAL_BANK_CONTENT_LEN*(bank-1)) + eFuse_Addr - 1;
- DBG_8192C("%s: bank(%d) data end at %#x , used =%d\n", __func__, bank, eFuse_Addr-1, used);
efuse_usage = (u8)((used*100)/total);
if (bPseudoTest) {
#ifdef HAL_EFUSE_MEMORY
@@ -1146,7 +954,7 @@ static u16 hal_EfuseGetCurrentSize_WiFi(
{
#ifdef HAL_EFUSE_MEMORY
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal;
+ struct efuse_hal *pEfuseHal = &pHalData->EfuseHal;
#endif
u16 efuse_addr = 0;
u16 start_addr = 0; /* for debug */
@@ -1165,25 +973,20 @@ static u16 hal_EfuseGetCurrentSize_WiFi(
rtw_hal_get_hwreg(padapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr);
start_addr = efuse_addr;
- DBG_8192C("%s: start_efuse_addr = 0x%X\n", __func__, efuse_addr);
/* switch bank back to bank 0 for later BT and wifi use. */
hal_EfuseSwitchToBank(padapter, 0, bPseudoTest);
count = 0;
while (AVAILABLE_EFUSE_ADDR(efuse_addr)) {
- if (efuse_OneByteRead(padapter, efuse_addr, &efuse_data, bPseudoTest) == false) {
- DBG_8192C(KERN_ERR "%s: efuse_OneByteRead Fail! addr = 0x%X !!\n", __func__, efuse_addr);
+ if (efuse_OneByteRead(padapter, efuse_addr, &efuse_data, bPseudoTest) == false)
goto error;
- }
if (efuse_data == 0xFF)
break;
if ((start_addr != 0) && (efuse_addr == start_addr)) {
count++;
- DBG_8192C(FUNC_ADPT_FMT ": [WARNING] efuse raw 0x%X = 0x%02X not 0xFF!!(%d times)\n",
- FUNC_ADPT_ARG(padapter), efuse_addr, efuse_data, count);
efuse_data = 0xFF;
if (count < 4) {
@@ -1235,7 +1038,6 @@ error:
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, &efuse_addr, bPseudoTest);
exit:
- DBG_8192C("%s: CurrentSize =%d\n", __func__, efuse_addr);
return efuse_addr;
}
@@ -1244,7 +1046,7 @@ static u16 hal_EfuseGetCurrentSize_BT(struct adapter *padapter, u8 bPseudoTest)
{
#ifdef HAL_EFUSE_MEMORY
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal;
+ struct efuse_hal *pEfuseHal = &pHalData->EfuseHal;
#endif
u16 btusedbytes;
u16 efuse_addr;
@@ -1265,16 +1067,12 @@ static u16 hal_EfuseGetCurrentSize_BT(struct adapter *padapter, u8 bPseudoTest)
efuse_addr = (u16)((btusedbytes%EFUSE_BT_REAL_BANK_CONTENT_LEN));
startBank = (u8)(1+(btusedbytes/EFUSE_BT_REAL_BANK_CONTENT_LEN));
- DBG_8192C("%s: start from bank =%d addr = 0x%X\n", __func__, startBank, efuse_addr);
-
EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_BANK, &retU2, bPseudoTest);
for (bank = startBank; bank < 3; bank++) {
- if (hal_EfuseSwitchToBank(padapter, bank, bPseudoTest) == false) {
- DBG_8192C(KERN_ERR "%s: switch bank(%d) Fail!!\n", __func__, bank);
+ if (hal_EfuseSwitchToBank(padapter, bank, bPseudoTest) == false)
/* bank = EFUSE_MAX_BANK; */
break;
- }
/* only when bank is switched we have to reset the efuse_addr. */
if (bank != startBank)
@@ -1282,12 +1080,10 @@ static u16 hal_EfuseGetCurrentSize_BT(struct adapter *padapter, u8 bPseudoTest)
#if 1
while (AVAILABLE_EFUSE_ADDR(efuse_addr)) {
- if (efuse_OneByteRead(padapter, efuse_addr, &efuse_data, bPseudoTest) == false) {
- DBG_8192C(KERN_ERR "%s: efuse_OneByteRead Fail! addr = 0x%X !!\n", __func__, efuse_addr);
+ if (efuse_OneByteRead(padapter, efuse_addr,
+ &efuse_data, bPseudoTest) == false)
/* bank = EFUSE_MAX_BANK; */
break;
- }
- DBG_8192C("%s: efuse_OneByteRead ! addr = 0x%X !efuse_data = 0x%X! bank =%d\n", __func__, efuse_addr, efuse_data, bank);
if (efuse_data == 0xFF)
break;
@@ -1296,7 +1092,6 @@ static u16 hal_EfuseGetCurrentSize_BT(struct adapter *padapter, u8 bPseudoTest)
hoffset = GET_HDR_OFFSET_2_0(efuse_data);
efuse_addr++;
efuse_OneByteRead(padapter, efuse_addr, &efuse_data, bPseudoTest);
- DBG_8192C("%s: efuse_OneByteRead EXT_HEADER ! addr = 0x%X !efuse_data = 0x%X! bank =%d\n", __func__, efuse_addr, efuse_data, bank);
if (ALL_WORDS_DISABLED(efuse_data)) {
efuse_addr++;
@@ -1311,9 +1106,6 @@ static u16 hal_EfuseGetCurrentSize_BT(struct adapter *padapter, u8 bPseudoTest)
hworden = efuse_data & 0x0F;
}
- DBG_8192C(FUNC_ADPT_FMT": Offset =%d Worden =%#X\n",
- FUNC_ADPT_ARG(padapter), hoffset, hworden);
-
word_cnts = Efuse_CalculateWordCnts(hworden);
/* read next header */
efuse_addr += (word_cnts*2)+1;
@@ -1363,7 +1155,6 @@ static u16 hal_EfuseGetCurrentSize_BT(struct adapter *padapter, u8 bPseudoTest)
/* RT_DISP(FEEPROM, EFUSE_PG, ("Hal_EfuseGetCurrentSize_BT92C(), already use %u bytes\n", pEfuseHal->BTEfuseUsedBytes)); */
}
- DBG_8192C("%s: CurrentSize =%d\n", __func__, retU2);
return retU2;
}
@@ -1394,8 +1185,6 @@ static u8 Hal_EfuseWordEnableDataWrite(
u8 badworden = 0x0F;
u8 tmpdata[PGPKT_DATA_SIZE];
-
-/* DBG_8192C("%s: efuse_addr =%#x word_en =%#x\n", __func__, efuse_addr, word_en); */
memset(tmpdata, 0xFF, PGPKT_DATA_SIZE);
if (!(word_en & BIT(0))) {
@@ -1467,10 +1256,8 @@ static s32 Hal_EfusePgPacketRead(
return false;
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAX_SECTION, &max_section, bPseudoTest);
- if (offset > max_section) {
- DBG_8192C("%s: Packet offset(%d) is illegal(>%d)!\n", __func__, offset, max_section);
+ if (offset > max_section)
return false;
- }
memset(data, 0xFF, PGPKT_DATA_SIZE);
ret = true;
@@ -1492,10 +1279,8 @@ static s32 Hal_EfusePgPacketRead(
if (EXT_HEADER(efuse_data)) {
hoffset = GET_HDR_OFFSET_2_0(efuse_data);
efuse_OneByteRead(padapter, efuse_addr++, &efuse_data, bPseudoTest);
- if (ALL_WORDS_DISABLED(efuse_data)) {
- DBG_8192C("%s: Error!! All words disabled!\n", __func__);
+ if (ALL_WORDS_DISABLED(efuse_data))
continue;
- }
hoffset |= ((efuse_data & 0xF0) >> 1);
hworden = efuse_data & 0x0F;
@@ -1509,11 +1294,9 @@ static s32 Hal_EfusePgPacketRead(
/* Check word enable condition in the section */
if (!(hworden & (0x01<<i))) {
efuse_OneByteRead(padapter, efuse_addr++, &efuse_data, bPseudoTest);
-/* DBG_8192C("%s: efuse[%#X]= 0x%02X\n", __func__, efuse_addr+tmpidx, efuse_data); */
data[i*2] = efuse_data;
efuse_OneByteRead(padapter, efuse_addr++, &efuse_data, bPseudoTest);
-/* DBG_8192C("%s: efuse[%#X]= 0x%02X\n", __func__, efuse_addr+tmpidx, efuse_data); */
data[(i*2)+1] = efuse_data;
}
}
@@ -1535,13 +1318,11 @@ static u8 hal_EfusePgCheckAvailableAddr(
EFUSE_GetEfuseDefinition(padapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, &max_available, bPseudoTest);
-/* DBG_8192C("%s: max_available =%d\n", __func__, max_available); */
current_size = Efuse_GetCurrentSize(padapter, efuseType, bPseudoTest);
- if (current_size >= max_available) {
- DBG_8192C("%s: Error!! current_size(%d)>max_available(%d)\n", __func__, current_size, max_available);
+ if (current_size >= max_available)
return false;
- }
+
return true;
}
@@ -1549,7 +1330,7 @@ static void hal_EfuseConstructPGPkt(
u8 offset,
u8 word_en,
u8 *pData,
- PPGPKT_STRUCT pTargetPkt
+ struct pgpkt_struct *pTargetPkt
)
{
memset(pTargetPkt->data, 0xFF, PGPKT_DATA_SIZE);
@@ -1563,12 +1344,12 @@ static u8 hal_EfusePartialWriteCheck(
struct adapter *padapter,
u8 efuseType,
u16 *pAddr,
- PPGPKT_STRUCT pTargetPkt,
+ struct pgpkt_struct *pTargetPkt,
u8 bPseudoTest
)
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal;
+ struct efuse_hal *pEfuseHal = &pHalData->EfuseHal;
u8 bRet = false;
u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0;
u8 efuse_data = 0;
@@ -1596,20 +1377,16 @@ static u8 hal_EfusePartialWriteCheck(
rtw_hal_get_hwreg(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *)&startAddr);
}
startAddr %= efuse_max;
- DBG_8192C("%s: startAddr =%#X\n", __func__, startAddr);
while (1) {
if (startAddr >= efuse_max_available_len) {
bRet = false;
- DBG_8192C("%s: startAddr(%d) >= efuse_max_available_len(%d)\n", __func__, startAddr, efuse_max_available_len);
break;
}
if (efuse_OneByteRead(padapter, startAddr, &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) {
#if 1
bRet = false;
- DBG_8192C("%s: Something Wrong! last bytes(%#X = 0x%02X) is not 0xFF\n",
- __func__, startAddr, efuse_data);
break;
#else
if (EXT_HEADER(efuse_data)) {
@@ -1617,7 +1394,6 @@ static u8 hal_EfusePartialWriteCheck(
startAddr++;
efuse_OneByteRead(padapter, startAddr, &efuse_data, bPseudoTest);
if (ALL_WORDS_DISABLED(efuse_data)) {
- DBG_8192C("%s: Error condition, all words disabled!", __func__);
bRet = false;
break;
} else {
@@ -1638,7 +1414,6 @@ static u8 hal_EfusePartialWriteCheck(
(hal_EfuseCheckIfDatafollowed(padapter, curPkt.word_cnts, startAddr+1, bPseudoTest) == false) &&
wordEnMatched(pTargetPkt, &curPkt, &matched_wden) == true
) {
- DBG_8192C("%s: Need to partial write data by the previous wrote header\n", __func__);
/* Here to write partial data */
badworden = Efuse_WordEnableDataWrite(padapter, startAddr+1, matched_wden, pTargetPkt->data, bPseudoTest);
if (badworden != 0x0F) {
@@ -1668,7 +1443,6 @@ static u8 hal_EfusePartialWriteCheck(
} else {
/* not used header, 0xff */
*pAddr = startAddr;
-/* DBG_8192C("%s: Started from unused header offset =%d\n", __func__, startAddr)); */
bRet = true;
break;
}
@@ -1681,7 +1455,7 @@ static u8 hal_EfusePgPacketWrite1ByteHeader(
struct adapter *padapter,
u8 efuseType,
u16 *pAddr,
- PPGPKT_STRUCT pTargetPkt,
+ struct pgpkt_struct *pTargetPkt,
u8 bPseudoTest
)
{
@@ -1689,8 +1463,6 @@ static u8 hal_EfusePgPacketWrite1ByteHeader(
u16 efuse_addr = *pAddr;
u8 repeatcnt = 0;
-
-/* DBG_8192C("%s\n", __func__); */
pg_header = ((pTargetPkt->offset << 4) & 0xf0) | pTargetPkt->word_en;
do {
@@ -1698,16 +1470,13 @@ static u8 hal_EfusePgPacketWrite1ByteHeader(
efuse_OneByteRead(padapter, efuse_addr, &tmp_header, bPseudoTest);
if (tmp_header != 0xFF)
break;
- if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) {
- DBG_8192C("%s: Repeat over limit for pg_header!!\n", __func__);
+ if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_)
return false;
- }
+
} while (1);
- if (tmp_header != pg_header) {
- DBG_8192C(KERN_ERR "%s: PG Header Fail!!(pg = 0x%02X read = 0x%02X)\n", __func__, pg_header, tmp_header);
+ if (tmp_header != pg_header)
return false;
- }
*pAddr = efuse_addr;
@@ -1718,7 +1487,7 @@ static u8 hal_EfusePgPacketWrite2ByteHeader(
struct adapter *padapter,
u8 efuseType,
u16 *pAddr,
- PPGPKT_STRUCT pTargetPkt,
+ struct pgpkt_struct *pTargetPkt,
u8 bPseudoTest
)
{
@@ -1726,35 +1495,26 @@ static u8 hal_EfusePgPacketWrite2ByteHeader(
u8 pg_header = 0, tmp_header = 0;
u8 repeatcnt = 0;
-
-/* DBG_8192C("%s\n", __func__); */
EFUSE_GetEfuseDefinition(padapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, &efuse_max_available_len, bPseudoTest);
efuse_addr = *pAddr;
- if (efuse_addr >= efuse_max_available_len) {
- DBG_8192C("%s: addr(%d) over available (%d)!!\n", __func__,
- efuse_addr, efuse_max_available_len);
+ if (efuse_addr >= efuse_max_available_len)
return false;
- }
pg_header = ((pTargetPkt->offset & 0x07) << 5) | 0x0F;
-/* DBG_8192C("%s: pg_header = 0x%x\n", __func__, pg_header); */
do {
efuse_OneByteWrite(padapter, efuse_addr, pg_header, bPseudoTest);
efuse_OneByteRead(padapter, efuse_addr, &tmp_header, bPseudoTest);
if (tmp_header != 0xFF)
break;
- if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) {
- DBG_8192C("%s: Repeat over limit for pg_header!!\n", __func__);
+ if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_)
return false;
- }
+
} while (1);
- if (tmp_header != pg_header) {
- DBG_8192C(KERN_ERR "%s: PG Header Fail!!(pg = 0x%02X read = 0x%02X)\n", __func__, pg_header, tmp_header);
+ if (tmp_header != pg_header)
return false;
- }
/* to write ext_header */
efuse_addr++;
@@ -1765,16 +1525,13 @@ static u8 hal_EfusePgPacketWrite2ByteHeader(
efuse_OneByteRead(padapter, efuse_addr, &tmp_header, bPseudoTest);
if (tmp_header != 0xFF)
break;
- if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) {
- DBG_8192C("%s: Repeat over limit for ext_header!!\n", __func__);
+ if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_)
return false;
- }
+
} while (1);
- if (tmp_header != pg_header) { /* offset PG fail */
- DBG_8192C(KERN_ERR "%s: PG EXT Header Fail!!(pg = 0x%02X read = 0x%02X)\n", __func__, pg_header, tmp_header);
+ if (tmp_header != pg_header) /* offset PG fail */
return false;
- }
*pAddr = efuse_addr;
@@ -1785,7 +1542,7 @@ static u8 hal_EfusePgPacketWriteHeader(
struct adapter *padapter,
u8 efuseType,
u16 *pAddr,
- PPGPKT_STRUCT pTargetPkt,
+ struct pgpkt_struct *pTargetPkt,
u8 bPseudoTest
)
{
@@ -1803,7 +1560,7 @@ static u8 hal_EfusePgPacketWriteData(
struct adapter *padapter,
u8 efuseType,
u16 *pAddr,
- PPGPKT_STRUCT pTargetPkt,
+ struct pgpkt_struct *pTargetPkt,
u8 bPseudoTest
)
{
@@ -1813,12 +1570,9 @@ static u8 hal_EfusePgPacketWriteData(
efuse_addr = *pAddr;
badworden = Efuse_WordEnableDataWrite(padapter, efuse_addr+1, pTargetPkt->word_en, pTargetPkt->data, bPseudoTest);
- if (badworden != 0x0F) {
- DBG_8192C("%s: Fail!!\n", __func__);
+ if (badworden != 0x0F)
return false;
- }
-/* DBG_8192C("%s: ok\n", __func__); */
return true;
}
@@ -1830,7 +1584,7 @@ static s32 Hal_EfusePgPacketWrite(
bool bPseudoTest
)
{
- PGPKT_STRUCT targetPkt;
+ struct pgpkt_struct targetPkt;
u16 startAddr = 0;
u8 efuseType = EFUSE_WIFI;
@@ -1859,7 +1613,7 @@ static bool Hal_EfusePgPacketWrite_BT(
bool bPseudoTest
)
{
- PGPKT_STRUCT targetPkt;
+ struct pgpkt_struct targetPkt;
u16 startAddr = 0;
u8 efuseType = EFUSE_BT;
@@ -1880,10 +1634,10 @@ static bool Hal_EfusePgPacketWrite_BT(
return true;
}
-static HAL_VERSION ReadChipVersion8723B(struct adapter *padapter)
+static struct hal_version ReadChipVersion8723B(struct adapter *padapter)
{
u32 value32;
- HAL_VERSION ChipVersion;
+ struct hal_version ChipVersion;
struct hal_com_data *pHalData;
/* YJ, TODO, move read chip type here */
@@ -1920,8 +1674,6 @@ static HAL_VERSION ReadChipVersion8723B(struct adapter *padapter)
else
pHalData->rf_type = RF_1T1R;
- MSG_8192C("RF_Type is %x!!\n", pHalData->rf_type);
-
return ChipVersion;
}
@@ -1993,12 +1745,6 @@ static void ResumeTxBeacon(struct adapter *padapter)
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-
- /* 2010.03.01. Marked by tynli. No need to call workitem beacause 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"));
-
pHalData->RegFwHwTxQCtrl |= BIT(6);
rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, pHalData->RegFwHwTxQCtrl);
rtw_write8(padapter, REG_TBTT_PROHIBIT+1, 0xff);
@@ -2010,12 +1756,6 @@ static void StopTxBeacon(struct adapter *padapter)
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-
- /* 2010.03.01. Marked by tynli. No need to call workitem beacause 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"));
-
pHalData->RegFwHwTxQCtrl &= ~BIT(6);
rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, pHalData->RegFwHwTxQCtrl);
rtw_write8(padapter, REG_TBTT_PROHIBIT+1, 0x64);
@@ -2094,7 +1834,7 @@ static void rtl8723b_SetBeaconRelatedRegisters(struct adapter *padapter)
static void rtl8723b_GetHalODMVar(
struct adapter *Adapter,
- enum HAL_ODM_VARIABLE eVariable,
+ enum hal_odm_variable eVariable,
void *pValue1,
void *pValue2
)
@@ -2104,7 +1844,7 @@ static void rtl8723b_GetHalODMVar(
static void rtl8723b_SetHalODMVar(
struct adapter *Adapter,
- enum HAL_ODM_VARIABLE eVariable,
+ enum hal_odm_variable eVariable,
void *pValue1,
bool bSet
)
@@ -2114,13 +1854,10 @@ static void rtl8723b_SetHalODMVar(
static void hal_notch_filter_8723b(struct adapter *adapter, bool enable)
{
- if (enable) {
- DBG_871X("Enable notch filter\n");
+ if (enable)
rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) | BIT1);
- } else {
- DBG_871X("Disable notch filter\n");
+ else
rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) & ~BIT1);
- }
}
static void UpdateHalRAMask8723B(struct adapter *padapter, u32 mac_id, u8 rssi_level)
@@ -2133,8 +1870,6 @@ static void UpdateHalRAMask8723B(struct adapter *padapter, u32 mac_id, u8 rssi_l
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- DBG_871X("%s(): mac_id =%d rssi_level =%d\n", __func__, mac_id, rssi_level);
-
if (mac_id >= NUM_STA) /* CAM_SIZE */
return;
@@ -2148,31 +1883,18 @@ static void UpdateHalRAMask8723B(struct adapter *padapter, u32 mac_id, u8 rssi_l
rate_bitmap = 0xffffffff;
rate_bitmap = ODM_Get_Rate_Bitmap(&pHalData->odmpriv, mac_id, mask, rssi_level);
- DBG_871X("%s => mac_id:%d, networkType:0x%02x, mask:0x%08x\n\t ==> rssi_level:%d, rate_bitmap:0x%08x\n",
- __func__, mac_id, psta->wireless_mode, mask, rssi_level, rate_bitmap);
mask &= rate_bitmap;
rate_bitmap = hal_btcoex_GetRaMask(padapter);
mask &= ~rate_bitmap;
-#ifdef CONFIG_CMCC_TEST
- if (pmlmeext->cur_wireless_mode & WIRELESS_11G) {
- if (mac_id == 0) {
- DBG_871X("CMCC_BT update raid entry, mask = 0x%x\n", mask);
- mask &= 0xffffff00; /* disable CCK & <24M OFDM rate for 11G mode for CMCC */
- DBG_871X("CMCC_BT update raid entry, mask = 0x%x\n", mask);
- }
- }
-#endif
-
if (pHalData->fw_ractrl) {
rtl8723b_set_FwMacIdConfig_cmd(padapter, mac_id, psta->raid, psta->bw_mode, shortGIrate, mask);
}
/* set correct initial date rate for each mac_id */
pdmpriv->INIDATA_RATE[mac_id] = psta->init_rate;
- DBG_871X("%s(): mac_id =%d raid = 0x%x bw =%d mask = 0x%x init_rate = 0x%x\n", __func__, mac_id, psta->raid, psta->bw_mode, mask, psta->init_rate);
}
@@ -2302,8 +2024,6 @@ u8 GetEEPROMSize8723B(struct adapter *padapter)
/* 6: EEPROM used is 93C46, 4: boot from E-Fuse. */
size = (cr & BOOT_FROM_EEPROM) ? 6 : 4;
- MSG_8192C("EEPROM type is %s\n", size == 4 ? "E-FUSE" : "93C46");
-
return size;
}
@@ -2335,15 +2055,8 @@ s32 rtl8723b_InitLLTTable(struct adapter *padapter)
}
passing_time = jiffies_to_msecs(jiffies - start);
- if (passing_time > 1000) {
- DBG_8192C(
- "%s: FAIL!! REG_AUTO_LLT(0x%X) =%08x\n",
- __func__,
- REG_AUTO_LLT,
- val32
- );
+ if (passing_time > 1000)
break;
- }
msleep(1);
} while (1);
@@ -2368,9 +2081,6 @@ static bool Hal_GetChnlGroup8723B(u8 Channel, u8 *pGroup)
*pGroup = 3;
else if (12 <= Channel && Channel <= 14)
*pGroup = 4;
- else {
- RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("==>Hal_GetChnlGroup8723B in 2.4 G, but Channel %d in Group not found\n", Channel));
- }
} else {
bIn24G = false;
@@ -2402,21 +2112,7 @@ static bool Hal_GetChnlGroup8723B(u8 Channel, u8 *pGroup)
*pGroup = 12;
else if (173 <= Channel && Channel <= 177)
*pGroup = 13;
- else {
- RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("==>Hal_GetChnlGroup8723B in 5G, but Channel %d in Group not found\n", Channel));
- }
-
}
- RT_TRACE(
- _module_hci_hal_init_c_,
- _drv_info_,
- (
- "<==Hal_GetChnlGroup8723B, (%s) Channel = %d, Group =%d,\n",
- bIn24G ? "2.4G" : "5G",
- Channel,
- *pGroup
- )
- );
return bIn24G;
}
@@ -2431,7 +2127,6 @@ void Hal_InitPGData(struct adapter *padapter, u8 *PROMContent)
memcpy((void *)PROMContent, (void *)pEEPROM->efuse_eeprom_data, HWSET_MAX_SIZE_8723B);
}
} else {/* autoload fail */
- RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("AutoLoad Fail reported from CR9346!!\n"));
if (!pEEPROM->EepromOrEfuse)
EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false);
memcpy((void *)PROMContent, (void *)pEEPROM->efuse_eeprom_data, HWSET_MAX_SIZE_8723B);
@@ -2448,12 +2143,9 @@ void Hal_EfuseParseIDCode(struct adapter *padapter, u8 *hwinfo)
/* Checl 0x8129 again for making sure autoload status!! */
EEPROMId = le16_to_cpu(*((__le16 *)hwinfo));
if (EEPROMId != RTL_EEPROM_ID) {
- DBG_8192C("EEPROM ID(%#x) is invalid!!\n", EEPROMId);
pEEPROM->bautoload_fail_flag = true;
} else
pEEPROM->bautoload_fail_flag = false;
-
- RT_TRACE(_module_hal_init_c_, _drv_notice_, ("EEPROM ID = 0x%04x\n", EEPROMId));
}
static void Hal_ReadPowerValueFromPROM_8723B(
@@ -2472,7 +2164,6 @@ static void Hal_ReadPowerValueFromPROM_8723B(
AutoLoadFail = true;
if (AutoLoadFail) {
- DBG_871X("%s(): Use Default value!\n", __func__);
for (rfPath = 0; rfPath < MAX_RF_PATH; rfPath++) {
/* 2.4G default value */
for (group = 0; group < MAX_CHNL_GROUP_24G; group++) {
@@ -2594,11 +2285,6 @@ void Hal_EfuseParseTxPowerInfo_8723B(
pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][group];
pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][group];
}
-#ifdef DEBUG
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("======= Path %d, ChannelIndex %d, Group %d =======\n", rfPath, ch, group));
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Index24G_CCK_Base[%d][%d] = 0x%x\n", rfPath, ch, pHalData->Index24G_CCK_Base[rfPath][ch]));
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Index24G_BW40_Base[%d][%d] = 0x%x\n", rfPath, ch, pHalData->Index24G_BW40_Base[rfPath][ch]));
-#endif
}
for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) {
@@ -2606,14 +2292,6 @@ void Hal_EfuseParseTxPowerInfo_8723B(
pHalData->OFDM_24G_Diff[rfPath][TxCount] = pwrInfo24G.OFDM_Diff[rfPath][TxCount];
pHalData->BW20_24G_Diff[rfPath][TxCount] = pwrInfo24G.BW20_Diff[rfPath][TxCount];
pHalData->BW40_24G_Diff[rfPath][TxCount] = pwrInfo24G.BW40_Diff[rfPath][TxCount];
-
-#ifdef DEBUG
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("--------------------------------------- 2.4G ---------------------------------------\n"));
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("CCK_24G_Diff[%d][%d]= %d\n", rfPath, TxCount, pHalData->CCK_24G_Diff[rfPath][TxCount]));
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("OFDM_24G_Diff[%d][%d]= %d\n", rfPath, TxCount, pHalData->OFDM_24G_Diff[rfPath][TxCount]));
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("BW20_24G_Diff[%d][%d]= %d\n", rfPath, TxCount, pHalData->BW20_24G_Diff[rfPath][TxCount]));
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("BW40_24G_Diff[%d][%d]= %d\n", rfPath, TxCount, pHalData->BW40_24G_Diff[rfPath][TxCount]));
-#endif
}
}
@@ -2624,8 +2302,6 @@ void Hal_EfuseParseTxPowerInfo_8723B(
pHalData->EEPROMRegulatory = (EEPROM_DEFAULT_BOARD_OPTION&0x7); /* bit0~2 */
} else
pHalData->EEPROMRegulatory = 0;
-
- RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("EEPROMRegulatory = 0x%x\n", pHalData->EEPROMRegulatory));
}
void Hal_EfuseParseBTCoexistInfo_8723B(
@@ -2666,13 +2342,6 @@ void Hal_EfuseParseBTCoexistInfo_8723B(
}
if (padapter->registrypriv.ant_num > 0) {
- DBG_8192C(
- "%s: Apply driver defined antenna number(%d) to replace origin(%d)\n",
- __func__,
- padapter->registrypriv.ant_num,
- pHalData->EEPROMBluetoothAntNum == Ant_x2 ? 2 : 1
- );
-
switch (padapter->registrypriv.ant_num) {
case 1:
pHalData->EEPROMBluetoothAntNum = Ant_x1;
@@ -2681,11 +2350,6 @@ void Hal_EfuseParseBTCoexistInfo_8723B(
pHalData->EEPROMBluetoothAntNum = Ant_x2;
break;
default:
- DBG_8192C(
- "%s: Discard invalid driver defined antenna number(%d)!\n",
- __func__,
- padapter->registrypriv.ant_num
- );
break;
}
}
@@ -2695,13 +2359,6 @@ void Hal_EfuseParseBTCoexistInfo_8723B(
hal_btcoex_SetPgAntNum(padapter, pHalData->EEPROMBluetoothAntNum == Ant_x2 ? 2 : 1);
if (pHalData->EEPROMBluetoothAntNum == Ant_x1)
hal_btcoex_SetSingleAntPath(padapter, pHalData->ant_path);
-
- DBG_8192C(
- "%s: %s BT-coex, ant_num =%d\n",
- __func__,
- pHalData->EEPROMBluetoothCoexist == true ? "Enable" : "Disable",
- pHalData->EEPROMBluetoothAntNum == Ant_x2 ? 2 : 1
- );
}
void Hal_EfuseParseEEPROMVer_8723B(
@@ -2710,13 +2367,10 @@ void Hal_EfuseParseEEPROMVer_8723B(
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-/* RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("%s(): AutoLoadFail = %d\n", __func__, AutoLoadFail)); */
if (!AutoLoadFail)
pHalData->EEPROMVersion = hwinfo[EEPROM_VERSION_8723B];
else
pHalData->EEPROMVersion = 1;
- RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("Hal_EfuseParseEEPROMVer(), EEVer = %d\n",
- pHalData->EEPROMVersion));
}
@@ -2731,7 +2385,6 @@ void Hal_EfuseParsePackageType_8723B(
Efuse_PowerSwitch(padapter, false, true);
efuse_OneByteRead(padapter, 0x1FB, &efuseContent, false);
- DBG_871X("%s phy efuse read 0x1FB =%x\n", __func__, efuseContent);
Efuse_PowerSwitch(padapter, false, false);
package = efuseContent & 0x7;
@@ -2753,8 +2406,6 @@ void Hal_EfuseParsePackageType_8723B(
pHalData->PackageType = PACKAGE_DEFAULT;
break;
}
-
- DBG_871X("PackageType = 0x%X\n", pHalData->PackageType);
}
@@ -2765,9 +2416,7 @@ void Hal_EfuseParseVoltage_8723B(
struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter);
/* memcpy(pEEPROM->adjuseVoltageVal, &hwinfo[EEPROM_Voltage_ADDR_8723B], 1); */
- DBG_871X("%s hwinfo[EEPROM_Voltage_ADDR_8723B] =%02x\n", __func__, hwinfo[EEPROM_Voltage_ADDR_8723B]);
pEEPROM->adjuseVoltageVal = (hwinfo[EEPROM_Voltage_ADDR_8723B] & 0xf0) >> 4;
- DBG_871X("%s pEEPROM->adjuseVoltageVal =%x\n", __func__, pEEPROM->adjuseVoltageVal);
}
void Hal_EfuseParseChnlPlan_8723B(
@@ -2783,8 +2432,6 @@ void Hal_EfuseParseChnlPlan_8723B(
);
Hal_ChannelPlanToRegulation(padapter, padapter->mlmepriv.ChannelPlan);
-
- RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("EEPROM ChannelPlan = 0x%02x\n", padapter->mlmepriv.ChannelPlan));
}
void Hal_EfuseParseCustomerID_8723B(
@@ -2793,13 +2440,10 @@ void Hal_EfuseParseCustomerID_8723B(
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-/* RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("%s(): AutoLoadFail = %d\n", __func__, AutoLoadFail)); */
if (!AutoLoadFail)
pHalData->EEPROMCustomerID = hwinfo[EEPROM_CustomID_8723B];
else
pHalData->EEPROMCustomerID = 0;
-
- RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("EEPROM Customer ID: 0x%2x\n", pHalData->EEPROMCustomerID));
}
void Hal_EfuseParseAntennaDiversity_8723B(
@@ -2816,15 +2460,12 @@ void Hal_EfuseParseXtal_8723B(
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-/* RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("%s(): AutoLoadFail = %d\n", __func__, AutoLoadFail)); */
if (!AutoLoadFail) {
pHalData->CrystalCap = hwinfo[EEPROM_XTAL_8723B];
if (pHalData->CrystalCap == 0xFF)
pHalData->CrystalCap = EEPROM_Default_CrystalCap_8723B; /* what value should 8812 set? */
} else
pHalData->CrystalCap = EEPROM_Default_CrystalCap_8723B;
-
- RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("EEPROM CrystalCap: 0x%2x\n", pHalData->CrystalCap));
}
@@ -2834,7 +2475,6 @@ void Hal_EfuseParseThermalMeter_8723B(
{
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
-/* RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("%s(): AutoLoadFail = %d\n", __func__, AutoLoadFail)); */
/* */
/* ThermalMeter from EEPROM */
/* */
@@ -2847,8 +2487,6 @@ void Hal_EfuseParseThermalMeter_8723B(
pHalData->bAPKThermalMeterIgnore = true;
pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_8723B;
}
-
- RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("EEPROM ThermalMeter = 0x%x\n", pHalData->EEPROMThermalMeter));
}
@@ -2862,15 +2500,11 @@ void Hal_ReadRFGainOffset(
if (!AutoloadFail) {
Adapter->eeprompriv.EEPROMRFGainOffset = PROMContent[EEPROM_RF_GAIN_OFFSET];
- DBG_871X("AutoloadFail =%x,\n", AutoloadFail);
Adapter->eeprompriv.EEPROMRFGainVal = EFUSE_Read1Byte(Adapter, EEPROM_RF_GAIN_VAL);
- DBG_871X("Adapter->eeprompriv.EEPROMRFGainVal =%x\n", Adapter->eeprompriv.EEPROMRFGainVal);
} else {
Adapter->eeprompriv.EEPROMRFGainOffset = 0;
Adapter->eeprompriv.EEPROMRFGainVal = 0xFF;
- DBG_871X("else AutoloadFail =%x,\n", AutoloadFail);
}
- DBG_871X("EEPRORFGainOffset = 0x%02x\n", Adapter->eeprompriv.EEPROMRFGainOffset);
}
u8 BWMapping_8723B(struct adapter *Adapter, struct pkt_attrib *pattrib)
@@ -2878,8 +2512,6 @@ u8 BWMapping_8723B(struct adapter *Adapter, struct pkt_attrib *pattrib)
u8 BWSettingOfDesc = 0;
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- /* DBG_871X("BWMapping pHalData->CurrentChannelBW %d, pattrib->bwmode %d\n", pHalData->CurrentChannelBW, pattrib->bwmode); */
-
if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_80) {
if (pattrib->bwmode == CHANNEL_WIDTH_80)
BWSettingOfDesc = 2;
@@ -2906,8 +2538,6 @@ u8 SCMapping_8723B(struct adapter *Adapter, struct pkt_attrib *pattrib)
u8 SCSettingOfDesc = 0;
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- /* DBG_871X("SCMapping: pHalData->CurrentChannelBW %d, pHalData->nCur80MhzPrimeSC %d, pHalData->nCur40MhzPrimeSC %d\n", pHalData->CurrentChannelBW, pHalData->nCur80MhzPrimeSC, pHalData->nCur40MhzPrimeSC); */
-
if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_80) {
if (pattrib->bwmode == CHANNEL_WIDTH_80) {
SCSettingOfDesc = VHT_DATA_SC_DONOT_CARE;
@@ -2916,8 +2546,6 @@ u8 SCMapping_8723B(struct adapter *Adapter, struct pkt_attrib *pattrib)
SCSettingOfDesc = VHT_DATA_SC_40_LOWER_OF_80MHZ;
else if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)
SCSettingOfDesc = VHT_DATA_SC_40_UPPER_OF_80MHZ;
- else
- DBG_871X("SCMapping: Not Correct Primary40MHz Setting\n");
} else {
if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER))
SCSettingOfDesc = VHT_DATA_SC_20_LOWEST_OF_80MHZ;
@@ -2927,12 +2555,8 @@ u8 SCMapping_8723B(struct adapter *Adapter, struct pkt_attrib *pattrib)
SCSettingOfDesc = VHT_DATA_SC_20_UPPER_OF_80MHZ;
else if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER))
SCSettingOfDesc = VHT_DATA_SC_20_UPPERST_OF_80MHZ;
- else
- DBG_871X("SCMapping: Not Correct Primary40MHz Setting\n");
}
} else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) {
- /* DBG_871X("SCMapping: HT Case: pHalData->CurrentChannelBW %d, pHalData->nCur40MhzPrimeSC %d\n", pHalData->CurrentChannelBW, pHalData->nCur40MhzPrimeSC); */
-
if (pattrib->bwmode == CHANNEL_WIDTH_40) {
SCSettingOfDesc = VHT_DATA_SC_DONOT_CARE;
} else if (pattrib->bwmode == CHANNEL_WIDTH_20) {
@@ -2999,10 +2623,8 @@ static u8 fill_txdesc_sectype(struct pkt_attrib *pattrib)
return sectype;
}
-static void fill_txdesc_vcs_8723b(struct adapter *padapter, struct pkt_attrib *pattrib, PTXDESC_8723B ptxdesc)
+static void fill_txdesc_vcs_8723b(struct adapter *padapter, struct pkt_attrib *pattrib, struct txdesc_8723b *ptxdesc)
{
- /* DBG_8192C("cvs_mode =%d\n", pattrib->vcs_mode); */
-
if (pattrib->vcs_mode) {
switch (pattrib->vcs_mode) {
case RTS_CTS:
@@ -3032,10 +2654,8 @@ static void fill_txdesc_vcs_8723b(struct adapter *padapter, struct pkt_attrib *p
}
}
-static void fill_txdesc_phy_8723b(struct adapter *padapter, struct pkt_attrib *pattrib, PTXDESC_8723B ptxdesc)
+static void fill_txdesc_phy_8723b(struct adapter *padapter, struct pkt_attrib *pattrib, struct txdesc_8723b *ptxdesc)
{
- /* DBG_8192C("bwmode =%d, ch_off =%d\n", pattrib->bwmode, pattrib->ch_offset); */
-
if (pattrib->ht_en) {
ptxdesc->data_bw = BWMapping_8723B(padapter, pattrib);
@@ -3052,7 +2672,7 @@ static void rtl8723b_fill_default_txdesc(
struct mlme_ext_priv *pmlmeext;
struct mlme_ext_info *pmlmeinfo;
struct pkt_attrib *pattrib;
- PTXDESC_8723B ptxdesc;
+ struct txdesc_8723b *ptxdesc;
s32 bmcst;
memset(pbuf, 0, TXDESC_SIZE);
@@ -3065,7 +2685,7 @@ static void rtl8723b_fill_default_txdesc(
pattrib = &pxmitframe->attrib;
bmcst = IS_MCAST(pattrib->ra);
- ptxdesc = (PTXDESC_8723B)pbuf;
+ ptxdesc = (struct txdesc_8723b *)pbuf;
if (pxmitframe->frame_tag == DATA_FRAMETAG) {
u8 drv_userate = 0;
@@ -3087,9 +2707,6 @@ static void rtl8723b_fill_default_txdesc(
(pattrib->ether_type != 0x88B4) &&
(pattrib->dhcp_pkt != 1) &&
(drv_userate != 1)
-#ifdef CONFIG_AUTO_AP_MODE
- && (!pattrib->pctrl)
-#endif
) {
/* Non EAP & ARP & DHCP type data packet */
@@ -3126,10 +2743,6 @@ static void rtl8723b_fill_default_txdesc(
ptxdesc->data_ldpc = 1;
if (pattrib->stbc)
ptxdesc->data_stbc = 1;
-
-#ifdef CONFIG_CMCC_TEST
- ptxdesc->data_short = 1; /* use cck short premble */
-#endif
} else {
/* EAP data packet and ARP packet. */
/* Use the 1M data rate to send the EAP/ARP packet. */
@@ -3140,13 +2753,10 @@ static void rtl8723b_fill_default_txdesc(
if (pmlmeinfo->preamble_mode == PREAMBLE_SHORT)
ptxdesc->data_short = 1;/* DATA_SHORT */
ptxdesc->datarate = MRateToHwRate(pmlmeext->tx_rate);
- DBG_871X("YJ: %s(): ARP Data: userate =%d, datarate = 0x%x\n", __func__, ptxdesc->userate, ptxdesc->datarate);
}
ptxdesc->usb_txagg_num = pxmitframe->agg_num;
} else if (pxmitframe->frame_tag == MGNT_FRAMETAG) {
-/* RT_TRACE(_module_hal_xmit_c_, _drv_notice_, ("%s: MGNT_FRAMETAG\n", __func__)); */
-
ptxdesc->macid = pattrib->mac_id; /* CAM_ID(MAC_ID) */
ptxdesc->qsel = pattrib->qsel;
ptxdesc->rate_id = pattrib->raid; /* Rate ID */
@@ -3166,17 +2776,10 @@ static void rtl8723b_fill_default_txdesc(
/* CCX-TXRPT ack for xmit mgmt frames. */
if (pxmitframe->ack_report) {
- #ifdef DBG_CCX
- DBG_8192C("%s set spe_rpt\n", __func__);
- #endif
ptxdesc->spe_rpt = 1;
ptxdesc->sw_define = (u8)(GET_PRIMARY_ADAPTER(padapter)->xmitpriv.seq_no);
}
- } else if (pxmitframe->frame_tag == TXAGG_FRAMETAG) {
- RT_TRACE(_module_hal_xmit_c_, _drv_warning_, ("%s: TXAGG_FRAMETAG\n", __func__));
} else {
- RT_TRACE(_module_hal_xmit_c_, _drv_warning_, ("%s: frame_tag = 0x%x\n", __func__, pxmitframe->frame_tag));
-
ptxdesc->macid = pattrib->mac_id; /* CAM_ID(MAC_ID) */
ptxdesc->rate_id = pattrib->raid; /* Rate ID */
ptxdesc->qsel = pattrib->qsel;
@@ -3325,22 +2928,10 @@ static void hw_var_set_opmode(struct adapter *padapter, u8 variable, u8 *val)
/* set net_type */
Set_MSR(padapter, mode);
- DBG_871X("#### %s() -%d iface_type(0) mode = %d ####\n", __func__, __LINE__, mode);
if ((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) {
{
StopTxBeacon(padapter);
-#ifdef CONFIG_INTERRUPT_BASED_TXBCN
-#ifdef CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT
- rtw_write8(padapter, REG_DRVERLYINT, 0x05); /* restore early int time to 5ms */
- UpdateInterruptMask8812AU(padapter, true, 0, IMR_BCNDMAINT0_8723B);
-#endif /* CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT */
-
-#ifdef CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR
- UpdateInterruptMask8812AU(padapter, true, 0, (IMR_TXBCN0ERR_8723B|IMR_TXBCN0OK_8723B));
-#endif /* CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR */
-
-#endif /* CONFIG_INTERRUPT_BASED_TXBCN */
}
/* disable atim wnd */
@@ -3350,16 +2941,6 @@ static void hw_var_set_opmode(struct adapter *padapter, u8 variable, u8 *val)
ResumeTxBeacon(padapter);
rtw_write8(padapter, REG_BCN_CTRL, DIS_TSF_UDT|EN_BCN_FUNCTION|DIS_BCNQ_SUB);
} else if (mode == _HW_STATE_AP_) {
-#ifdef CONFIG_INTERRUPT_BASED_TXBCN
-#ifdef CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT
- UpdateInterruptMask8723BU(padapter, true, IMR_BCNDMAINT0_8723B, 0);
-#endif /* CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT */
-
-#ifdef CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR
- UpdateInterruptMask8723BU(padapter, true, (IMR_TXBCN0ERR_8723B|IMR_TXBCN0OK_8723B), 0);
-#endif /* CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR */
-
-#endif /* CONFIG_INTERRUPT_BASED_TXBCN */
ResumeTxBeacon(padapter);
@@ -3620,22 +3201,15 @@ static void hw_var_set_mlme_join(struct adapter *padapter, u8 variable, u8 *val)
void CCX_FwC2HTxRpt_8723b(struct adapter *padapter, u8 *pdata, u8 len)
{
- u8 seq_no;
#define GET_8723B_C2H_TX_RPT_LIFE_TIME_OVER(_Header) LE_BITS_TO_1BYTE((_Header + 0), 6, 1)
#define GET_8723B_C2H_TX_RPT_RETRY_OVER(_Header) LE_BITS_TO_1BYTE((_Header + 0), 7, 1)
- /* DBG_871X("%s, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", __func__, */
- /* *pdata, *(pdata+1), *(pdata+2), *(pdata+3), *(pdata+4), *(pdata+5), *(pdata+6), *(pdata+7)); */
-
- seq_no = *(pdata+6);
-
if (GET_8723B_C2H_TX_RPT_RETRY_OVER(pdata) | GET_8723B_C2H_TX_RPT_LIFE_TIME_OVER(pdata)) {
rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_CCX_PKT_FAIL);
}
/*
else if (seq_no != padapter->xmitpriv.seq_no) {
- DBG_871X("tx_seq_no =%d, rpt_seq_no =%d\n", padapter->xmitpriv.seq_no, seq_no);
rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_CCX_PKT_FAIL);
}
*/
@@ -3658,10 +3232,8 @@ s32 c2h_handler_8723b(struct adapter *padapter, u8 *buf)
{
struct c2h_evt_hdr_88xx *pC2hEvent = (struct c2h_evt_hdr_88xx *)buf;
s32 ret = _SUCCESS;
- u8 index = 0;
if (!pC2hEvent) {
- DBG_8192C("%s(): pC2hEventis NULL\n", __func__);
ret = _FAIL;
goto exit;
}
@@ -3671,7 +3243,6 @@ s32 c2h_handler_8723b(struct adapter *padapter, u8 *buf)
break;
case C2H_DBG:
{
- RT_TRACE(_module_hal_init_c_, _drv_info_, ("c2h_handler_8723b: %s\n", pC2hEvent->payload));
}
break;
@@ -3684,10 +3255,6 @@ s32 c2h_handler_8723b(struct adapter *padapter, u8 *buf)
break;
case C2H_HW_INFO_EXCH:
- RT_TRACE(_module_hal_init_c_, _drv_info_, ("[BT], C2H_HW_INFO_EXCH\n"));
- for (index = 0; index < pC2hEvent->plen; index++) {
- RT_TRACE(_module_hal_init_c_, _drv_info_, ("[BT], tmpBuf[%d]= 0x%x\n", index, pC2hEvent->payload[index]));
- }
break;
case C2H_8723B_BT_INFO:
@@ -3706,21 +3273,16 @@ exit:
return ret;
}
-static void process_c2h_event(struct adapter *padapter, PC2H_EVT_HDR pC2hEvent, u8 *c2hBuf)
+static void process_c2h_event(struct adapter *padapter, struct c2h_evt_hdr_t *pC2hEvent, u8 *c2hBuf)
{
- u8 index = 0;
-
- if (!c2hBuf) {
- DBG_8192C("%s c2hbuff is NULL\n", __func__);
+ if (!c2hBuf)
return;
- }
switch (pC2hEvent->CmdID) {
case C2H_AP_RPT_RSP:
break;
case C2H_DBG:
{
- RT_TRACE(_module_hal_init_c_, _drv_info_, ("C2HCommandHandler: %s\n", c2hBuf));
}
break;
@@ -3733,10 +3295,6 @@ static void process_c2h_event(struct adapter *padapter, PC2H_EVT_HDR pC2hEvent,
break;
case C2H_HW_INFO_EXCH:
- RT_TRACE(_module_hal_init_c_, _drv_info_, ("[BT], C2H_HW_INFO_EXCH\n"));
- for (index = 0; index < pC2hEvent->CmdLen; index++) {
- RT_TRACE(_module_hal_init_c_, _drv_info_, ("[BT], tmpBuf[%d]= 0x%x\n", index, c2hBuf[index]));
- }
break;
case C2H_8723B_BT_INFO:
@@ -3750,24 +3308,15 @@ static void process_c2h_event(struct adapter *padapter, PC2H_EVT_HDR pC2hEvent,
void C2HPacketHandler_8723B(struct adapter *padapter, u8 *pbuffer, u16 length)
{
- C2H_EVT_HDR C2hEvent;
+ struct c2h_evt_hdr_t C2hEvent;
u8 *tmpBuf = NULL;
-#ifdef CONFIG_WOWLAN
- struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
-
- if (pwrpriv->wowlan_mode) {
- DBG_871X("%s(): return because wowolan_mode ==true! CMDID =%d\n", __func__, pbuffer[0]);
- return;
- }
-#endif
C2hEvent.CmdID = pbuffer[0];
C2hEvent.CmdSeq = pbuffer[1];
C2hEvent.CmdLen = length-2;
tmpBuf = pbuffer+2;
- /* DBG_871X("%s C2hEvent.CmdID:%x C2hEvent.CmdLen:%x C2hEvent.CmdSeq:%x\n", */
- /* __func__, C2hEvent.CmdID, C2hEvent.CmdLen, C2hEvent.CmdSeq); */
- RT_PRINT_DATA(_module_hal_init_c_, _drv_notice_, "C2HPacketHandler_8723B(): Command Content:\n", tmpBuf, C2hEvent.CmdLen);
+ print_hex_dump_debug(DRIVER_PREFIX ": C2HPacketHandler_8723B(): Command Content:\n",
+ DUMP_PREFIX_NONE, 16, 1, tmpBuf, C2hEvent.CmdLen, false);
process_c2h_event(padapter, &C2hEvent, tmpBuf);
/* c2h_handler_8723b(padapter,&C2hEvent); */
@@ -3807,22 +3356,15 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
case HW_VAR_BASIC_RATE:
{
struct mlme_ext_info *mlmext_info = &padapter->mlmeextpriv.mlmext_info;
- u16 input_b = 0, masked = 0, ioted = 0, BrateCfg = 0;
+ u16 BrateCfg = 0;
u16 rrsr_2g_force_mask = (RRSR_11M|RRSR_5_5M|RRSR_1M);
u16 rrsr_2g_allow_mask = (RRSR_24M|RRSR_12M|RRSR_6M|RRSR_CCK_RATES);
HalSetBrateCfg(padapter, val, &BrateCfg);
- input_b = BrateCfg;
/* apply force and allow mask */
BrateCfg |= rrsr_2g_force_mask;
BrateCfg &= rrsr_2g_allow_mask;
- masked = BrateCfg;
-
- #ifdef CONFIG_CMCC_TEST
- BrateCfg |= (RRSR_11M|RRSR_5_5M|RRSR_1M); /* use 11M to send ACK */
- BrateCfg |= (RRSR_24M|RRSR_18M|RRSR_12M); /* CMCC_OFDM_ACK 12/18/24M */
- #endif
/* IOT consideration */
if (mlmext_info->assoc_AP_vendor == HT_IOT_PEER_CISCO) {
@@ -3830,12 +3372,9 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
if ((BrateCfg & (RRSR_24M|RRSR_12M|RRSR_6M)) == 0)
BrateCfg |= RRSR_6M;
}
- ioted = BrateCfg;
pHalData->BasicRateSet = BrateCfg;
- DBG_8192C("HW_VAR_BASIC_RATE: %#x -> %#x -> %#x\n", input_b, masked, ioted);
-
/* Set RRSR rate table. */
rtw_write16(padapter, REG_RRSR, BrateCfg);
rtw_write8(padapter, REG_RRSR+2, rtw_read8(padapter, REG_RRSR+2)&0xf0);
@@ -3899,14 +3438,12 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
val32 = rtw_read32(padapter, REG_RCR);
val32 |= RCR_AM;
rtw_write32(padapter, REG_RCR, val32);
- DBG_8192C("%s, %d, RCR = %x\n", __func__, __LINE__, rtw_read32(padapter, REG_RCR));
break;
case HW_VAR_OFF_RCR_AM:
val32 = rtw_read32(padapter, REG_RCR);
val32 &= ~RCR_AM;
rtw_write32(padapter, REG_RCR, val32);
- DBG_8192C("%s, %d, RCR = %x\n", __func__, __LINE__, rtw_read32(padapter, REG_RCR));
break;
case HW_VAR_BEACON_INTERVAL:
@@ -3962,9 +3499,7 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
ulCommand = ulCommand | CAM_POLLINIG | CAM_WRITE;
/* write content 0 is equall to mark invalid */
rtw_write32(padapter, WCAMI, ulContent); /* mdelay(40); */
- /* RT_TRACE(COMP_SEC, DBG_LOUD, ("CAM_empty_entry(): WRITE A4: %lx\n", ulContent)); */
rtw_write32(padapter, RWCAM, ulCommand); /* mdelay(40); */
- /* RT_TRACE(COMP_SEC, DBG_LOUD, ("CAM_empty_entry(): WRITE A0: %lx\n", ulCommand)); */
}
}
break;
@@ -4020,7 +3555,6 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
hwctrl |= AcmHw_VoqEn;
}
- DBG_8192C("[HW_VAR_ACM_CTRL] Write 0x%02X\n", hwctrl);
rtw_write8(padapter, REG_ACMHWCTRL, hwctrl);
}
break;
@@ -4066,7 +3600,7 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
case HW_VAR_INITIAL_GAIN:
{
- DIG_T *pDigTable = &pHalData->odmpriv.DM_DigTable;
+ struct dig_t *pDigTable = &pHalData->odmpriv.DM_DigTable;
u32 rx_gain = *(u32 *)val;
if (rx_gain == 0xff) {/* restore rx gain */
@@ -4124,14 +3658,8 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
val32 &= RXDMA_IDLE;
if (val32)
break;
-
- DBG_871X("%s: [HW_VAR_FIFO_CLEARN_UP] val =%x times:%d\n", __func__, val32, trycnt);
} while (--trycnt);
- if (trycnt == 0) {
- DBG_8192C("[HW_VAR_FIFO_CLEARN_UP] Stop RX DMA failed......\n");
- }
-
/* RQPN Load 0 */
rtw_write16(padapter, REG_RQPN_NPQ, 0);
rtw_write32(padapter, REG_RQPN, 0x80000000);
@@ -4142,17 +3670,14 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
case HW_VAR_APFM_ON_MAC:
pHalData->bMacPwrCtrlOn = *val;
- DBG_8192C("%s: bMacPwrCtrlOn =%d\n", __func__, pHalData->bMacPwrCtrlOn);
break;
case HW_VAR_NAV_UPPER:
{
u32 usNavUpper = *((u32 *)val);
- if (usNavUpper > HAL_NAV_UPPER_UNIT_8723B * 0xFF) {
- RT_TRACE(_module_hal_init_c_, _drv_notice_, ("The setting value (0x%08X us) of NAV_UPPER is larger than (%d * 0xFF)!!!\n", usNavUpper, HAL_NAV_UPPER_UNIT_8723B));
+ if (usNavUpper > HAL_NAV_UPPER_UNIT_8723B * 0xFF)
break;
- }
usNavUpper = DIV_ROUND_UP(usNavUpper,
HAL_NAV_UPPER_UNIT_8723B);
@@ -4202,16 +3727,12 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
case HW_VAR_MACID_SLEEP:
/* Input is MACID */
val32 = *(u32 *)val;
- if (val32 > 31) {
- DBG_8192C(FUNC_ADPT_FMT ": [HW_VAR_MACID_SLEEP] Invalid macid(%d)\n",
- FUNC_ADPT_ARG(padapter), val32);
+ if (val32 > 31)
break;
- }
+
val8 = (u8)val32; /* macid is between 0~31 */
val32 = rtw_read32(padapter, REG_MACID_SLEEP);
- DBG_8192C(FUNC_ADPT_FMT ": [HW_VAR_MACID_SLEEP] macid =%d, org MACID_SLEEP = 0x%08X\n",
- FUNC_ADPT_ARG(padapter), val8, val32);
if (val32 & BIT(val8))
break;
val32 |= BIT(val8);
@@ -4221,16 +3742,12 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
case HW_VAR_MACID_WAKEUP:
/* Input is MACID */
val32 = *(u32 *)val;
- if (val32 > 31) {
- DBG_8192C(FUNC_ADPT_FMT ": [HW_VAR_MACID_WAKEUP] Invalid macid(%d)\n",
- FUNC_ADPT_ARG(padapter), val32);
+ if (val32 > 31)
break;
- }
+
val8 = (u8)val32; /* macid is between 0~31 */
val32 = rtw_read32(padapter, REG_MACID_SLEEP);
- DBG_8192C(FUNC_ADPT_FMT ": [HW_VAR_MACID_WAKEUP] macid =%d, org MACID_SLEEP = 0x%08X\n",
- FUNC_ADPT_ARG(padapter), val8, val32);
if (!(val32 & BIT(val8)))
break;
val32 &= ~BIT(val8);
@@ -4314,19 +3831,6 @@ void GetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
val16 = rtw_read16(padapter, REG_TXPKT_EMPTY);
*val = (val16 & BIT(10)) ? true:false;
break;
-#ifdef CONFIG_WOWLAN
- case HW_VAR_RPWM_TOG:
- *val = rtw_read8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HRPWM1) & BIT7;
- break;
- case HW_VAR_WAKEUP_REASON:
- *val = rtw_read8(padapter, REG_WOWLAN_WAKE_REASON);
- if (*val == 0xEA)
- *val = 0;
- break;
- case HW_VAR_SYS_CLKR:
- *val = rtw_read8(padapter, REG_SYS_CLKR);
- break;
-#endif
default:
GetHwReg(padapter, variable, val);
break;
@@ -4336,7 +3840,7 @@ void GetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val)
/* Description:
* Change default setting of specified variable.
*/
-u8 SetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, void *pval)
+u8 SetHalDefVar8723B(struct adapter *padapter, enum hal_def_variable variable, void *pval)
{
u8 bResult;
@@ -4354,7 +3858,7 @@ u8 SetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, v
/* Description:
* Query setting of specified variable.
*/
-u8 GetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, void *pval)
+u8 GetHalDefVar8723B(struct adapter *padapter, enum hal_def_variable variable, void *pval)
{
u8 bResult;
@@ -4398,19 +3902,12 @@ u8 GetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, v
u32 rate_mask1, rate_mask2;
u8 curr_tx_rate, curr_tx_sgi, hight_rate, lowest_rate;
- DBG_8192C("============ RA status check Mac_id:%d ===================\n", mac_id);
-
cmd = 0x40000100 | mac_id;
rtw_write32(padapter, REG_HMEBOX_DBG_2_8723B, cmd);
msleep(10);
ra_info1 = rtw_read32(padapter, 0x2F0);
curr_tx_rate = ra_info1&0x7F;
curr_tx_sgi = (ra_info1>>7)&0x01;
- DBG_8192C("[ ra_info1:0x%08x ] =>cur_tx_rate = %s, cur_sgi:%d, PWRSTS = 0x%02x \n",
- ra_info1,
- HDATA_RATE(curr_tx_rate),
- curr_tx_sgi,
- (ra_info1>>8) & 0x07);
cmd = 0x40000400 | mac_id;
rtw_write32(padapter, REG_HMEBOX_DBG_2_8723B, cmd);
@@ -4422,22 +3919,6 @@ u8 GetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, v
hight_rate = ra_info2&0xFF;
lowest_rate = (ra_info2>>8) & 0xFF;
- DBG_8192C("[ ra_info1:0x%08x ] =>RSSI =%d, BW_setting = 0x%02x, DISRA = 0x%02x, VHT_EN = 0x%02x\n",
- ra_info1,
- ra_info1&0xFF,
- (ra_info1>>8) & 0xFF,
- (ra_info1>>16) & 0xFF,
- (ra_info1>>24) & 0xFF);
-
- DBG_8192C("[ ra_info2:0x%08x ] =>hight_rate =%s, lowest_rate =%s, SGI = 0x%02x, RateID =%d\n",
- ra_info2,
- HDATA_RATE(hight_rate),
- HDATA_RATE(lowest_rate),
- (ra_info2>>16) & 0xFF,
- (ra_info2>>24) & 0xFF);
-
- DBG_8192C("rate_mask2 = 0x%08x, rate_mask1 = 0x%08x\n", rate_mask2, rate_mask1);
-
}
break;
@@ -4461,29 +3942,15 @@ u8 GetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, v
return bResult;
}
-#ifdef CONFIG_WOWLAN
-void Hal_DetectWoWMode(struct adapter *padapter)
-{
- adapter_to_pwrctl(padapter)->bSupportRemoteWakeup = true;
- DBG_871X("%s\n", __func__);
-}
-#endif /* CONFIG_WOWLAN */
-
void rtl8723b_start_thread(struct adapter *padapter)
{
-#ifndef CONFIG_SDIO_TX_TASKLET
struct xmit_priv *xmitpriv = &padapter->xmitpriv;
xmitpriv->SdioXmitThread = kthread_run(rtl8723bs_xmit_thread, padapter, "RTWHALXT");
- if (IS_ERR(xmitpriv->SdioXmitThread)) {
- RT_TRACE(_module_hal_xmit_c_, _drv_err_, ("%s: start rtl8723bs_xmit_thread FAIL!!\n", __func__));
- }
-#endif
}
void rtl8723b_stop_thread(struct adapter *padapter)
{
-#ifndef CONFIG_SDIO_TX_TASKLET
struct xmit_priv *xmitpriv = &padapter->xmitpriv;
/* stop xmit_buf_thread */
@@ -4492,36 +3959,4 @@ void rtl8723b_stop_thread(struct adapter *padapter)
wait_for_completion(&xmitpriv->SdioXmitTerminate);
xmitpriv->SdioXmitThread = NULL;
}
-#endif
-}
-
-#if defined(CONFIG_CHECK_BT_HANG)
-extern void check_bt_status_work(void *data);
-void rtl8723bs_init_checkbthang_workqueue(struct adapter *adapter)
-{
- adapter->priv_checkbt_wq = alloc_workqueue("sdio_wq", 0, 0);
- INIT_DELAYED_WORK(&adapter->checkbt_work, (void *)check_bt_status_work);
-}
-
-void rtl8723bs_free_checkbthang_workqueue(struct adapter *adapter)
-{
- if (adapter->priv_checkbt_wq) {
- cancel_delayed_work_sync(&adapter->checkbt_work);
- flush_workqueue(adapter->priv_checkbt_wq);
- destroy_workqueue(adapter->priv_checkbt_wq);
- adapter->priv_checkbt_wq = NULL;
- }
}
-
-void rtl8723bs_cancle_checkbthang_workqueue(struct adapter *adapter)
-{
- if (adapter->priv_checkbt_wq)
- cancel_delayed_work_sync(&adapter->checkbt_work);
-}
-
-void rtl8723bs_hal_check_bt_hang(struct adapter *adapter)
-{
- if (adapter->priv_checkbt_wq)
- queue_delayed_work(adapter->priv_checkbt_wq, &(adapter->checkbt_work), 0);
-}
-#endif
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
index 22365926a9f8..f43abf9b0d22 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
@@ -108,7 +108,7 @@ void PHY_SetBBReg_8723B(
/* */
static u32 phy_RFSerialRead_8723B(
- struct adapter *Adapter, enum RF_PATH eRFPath, u32 Offset
+ struct adapter *Adapter, enum rf_path eRFPath, u32 Offset
)
{
u32 retValue = 0;
@@ -202,7 +202,7 @@ static u32 phy_RFSerialRead_8723B(
*/
static void phy_RFSerialWrite_8723B(
struct adapter *Adapter,
- enum RF_PATH eRFPath,
+ enum rf_path eRFPath,
u32 Offset,
u32 Data
)
@@ -547,11 +547,8 @@ void PHY_SetTxPowerIndex(
break;
default:
- DBG_871X("Invalid Rate!!\n");
break;
}
- } else {
- RT_TRACE(_module_hal_init_c_, _drv_err_, ("Invalid RFPath!!\n"));
}
}
@@ -559,7 +556,7 @@ u8 PHY_GetTxPowerIndex(
struct adapter *padapter,
u8 RFPath,
u8 Rate,
- enum CHANNEL_WIDTH BandWidth,
+ enum channel_width BandWidth,
u8 Channel
)
{
@@ -594,8 +591,8 @@ u8 PHY_GetTxPowerIndex(
void PHY_SetTxPowerLevel8723B(struct adapter *Adapter, u8 Channel)
{
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
- pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable;
+ struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
+ struct fat_t *pDM_FatTable = &pDM_Odm->DM_FatTable;
u8 RFPath = ODM_RF_PATH_A;
if (pHalData->AntDivCfg) {/* antenna diversity Enable */
@@ -604,11 +601,7 @@ void PHY_SetTxPowerLevel8723B(struct adapter *Adapter, u8 Channel)
RFPath = pHalData->ant_path;
}
- RT_TRACE(_module_hal_init_c_, _drv_info_, ("==>PHY_SetTxPowerLevel8723B()\n"));
-
PHY_SetTxPowerLevelByPath(Adapter, Channel, RFPath);
-
- RT_TRACE(_module_hal_init_c_, _drv_info_, ("<==PHY_SetTxPowerLevel8723B()\n"));
}
void PHY_GetTxPowerLevel8723B(struct adapter *Adapter, s32 *powerlevel)
@@ -616,7 +609,7 @@ void PHY_GetTxPowerLevel8723B(struct adapter *Adapter, s32 *powerlevel)
}
static void phy_SetRegBW_8723B(
- struct adapter *Adapter, enum CHANNEL_WIDTH CurrentBW
+ struct adapter *Adapter, enum channel_width CurrentBW
)
{
u16 RegRfMod_BW, u2tmp = 0;
@@ -638,7 +631,6 @@ static void phy_SetRegBW_8723B(
break;
default:
- DBG_871X("phy_PostSetBWMode8723B(): unknown Bandwidth: %#X\n", CurrentBW);
break;
}
}
@@ -648,23 +640,11 @@ static u8 phy_GetSecondaryChnl_8723B(struct adapter *Adapter)
u8 SCSettingOf40 = 0, SCSettingOf20 = 0;
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- RT_TRACE(
- _module_hal_init_c_,
- _drv_info_,
- (
- "SCMapping: VHT Case: pHalData->CurrentChannelBW %d, pHalData->nCur80MhzPrimeSC %d, pHalData->nCur40MhzPrimeSC %d\n",
- pHalData->CurrentChannelBW,
- pHalData->nCur80MhzPrimeSC,
- pHalData->nCur40MhzPrimeSC
- )
- );
if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_80) {
if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)
SCSettingOf40 = VHT_DATA_SC_40_LOWER_OF_80MHZ;
else if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)
SCSettingOf40 = VHT_DATA_SC_40_UPPER_OF_80MHZ;
- else
- RT_TRACE(_module_hal_init_c_, _drv_err_, ("SCMapping: Not Correct Primary40MHz Setting\n"));
if (
(pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) &&
@@ -686,28 +666,13 @@ static u8 phy_GetSecondaryChnl_8723B(struct adapter *Adapter)
(pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)
)
SCSettingOf20 = VHT_DATA_SC_20_UPPERST_OF_80MHZ;
- else
- RT_TRACE(_module_hal_init_c_, _drv_err_, ("SCMapping: Not Correct Primary40MHz Setting\n"));
} else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) {
- RT_TRACE(
- _module_hal_init_c_,
- _drv_info_,
- (
- "SCMapping: VHT Case: pHalData->CurrentChannelBW %d, pHalData->nCur40MhzPrimeSC %d\n",
- pHalData->CurrentChannelBW,
- pHalData->nCur40MhzPrimeSC
- )
- );
-
if (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)
SCSettingOf20 = VHT_DATA_SC_20_UPPER_OF_80MHZ;
else if (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)
SCSettingOf20 = VHT_DATA_SC_20_LOWER_OF_80MHZ;
- else
- RT_TRACE(_module_hal_init_c_, _drv_err_, ("SCMapping: Not Correct Primary40MHz Setting\n"));
}
- RT_TRACE(_module_hal_init_c_, _drv_info_, ("SCMapping: SC Value %x\n", ((SCSettingOf40 << 4) | SCSettingOf20)));
return (SCSettingOf40 << 4) | SCSettingOf20;
}
@@ -768,23 +733,12 @@ static void phy_SwChnl8723B(struct adapter *padapter)
pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff00) | channelToSW);
PHY_SetRFReg(padapter, ODM_RF_PATH_A, RF_CHNLBW, 0x3FF, pHalData->RfRegChnlVal[0]);
PHY_SetRFReg(padapter, ODM_RF_PATH_B, RF_CHNLBW, 0x3FF, pHalData->RfRegChnlVal[0]);
-
- DBG_8192C("===>phy_SwChnl8723B: Channel = %d\n", channelToSW);
}
static void phy_SwChnlAndSetBwMode8723B(struct adapter *Adapter)
{
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- if (Adapter->bNotifyChannelChange) {
- DBG_871X("[%s] bSwChnl =%d, ch =%d, bSetChnlBW =%d, bw =%d\n",
- __func__,
- pHalData->bSwChnl,
- pHalData->CurrentChannel,
- pHalData->bSetChnlBW,
- pHalData->CurrentChannelBW);
- }
-
if (Adapter->bDriverStopped || Adapter->bSurpriseRemoved)
return;
@@ -806,25 +760,23 @@ static void PHY_HandleSwChnlAndSetBW8723B(
bool bSwitchChannel,
bool bSetBandWidth,
u8 ChannelNum,
- enum CHANNEL_WIDTH ChnlWidth,
- enum EXTCHNL_OFFSET ExtChnlOffsetOf40MHz,
- enum EXTCHNL_OFFSET ExtChnlOffsetOf80MHz,
+ enum channel_width ChnlWidth,
+ enum extchnl_offset ExtChnlOffsetOf40MHz,
+ enum extchnl_offset ExtChnlOffsetOf80MHz,
u8 CenterFrequencyIndex1
)
{
/* static bool bInitialzed = false; */
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
u8 tmpChannel = pHalData->CurrentChannel;
- enum CHANNEL_WIDTH tmpBW = pHalData->CurrentChannelBW;
+ enum channel_width tmpBW = pHalData->CurrentChannelBW;
u8 tmpnCur40MhzPrimeSC = pHalData->nCur40MhzPrimeSC;
u8 tmpnCur80MhzPrimeSC = pHalData->nCur80MhzPrimeSC;
u8 tmpCenterFrequencyIndex1 = pHalData->CurrentCenterFrequencyIndex1;
/* check is swchnl or setbw */
- if (!bSwitchChannel && !bSetBandWidth) {
- DBG_871X("PHY_HandleSwChnlAndSetBW8812: not switch channel and not set bandwidth\n");
+ if (!bSwitchChannel && !bSetBandWidth)
return;
- }
/* skip change for channel or bandwidth is the same */
if (bSwitchChannel) {
@@ -874,7 +826,7 @@ static void PHY_HandleSwChnlAndSetBW8723B(
void PHY_SetBWMode8723B(
struct adapter *Adapter,
- enum CHANNEL_WIDTH Bandwidth, /* 20M or 40M */
+ enum channel_width Bandwidth, /* 20M or 40M */
unsigned char Offset /* Upper, Lower, or Don't care */
)
{
@@ -892,7 +844,7 @@ void PHY_SwChnl8723B(struct adapter *Adapter, u8 channel)
void PHY_SetSwChnlBWMode8723B(
struct adapter *Adapter,
u8 channel,
- enum CHANNEL_WIDTH Bandwidth,
+ enum channel_width Bandwidth,
u8 Offset40,
u8 Offset80
)
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
index aafceaf9b139..38228b46b1ee 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
@@ -55,7 +55,7 @@
* Note: For RF type 0222D
*---------------------------------------------------------------------------*/
void PHY_RF6052SetBandwidth8723B(
- struct adapter *Adapter, enum CHANNEL_WIDTH Bandwidth
+ struct adapter *Adapter, enum channel_width Bandwidth
) /* 20M or 40M */
{
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
@@ -74,7 +74,6 @@ void PHY_RF6052SetBandwidth8723B(
break;
default:
- /* RT_TRACE(COMP_DBG, DBG_LOUD, ("PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n", Bandwidth)); */
break;
}
@@ -153,7 +152,6 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
ODM_ConfigRFWithTxPwrTrackHeaderFile(&pHalData->odmpriv);
- /* RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF6052_Config_ParaFile()\n")); */
return _SUCCESS;
}
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c
index 86512264e280..f2f02a69f0af 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c
@@ -13,7 +13,6 @@ static void process_rssi(struct adapter *padapter, union recv_frame *prframe)
struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data;
- /* DBG_8192C("process_rssi => pattrib->rssil(%d) signal_strength(%d)\n ", pattrib->RecvSignalPower, pattrib->signal_strength); */
/* if (pRfd->Status.bPacketToSelf || pRfd->Status.bPacketBeacon) */
{
if (signal_stat->update_req) {
@@ -40,8 +39,6 @@ static void process_link_qual(struct adapter *padapter, union recv_frame *prfram
pattrib = &prframe->u.hdr.attrib;
signal_stat = &padapter->recvpriv.signal_qual_data;
- /* DBG_8192C("process_link_qual => pattrib->signal_qual(%d)\n ", pattrib->signal_qual); */
-
if (signal_stat->update_req) {
signal_stat->total_num = 0;
signal_stat->total_val = 0;
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
index 2d15a5f7648d..7c2680b6508c 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
@@ -38,7 +38,6 @@ static void update_recvframe_attrib(struct adapter *padapter,
/* update rx report to recv_frame attribute */
pattrib->pkt_rpt_type = prxreport->c2h_ind ? C2H_PACKET : NORMAL_RX;
-/* DBG_871X("%s: pkt_rpt_type =%d\n", __func__, pattrib->pkt_rpt_type); */
if (pattrib->pkt_rpt_type == NORMAL_RX) {
/* Normal rx packet */
@@ -98,7 +97,7 @@ static void update_recvframe_phyinfo(union recv_frame *precvframe,
.is_beacon = false,
};
- /* _irqL irqL; */
+ /* unsigned long irqL; */
struct sta_priv *pstapriv;
struct sta_info *psta;
@@ -124,11 +123,9 @@ static void update_recvframe_phyinfo(union recv_frame *precvframe,
pstapriv = &padapter->stapriv;
psta = rtw_get_stainfo(pstapriv, sa);
- if (psta) {
+ if (psta)
pkt_info.station_id = psta->mac_id;
- /* DBG_8192C("%s ==> StationID(%d)\n",
- * __func__, pkt_info.station_id); */
- }
+
pkt_info.data_rate = pattrib->data_rate;
/* rtl8723b_query_rx_phy_status(precvframe, pphy_status); */
@@ -165,8 +162,6 @@ static void rtl8723bs_c2h_packet_handler(struct adapter *padapter,
if (length == 0)
return;
- /* DBG_871X("+%s() length =%d\n", __func__, length); */
-
tmp = rtw_zmalloc(length);
if (!tmp)
return;
@@ -177,8 +172,6 @@ static void rtl8723bs_c2h_packet_handler(struct adapter *padapter,
if (!res)
kfree(tmp);
-
- /* DBG_871X("-%s res(%d)\n", __func__, res); */
}
static inline union recv_frame *try_alloc_recvframe(struct recv_priv *precvpriv,
@@ -188,7 +181,6 @@ static inline union recv_frame *try_alloc_recvframe(struct recv_priv *precvpriv,
precvframe = rtw_alloc_recvframe(&precvpriv->free_recv_queue);
if (!precvframe) {
- DBG_8192C("%s: no enough recv frame!\n", __func__);
rtw_enqueue_recvbuf_to_head(precvbuf,
&precvpriv->recv_buf_pending_queue);
@@ -207,8 +199,6 @@ static inline bool rx_crc_err(struct recv_priv *precvpriv,
{
/* fix Hardware RX data error, drop whole recv_buffer */
if ((!(p_hal_data->ReceiveConfig & RCR_ACRC32)) && pattrib->crc_err) {
- DBG_8192C("%s()-%d: RX Warning! rx CRC ERROR !!\n",
- __func__, __LINE__);
rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue);
return true;
}
@@ -221,8 +211,6 @@ static inline bool pkt_exceeds_tail(struct recv_priv *precvpriv,
union recv_frame *precvframe)
{
if (end > tail) {
- DBG_8192C("%s()-%d: : next pkt len(%p,%d) exceed ptail(%p)!\n",
- __func__, __LINE__, ptr, pkt_offset, precvbuf->ptail);
rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue);
return true;
}
@@ -242,7 +230,7 @@ static void rtl8723bs_recv_tasklet(struct tasklet_struct *t)
struct __queue *recv_buf_queue;
u8 *ptr;
u32 pkt_offset, skb_len, alloc_sz;
- _pkt *pkt_copy = NULL;
+ struct sk_buff *pkt_copy = NULL;
u8 shift_sz = 0, rx_report_sz = 0;
p_hal_data = GET_HAL_DATA(padapter);
@@ -281,9 +269,6 @@ static void rtl8723bs_recv_tasklet(struct tasklet_struct *t)
break;
if ((pattrib->crc_err) || (pattrib->icv_err)) {
- DBG_8192C("%s: crc_err =%d icv_err =%d, skip!\n",
- __func__, pattrib->crc_err,
- pattrib->icv_err);
rtw_free_recvframe(precvframe,
&precvpriv->free_recv_queue);
} else {
@@ -312,7 +297,6 @@ static void rtl8723bs_recv_tasklet(struct tasklet_struct *t)
pkt_copy = rtw_skb_alloc(alloc_sz);
if (!pkt_copy) {
- DBG_8192C("%s: alloc_skb fail, drop frame\n", __func__);
rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue);
break;
}
@@ -345,11 +329,9 @@ static void rtl8723bs_recv_tasklet(struct tasklet_struct *t)
if (pattrib->physt)
update_recvframe_phyinfo(precvframe, (struct phy_stat *)ptr);
- if (rtw_recv_entry(precvframe) != _SUCCESS) {
- RT_TRACE(_module_rtl871x_recv_c_, _drv_dump_, ("%s: rtw_recv_entry(precvframe) != _SUCCESS\n", __func__));
- }
+ rtw_recv_entry(precvframe);
} else if (pattrib->pkt_rpt_type == C2H_PACKET) {
- C2H_EVT_HDR C2hEvent;
+ struct c2h_evt_hdr_t C2hEvent;
u16 len_c2h = pattrib->pkt_len;
u8 *pbuf_c2h = precvframe->u.hdr.rx_data;
@@ -404,7 +386,6 @@ s32 rtl8723bs_init_recv_priv(struct adapter *padapter)
precvpriv->pallocated_recv_buf = rtw_zmalloc(n);
if (!precvpriv->pallocated_recv_buf) {
res = _FAIL;
- RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("alloc recv_buf fail!\n"));
goto exit;
}
@@ -428,10 +409,6 @@ s32 rtl8723bs_init_recv_priv(struct adapter *padapter)
alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1);
skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment));
}
-
- if (!precvbuf->pskb) {
- DBG_871X("%s: alloc_skb fail!\n", __func__);
- }
}
list_add_tail(&precvbuf->list, &precvpriv->free_recv_buf_queue.queue);
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
index a3bd9c2002c9..bd95e62fb053 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
@@ -19,18 +19,12 @@ static u8 rtw_sdio_wait_enough_TxOQT_space(struct adapter *padapter, u8 agg_num)
if (
(padapter->bSurpriseRemoved) ||
(padapter->bDriverStopped)
- ) {
- DBG_871X("%s: bSurpriseRemoved or bDriverStopped (wait TxOQT)\n", __func__);
+ )
return false;
- }
HalQueryTxOQTBufferStatus8723BSdio(padapter);
if ((++n % 60) == 0) {
- if ((n % 300) == 0) {
- DBG_871X("%s(%d): QOT free space(%d), agg_num: %d\n",
- __func__, n, pHalData->SdioTxOQTFreeSpace, agg_num);
- }
msleep(1);
/* yield(); */
}
@@ -101,14 +95,8 @@ query_free_page:
if (
(padapter->bSurpriseRemoved) ||
(padapter->bDriverStopped)
- ) {
- RT_TRACE(
- _module_hal_xmit_c_,
- _drv_notice_,
- ("%s: bSurpriseRemoved(write port)\n", __func__)
- );
+ )
goto free_xmitbuf;
- }
if (rtw_sdio_wait_enough_TxOQT_space(padapter, pxmitbuf->agg_num) == false)
goto free_xmitbuf;
@@ -124,10 +112,6 @@ free_xmitbuf:
/* pxmitbuf->priv_data = NULL; */
rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
-#ifdef CONFIG_SDIO_TX_TASKLET
- tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
-#endif
-
return _FAIL;
}
@@ -149,24 +133,14 @@ s32 rtl8723bs_xmit_buf_handler(struct adapter *padapter)
pxmitpriv = &padapter->xmitpriv;
if (wait_for_completion_interruptible(&pxmitpriv->xmit_comp)) {
- DBG_871X_LEVEL(_drv_emerg_, "%s: down SdioXmitBufSema fail!\n", __func__);
+ netdev_emerg(padapter->pnetdev,
+ "%s: down SdioXmitBufSema fail!\n", __func__);
return _FAIL;
}
ret = (padapter->bDriverStopped) || (padapter->bSurpriseRemoved);
- if (ret) {
- RT_TRACE(
- _module_hal_xmit_c_,
- _drv_err_,
- (
- "%s: bDriverStopped(%d) bSurpriseRemoved(%d)!\n",
- __func__,
- padapter->bDriverStopped,
- padapter->bSurpriseRemoved
- )
- );
+ if (ret)
return _FAIL;
- }
queue_pending = check_pending_xmitbuf(pxmitpriv);
@@ -256,22 +230,6 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv
ptxservq = container_of(sta_plist, struct tx_servq, tx_pending);
sta_plist = get_next(sta_plist);
-#ifdef DBG_XMIT_BUF
- DBG_871X(
- "%s idx:%d hwxmit_pkt_num:%d ptxservq_pkt_num:%d\n",
- __func__,
- idx,
- phwxmit->accnt,
- ptxservq->qcnt
- );
- DBG_871X(
- "%s free_xmit_extbuf_cnt =%d free_xmitbuf_cnt =%d free_xmitframe_cnt =%d\n",
- __func__,
- pxmitpriv->free_xmit_extbuf_cnt,
- pxmitpriv->free_xmitbuf_cnt,
- pxmitpriv->free_xmitframe_cnt
- );
-#endif
pframe_queue = &ptxservq->sta_pending;
frame_phead = get_list_head(pframe_queue);
@@ -307,7 +265,9 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv
pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv);
if (!pxmitbuf) {
#ifdef DBG_XMIT_BUF
- DBG_871X_LEVEL(_drv_err_, "%s: xmit_buf is not enough!\n", __func__);
+ netdev_err(padapter->pnetdev,
+ "%s: xmit_buf is not enough!\n",
+ __func__);
#endif
err = -2;
complete(&(pxmitpriv->xmit_comp));
@@ -317,19 +277,12 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv
}
/* ok to send, remove frame from queue */
- if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true) {
+ if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true)
if (
(pxmitframe->attrib.psta->state & WIFI_SLEEP_STATE) &&
(pxmitframe->attrib.triggered == 0)
- ) {
- DBG_871X(
- "%s: one not triggered pkt in queue when this STA sleep,"
- " break and goto next sta\n",
- __func__
- );
+ )
break;
- }
- }
list_del_init(&pxmitframe->list);
ptxservq->qcnt--;
@@ -346,7 +299,9 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv
ret = rtw_xmitframe_coalesce(padapter, pxmitframe->pkt, pxmitframe);
if (ret == _FAIL) {
- DBG_871X_LEVEL(_drv_err_, "%s: coalesce FAIL!", __func__);
+ netdev_err(padapter->pnetdev,
+ "%s: coalesce FAIL!",
+ __func__);
/* Todo: error handler */
} else {
k++;
@@ -378,8 +333,6 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv
/* dump xmit_buf to hw tx fifo */
if (pxmitbuf) {
- RT_TRACE(_module_hal_xmit_c_, _drv_info_, ("pxmitbuf->len =%d enqueue\n", pxmitbuf->len));
-
if (pxmitbuf->len > 0) {
struct xmit_frame *pframe;
pframe = (struct xmit_frame *)pxmitbuf->priv_data;
@@ -419,7 +372,8 @@ static s32 rtl8723bs_xmit_handler(struct adapter *padapter)
pxmitpriv = &padapter->xmitpriv;
if (wait_for_completion_interruptible(&pxmitpriv->SdioXmitStart)) {
- DBG_871X_LEVEL(_drv_emerg_, "%s: SdioXmitStart fail!\n", __func__);
+ netdev_emerg(padapter->pnetdev, "%s: SdioXmitStart fail!\n",
+ __func__);
return _FAIL;
}
@@ -427,19 +381,8 @@ next:
if (
(padapter->bDriverStopped) ||
(padapter->bSurpriseRemoved)
- ) {
- RT_TRACE(
- _module_hal_xmit_c_,
- _drv_notice_,
- (
- "%s: bDriverStopped(%d) bSurpriseRemoved(%d)\n",
- __func__,
- padapter->bDriverStopped,
- padapter->bSurpriseRemoved
- )
- );
+ )
return _FAIL;
- }
spin_lock_bh(&pxmitpriv->lock);
ret = rtw_txframes_pending(padapter);
@@ -485,8 +428,6 @@ int rtl8723bs_xmit_thread(void *context)
rtw_sprintf(thread_name, 20, "RTWHALXT-%s", ADPT_ARG(padapter));
thread_enter(thread_name);
- DBG_871X("start "FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
-
do {
ret = rtl8723bs_xmit_handler(padapter);
if (signal_pending(current)) {
@@ -496,8 +437,6 @@ int rtl8723bs_xmit_thread(void *context)
complete(&pxmitpriv->SdioXmitTerminate);
- RT_TRACE(_module_hal_xmit_c_, _drv_notice_, ("-%s\n", __func__));
-
thread_exit();
}
@@ -513,8 +452,6 @@ s32 rtl8723bs_mgnt_xmit(
u8 *pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;
u8 txdesc_size = TXDESC_SIZE;
- RT_TRACE(_module_hal_xmit_c_, _drv_info_, ("+%s\n", __func__));
-
pattrib = &pmgntframe->attrib;
pxmitbuf = pmgntframe->pxmitbuf;
@@ -576,7 +513,6 @@ s32 rtl8723bs_hal_xmit(
err = rtw_xmitframe_enqueue(padapter, pxmitframe);
spin_unlock_bh(&pxmitpriv->lock);
if (err != _SUCCESS) {
- RT_TRACE(_module_hal_xmit_c_, _drv_err_, ("rtl8723bs_hal_xmit: enqueue xmitframe fail\n"));
rtw_free_xmitframe(pxmitpriv, pxmitframe);
pxmitpriv->tx_drop++;
@@ -601,11 +537,7 @@ s32 rtl8723bs_hal_xmitframe_enqueue(
pxmitpriv->tx_drop++;
} else {
-#ifdef CONFIG_SDIO_TX_TASKLET
- tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
-#else
complete(&pxmitpriv->SdioXmitStart);
-#endif
}
return err;
diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c
index 718ee9eee87c..abd90026a8c7 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c
@@ -42,63 +42,6 @@ static u8 CardEnable(struct adapter *padapter)
return ret;
}
-#ifdef CONFIG_GPIO_WAKEUP
-/* we set it high under init and fw will */
-/* give us Low Pulse when host wake up */
-void HostWakeUpGpioClear(struct adapter *Adapter)
-{
- u32 value32;
-
- value32 = rtw_read32(Adapter, REG_GPIO_PIN_CTRL_2);
-
- /* set GPIO 12 1 */
- value32 |= BIT(12);/* 4+8 */
- /* GPIO 12 out put */
- value32 |= BIT(20);/* 4+16 */
-
- rtw_write32(Adapter, REG_GPIO_PIN_CTRL_2, value32);
-} /* HostWakeUpGpioClear */
-
-void HalSetOutPutGPIO(struct adapter *padapter, u8 index, u8 OutPutValue)
-{
- if (index <= 7) {
- /* config GPIO mode */
- rtw_write8(padapter, REG_GPIO_PIN_CTRL + 3, rtw_read8(padapter, REG_GPIO_PIN_CTRL + 3) & ~BIT(index));
-
- /* config GPIO Sel */
- /* 0: input */
- /* 1: output */
- rtw_write8(padapter, REG_GPIO_PIN_CTRL + 2, rtw_read8(padapter, REG_GPIO_PIN_CTRL + 2) | BIT(index));
-
- /* set output value */
- if (OutPutValue)
- rtw_write8(padapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(padapter, REG_GPIO_PIN_CTRL + 1) | BIT(index));
- else
- rtw_write8(padapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(padapter, REG_GPIO_PIN_CTRL + 1) & ~BIT(index));
- } else {
- /* 88C Series: */
- /* index: 11~8 transform to 3~0 */
- /* 8723 Series: */
- /* index: 12~8 transform to 4~0 */
- index -= 8;
-
- /* config GPIO mode */
- rtw_write8(padapter, REG_GPIO_PIN_CTRL_2 + 3, rtw_read8(padapter, REG_GPIO_PIN_CTRL_2 + 3) & ~BIT(index));
-
- /* config GPIO Sel */
- /* 0: input */
- /* 1: output */
- rtw_write8(padapter, REG_GPIO_PIN_CTRL_2 + 2, rtw_read8(padapter, REG_GPIO_PIN_CTRL_2 + 2) | BIT(index));
-
- /* set output value */
- if (OutPutValue)
- rtw_write8(padapter, REG_GPIO_PIN_CTRL_2 + 1, rtw_read8(padapter, REG_GPIO_PIN_CTRL_2 + 1) | BIT(index));
- else
- rtw_write8(padapter, REG_GPIO_PIN_CTRL_2 + 1, rtw_read8(padapter, REG_GPIO_PIN_CTRL_2 + 1) & ~BIT(index));
- }
-}
-#endif
-
static
u8 _InitPowerOn_8723BS(struct adapter *padapter)
{
@@ -110,31 +53,11 @@ u8 _InitPowerOn_8723BS(struct adapter *padapter)
/* all of these MUST be configured before power on */
-#ifdef CONFIG_EXT_CLK
- /* Use external crystal(XTAL) */
- value8 = rtw_read8(padapter, REG_PAD_CTRL1_8723B + 2);
- value8 |= BIT(7);
- rtw_write8(padapter, REG_PAD_CTRL1_8723B + 2, value8);
-
- /* CLK_REQ High active or Low Active */
- /* Request GPIO polarity: */
- /* 0: low active */
- /* 1: high active */
- value8 = rtw_read8(padapter, REG_MULTI_FUNC_CTRL + 1);
- value8 |= BIT(5);
- rtw_write8(padapter, REG_MULTI_FUNC_CTRL + 1, value8);
-#endif /* CONFIG_EXT_CLK */
/* only cmd52 can be used before power on(card enable) */
ret = CardEnable(padapter);
- if (!ret) {
- RT_TRACE(
- _module_hci_hal_init_c_,
- _drv_emerg_,
- ("%s: run power on flow fail\n", __func__)
- );
+ if (!ret)
return _FAIL;
- }
/* Radio-Off Pin Trigger */
value8 = rtw_read8(padapter, REG_GPIO_INTM + 1);
@@ -178,21 +101,14 @@ u8 _InitPowerOn_8723BS(struct adapter *padapter)
/* Switch the control of EESK, EECS to RFC for DPDT or Antenna switch */
value16 |= BIT(11); /* BIT_EEPRPAD_RFE_CTRL_EN */
rtw_write16(padapter, REG_PWR_DATA, value16);
-/* DBG_8192C("%s: REG_PWR_DATA(0x%x) = 0x%04X\n", __func__, REG_PWR_DATA, rtw_read16(padapter, REG_PWR_DATA)); */
value32 = rtw_read32(padapter, REG_LEDCFG0);
value32 |= BIT(23); /* DPDT_SEL_EN, 1 for SW control */
rtw_write32(padapter, REG_LEDCFG0, value32);
-/* DBG_8192C("%s: REG_LEDCFG0(0x%x) = 0x%08X\n", __func__, REG_LEDCFG0, rtw_read32(padapter, REG_LEDCFG0)); */
value8 = rtw_read8(padapter, REG_PAD_CTRL1_8723B);
value8 &= ~BIT(0); /* BIT_SW_DPDT_SEL_DATA, DPDT_SEL default configuration */
rtw_write8(padapter, REG_PAD_CTRL1_8723B, value8);
-/* DBG_8192C("%s: REG_PAD_CTRL1(0x%x) = 0x%02X\n", __func__, REG_PAD_CTRL1_8723B, rtw_read8(padapter, REG_PAD_CTRL1_8723B)); */
-
-#ifdef CONFIG_GPIO_WAKEUP
- HostWakeUpGpioClear(padapter);
-#endif
return _SUCCESS;
}
@@ -214,7 +130,6 @@ static void _init_available_page_threshold(struct adapter *padapter, u8 numHQ, u
rtw_write16(padapter, 0x218, HQ_threshold);
rtw_write16(padapter, 0x21A, NQ_threshold);
rtw_write16(padapter, 0x21C, LQ_threshold);
- DBG_8192C("%s(): Enable Tx FIFO Page Threshold H:0x%x, N:0x%x, L:0x%x\n", __func__, HQ_threshold, NQ_threshold, LQ_threshold);
}
static void _InitQueueReservedPage(struct adapter *padapter)
@@ -660,7 +575,6 @@ static void _InitRFType(struct adapter *padapter)
pHalData->rf_chip = RF_6052;
pHalData->rf_type = RF_1T1R;
- DBG_8192C("Set RF Chip ID to RF_6052 and RF type to 1T1R.\n");
}
static void _RfPowerSave(struct adapter *padapter)
@@ -686,8 +600,6 @@ static bool HalDetectPwrDownMode(struct adapter *Adapter)
else
pHalData->pwrdown = false;
- DBG_8192C("HalDetectPwrDownMode(): PDN =%d\n", pHalData->pwrdown);
-
return pHalData->pwrdown;
} /* HalDetectPwrDownMode */
@@ -710,8 +622,6 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter)
u8 cpwm_orig, cpwm_now;
u8 val8, bMacPwrCtrlOn = true;
- DBG_871X("%s: Leaving IPS in FWLPS state\n", __func__);
-
/* for polling cpwm */
cpwm_orig = 0;
rtw_hal_get_hwreg(padapter, HW_VAR_CPWM, &cpwm_orig);
@@ -722,7 +632,6 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter)
val8 += 0x80;
val8 |= BIT(6);
rtw_write8(padapter, SDIO_LOCAL_BASE | SDIO_REG_HRPWM1, val8);
- DBG_871X("%s: write rpwm =%02x\n", __func__, val8);
adapter_to_pwrctl(padapter)->tog = (val8 + 0x80) & 0x80;
/* do polling cpwm */
@@ -735,10 +644,9 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter)
if ((cpwm_orig ^ cpwm_now) & 0x80)
break;
- if (jiffies_to_msecs(jiffies - start_time) > 100) {
- DBG_871X("%s: polling cpwm timeout when leaving IPS in FWLPS state\n", __func__);
+ if (jiffies_to_msecs(jiffies - start_time) > 100)
break;
- }
+
} while (1);
rtl8723b_set_FwPwrModeInIPS_cmd(padapter, 0);
@@ -750,49 +658,21 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter)
return _SUCCESS;
}
-#ifdef CONFIG_WOWLAN
- if (rtw_read8(padapter, REG_MCUFWDL) & BIT7) {
- u8 reg_val = 0;
- DBG_871X("+Reset Entry+\n");
- rtw_write8(padapter, REG_MCUFWDL, 0x00);
- _8051Reset8723(padapter);
- /* reset BB */
- reg_val = rtw_read8(padapter, REG_SYS_FUNC_EN);
- reg_val &= ~(BIT(0) | BIT(1));
- rtw_write8(padapter, REG_SYS_FUNC_EN, reg_val);
- /* reset RF */
- rtw_write8(padapter, REG_RF_CTRL, 0);
- /* reset TRX path */
- rtw_write16(padapter, REG_CR, 0);
- /* reset MAC, Digital Core */
- reg_val = rtw_read8(padapter, REG_SYS_FUNC_EN + 1);
- reg_val &= ~(BIT(4) | BIT(7));
- rtw_write8(padapter, REG_SYS_FUNC_EN + 1, reg_val);
- reg_val = rtw_read8(padapter, REG_SYS_FUNC_EN + 1);
- reg_val |= BIT(4) | BIT(7);
- rtw_write8(padapter, REG_SYS_FUNC_EN + 1, reg_val);
- DBG_871X("-Reset Entry-\n");
- }
-#endif /* CONFIG_WOWLAN */
/* Disable Interrupt first. */
/* rtw_hal_disable_interrupt(padapter); */
ret = _InitPowerOn_8723BS(padapter);
- if (_FAIL == ret) {
- RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("Failed to init Power On!\n"));
+ if (ret == _FAIL)
return _FAIL;
- }
rtw_write8(padapter, REG_EARLY_MODE_CONTROL, 0);
ret = rtl8723b_FirmwareDownload(padapter, false);
if (ret != _SUCCESS) {
- RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("%s: Download Firmware failed!!\n", __func__));
padapter->bFWReady = false;
pHalData->fw_ractrl = false;
return ret;
} else {
- RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("rtl8723bs_hal_init(): Download Firmware Success!!\n"));
padapter->bFWReady = true;
pHalData->fw_ractrl = true;
}
@@ -817,20 +697,16 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter)
#if (HAL_MAC_ENABLE == 1)
ret = PHY_MACConfig8723B(padapter);
- if (ret != _SUCCESS) {
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Initializepadapter8192CSdio(): Fail to configure MAC!!\n"));
+ if (ret != _SUCCESS)
return ret;
- }
#endif
/* */
/* d. Initialize BB related configurations. */
/* */
#if (HAL_BB_ENABLE == 1)
ret = PHY_BBConfig8723B(padapter);
- if (ret != _SUCCESS) {
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Initializepadapter8192CSdio(): Fail to configure BB!!\n"));
+ if (ret != _SUCCESS)
return ret;
- }
#endif
/* If RF is on, we need to init RF. Otherwise, skip the procedure. */
@@ -839,10 +715,8 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter)
{
#if (HAL_RF_ENABLE == 1)
ret = PHY_RFConfig8723B(padapter);
- if (ret != _SUCCESS) {
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Initializepadapter8192CSdio(): Fail to configure RF!!\n"));
+ if (ret != _SUCCESS)
return ret;
- }
#endif
}
@@ -850,9 +724,9 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter)
/* Joseph Note: Keep RfRegChnlVal for later use. */
/* */
pHalData->RfRegChnlVal[0] =
- PHY_QueryRFReg(padapter, (enum RF_PATH)0, RF_CHNLBW, bRFRegOffsetMask);
+ PHY_QueryRFReg(padapter, (enum rf_path)0, RF_CHNLBW, bRFRegOffsetMask);
pHalData->RfRegChnlVal[1] =
- PHY_QueryRFReg(padapter, (enum RF_PATH)1, RF_CHNLBW, bRFRegOffsetMask);
+ PHY_QueryRFReg(padapter, (enum rf_path)1, RF_CHNLBW, bRFRegOffsetMask);
/* if (!pHalData->bMACFuncEnable) { */
@@ -861,10 +735,9 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter)
/* init LLT after tx buffer boundary is defined */
ret = rtl8723b_InitLLTTable(padapter);
- if (_SUCCESS != ret) {
- DBG_8192C("%s: Failed to init LLT Table!\n", __func__);
+ if (ret != _SUCCESS)
return _FAIL;
- }
+
/* */
_InitQueuePriority(padapter);
_InitPageBoundary(padapter);
@@ -992,8 +865,6 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter)
/* Init BT hw config. */
hal_btcoex_InitHwConfig(padapter, false);
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("-%s\n", __func__));
-
return _SUCCESS;
}
@@ -1011,9 +882,6 @@ static void CardDisableRTL8723BSdio(struct adapter *padapter)
/* Run LPS WL RFOFF flow */
ret = HalPwrSeqCmdParsing(padapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, rtl8723B_enter_lps_flow);
- if (ret == _FAIL) {
- DBG_8192C(KERN_ERR "%s: run RF OFF flow fail!\n", __func__);
- }
/* ==== Reset digital sequence ====== */
@@ -1044,9 +912,6 @@ static void CardDisableRTL8723BSdio(struct adapter *padapter)
ret = false;
rtw_hal_set_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn);
ret = HalPwrSeqCmdParsing(padapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, rtl8723B_card_disable_flow);
- if (!ret) {
- DBG_8192C(KERN_ERR "%s: run CARD DISABLE flow fail!\n", __func__);
- }
}
static u32 rtl8723bs_hal_deinit(struct adapter *padapter)
@@ -1060,14 +925,11 @@ static u32 rtl8723bs_hal_deinit(struct adapter *padapter)
int cnt = 0;
u8 val8 = 0;
- DBG_871X("%s: issue H2C to FW when entering IPS\n", __func__);
-
rtl8723b_set_FwPwrModeInIPS_cmd(padapter, 0x3);
/* poll 0x1cc to make sure H2C command already finished by FW; MAC_0x1cc = 0 means H2C done by FW. */
do {
val8 = rtw_read8(padapter, REG_HMETFR);
cnt++;
- DBG_871X("%s polling REG_HMETFR = 0x%x, cnt =%d\n", __func__, val8, cnt);
mdelay(10);
} while (cnt < 100 && (val8 != 0));
/* H2C done, enter 32k */
@@ -1077,32 +939,15 @@ static u32 rtl8723bs_hal_deinit(struct adapter *padapter)
val8 += 0x80;
val8 |= BIT(0);
rtw_write8(padapter, SDIO_LOCAL_BASE | SDIO_REG_HRPWM1, val8);
- DBG_871X("%s: write rpwm =%02x\n", __func__, val8);
adapter_to_pwrctl(padapter)->tog = (val8 + 0x80) & 0x80;
cnt = val8 = 0;
do {
val8 = rtw_read8(padapter, REG_CR);
cnt++;
- DBG_871X("%s polling 0x100 = 0x%x, cnt =%d\n", __func__, val8, cnt);
mdelay(10);
} while (cnt < 100 && (val8 != 0xEA));
- } else {
- DBG_871X(
- "MAC_1C0 =%08x, MAC_1C4 =%08x, MAC_1C8 =%08x, MAC_1CC =%08x\n",
- rtw_read32(padapter, 0x1c0),
- rtw_read32(padapter, 0x1c4),
- rtw_read32(padapter, 0x1c8),
- rtw_read32(padapter, 0x1cc)
- );
}
- DBG_871X(
- "polling done when entering IPS, check result : 0x100 = 0x%x, cnt =%d, MAC_1cc = 0x%02x\n",
- rtw_read8(padapter, REG_CR),
- cnt,
- rtw_read8(padapter, REG_HMETFR)
- );
-
adapter_to_pwrctl(padapter)->pre_ips_type = 0;
} else {
@@ -1129,10 +974,6 @@ static u32 rtl8723bs_inirp_init(struct adapter *padapter)
static u32 rtl8723bs_inirp_deinit(struct adapter *padapter)
{
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("+rtl8723bs_inirp_deinit\n"));
-
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("-rtl8723bs_inirp_deinit\n"));
-
return _SUCCESS;
}
@@ -1229,10 +1070,6 @@ static void Hal_EfuseParseMACAddr_8723BS(
/* Read Permanent MAC address */
memcpy(pEEPROM->mac_addr, &hwinfo[EEPROM_MAC_ADDR_8723BS], ETH_ALEN);
}
-/* NicIFSetMacAddress(padapter, padapter->PermanentAddress); */
-
- RT_TRACE(_module_hci_hal_init_c_, _drv_notice_,
- ("Hal_EfuseParseMACAddr_8723BS: Permanent Address = %pM\n", pEEPROM->mac_addr));
}
static void Hal_EfuseParseBoardType_8723BS(
@@ -1247,7 +1084,6 @@ static void Hal_EfuseParseBoardType_8723BS(
pHalData->BoardType = (EEPROM_DEFAULT_BOARD_OPTION & 0xE0) >> 5;
} else
pHalData->BoardType = 0;
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Board Type: 0x%2x\n", pHalData->BoardType));
}
static void _ReadEfuseInfo8723BS(struct adapter *padapter)
@@ -1255,15 +1091,10 @@ static void _ReadEfuseInfo8723BS(struct adapter *padapter)
struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter);
u8 *hwinfo = NULL;
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("====>_ReadEfuseInfo8723BS()\n"));
-
/* */
/* This part read and parse the eeprom/efuse content */
/* */
- if (sizeof(pEEPROM->efuse_eeprom_data) < HWSET_MAX_SIZE_8723B)
- DBG_871X("[WARNING] size of efuse_eeprom_data is less than HWSET_MAX_SIZE_8723B!\n");
-
hwinfo = pEEPROM->efuse_eeprom_data;
Hal_InitPGData(padapter, hwinfo);
@@ -1289,13 +1120,7 @@ static void _ReadEfuseInfo8723BS(struct adapter *padapter)
Hal_EfuseParseVoltage_8723B(padapter, hwinfo, pEEPROM->bautoload_fail_flag);
-#ifdef CONFIG_WOWLAN
- Hal_DetectWoWMode(padapter);
-#endif
-
Hal_ReadRFGainOffset(padapter, hwinfo, pEEPROM->bautoload_fail_flag);
-
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("<==== _ReadEfuseInfo8723BS()\n"));
}
static void _ReadPROMContent(struct adapter *padapter)
@@ -1308,12 +1133,6 @@ static void _ReadPROMContent(struct adapter *padapter)
pEEPROM->EepromOrEfuse = (eeValue & BOOT_FROM_EEPROM) ? true : false;
pEEPROM->bautoload_fail_flag = (eeValue & EEPROM_EN) ? false : true;
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
- ("%s: 9346CR = 0x%02X, Boot from %s, Autoload %s\n",
- __func__, eeValue,
- (pEEPROM->EepromOrEfuse ? "EEPROM" : "EFUSE"),
- (pEEPROM->bautoload_fail_flag ? "Fail" : "OK")));
-
/* pHalData->EEType = IS_BOOT_FROM_EEPROM(Adapter) ? EEPROM_93C46 : EEPROM_BOOT_EFUSE; */
_ReadEfuseInfo8723BS(padapter);
@@ -1334,9 +1153,6 @@ static void _InitOtherVariable(struct adapter *Adapter)
static s32 _ReadAdapterInfo8723BS(struct adapter *padapter)
{
u8 val8;
- unsigned long start;
-
- RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("+_ReadAdapterInfo8723BS\n"));
/* before access eFuse, make sure card enable has been called */
if (!padapter->hw_init_completed)
@@ -1344,13 +1160,9 @@ static s32 _ReadAdapterInfo8723BS(struct adapter *padapter)
val8 = rtw_read8(padapter, 0x4e);
- MSG_8192C("%s, 0x4e = 0x%x\n", __func__, val8);
val8 |= BIT(6);
rtw_write8(padapter, 0x4e, val8);
-
- start = jiffies;
-
_EfuseCellSel(padapter);
_ReadRFType(padapter);
_ReadPROMContent(padapter);
@@ -1361,9 +1173,6 @@ static s32 _ReadAdapterInfo8723BS(struct adapter *padapter)
CardDisableRTL8723BSdio(padapter);/* for the power consumption issue, wifi ko module is loaded during booting, but wifi GUI is off */
}
-
- MSG_8192C("<==== _ReadAdapterInfo8723BS in %d ms\n", jiffies_to_msecs(jiffies - start));
-
return _SUCCESS;
}
@@ -1383,23 +1192,6 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val)
{
u8 val8;
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
- struct wowlan_ioctl_param *poidparam;
- struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
- int res;
- u32 tmp;
- u16 len = 0;
- u8 trycnt = 100;
- u32 himr = 0;
-#if defined(CONFIG_WOWLAN)
- struct security_priv *psecuritypriv = &padapter->securitypriv;
- struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- struct sta_info *psta = NULL;
- u64 iv_low = 0, iv_high = 0;
- u8 mstatus = (*(u8 *)val);
-#endif
-#endif
-
switch (variable) {
case HW_VAR_SET_RPWM:
/* rpwm value only use BIT0(clock bit) , BIT6(Ack bit), and BIT7(Toggle bit) */
@@ -1424,322 +1216,6 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val)
val8 = *val;
break;
-#ifdef CONFIG_WOWLAN
- case HW_VAR_WOWLAN:
- {
- poidparam = (struct wowlan_ioctl_param *)val;
- switch (poidparam->subcode) {
- case WOWLAN_ENABLE:
- DBG_871X_LEVEL(_drv_always_, "WOWLAN_ENABLE\n");
-
- /* backup data rate to register 0x8b for wowlan FW */
- rtw_write8(padapter, 0x8d, 1);
- rtw_write8(padapter, 0x8c, 0);
- rtw_write8(padapter, 0x8f, 0x40);
- rtw_write8(padapter, 0x8b,
- rtw_read8(padapter, 0x2f0));
-
- /* 1. Download WOWLAN FW */
- DBG_871X_LEVEL(_drv_always_, "Re-download WoWlan FW!\n");
- SetFwRelatedForWoWLAN8723b(padapter, true);
-
- /* 2. RX DMA stop */
- DBG_871X_LEVEL(_drv_always_, "Pause DMA\n");
- rtw_write32(padapter, REG_RXPKT_NUM, (rtw_read32(padapter, REG_RXPKT_NUM) | RW_RELEASE_EN));
- do {
- if ((rtw_read32(padapter, REG_RXPKT_NUM) & RXDMA_IDLE)) {
- DBG_871X_LEVEL(_drv_always_, "RX_DMA_IDLE is true\n");
- break;
- } else {
- /* If RX_DMA is not idle, receive one pkt from DMA */
- res = sdio_local_read(padapter, SDIO_REG_RX0_REQ_LEN, 4, (u8 *)&tmp);
- len = le16_to_cpu(tmp);
- DBG_871X_LEVEL(_drv_always_, "RX len:%d\n", len);
- if (len > 0)
- res = RecvOnePkt(padapter, len);
- else
- DBG_871X_LEVEL(_drv_always_, "read length fail %d\n", len);
-
- DBG_871X_LEVEL(_drv_always_, "RecvOnePkt Result: %d\n", res);
- }
- } while (trycnt--);
- if (trycnt == 0)
- DBG_871X_LEVEL(_drv_always_, "Stop RX DMA failed......\n");
-
- /* 3. Clear IMR and ISR */
- DBG_871X_LEVEL(_drv_always_, "Clear IMR and ISR\n");
- tmp = 0;
- sdio_local_write(padapter, SDIO_REG_HIMR_ON, 4, (u8 *)&tmp);
- sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp);
- sdio_local_read(padapter, SDIO_REG_HISR, 4, (u8 *)&tmp);
- sdio_local_write(padapter, SDIO_REG_HISR, 4, (u8 *)&tmp);
-
- /* 4. Enable CPWM2 only */
- DBG_871X_LEVEL(_drv_always_, "Enable only CPWM2\n");
- sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp);
- DBG_871X("DisableInterruptButCpwm28723BSdio(): Read SDIO_REG_HIMR: 0x%08x\n", tmp);
-
- himr = cpu_to_le32(SDIO_HIMR_DISABLED) | SDIO_HIMR_CPWM2_MSK;
- sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&himr);
-
- sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp);
- DBG_871X("DisableInterruptButCpwm28723BSdio(): Read again SDIO_REG_HIMR: 0x%08x\n", tmp);
-
- /* 5. Set Enable WOWLAN H2C command. */
- DBG_871X_LEVEL(_drv_always_, "Set Enable WOWLan cmd\n");
- rtl8723b_set_wowlan_cmd(padapter, 1);
-
- /* 6. Check EnableWoWlan CMD is ready */
- if (!pwrctl->wowlan_pno_enable) {
- DBG_871X_LEVEL(_drv_always_, "Check EnableWoWlan CMD is ready\n");
- mstatus = rtw_read8(padapter, REG_WOW_CTRL);
- trycnt = 10;
- while (!(mstatus & BIT1) && trycnt > 1) {
- mstatus = rtw_read8(padapter, REG_WOW_CTRL);
- DBG_871X("Loop index: %d :0x%02x\n", trycnt, mstatus);
- trycnt--;
- msleep(2);
- }
- }
- break;
-
- case WOWLAN_DISABLE:
- DBG_871X_LEVEL(_drv_always_, "WOWLAN_DISABLE\n");
-
- psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(pmlmepriv));
- if (psta)
- rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_DISCONNECT, psta->mac_id);
- else
- DBG_871X("psta is null\n");
-
- /* 1. Read wakeup reason */
- pwrctl->wowlan_wake_reason = rtw_read8(padapter, REG_WOWLAN_WAKE_REASON);
- DBG_871X_LEVEL(
- _drv_always_,
- "wakeup_reason: 0x%02x, mac_630 = 0x%08x, mac_634 = 0x%08x, mac_1c0 = 0x%08x, mac_1c4 = 0x%08x"
- ", mac_494 = 0x%08x, , mac_498 = 0x%08x, mac_49c = 0x%08x, mac_608 = 0x%08x, mac_4a0 = 0x%08x, mac_4a4 = 0x%08x\n"
- ", mac_1cc = 0x%08x, mac_2f0 = 0x%08x, mac_2f4 = 0x%08x, mac_2f8 = 0x%08x, mac_2fc = 0x%08x, mac_8c = 0x%08x",
- pwrctl->wowlan_wake_reason,
- rtw_read32(padapter, REG_WOWLAN_GTK_DBG1),
- rtw_read32(padapter, REG_WOWLAN_GTK_DBG2),
- rtw_read32(padapter, 0x1c0),
- rtw_read32(padapter, 0x1c4),
- rtw_read32(padapter, 0x494),
- rtw_read32(padapter, 0x498),
- rtw_read32(padapter, 0x49c),
- rtw_read32(padapter, 0x608),
- rtw_read32(padapter, 0x4a0),
- rtw_read32(padapter, 0x4a4),
- rtw_read32(padapter, 0x1cc),
- rtw_read32(padapter, 0x2f0),
- rtw_read32(padapter, 0x2f4),
- rtw_read32(padapter, 0x2f8),
- rtw_read32(padapter, 0x2fc),
- rtw_read32(padapter, 0x8c)
- );
-#ifdef CONFIG_PNO_SET_DEBUG
- DBG_871X("0x1b9: 0x%02x, 0x632: 0x%02x\n", rtw_read8(padapter, 0x1b9), rtw_read8(padapter, 0x632));
- DBG_871X("0x4fc: 0x%02x, 0x4fd: 0x%02x\n", rtw_read8(padapter, 0x4fc), rtw_read8(padapter, 0x4fd));
- DBG_871X("TXDMA STATUS: 0x%08x\n", rtw_read32(padapter, REG_TXDMA_STATUS));
-#endif
-
- {
- /* 2. Set Disable WOWLAN H2C command. */
- DBG_871X_LEVEL(_drv_always_, "Set Disable WOWLan cmd\n");
- rtl8723b_set_wowlan_cmd(padapter, 0);
-
- /* 3. Check Disable WoWlan CMD ready. */
- DBG_871X_LEVEL(_drv_always_, "Check DisableWoWlan CMD is ready\n");
- mstatus = rtw_read8(padapter, REG_WOW_CTRL);
- trycnt = 50;
- while (mstatus & BIT1 && trycnt > 1) {
- mstatus = rtw_read8(padapter, REG_WOW_CTRL);
- DBG_871X_LEVEL(_drv_always_, "Loop index: %d :0x%02x\n", trycnt, mstatus);
- trycnt--;
- msleep(10);
- }
-
- if (mstatus & BIT1) {
- DBG_871X_LEVEL(_drv_always_, "Disable WOW mode fail!!\n");
- DBG_871X("Set 0x690 = 0x00\n");
- rtw_write8(padapter, REG_WOW_CTRL, (rtw_read8(padapter, REG_WOW_CTRL) & 0xf0));
- DBG_871X_LEVEL(_drv_always_, "Release RXDMA\n");
- rtw_write32(padapter, REG_RXPKT_NUM, (rtw_read32(padapter, REG_RXPKT_NUM) & (~RW_RELEASE_EN)));
- }
-
- /* 3.1 read fw iv */
- iv_low = rtw_read32(padapter, REG_TXPKTBUF_IV_LOW);
- /* only low two bytes is PN, check AES_IV macro for detail */
- iv_low &= 0xffff;
- iv_high = rtw_read32(padapter, REG_TXPKTBUF_IV_HIGH);
- /* get the real packet number */
- pwrctl->wowlan_fw_iv = iv_high << 16 | iv_low;
- DBG_871X_LEVEL(_drv_always_, "fw_iv: 0x%016llx\n", pwrctl->wowlan_fw_iv);
- /* Update TX iv data. */
- rtw_set_sec_pn(padapter);
-
- /* 3.2 read GTK index and key */
- if (
- psecuritypriv->binstallKCK_KEK == true &&
- psecuritypriv->dot11PrivacyAlgrthm == _AES_
- ) {
- u8 gtk_keyindex = 0;
- u8 get_key[16];
- /* read gtk key index */
- gtk_keyindex = rtw_read8(padapter, 0x48c);
-
- if (gtk_keyindex < 4) {
- psecuritypriv->dot118021XGrpKeyid = gtk_keyindex;
- read_cam(padapter, gtk_keyindex, get_key);
- memcpy(psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, get_key, 16);
- DBG_871X_LEVEL(
- _drv_always_,
- "GTK (%d) = 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
- gtk_keyindex,
- psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[0],
- psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[1],
- psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[2],
- psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[3]
- );
- } else
- DBG_871X_LEVEL(_drv_always_, "GTK index =%d\n", gtk_keyindex);
- }
-
- /* 4. Re-download Normal FW. */
- DBG_871X_LEVEL(_drv_always_, "Re-download Normal FW!\n");
- SetFwRelatedForWoWLAN8723b(padapter, false);
- }
-#ifdef CONFIG_GPIO_WAKEUP
- DBG_871X_LEVEL(_drv_always_, "Set Wake GPIO to high for default.\n");
- HalSetOutPutGPIO(padapter, WAKEUP_GPIO_IDX, 1);
-#endif
-
- /* 5. Download reserved pages and report media status if needed. */
- if (
- (pwrctl->wowlan_wake_reason != FWDecisionDisconnect) &&
- (pwrctl->wowlan_wake_reason != Rx_Pairwisekey) &&
- (pwrctl->wowlan_wake_reason != Rx_DisAssoc) &&
- (pwrctl->wowlan_wake_reason != Rx_DeAuth)
- ) {
- rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT);
- if (psta)
- rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_CONNECT, psta->mac_id);
- }
-#ifdef CONFIG_PNO_SUPPORT
- rtw_write8(padapter, 0x1b8, 0);
- DBG_871X("reset 0x1b8: %d\n", rtw_read8(padapter, 0x1b8));
- rtw_write8(padapter, 0x1b9, 0);
- DBG_871X("reset 0x1b9: %d\n", rtw_read8(padapter, 0x1b9));
- rtw_write8(padapter, REG_PNO_STATUS, 0);
- DBG_871X("reset REG_PNO_STATUS: %d\n", rtw_read8(padapter, REG_PNO_STATUS));
-#endif
- break;
-
- default:
- break;
- }
- }
- break;
-#endif /* CONFIG_WOWLAN */
-#ifdef CONFIG_AP_WOWLAN
- case HW_VAR_AP_WOWLAN:
- {
- poidparam = (struct wowlan_ioctl_param *)val;
- switch (poidparam->subcode) {
- case WOWLAN_AP_ENABLE:
- DBG_871X("%s, WOWLAN_AP_ENABLE\n", __func__);
- /* 1. Download WOWLAN FW */
- DBG_871X_LEVEL(_drv_always_, "Re-download WoWlan FW!\n");
- SetFwRelatedForWoWLAN8723b(padapter, true);
-
- /* 2. RX DMA stop */
- DBG_871X_LEVEL(_drv_always_, "Pause DMA\n");
- rtw_write32(padapter, REG_RXPKT_NUM,
- (rtw_read32(padapter, REG_RXPKT_NUM) | RW_RELEASE_EN));
- do {
- if ((rtw_read32(padapter, REG_RXPKT_NUM) & RXDMA_IDLE)) {
- DBG_871X_LEVEL(_drv_always_, "RX_DMA_IDLE is true\n");
- break;
- } else {
- /* If RX_DMA is not idle, receive one pkt from DMA */
- res = sdio_local_read(padapter, SDIO_REG_RX0_REQ_LEN, 4, (u8 *)&tmp);
- len = le16_to_cpu(tmp);
-
- DBG_871X_LEVEL(_drv_always_, "RX len:%d\n", len);
- if (len > 0)
- res = RecvOnePkt(padapter, len);
- else
- DBG_871X_LEVEL(_drv_always_, "read length fail %d\n", len);
-
- DBG_871X_LEVEL(_drv_always_, "RecvOnePkt Result: %d\n", res);
- }
- } while (trycnt--);
-
- if (trycnt == 0)
- DBG_871X_LEVEL(_drv_always_, "Stop RX DMA failed......\n");
-
- /* 3. Clear IMR and ISR */
- DBG_871X_LEVEL(_drv_always_, "Clear IMR and ISR\n");
- tmp = 0;
- sdio_local_write(padapter, SDIO_REG_HIMR_ON, 4, (u8 *)&tmp);
- sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp);
- sdio_local_read(padapter, SDIO_REG_HISR, 4, (u8 *)&tmp);
- sdio_local_write(padapter, SDIO_REG_HISR, 4, (u8 *)&tmp);
-
- /* 4. Enable CPWM2 only */
- DBG_871X_LEVEL(_drv_always_, "Enable only CPWM2\n");
- sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp);
- DBG_871X("DisableInterruptButCpwm28723BSdio(): Read SDIO_REG_HIMR: 0x%08x\n", tmp);
-
- himr = cpu_to_le32(SDIO_HIMR_DISABLED) | SDIO_HIMR_CPWM2_MSK;
- sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&himr);
-
- sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp);
- DBG_871X("DisableInterruptButCpwm28723BSdio(): Read again SDIO_REG_HIMR: 0x%08x\n", tmp);
-
- /* 5. Set Enable WOWLAN H2C command. */
- DBG_871X_LEVEL(_drv_always_, "Set Enable AP WOWLan cmd\n");
- rtl8723b_set_ap_wowlan_cmd(padapter, 1);
- /* 6. add some delay for H2C cmd ready */
- msleep(10);
-
- rtw_write8(padapter, REG_WOWLAN_WAKE_REASON, 0);
- break;
- case WOWLAN_AP_DISABLE:
- DBG_871X("%s, WOWLAN_AP_DISABLE\n", __func__);
- /* 1. Read wakeup reason */
- pwrctl->wowlan_wake_reason =
- rtw_read8(padapter, REG_WOWLAN_WAKE_REASON);
-
- DBG_871X_LEVEL(_drv_always_, "wakeup_reason: 0x%02x\n",
- pwrctl->wowlan_wake_reason);
-
- /* 2. Set Disable WOWLAN H2C command. */
- DBG_871X_LEVEL(_drv_always_, "Set Disable WOWLan cmd\n");
- rtl8723b_set_ap_wowlan_cmd(padapter, 0);
- /* 6. add some delay for H2C cmd ready */
- msleep(2);
-
- DBG_871X_LEVEL(_drv_always_, "Release RXDMA\n");
-
- rtw_write32(padapter, REG_RXPKT_NUM,
- (rtw_read32(padapter, REG_RXPKT_NUM) & (~RW_RELEASE_EN)));
-
- SetFwRelatedForWoWLAN8723b(padapter, false);
-
-#ifdef CONFIG_GPIO_WAKEUP
- DBG_871X_LEVEL(_drv_always_, "Set Wake GPIO to high for default.\n");
- HalSetOutPutGPIO(padapter, WAKEUP_GPIO_IDX, 1);
-#endif /* CONFIG_GPIO_WAKEUP */
- rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT);
- issue_beacon(padapter, 0);
- break;
- default:
- break;
- }
-}
- break;
-#endif /* CONFIG_AP_WOWLAN */
case HW_VAR_DM_IN_LPS:
rtl8723b_hal_dm_in_lps(padapter);
break;
@@ -1776,7 +1252,6 @@ static void SetHwRegWithBuf8723B(struct adapter *padapter, u8 variable, u8 *pbuf
{
switch (variable) {
case HW_VAR_C2H_HANDLE:
- /* DBG_8192C("%s len =%d\n", __func__, len); */
C2HPacketHandler_8723B(padapter, pbuf, len);
break;
default:
@@ -1789,7 +1264,7 @@ static void SetHwRegWithBuf8723B(struct adapter *padapter, u8 variable, u8 *pbuf
/* Query setting of specified variable. */
/* */
static u8 GetHalDefVar8723BSDIO(
- struct adapter *Adapter, enum HAL_DEF_VARIABLE eVariable, void *pValue
+ struct adapter *Adapter, enum hal_def_variable eVariable, void *pValue
)
{
u8 bResult = _SUCCESS;
@@ -1817,7 +1292,7 @@ static u8 GetHalDefVar8723BSDIO(
/* Change default setting of specified variable. */
/* */
static u8 SetHalDefVar8723BSDIO(struct adapter *Adapter,
- enum HAL_DEF_VARIABLE eVariable, void *pValue)
+ enum hal_def_variable eVariable, void *pValue)
{
return SetHalDefVar8723B(Adapter, eVariable, pValue);
}
@@ -1847,9 +1322,6 @@ void rtl8723bs_set_hal_ops(struct adapter *padapter)
pHalFunc->enable_interrupt = &EnableInterrupt8723BSdio;
pHalFunc->disable_interrupt = &DisableInterrupt8723BSdio;
pHalFunc->check_ips_status = &CheckIPSStatus;
-#ifdef CONFIG_WOWLAN
- pHalFunc->clear_interrupt = &ClearInterrupt8723BSdio;
-#endif
pHalFunc->SetHwRegHandler = &SetHwReg8723BS;
pHalFunc->GetHwRegHandler = &GetHwReg8723BS;
pHalFunc->SetHwRegHandlerWithBuf = &SetHwRegWithBuf8723B;
@@ -1859,11 +1331,4 @@ void rtl8723bs_set_hal_ops(struct adapter *padapter)
pHalFunc->hal_xmit = &rtl8723bs_hal_xmit;
pHalFunc->mgnt_xmit = &rtl8723bs_mgnt_xmit;
pHalFunc->hal_xmitframe_enqueue = &rtl8723bs_hal_xmitframe_enqueue;
-
-#if defined(CONFIG_CHECK_BT_HANG)
- pHalFunc->hal_init_checkbthang_workqueue = &rtl8723bs_init_checkbthang_workqueue;
- pHalFunc->hal_free_checkbthang_workqueue = &rtl8723bs_free_checkbthang_workqueue;
- pHalFunc->hal_cancle_checkbthang_workqueue = &rtl8723bs_cancle_checkbthang_workqueue;
- pHalFunc->hal_checke_bt_hang = &rtl8723bs_hal_check_bt_hang;
-#endif
}
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 369f55d11519..a31694525bc1 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -10,16 +10,13 @@
#include <rtw_debug.h>
#include <rtl8723b_hal.h>
-/* define SDIO_DEBUG_IO 1 */
-
-
/* */
/* Description: */
/* The following mapping is for SDIO host local register space. */
/* */
/* Creadted by Roger, 2011.01.31. */
/* */
-static void HalSdioGetCmdAddr8723BSdio(
+static void hal_sdio_get_cmd_addr_8723b(
struct adapter *adapter,
u8 device_id,
u32 addr,
@@ -95,10 +92,6 @@ static u8 get_deviceid(u32 addr)
return devide_id;
}
-/*
- * Ref:
- *HalSdioGetCmdAddr8723BSdio()
- */
static u32 _cvrt2ftaddr(const u32 addr, u8 *pdevice_id, u16 *poffset)
{
u8 device_id;
@@ -177,19 +170,10 @@ static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr)
if (
((device_id == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) ||
(!mac_pwr_ctrl_on) ||
- (adapter_to_pwrctl(adapter)->bFwCurrentInPSMode)
+ (adapter_to_pwrctl(adapter)->fw_current_in_ps_mode)
) {
err = sd_cmd52_read(intfhdl, ftaddr, 4, (u8 *)&le_tmp);
-#ifdef SDIO_DEBUG_IO
- if (!err) {
-#endif
- return le32_to_cpu(le_tmp);
-#ifdef SDIO_DEBUG_IO
- }
-
- DBG_8192C(KERN_ERR "%s: Mac Power off, Read FAIL(%d)! addr = 0x%x\n", __func__, err, addr);
- return SDIO_ERR_VAL32;
-#endif
+ return le32_to_cpu(le_tmp);
}
/* 4 bytes alignment */
@@ -200,10 +184,8 @@ static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr)
u8 *tmpbuf;
tmpbuf = rtw_malloc(8);
- if (!tmpbuf) {
- DBG_8192C(KERN_ERR "%s: Allocate memory FAIL!(size =8) addr = 0x%x\n", __func__, addr);
+ if (!tmpbuf)
return SDIO_ERR_VAL32;
- }
ftaddr &= ~(u16)0x3;
sd_read(intfhdl, ftaddr, 8, tmpbuf);
@@ -234,7 +216,7 @@ static s32 sdio_readN(struct intf_hdl *intfhdl, u32 addr, u32 cnt, u8 *buf)
if (
((device_id == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) ||
(!mac_pwr_ctrl_on) ||
- (adapter_to_pwrctl(adapter)->bFwCurrentInPSMode)
+ (adapter_to_pwrctl(adapter)->fw_current_in_ps_mode)
)
return sd_cmd52_read(intfhdl, ftaddr, cnt, buf);
@@ -301,7 +283,7 @@ static s32 sdio_write32(struct intf_hdl *intfhdl, u32 addr, u32 val)
if (
((device_id == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) ||
(!mac_pwr_ctrl_on) ||
- (adapter_to_pwrctl(adapter)->bFwCurrentInPSMode)
+ (adapter_to_pwrctl(adapter)->fw_current_in_ps_mode)
) {
le_tmp = cpu_to_le32(val);
@@ -338,7 +320,7 @@ static s32 sdio_writeN(struct intf_hdl *intfhdl, u32 addr, u32 cnt, u8 *buf)
if (
((device_id == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) ||
(!mac_pwr_ctrl_on) ||
- (adapter_to_pwrctl(adapter)->bFwCurrentInPSMode)
+ (adapter_to_pwrctl(adapter)->fw_current_in_ps_mode)
)
return sd_cmd52_write(intfhdl, ftaddr, cnt, buf);
@@ -426,7 +408,7 @@ static u32 sdio_read_port(
psdio = &adapter_to_dvobj(adapter)->intf_data;
hal = GET_HAL_DATA(adapter);
- HalSdioGetCmdAddr8723BSdio(adapter, addr, hal->SdioRxFIFOCnt++, &addr);
+ hal_sdio_get_cmd_addr_8723b(adapter, addr, hal->SdioRxFIFOCnt++, &addr);
if (cnt > psdio->block_transfer_len)
cnt = _RND(cnt, psdio->block_transfer_len);
@@ -469,13 +451,11 @@ static u32 sdio_write_port(
adapter = intfhdl->padapter;
psdio = &adapter_to_dvobj(adapter)->intf_data;
- if (!adapter->hw_init_completed) {
- DBG_871X("%s [addr = 0x%x cnt =%d] adapter->hw_init_completed == false\n", __func__, addr, cnt);
+ if (!adapter->hw_init_completed)
return _FAIL;
- }
cnt = round_up(cnt, 4);
- HalSdioGetCmdAddr8723BSdio(adapter, addr, cnt >> 2, &addr);
+ hal_sdio_get_cmd_addr_8723b(adapter, addr, cnt >> 2, &addr);
if (cnt > psdio->block_transfer_len)
cnt = _RND(cnt, psdio->block_transfer_len);
@@ -528,7 +508,7 @@ static s32 _sdio_local_read(
intfhdl = &adapter->iopriv.intf;
- HalSdioGetCmdAddr8723BSdio(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
+ hal_sdio_get_cmd_addr_8723b(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
rtw_hal_get_hwreg(adapter, HW_VAR_APFM_ON_MAC, &mac_pwr_ctrl_on);
if (!mac_pwr_ctrl_on)
@@ -566,12 +546,12 @@ s32 sdio_local_read(
intfhdl = &adapter->iopriv.intf;
- HalSdioGetCmdAddr8723BSdio(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
+ hal_sdio_get_cmd_addr_8723b(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
rtw_hal_get_hwreg(adapter, HW_VAR_APFM_ON_MAC, &mac_pwr_ctrl_on);
if (
(!mac_pwr_ctrl_on) ||
- (adapter_to_pwrctl(adapter)->bFwCurrentInPSMode)
+ (adapter_to_pwrctl(adapter)->fw_current_in_ps_mode)
)
return sd_cmd52_read(intfhdl, addr, cnt, buf);
@@ -604,20 +584,14 @@ s32 sdio_local_write(
s32 err;
u8 *tmpbuf;
- if (addr & 0x3)
- DBG_8192C("%s, address must be 4 bytes alignment\n", __func__);
-
- if (cnt & 0x3)
- DBG_8192C("%s, size must be the multiple of 4\n", __func__);
-
intfhdl = &adapter->iopriv.intf;
- HalSdioGetCmdAddr8723BSdio(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
+ hal_sdio_get_cmd_addr_8723b(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
rtw_hal_get_hwreg(adapter, HW_VAR_APFM_ON_MAC, &mac_pwr_ctrl_on);
if (
(!mac_pwr_ctrl_on) ||
- (adapter_to_pwrctl(adapter)->bFwCurrentInPSMode)
+ (adapter_to_pwrctl(adapter)->fw_current_in_ps_mode)
)
return sd_cmd52_write(intfhdl, addr, cnt, buf);
@@ -639,24 +613,24 @@ u8 SdioLocalCmd52Read1Byte(struct adapter *adapter, u32 addr)
u8 val = 0;
struct intf_hdl *intfhdl = &adapter->iopriv.intf;
- HalSdioGetCmdAddr8723BSdio(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
+ hal_sdio_get_cmd_addr_8723b(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
sd_cmd52_read(intfhdl, addr, 1, &val);
return val;
}
-static u16 SdioLocalCmd52Read2Byte(struct adapter *adapter, u32 addr)
+static u16 sdio_local_cmd52_read2byte(struct adapter *adapter, u32 addr)
{
__le16 val = 0;
struct intf_hdl *intfhdl = &adapter->iopriv.intf;
- HalSdioGetCmdAddr8723BSdio(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
+ hal_sdio_get_cmd_addr_8723b(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
sd_cmd52_read(intfhdl, addr, 2, (u8 *)&val);
return le16_to_cpu(val);
}
-static u32 SdioLocalCmd53Read4Byte(struct adapter *adapter, u32 addr)
+static u32 sdio_local_cmd53_read4byte(struct adapter *adapter, u32 addr)
{
u8 mac_pwr_ctrl_on;
@@ -664,9 +638,9 @@ static u32 SdioLocalCmd53Read4Byte(struct adapter *adapter, u32 addr)
struct intf_hdl *intfhdl = &adapter->iopriv.intf;
__le32 le_tmp;
- HalSdioGetCmdAddr8723BSdio(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
+ hal_sdio_get_cmd_addr_8723b(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
rtw_hal_get_hwreg(adapter, HW_VAR_APFM_ON_MAC, &mac_pwr_ctrl_on);
- if (!mac_pwr_ctrl_on || adapter_to_pwrctl(adapter)->bFwCurrentInPSMode) {
+ if (!mac_pwr_ctrl_on || adapter_to_pwrctl(adapter)->fw_current_in_ps_mode) {
sd_cmd52_read(intfhdl, addr, 4, (u8 *)&le_tmp);
val = le32_to_cpu(le_tmp);
} else {
@@ -679,21 +653,21 @@ void SdioLocalCmd52Write1Byte(struct adapter *adapter, u32 addr, u8 v)
{
struct intf_hdl *intfhdl = &adapter->iopriv.intf;
- HalSdioGetCmdAddr8723BSdio(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
+ hal_sdio_get_cmd_addr_8723b(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
sd_cmd52_write(intfhdl, addr, 1, &v);
}
-static void SdioLocalCmd52Write4Byte(struct adapter *adapter, u32 addr, u32 v)
+static void sdio_local_cmd52_write4byte(struct adapter *adapter, u32 addr, u32 v)
{
struct intf_hdl *intfhdl = &adapter->iopriv.intf;
__le32 le_tmp;
- HalSdioGetCmdAddr8723BSdio(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
+ hal_sdio_get_cmd_addr_8723b(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
le_tmp = cpu_to_le32(v);
sd_cmd52_write(intfhdl, addr, 4, (u8 *)&le_tmp);
}
-static s32 ReadInterrupt8723BSdio(struct adapter *adapter, u32 *phisr)
+static s32 read_interrupt_8723b_sdio(struct adapter *adapter, u32 *phisr)
{
u32 hisr, himr;
u8 val8, hisr_len;
@@ -777,30 +751,10 @@ void EnableInterrupt8723BSdio(struct adapter *adapter)
himr = cpu_to_le32(haldata->sdio_himr);
sdio_local_write(adapter, SDIO_REG_HIMR, 4, (u8 *)&himr);
- RT_TRACE(
- _module_hci_ops_c_,
- _drv_notice_,
- (
- "%s: enable SDIO HIMR = 0x%08X\n",
- __func__,
- haldata->sdio_himr
- )
- );
-
/* Update current system IMR settings */
tmp = rtw_read32(adapter, REG_HSIMR);
rtw_write32(adapter, REG_HSIMR, tmp | haldata->SysIntrMask);
- RT_TRACE(
- _module_hci_ops_c_,
- _drv_notice_,
- (
- "%s: enable HSIMR = 0x%08X\n",
- __func__,
- haldata->SysIntrMask
- )
- );
-
/* */
/* <Roger_Notes> There are some C2H CMDs have been sent before system interrupt is enabled, e.g., C2H, CPWM. */
/* So we need to clear all C2H events that FW has notified, otherwise FW won't schedule any commands anymore. */
@@ -837,13 +791,6 @@ void DisableInterrupt8723BSdio(struct adapter *adapter)
/* */
u8 CheckIPSStatus(struct adapter *adapter)
{
- DBG_871X(
- "%s(): Read 0x100 = 0x%02x 0x86 = 0x%02x\n",
- __func__,
- rtw_read8(adapter, 0x100),
- rtw_read8(adapter, 0x86)
- );
-
if (rtw_read8(adapter, 0x100) == 0xEA)
return true;
else
@@ -865,7 +812,8 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size)
recv_priv = &adapter->recvpriv;
recvbuf = rtw_dequeue_recvbuf(&recv_priv->free_recv_buf_queue);
if (!recvbuf) {
- DBG_871X_LEVEL(_drv_err_, "%s: alloc recvbuf FAIL!\n", __func__);
+ netdev_err(adapter->pnetdev, "%s: alloc recvbuf FAIL!\n",
+ __func__);
return NULL;
}
@@ -884,19 +832,15 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size)
skb_reserve(recvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment));
}
- if (!recvbuf->pskb) {
- DBG_871X("%s: alloc_skb fail! read =%d\n", __func__, readsize);
+ if (!recvbuf->pskb)
return NULL;
- }
}
/* 3 3. read data from rxfifo */
readbuf = recvbuf->pskb->data;
ret = sdio_read_port(&adapter->iopriv.intf, WLAN_RX0FF_DEVICE_ID, readsize, readbuf);
- if (ret == _FAIL) {
- RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("%s: read port FAIL!\n", __func__));
+ if (ret == _FAIL)
return NULL;
- }
/* 3 4. init recvbuf */
recvbuf->len = size;
@@ -943,11 +887,9 @@ void sd_int_dpc(struct adapter *adapter)
}
if (hal->sdio_hisr & SDIO_HISR_CPWM1) {
- struct reportpwrstate_parm report;
-
del_timer_sync(&(pwrctl->pwr_rpwm_timer));
- report.state = SdioLocalCmd52Read1Byte(adapter, SDIO_REG_HCPWM1_8723B);
+ SdioLocalCmd52Read1Byte(adapter, SDIO_REG_HCPWM1_8723B);
_set_workitem(&(pwrctl->cpwm_event));
}
@@ -959,26 +901,16 @@ void sd_int_dpc(struct adapter *adapter)
status = rtw_malloc(4);
if (status) {
addr = REG_TXDMA_STATUS;
- HalSdioGetCmdAddr8723BSdio(adapter, WLAN_IOREG_DEVICE_ID, addr, &addr);
+ hal_sdio_get_cmd_addr_8723b(adapter, WLAN_IOREG_DEVICE_ID, addr, &addr);
_sd_read(intfhdl, addr, 4, status);
_sd_write(intfhdl, addr, 4, status);
- DBG_8192C("%s: SDIO_HISR_TXERR (0x%08x)\n", __func__, le32_to_cpu(*(u32 *)status));
kfree(status);
- } else {
- DBG_8192C("%s: SDIO_HISR_TXERR, but can't allocate memory to read status!\n", __func__);
}
}
- if (hal->sdio_hisr & SDIO_HISR_TXBCNOK)
- DBG_8192C("%s: SDIO_HISR_TXBCNOK\n", __func__);
-
- if (hal->sdio_hisr & SDIO_HISR_TXBCNERR)
- DBG_8192C("%s: SDIO_HISR_TXBCNERR\n", __func__);
-#ifndef CONFIG_C2H_PACKET_EN
if (hal->sdio_hisr & SDIO_HISR_C2HCMD) {
struct c2h_evt_hdr_88xx *c2h_evt;
- DBG_8192C("%s: C2H Command\n", __func__);
c2h_evt = rtw_zmalloc(16);
if (c2h_evt) {
if (c2h_evt_read_88xx(adapter, (u8 *)c2h_evt) == _SUCCESS) {
@@ -992,18 +924,10 @@ void sd_int_dpc(struct adapter *adapter)
}
} else {
/* Error handling for malloc fail */
- if (rtw_cbuf_push(adapter->evtpriv.c2h_queue, NULL) != _SUCCESS)
- DBG_871X("%s rtw_cbuf_push fail\n", __func__);
+ rtw_cbuf_push(adapter->evtpriv.c2h_queue, NULL);
_set_workitem(&adapter->evtpriv.c2h_wk);
}
}
-#endif
-
- if (hal->sdio_hisr & SDIO_HISR_RXFOVW)
- DBG_8192C("%s: Rx Overflow\n", __func__);
-
- if (hal->sdio_hisr & SDIO_HISR_RXERR)
- DBG_8192C("%s: Rx Error\n", __func__);
if (hal->sdio_hisr & SDIO_HISR_RX_REQUEST) {
struct recv_buf *recvbuf;
@@ -1012,14 +936,13 @@ void sd_int_dpc(struct adapter *adapter)
hal->sdio_hisr ^= SDIO_HISR_RX_REQUEST;
do {
- hal->SdioRxFIFOSize = SdioLocalCmd52Read2Byte(adapter, SDIO_REG_RX0_REQ_LEN);
+ hal->SdioRxFIFOSize = sdio_local_cmd52_read2byte(adapter, SDIO_REG_RX0_REQ_LEN);
if (hal->SdioRxFIFOSize != 0) {
recvbuf = sd_recv_rxfifo(adapter, hal->SdioRxFIFOSize);
if (recvbuf)
sd_rxhandler(adapter, recvbuf);
else {
alloc_fail_time++;
- DBG_871X("recvbuf is Null for %d times because alloc memory failed\n", alloc_fail_time);
if (alloc_fail_time >= 10)
break;
}
@@ -1028,15 +951,11 @@ void sd_int_dpc(struct adapter *adapter)
break;
hisr = 0;
- ReadInterrupt8723BSdio(adapter, &hisr);
+ read_interrupt_8723b_sdio(adapter, &hisr);
hisr &= SDIO_HISR_RX_REQUEST;
if (!hisr)
break;
} while (1);
-
- if (alloc_fail_time == 10)
- DBG_871X("exit because alloc memory failed more than 10 times\n");
-
}
}
@@ -1052,7 +971,7 @@ void sd_int_hdl(struct adapter *adapter)
hal = GET_HAL_DATA(adapter);
hal->sdio_hisr = 0;
- ReadInterrupt8723BSdio(adapter, &hal->sdio_hisr);
+ read_interrupt_8723b_sdio(adapter, &hal->sdio_hisr);
if (hal->sdio_hisr & hal->sdio_himr) {
u32 v32;
@@ -1062,13 +981,9 @@ void sd_int_hdl(struct adapter *adapter)
/* clear HISR */
v32 = hal->sdio_hisr & MASK_SDIO_HISR_CLEAR;
if (v32)
- SdioLocalCmd52Write4Byte(adapter, SDIO_REG_HISR, v32);
+ sdio_local_cmd52_write4byte(adapter, SDIO_REG_HISR, v32);
sd_int_dpc(adapter);
- } else {
- RT_TRACE(_module_hci_ops_c_, _drv_err_,
- ("%s: HISR(0x%08x) and HIMR(0x%08x) not match!\n",
- __func__, hal->sdio_hisr, hal->sdio_himr));
}
}
@@ -1089,16 +1004,9 @@ u8 HalQueryTxBufferStatus8723BSdio(struct adapter *adapter)
hal = GET_HAL_DATA(adapter);
- numof_free_page = SdioLocalCmd53Read4Byte(adapter, SDIO_REG_FREE_TXPG);
+ numof_free_page = sdio_local_cmd53_read4byte(adapter, SDIO_REG_FREE_TXPG);
memcpy(hal->SdioTxFIFOFreePage, &numof_free_page, 4);
- RT_TRACE(_module_hci_ops_c_, _drv_notice_,
- ("%s: Free page for HIQ(%#x), MIDQ(%#x), LOWQ(%#x), PUBQ(%#x)\n",
- __func__,
- hal->SdioTxFIFOFreePage[HI_QUEUE_IDX],
- hal->SdioTxFIFOFreePage[MID_QUEUE_IDX],
- hal->SdioTxFIFOFreePage[LOW_QUEUE_IDX],
- hal->SdioTxFIFOFreePage[PUBLIC_QUEUE_IDX]));
return true;
}
@@ -1114,39 +1022,4 @@ void HalQueryTxOQTBufferStatus8723BSdio(struct adapter *adapter)
haldata->SdioTxOQTFreeSpace = SdioLocalCmd52Read1Byte(adapter, SDIO_REG_OQT_FREE_PG);
}
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-u8 RecvOnePkt(struct adapter *adapter, u32 size)
-{
- struct recv_buf *recvbuf;
- struct dvobj_priv *sddev;
- struct sdio_func *func;
-
- u8 res = false;
-
- DBG_871X("+%s: size: %d+\n", __func__, size);
- if (!adapter) {
- DBG_871X(KERN_ERR "%s: adapter is NULL!\n", __func__);
- return false;
- }
-
- sddev = adapter_to_dvobj(adapter);
- psdio_data = &sddev->intf_data;
- func = psdio_data->func;
-
- if (size) {
- sdio_claim_host(func);
- recvbuf = sd_recv_rxfifo(adapter, size);
-
- if (recvbuf) {
- sd_rxhandler(adapter, recvbuf);
- res = true;
- } else {
- res = false;
- }
- sdio_release_host(func);
- }
- DBG_871X("-%s-\n", __func__);
- return res;
-}
-#endif /* CONFIG_WOWLAN */
diff --git a/drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h b/drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h
index fb80901f0788..4b3a7c051630 100644
--- a/drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h
+++ b/drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h
@@ -34,7 +34,7 @@
/*--------------------------Define Parameters-------------------------------*/
/* */
-/* 8192S Regsiter offset definition */
+/* 8192S Register offset definition */
/* */
/* */
@@ -43,7 +43,7 @@
/* 2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00 */
/* 3. RF register 0x00-2E */
/* 4. Bit Mask for BB/RF register */
-/* 5. Other defintion for BB/RF R/W */
+/* 5. Other definition for BB/RF R/W */
/* */
@@ -137,7 +137,7 @@
#define rFPGA0_AnalogParameter3 0x888 /* Useless now */
#define rFPGA0_AnalogParameter4 0x88c
-#define rFPGA0_XA_LSSIReadBack 0x8a0 /* Tranceiver LSSI Readback */
+#define rFPGA0_XA_LSSIReadBack 0x8a0 /* Transceiver LSSI Readback */
#define rFPGA0_XB_LSSIReadBack 0x8a4
#define rFPGA0_XC_LSSIReadBack 0x8a8
#define rFPGA0_XD_LSSIReadBack 0x8ac
@@ -206,7 +206,7 @@
#define rOFDM0_TRSWIsolation 0xc0c
#define rOFDM0_XARxAFE 0xc10 /* RxIQ DC offset, Rx digital filter, DC notch filter */
-#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imblance matrix */
+#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imbalance matrix */
#define rOFDM0_XBRxAFE 0xc18
#define rOFDM0_XBRxIQImbalance 0xc1c
#define rOFDM0_XCRxAFE 0xc20
diff --git a/drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h b/drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h
index 459f2f9d4bbb..e30071935d27 100644
--- a/drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h
+++ b/drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h
@@ -82,12 +82,12 @@
#define PWR_CUT_ALL_MSK 0xFF
-typedef enum _PWRSEQ_CMD_DELAY_UNIT_ {
+enum {
PWRSEQ_DELAY_US,
PWRSEQ_DELAY_MS,
-} PWRSEQ_DELAY_UNIT;
+};
-typedef struct _WL_PWR_CFG_ {
+struct wlan_pwr_cfg {
u16 offset;
u8 cut_msk;
u8 fab_msk:4;
@@ -96,7 +96,7 @@ typedef struct _WL_PWR_CFG_ {
u8 cmd:4;
u8 msk;
u8 value;
-} WLAN_PWR_CFG, *PWLAN_PWR_CFG;
+};
#define GET_PWR_CFG_OFFSET(__PWR_CMD) __PWR_CMD.offset
@@ -113,10 +113,10 @@ typedef struct _WL_PWR_CFG_ {
/* Prototype of protected function. */
/* */
u8 HalPwrSeqCmdParsing(
- struct adapter * padapter,
+ struct adapter *padapter,
u8 CutVersion,
u8 FabVersion,
u8 InterfaceType,
- WLAN_PWR_CFG PwrCfgCmd[]);
+ struct wlan_pwr_cfg PwrCfgCmd[]);
#endif
diff --git a/drivers/staging/rtl8723bs/include/HalVerDef.h b/drivers/staging/rtl8723bs/include/HalVerDef.h
index b4744be2cbe1..bab226f77b24 100644
--- a/drivers/staging/rtl8723bs/include/HalVerDef.h
+++ b/drivers/staging/rtl8723bs/include/HalVerDef.h
@@ -7,8 +7,8 @@
#ifndef __HAL_VERSION_DEF_H__
#define __HAL_VERSION_DEF_H__
-/* HAL_IC_TYPE_E */
-typedef enum tag_HAL_IC_Type_Definition {
+/* hal_ic_type_e */
+enum hal_ic_type_e { /* tag_HAL_IC_Type_Definition */
CHIP_8192S = 0,
CHIP_8188C = 1,
CHIP_8192C = 2,
@@ -19,17 +19,17 @@ typedef enum tag_HAL_IC_Type_Definition {
CHIP_8821 = 7,
CHIP_8723B = 8,
CHIP_8192E = 9,
-} HAL_IC_TYPE_E;
+};
-/* HAL_CHIP_TYPE_E */
-typedef enum tag_HAL_CHIP_Type_Definition {
+/* hal_chip_type_e */
+enum hal_chip_type_e { /* tag_HAL_CHIP_Type_Definition */
TEST_CHIP = 0,
NORMAL_CHIP = 1,
FPGA = 2,
-} HAL_CHIP_TYPE_E;
+};
-/* HAL_CUT_VERSION_E */
-typedef enum tag_HAL_Cut_Version_Definition {
+/* hal_cut_version_e */
+enum hal_cut_version_e { /* tag_HAL_Cut_Version_Definition */
A_CUT_VERSION = 0,
B_CUT_VERSION = 1,
C_CUT_VERSION = 2,
@@ -41,16 +41,16 @@ typedef enum tag_HAL_Cut_Version_Definition {
I_CUT_VERSION = 8,
J_CUT_VERSION = 9,
K_CUT_VERSION = 10,
-} HAL_CUT_VERSION_E;
+};
/* HAL_Manufacturer */
-typedef enum tag_HAL_Manufacturer_Version_Definition {
+enum hal_vendor_e { /* tag_HAL_Manufacturer_Version_Definition */
CHIP_VENDOR_TSMC = 0,
CHIP_VENDOR_UMC = 1,
CHIP_VENDOR_SMIC = 2,
-} HAL_VENDOR_E;
+};
-typedef enum tag_HAL_RF_Type_Definition {
+enum hal_rf_type_e { /* tag_HAL_RF_Type_Definition */
RF_TYPE_1T1R = 0,
RF_TYPE_1T2R = 1,
RF_TYPE_2T2R = 2,
@@ -59,38 +59,38 @@ typedef enum tag_HAL_RF_Type_Definition {
RF_TYPE_3T3R = 5,
RF_TYPE_3T4R = 6,
RF_TYPE_4T4R = 7,
-} HAL_RF_TYPE_E;
+};
-typedef struct tag_HAL_VERSION {
- HAL_IC_TYPE_E ICType;
- HAL_CHIP_TYPE_E ChipType;
- HAL_CUT_VERSION_E CUTVersion;
- HAL_VENDOR_E VendorType;
- HAL_RF_TYPE_E RFType;
+struct hal_version { /* tag_HAL_VERSION */
+ enum hal_ic_type_e ICType;
+ enum hal_chip_type_e ChipType;
+ enum hal_cut_version_e CUTVersion;
+ enum hal_vendor_e VendorType;
+ enum hal_rf_type_e RFType;
u8 ROMVer;
-} HAL_VERSION, *PHAL_VERSION;
+};
/* VERSION_8192C VersionID; */
-/* HAL_VERSION VersionID; */
+/* hal_version VersionID; */
/* Get element */
-#define GET_CVID_IC_TYPE(version) ((HAL_IC_TYPE_E)((version).ICType))
-#define GET_CVID_CHIP_TYPE(version) ((HAL_CHIP_TYPE_E)((version).ChipType))
-#define GET_CVID_RF_TYPE(version) ((HAL_RF_TYPE_E)((version).RFType))
-#define GET_CVID_MANUFACTUER(version) ((HAL_VENDOR_E)((version).VendorType))
-#define GET_CVID_CUT_VERSION(version) ((HAL_CUT_VERSION_E)((version).CUTVersion))
+#define GET_CVID_IC_TYPE(version) ((enum hal_ic_type_e)((version).ICType))
+#define GET_CVID_CHIP_TYPE(version) ((enum hal_chip_type_e)((version).ChipType))
+#define GET_CVID_RF_TYPE(version) ((enum hal_rf_type_e)((version).RFType))
+#define GET_CVID_MANUFACTUER(version) ((enum hal_vendor_e)((version).VendorType))
+#define GET_CVID_CUT_VERSION(version) ((enum hal_cut_version_e)((version).CUTVersion))
#define GET_CVID_ROM_VERSION(version) (((version).ROMVer) & ROM_VERSION_MASK)
/* */
/* Common Macro. -- */
/* */
-/* HAL_VERSION VersionID */
+/* hal_version VersionID */
-/* HAL_CHIP_TYPE_E */
+/* hal_chip_type_e */
#define IS_TEST_CHIP(version) ((GET_CVID_CHIP_TYPE(version) == TEST_CHIP) ? true : false)
#define IS_NORMAL_CHIP(version) ((GET_CVID_CHIP_TYPE(version) == NORMAL_CHIP) ? true : false)
-/* HAL_CUT_VERSION_E */
+/* hal_cut_version_e */
#define IS_A_CUT(version) ((GET_CVID_CUT_VERSION(version) == A_CUT_VERSION) ? true : false)
#define IS_B_CUT(version) ((GET_CVID_CUT_VERSION(version) == B_CUT_VERSION) ? true : false)
#define IS_C_CUT(version) ((GET_CVID_CUT_VERSION(version) == C_CUT_VERSION) ? true : false)
@@ -100,12 +100,12 @@ typedef struct tag_HAL_VERSION {
#define IS_J_CUT(version) ((GET_CVID_CUT_VERSION(version) == J_CUT_VERSION) ? true : false)
#define IS_K_CUT(version) ((GET_CVID_CUT_VERSION(version) == K_CUT_VERSION) ? true : false)
-/* HAL_VENDOR_E */
+/* hal_vendor_e */
#define IS_CHIP_VENDOR_TSMC(version) ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_TSMC) ? true : false)
#define IS_CHIP_VENDOR_UMC(version) ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_UMC) ? true : false)
#define IS_CHIP_VENDOR_SMIC(version) ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_SMIC) ? true : false)
-/* HAL_RF_TYPE_E */
+/* hal_rf_type_e */
#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)
diff --git a/drivers/staging/rtl8723bs/include/autoconf.h b/drivers/staging/rtl8723bs/include/autoconf.h
index 86cf09ca5f06..944a7d2a1e53 100644
--- a/drivers/staging/rtl8723bs/include/autoconf.h
+++ b/drivers/staging/rtl8723bs/include/autoconf.h
@@ -12,7 +12,6 @@
/*
* Functions Config
*/
-/* define DEBUG_CFG80211 */
#ifndef CONFIG_WIRELESS_EXT
#error CONFIG_WIRELESS_EXT needs to be enabled for this driver to work
@@ -40,21 +39,12 @@
* Platform dependent
*/
#define WAKEUP_GPIO_IDX 12 /* WIFI Chip Side */
-#ifdef CONFIG_WOWLAN
-#define CONFIG_GTK_OL
-#endif /* CONFIG_WOWLAN */
/*
* Debug Related Config
*/
-#undef DEBUG
-#ifdef DEBUG
-#define DBG 1 /* for ODM & BTCOEX debug */
-/*#define DEBUG_RTL871X */
-#else /* !DEBUG */
#define DBG 0 /* for ODM & BTCOEX debug */
-#endif /* !DEBUG */
/* define DBG_XMIT_BUF */
/* define DBG_XMIT_BUF_EXT */
diff --git a/drivers/staging/rtl8723bs/include/basic_types.h b/drivers/staging/rtl8723bs/include/basic_types.h
index bab9811aeb5f..57bb717327ce 100644
--- a/drivers/staging/rtl8723bs/include/basic_types.h
+++ b/drivers/staging/rtl8723bs/include/basic_types.h
@@ -13,9 +13,7 @@
#include <linux/types.h>
-typedef signed int sint;
-
-#define FIELD_OFFSET(s, field) ((__kernel_ssize_t)&((s*)(0))->field)
+#define FIELD_OFFSET(s, field) ((__kernel_ssize_t)&((s *)(0))->field)
#define SIZE_PTR __kernel_size_t
#define SSIZE_PTR __kernel_ssize_t
@@ -189,7 +187,7 @@ typedef signed int sint;
); \
}
-/* Get the N-bytes aligment offset from the current length */
+/* Get the N-bytes alignent offset from the current length */
#define N_BYTE_ALIGMENT(__Value, __Aligment) ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / __Aligment) * __Aligment))
#define TEST_FLAG(__Flag, __testFlag) (((__Flag) & (__testFlag)) != 0)
diff --git a/drivers/staging/rtl8723bs/include/drv_conf.h b/drivers/staging/rtl8723bs/include/drv_conf.h
index 7fc88b07a25e..9cef9ce589a1 100644
--- a/drivers/staging/rtl8723bs/include/drv_conf.h
+++ b/drivers/staging/rtl8723bs/include/drv_conf.h
@@ -8,16 +8,6 @@
#define __DRV_CONF_H__
#include "autoconf.h"
-//About USB VENDOR REQ
-#if defined(CONFIG_USB_VENDOR_REQ_BUFFER_PREALLOC) && !defined(CONFIG_USB_VENDOR_REQ_MUTEX)
- #warning "define CONFIG_USB_VENDOR_REQ_MUTEX for CONFIG_USB_VENDOR_REQ_BUFFER_PREALLOC automatically"
- #define CONFIG_USB_VENDOR_REQ_MUTEX
-#endif
-#if defined(CONFIG_VENDOR_REQ_RETRY) && !defined(CONFIG_USB_VENDOR_REQ_MUTEX)
- #warning "define CONFIG_USB_VENDOR_REQ_MUTEX for CONFIG_VENDOR_REQ_RETRY automatically"
- #define CONFIG_USB_VENDOR_REQ_MUTEX
-#endif
-
#define DYNAMIC_CAMID_ALLOC
#ifndef CONFIG_RTW_HIQ_FILTER
diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h
index c73f581aea06..83d43e5726dd 100644
--- a/drivers/staging/rtl8723bs/include/drv_types.h
+++ b/drivers/staging/rtl8723bs/include/drv_types.h
@@ -14,7 +14,6 @@
#ifndef __DRV_TYPES_H__
#define __DRV_TYPES_H__
-#include <linux/version.h>
#include <linux/sched/signal.h>
#include <autoconf.h>
#include <basic_types.h>
@@ -24,15 +23,6 @@
#include <wifi.h>
#include <ieee80211.h>
-enum _NIC_VERSION {
-
- RTL8711_NIC,
- RTL8712_NIC,
- RTL8713_NIC,
- RTL8716_NIC
-
-};
-
#include <rtw_rf.h>
#include <rtw_ht.h>
@@ -77,15 +67,6 @@ enum _NIC_VERSION {
#define SPEC_DEV_ID_RF_CONFIG_2T2R BIT(4)
#define SPEC_DEV_ID_ASSIGN_IFNAME BIT(5)
-struct specific_device_id {
-
- u32 flags;
-
- u16 idVendor;
- u16 idProduct;
-
-};
-
struct registry_priv {
u8 chip_version;
u8 rfintfs;
@@ -196,9 +177,6 @@ struct registry_priv {
u8 RFE_Type;
u8 check_fw_ps;
-#ifdef CONFIG_MULTI_VIR_IFACES
- u8 ext_iface_num;/* primary/secondary iface is excluded */
-#endif
u8 qos_opt_enable;
u8 hiq_filter;
@@ -207,7 +185,7 @@ struct registry_priv {
/* For registry parameters */
#define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field))
-#define RGTRY_SZ(field) sizeof(((struct registry_priv*) 0)->field)
+#define RGTRY_SZ(field) sizeof(((struct registry_priv *)0)->field)
#define BSSID_OFT(field) ((u32)FIELD_OFFSET(struct wlan_bssid_ex, field))
#define BSSID_SZ(field) sizeof(((struct wlan_bssid_ex *) 0)->field)
@@ -219,131 +197,6 @@ struct registry_priv {
#define GET_IFACE_NUMS(padapter) (((struct adapter *)padapter)->dvobj->iface_nums)
#define GET_ADAPTER(padapter, iface_id) (((struct adapter *)padapter)->dvobj->padapters[iface_id])
-#ifdef CONFIG_DBG_COUNTER
-
-struct rx_logs {
- u32 intf_rx;
- u32 intf_rx_err_recvframe;
- u32 intf_rx_err_skb;
- u32 intf_rx_report;
- u32 core_rx;
- u32 core_rx_pre;
- u32 core_rx_pre_ver_err;
- u32 core_rx_pre_mgmt;
- u32 core_rx_pre_mgmt_err_80211w;
- u32 core_rx_pre_mgmt_err;
- u32 core_rx_pre_ctrl;
- u32 core_rx_pre_ctrl_err;
- u32 core_rx_pre_data;
- u32 core_rx_pre_data_wapi_seq_err;
- u32 core_rx_pre_data_wapi_key_err;
- u32 core_rx_pre_data_handled;
- u32 core_rx_pre_data_err;
- u32 core_rx_pre_data_unknown;
- u32 core_rx_pre_unknown;
- u32 core_rx_enqueue;
- u32 core_rx_dequeue;
- u32 core_rx_post;
- u32 core_rx_post_decrypt;
- u32 core_rx_post_decrypt_wep;
- u32 core_rx_post_decrypt_tkip;
- u32 core_rx_post_decrypt_aes;
- u32 core_rx_post_decrypt_wapi;
- u32 core_rx_post_decrypt_hw;
- u32 core_rx_post_decrypt_unknown;
- u32 core_rx_post_decrypt_err;
- u32 core_rx_post_defrag_err;
- u32 core_rx_post_portctrl_err;
- u32 core_rx_post_indicate;
- u32 core_rx_post_indicate_in_oder;
- u32 core_rx_post_indicate_reoder;
- u32 core_rx_post_indicate_err;
- u32 os_indicate;
- u32 os_indicate_ap_mcast;
- u32 os_indicate_ap_forward;
- u32 os_indicate_ap_self;
- u32 os_indicate_err;
- u32 os_netif_ok;
- u32 os_netif_err;
-};
-
-struct tx_logs {
- u32 os_tx;
- u32 os_tx_err_up;
- u32 os_tx_err_xmit;
- u32 os_tx_m2u;
- u32 os_tx_m2u_ignore_fw_linked;
- u32 os_tx_m2u_ignore_self;
- u32 os_tx_m2u_entry;
- u32 os_tx_m2u_entry_err_xmit;
- u32 os_tx_m2u_entry_err_skb;
- u32 os_tx_m2u_stop;
- u32 core_tx;
- u32 core_tx_err_pxmitframe;
- u32 core_tx_err_brtx;
- u32 core_tx_upd_attrib;
- u32 core_tx_upd_attrib_adhoc;
- u32 core_tx_upd_attrib_sta;
- u32 core_tx_upd_attrib_ap;
- u32 core_tx_upd_attrib_unknown;
- u32 core_tx_upd_attrib_dhcp;
- u32 core_tx_upd_attrib_icmp;
- u32 core_tx_upd_attrib_active;
- u32 core_tx_upd_attrib_err_ucast_sta;
- u32 core_tx_upd_attrib_err_ucast_ap_link;
- u32 core_tx_upd_attrib_err_sta;
- u32 core_tx_upd_attrib_err_link;
- u32 core_tx_upd_attrib_err_sec;
- u32 core_tx_ap_enqueue_warn_fwstate;
- u32 core_tx_ap_enqueue_warn_sta;
- u32 core_tx_ap_enqueue_warn_nosta;
- u32 core_tx_ap_enqueue_warn_link;
- u32 core_tx_ap_enqueue_warn_trigger;
- u32 core_tx_ap_enqueue_mcast;
- u32 core_tx_ap_enqueue_ucast;
- u32 core_tx_ap_enqueue;
- u32 intf_tx;
- u32 intf_tx_pending_ac;
- u32 intf_tx_pending_fw_under_survey;
- u32 intf_tx_pending_fw_under_linking;
- u32 intf_tx_pending_xmitbuf;
- u32 intf_tx_enqueue;
- u32 core_tx_enqueue;
- u32 core_tx_enqueue_class;
- u32 core_tx_enqueue_class_err_sta;
- u32 core_tx_enqueue_class_err_nosta;
- u32 core_tx_enqueue_class_err_fwlink;
- u32 intf_tx_direct;
- u32 intf_tx_direct_err_coalesce;
- u32 intf_tx_dequeue;
- u32 intf_tx_dequeue_err_coalesce;
- u32 intf_tx_dump_xframe;
- u32 intf_tx_dump_xframe_err_txdesc;
- u32 intf_tx_dump_xframe_err_port;
-};
-
-struct int_logs {
- u32 all;
- u32 err;
- u32 tbdok;
- u32 tbder;
- u32 bcnderr;
- u32 bcndma;
- u32 bcndma_e;
- u32 rx;
- u32 rx_rdu;
- u32 rx_fovw;
- u32 txfovw;
- u32 mgntok;
- u32 highdok;
- u32 bkdok;
- u32 bedok;
- u32 vidok;
- u32 vodok;
-};
-
-#endif /* CONFIG_DBG_COUNTER */
-
struct debug_priv {
u32 dbg_sdio_free_irq_error_cnt;
u32 dbg_sdio_alloc_irq_error_cnt;
@@ -402,7 +255,7 @@ struct rtw_traffic_statistics {
};
struct cam_ctl_t {
- _lock lock;
+ spinlock_t lock;
u64 bitmap;
};
@@ -412,15 +265,9 @@ struct cam_entry_cache {
u8 key[16];
};
-#define KEY_FMT "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
-#define KEY_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5], \
- ((u8 *)(x))[6], ((u8 *)(x))[7], ((u8 *)(x))[8], ((u8 *)(x))[9], ((u8 *)(x))[10], ((u8 *)(x))[11], \
- ((u8 *)(x))[12], ((u8 *)(x))[13], ((u8 *)(x))[14], ((u8 *)(x))[15]
-
struct dvobj_priv {
/*-------- below is common data --------*/
struct adapter *if1; /* PRIMARY_ADAPTER */
- struct adapter *if2; /* SECONDARY_ADAPTER */
s32 processing_dev_remove;
@@ -428,13 +275,13 @@ struct dvobj_priv {
/* for local/global synchronization */
/* */
- _lock lock;
+ spinlock_t lock;
int macid[NUM_STA];
- _mutex hw_init_mutex;
- _mutex h2c_fwcmd_mutex;
- _mutex setch_mutex;
- _mutex setbw_mutex;
+ struct mutex hw_init_mutex;
+ struct mutex h2c_fwcmd_mutex;
+ struct mutex setch_mutex;
+ struct mutex setbw_mutex;
unsigned char oper_channel; /* saved channel info when call set_channel_bw */
unsigned char oper_bwmode;
@@ -446,10 +293,6 @@ struct dvobj_priv {
struct cam_ctl_t cam_ctl;
struct cam_entry_cache cam_cache[TOTAL_CAM_ENTRY];
- /* For 92D, DMDP have 2 interface. */
- u8 InterfaceNumber;
- u8 NumInterfaces;
-
/* In /Out Pipe information */
int RtInPipe[2];
int RtOutPipe[4];
@@ -484,23 +327,17 @@ static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj)
struct adapter *dvobj_get_port0_adapter(struct dvobj_priv *dvobj);
-enum _IFACE_TYPE {
+enum {
IFACE_PORT0, /* mapping to port0 for C/D series chips */
IFACE_PORT1, /* mapping to port1 for C/D series chip */
MAX_IFACE_PORT,
};
-enum ADAPTER_TYPE {
- PRIMARY_ADAPTER,
- SECONDARY_ADAPTER,
- MAX_ADAPTER = 0xFF,
-};
-
-typedef enum _DRIVER_STATE {
+enum {
DRIVER_NORMAL = 0,
DRIVER_DISAPPEAR = 1,
DRIVER_REPLACE_DONGLE = 2,
-} DRIVER_STATE;
+};
struct adapter {
int DriverState;/* for disable driver using module, use dongle to replace module. */
@@ -518,7 +355,7 @@ struct adapter {
struct recv_priv recvpriv;
struct sta_priv stapriv;
struct security_priv securitypriv;
- _lock security_key_mutex; /* add for CONFIG_IEEE80211W, none 11w also can use */
+ spinlock_t security_key_mutex; /* add for CONFIG_IEEE80211W, none 11w also can use */
struct registry_priv registrypriv;
struct eeprom_priv eeprompriv;
@@ -526,7 +363,7 @@ struct adapter {
u32 setband;
- void * HalData;
+ void *HalData;
u32 hal_data_sz;
struct hal_ops HalFunc;
@@ -554,17 +391,16 @@ struct adapter {
void (*intf_free_irq)(struct dvobj_priv *dvobj);
- void (*intf_start)(struct adapter * adapter);
- void (*intf_stop)(struct adapter * adapter);
+ void (*intf_start)(struct adapter *adapter);
+ void (*intf_stop)(struct adapter *adapter);
- _nic_hdl pnetdev;
+ struct net_device *pnetdev;
char old_ifname[IFNAMSIZ];
/* used by rtw_rereg_nd_name related function */
struct rereg_nd_name_data {
- _nic_hdl old_pnetdev;
+ struct net_device *old_pnetdev;
char old_ifname[IFNAMSIZ];
- u8 old_ips_mode;
u8 old_bRegUseLed;
} rereg_nd_name_priv;
@@ -587,7 +423,7 @@ struct adapter {
/* The driver will show up the desired channel number when this flag is 1. */
u8 bNotifyChannelChange;
- /* pbuddystruct adapter is used only in two inteface case, (iface_nums =2 in struct dvobj_priv) */
+ /* pbuddystruct adapter is used only in two interface case, (iface_nums =2 in struct dvobj_priv) */
/* PRIMARY ADAPTER's buddy is SECONDARY_ADAPTER */
/* SECONDARY_ADAPTER's buddy is PRIMARY_ADAPTER */
/* for iface_id > SECONDARY_ADAPTER(IFACE_ID1), refer to padapters[iface_id] in struct dvobj_priv */
@@ -608,12 +444,6 @@ struct adapter {
u8 driver_rx_ampdu_factor;/* 0xff: disable drv ctrl, 0:8k, 1:16k, 2:32k, 3:64k; */
unsigned char in_cta_test;
-
-#ifdef CONFIG_DBG_COUNTER
- struct rx_logs rx_logs;
- struct tx_logs tx_logs;
- struct int_logs int_logs;
-#endif
};
#define adapter_to_dvobj(adapter) (adapter->dvobj)
@@ -659,17 +489,6 @@ static inline void RTW_ENABLE_FUNC(struct adapter *padapter, int func_bit)
(padapter)->bSurpriseRemoved || \
RTW_IS_FUNC_DISABLED((padapter), DF_TX_BIT))
-#ifdef CONFIG_GPIO_API
-int rtw_get_gpio(struct net_device *netdev, int gpio_num);
-int rtw_set_gpio_output_value(struct net_device *netdev, int gpio_num, bool isHigh);
-int rtw_config_gpio(struct net_device *netdev, int gpio_num, bool isOutput);
-#endif
-
-#ifdef CONFIG_WOWLAN
-void rtw_suspend_wow(struct adapter *padapter);
-int rtw_resume_process_wow(struct adapter *padapter);
-#endif
-
static inline u8 *myid(struct eeprom_priv *peepriv)
{
return peepriv->mac_addr;
diff --git a/drivers/staging/rtl8723bs/include/drv_types_sdio.h b/drivers/staging/rtl8723bs/include/drv_types_sdio.h
index 5e079838f59c..25b3c3a39ee4 100644
--- a/drivers/staging/rtl8723bs/include/drv_types_sdio.h
+++ b/drivers/staging/rtl8723bs/include/drv_types_sdio.h
@@ -11,11 +11,6 @@
#include <linux/mmc/sdio_func.h>
#include <linux/mmc/sdio_ids.h>
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
- #include <linux/mmc/host.h>
- #include <linux/mmc/card.h>
-#endif
-
struct sdio_data {
u8 func_number;
diff --git a/drivers/staging/rtl8723bs/include/hal_btcoex.h b/drivers/staging/rtl8723bs/include/hal_btcoex.h
index 29318b49c3ff..3c03be210d87 100644
--- a/drivers/staging/rtl8723bs/include/hal_btcoex.h
+++ b/drivers/staging/rtl8723bs/include/hal_btcoex.h
@@ -11,12 +11,12 @@
/* Some variables can't get from outsrc BT-Coex, */
/* so we need to save here */
-typedef struct _BT_COEXIST {
+struct bt_coexist {
u8 bBtExist;
u8 btTotalAntNum;
u8 btChipType;
u8 bInitlized;
-} BT_COEXIST, *PBT_COEXIST;
+};
void DBG_BT_INFO(u8 *dbgmsg);
diff --git a/drivers/staging/rtl8723bs/include/hal_com.h b/drivers/staging/rtl8723bs/include/hal_com.h
index fe7e2efce0e3..6bcc443d59fb 100644
--- a/drivers/staging/rtl8723bs/include/hal_com.h
+++ b/drivers/staging/rtl8723bs/include/hal_com.h
@@ -158,23 +158,19 @@
(rate == DESC_RATEVHTSS2MCS6) ? "VHTSS2MCS6" : \
(rate == DESC_RATEVHTSS2MCS7) ? "VHTSS2MCS7" : \
(rate == DESC_RATEVHTSS2MCS8) ? "VHTSS2MCS8" : \
-(rate == DESC_RATEVHTSS2MCS9) ? "VHTSS2MCS9" : "UNKNOW"
+(rate == DESC_RATEVHTSS2MCS9) ? "VHTSS2MCS9" : "UNKNOWN"
enum{
UP_LINK,
DOWN_LINK,
};
-typedef enum _RT_MEDIA_STATUS {
+enum rt_media_status {
RT_MEDIA_DISCONNECT = 0,
RT_MEDIA_CONNECT = 1
-} RT_MEDIA_STATUS;
+};
#define MAX_DLFW_PAGE_SIZE 4096 /* @ page : 4k bytes */
-enum FIRMWARE_SOURCE {
- FW_SOURCE_IMG_FILE = 0,
- FW_SOURCE_HEADER_FILE = 1, /* from header file */
-};
/* BK, BE, VI, VO, HCCA, MANAGEMENT, COMMAND, HIGH, BEACON. */
/* define MAX_TX_QUEUE 9 */
@@ -184,16 +180,12 @@ enum FIRMWARE_SOURCE {
#define TX_SELE_NQ BIT(2) /* Normal Queue */
#define TX_SELE_EQ BIT(3) /* Extern Queue */
-#define PageNum_128(_Len) (u32)(((_Len)>>7) + ((_Len)&0x7F ? 1:0))
-#define PageNum_256(_Len) (u32)(((_Len)>>8) + ((_Len)&0xFF ? 1:0))
-#define PageNum_512(_Len) (u32)(((_Len)>>9) + ((_Len)&0x1FF ? 1:0))
-#define PageNum(_Len, _Size) (u32)(((_Len)/(_Size)) + ((_Len)&((_Size) - 1) ? 1:0))
-
+#define PageNum_128(_Len) ((u32)(((_Len) >> 7) + ((_Len) & 0x7F ? 1 : 0)))
u8 rtw_hal_data_init(struct adapter *padapter);
void rtw_hal_data_deinit(struct adapter *padapter);
-void dump_chip_info(HAL_VERSION ChipVersion);
+void dump_chip_info(struct hal_version ChipVersion);
u8 /* return the final channel plan decision */
hal_com_config_channel_plan(
@@ -215,9 +207,9 @@ u8 MRateToHwRate(u8 rate);
u8 HwRateToMRate(u8 rate);
void HalSetBrateCfg(
- struct adapter * Adapter,
- u8 *mBratesOS,
- u16 *pBrateCfg);
+ struct adapter *Adapter,
+ u8 *mBratesOS,
+ u16 *pBrateCfg);
bool
Hal_MappingOutPipe(
@@ -227,7 +219,7 @@ u8 NumOutPipe
void hal_init_macaddr(struct adapter *adapter);
-void rtw_init_hal_com_default_value(struct adapter * Adapter);
+void rtw_init_hal_com_default_value(struct adapter *Adapter);
void c2h_evt_clear(struct adapter *adapter);
s32 c2h_evt_read_88xx(struct adapter *adapter, u8 *buf);
@@ -241,9 +233,9 @@ void SetHwReg(struct adapter *padapter, u8 variable, u8 *val);
void GetHwReg(struct adapter *padapter, u8 variable, u8 *val);
void rtw_hal_check_rxfifo_full(struct adapter *adapter);
-u8 SetHalDefVar(struct adapter *adapter, enum HAL_DEF_VARIABLE variable,
+u8 SetHalDefVar(struct adapter *adapter, enum hal_def_variable variable,
void *value);
-u8 GetHalDefVar(struct adapter *adapter, enum HAL_DEF_VARIABLE variable,
+u8 GetHalDefVar(struct adapter *adapter, enum hal_def_variable variable,
void *value);
bool eqNByte(u8 *str1, u8 *str2, u32 num);
@@ -278,22 +270,12 @@ void rtw_dump_raw_rssi_info(struct adapter *padapter);
void rtw_bb_rf_gain_offset(struct adapter *padapter);
void GetHalODMVar(struct adapter *Adapter,
- enum HAL_ODM_VARIABLE eVariable,
- void * pValue1,
- void * pValue2);
+ enum hal_odm_variable eVariable,
+ void *pValue1,
+ void *pValue2);
void SetHalODMVar(
- struct adapter * Adapter,
- enum HAL_ODM_VARIABLE eVariable,
- void * pValue1,
+ struct adapter *Adapter,
+ enum hal_odm_variable eVariable,
+ void *pValue1,
bool bSet);
-
-#ifdef CONFIG_BACKGROUND_NOISE_MONITOR
-struct noise_info {
- u8 bPauseDIG;
- u8 IGIValue;
- u32 max_time;/* ms */
- u8 chan;
-};
-#endif
-
#endif /* __HAL_COMMON_H__ */
diff --git a/drivers/staging/rtl8723bs/include/hal_com_h2c.h b/drivers/staging/rtl8723bs/include/hal_com_h2c.h
index b951bc288b89..24cd9415fa95 100644
--- a/drivers/staging/rtl8723bs/include/hal_com_h2c.h
+++ b/drivers/staging/rtl8723bs/include/hal_com_h2c.h
@@ -7,71 +7,6 @@
#ifndef __COMMON_H2C_H__
#define __COMMON_H2C_H__
-/* */
-/* H2C CMD DEFINITION ------------------------------------------------ */
-/* */
-/* 88e, 8723b, 8812, 8821, 92e use the same FW code base */
-enum h2c_cmd {
- /* Common Class: 000 */
- H2C_RSVD_PAGE = 0x00,
- H2C_MEDIA_STATUS_RPT = 0x01,
- H2C_SCAN_ENABLE = 0x02,
- H2C_KEEP_ALIVE = 0x03,
- H2C_DISCON_DECISION = 0x04,
- H2C_PSD_OFFLOAD = 0x05,
- H2C_AP_OFFLOAD = 0x08,
- H2C_BCN_RSVDPAGE = 0x09,
- H2C_PROBERSP_RSVDPAGE = 0x0A,
- H2C_FCS_RSVDPAGE = 0x10,
- H2C_FCS_INFO = 0x11,
- H2C_AP_WOW_GPIO_CTRL = 0x13,
-
- /* PoweSave Class: 001 */
- H2C_SET_PWR_MODE = 0x20,
- H2C_PS_TUNING_PARA = 0x21,
- H2C_PS_TUNING_PARA2 = 0x22,
- H2C_P2P_LPS_PARAM = 0x23,
- H2C_P2P_PS_OFFLOAD = 0x24,
- H2C_PS_SCAN_ENABLE = 0x25,
- H2C_SAP_PS_ = 0x26,
- H2C_INACTIVE_PS_ = 0x27, /* Inactive_PS */
- H2C_FWLPS_IN_IPS_ = 0x28,
-
- /* Dynamic Mechanism Class: 010 */
- H2C_MACID_CFG = 0x40,
- H2C_TXBF = 0x41,
- H2C_RSSI_SETTING = 0x42,
- H2C_AP_REQ_TXRPT = 0x43,
- H2C_INIT_RATE_COLLECT = 0x44,
-
- /* BT Class: 011 */
- H2C_B_TYPE_TDMA = 0x60,
- H2C_BT_INFO = 0x61,
- H2C_FORCE_BT_TXPWR = 0x62,
- H2C_BT_IGNORE_WLANACT = 0x63,
- H2C_DAC_SWING_VALUE = 0x64,
- H2C_ANT_SEL_RSV = 0x65,
- H2C_WL_OPMODE = 0x66,
- H2C_BT_MP_OPER = 0x67,
- H2C_BT_CONTROL = 0x68,
- H2C_BT_WIFI_CTRL = 0x69,
- H2C_BT_FW_PATCH = 0x6A,
-
- /* WOWLAN Class: 100 */
- H2C_WOWLAN = 0x80,
- H2C_REMOTE_WAKE_CTRL = 0x81,
- H2C_AOAC_GLOBAL_INFO = 0x82,
- H2C_AOAC_RSVD_PAGE = 0x83,
- H2C_AOAC_RSVD_PAGE2 = 0x84,
- H2C_D0_SCAN_OFFLOAD_CTRL = 0x85,
- H2C_D0_SCAN_OFFLOAD_INFO = 0x86,
- H2C_CHNL_SWITCH_OFFLOAD = 0x87,
- H2C_AOAC_RSVDPAGE3 = 0x88,
-
- H2C_RESET_TSF = 0xC0,
- H2C_MAXID,
-};
-
#define H2C_RSVDPAGE_LOC_LEN 5
#define H2C_MEDIA_STATUS_RPT_LEN 3
#define H2C_KEEP_ALIVE_CTRL_LEN 2
@@ -95,60 +30,6 @@ enum h2c_cmd {
#define H2C_BCN_RSVDPAGE_LEN 5
#define H2C_PROBERSP_RSVDPAGE_LEN 5
-#ifdef CONFIG_WOWLAN
-#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)
-#define cpMacAddr(des, src) ((des)[0] = (src)[0], (des)[1] = (src)[1], (des)[2] = (src)[2], (des)[3] = (src)[3], (des)[4] = (src)[4], (des)[5] = (src)[5])
-#define cpIpAddr(des, src) ((des)[0] = (src)[0], (des)[1] = (src)[1], (des)[2] = (src)[2], (des)[3] = (src)[3])
-
-/* */
-/* ARP packet */
-/* */
-/* LLC Header */
-#define GET_ARP_PKT_LLC_TYPE(__pHeader) ReadEF2Byte(((u8 *)(__pHeader)) + 6)
-
-/* ARP element */
-#define GET_ARP_PKT_OPERATION(__pHeader) ReadEF2Byte(((u8 *)(__pHeader)) + 6)
-#define GET_ARP_PKT_SENDER_MAC_ADDR(__pHeader, _val) cpMacAddr((u8 *)(_val), ((u8 *)(__pHeader))+8)
-#define GET_ARP_PKT_SENDER_IP_ADDR(__pHeader, _val) cpIpAddr((u8 *)(_val), ((u8 *)(__pHeader))+14)
-#define GET_ARP_PKT_TARGET_MAC_ADDR(__pHeader, _val) cpMacAddr((u8 *)(_val), ((u8 *)(__pHeader))+18)
-#define GET_ARP_PKT_TARGET_IP_ADDR(__pHeader, _val) cpIpAddr((u8 *)(_val), ((u8 *)(__pHeader))+24)
-
-#define SET_ARP_PKT_HW(__pHeader, __Value) WRITEEF2BYTE(((u8 *)(__pHeader)) + 0, __Value)
-#define SET_ARP_PKT_PROTOCOL(__pHeader, __Value) WRITEEF2BYTE(((u8 *)(__pHeader)) + 2, __Value)
-#define SET_ARP_PKT_HW_ADDR_LEN(__pHeader, __Value) WRITEEF1BYTE(((u8 *)(__pHeader)) + 4, __Value)
-#define SET_ARP_PKT_PROTOCOL_ADDR_LEN(__pHeader, __Value) WRITEEF1BYTE(((u8 *)(__pHeader)) + 5, __Value)
-#define SET_ARP_PKT_OPERATION(__pHeader, __Value) WRITEEF2BYTE(((u8 *)(__pHeader)) + 6, __Value)
-#define SET_ARP_PKT_SENDER_MAC_ADDR(__pHeader, _val) cpMacAddr(((u8 *)(__pHeader))+8, (u8 *)(_val))
-#define SET_ARP_PKT_SENDER_IP_ADDR(__pHeader, _val) cpIpAddr(((u8 *)(__pHeader))+14, (u8 *)(_val))
-#define SET_ARP_PKT_TARGET_MAC_ADDR(__pHeader, _val) cpMacAddr(((u8 *)(__pHeader))+18, (u8 *)(_val))
-#define SET_ARP_PKT_TARGET_IP_ADDR(__pHeader, _val) cpIpAddr(((u8 *)(__pHeader))+24, (u8 *)(_val))
-
-#define FW_WOWLAN_FUN_EN BIT(0)
-#define FW_WOWLAN_PATTERN_MATCH BIT(1)
-#define FW_WOWLAN_MAGIC_PKT BIT(2)
-#define FW_WOWLAN_UNICAST BIT(3)
-#define FW_WOWLAN_ALL_PKT_DROP BIT(4)
-#define FW_WOWLAN_GPIO_ACTIVE BIT(5)
-#define FW_WOWLAN_REKEY_WAKEUP BIT(6)
-#define FW_WOWLAN_DEAUTH_WAKEUP BIT(7)
-
-#define FW_WOWLAN_GPIO_WAKEUP_EN BIT(0)
-#define FW_FW_PARSE_MAGIC_PKT BIT(1)
-
-#define FW_REMOTE_WAKE_CTRL_EN BIT(0)
-#define FW_REALWOWLAN_EN BIT(5)
-
-#define FW_WOWLAN_KEEP_ALIVE_EN BIT(0)
-#define FW_ADOPT_USER BIT(1)
-#define FW_WOWLAN_KEEP_ALIVE_PKT_TYPE BIT(2)
-
-#define FW_REMOTE_WAKE_CTRL_EN BIT(0)
-#define FW_ARP_EN BIT(1)
-#define FW_REALWOWLAN_EN BIT(5)
-#define FW_WOW_FW_UNICAST_EN BIT(7)
-
-#endif /* CONFIG_WOWLAN */
-
/* _RSVDPAGE_LOC_CMD_0x00 */
#define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd, 0, 8, __Value)
#define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+1, 0, 8, __Value)
@@ -174,28 +55,6 @@ enum h2c_cmd {
#define SET_H2CCMD_DISCONDECISION_PARM_CHECK_PERIOD(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd+1, 0, 8, __Value)
#define SET_H2CCMD_DISCONDECISION_PARM_TRY_PKT_NUM(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd+2, 0, 8, __Value)
-#ifdef CONFIG_AP_WOWLAN
-/* _AP_Offload 0x08 */
-#define SET_H2CCMD_AP_WOWLAN_EN(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd, 0, 8, __Value)
-/* _BCN_RsvdPage 0x09 */
-#define SET_H2CCMD_AP_WOWLAN_RSVDPAGE_LOC_BCN(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd, 0, 8, __Value)
-/* _Probersp_RsvdPage 0x0a */
-#define SET_H2CCMD_AP_WOWLAN_RSVDPAGE_LOC_ProbeRsp(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd, 0, 8, __Value)
-/* _Probersp_RsvdPage 0x13 */
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_INDEX(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 4, __Value)
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_C2H_EN(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 1, __Value)
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_PLUS(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 5, 1, __Value)
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_HIGH_ACTIVE(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 6, 1, __Value)
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_EN(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 7, 1, __Value)
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_DURATION(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+1, 0, 8, __Value)
-#define SET_H2CCMD_AP_WOW_GPIO_CTRL_C2H_DURATION(__pH2CCmd, __Value)SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+2, 0, 8, __Value)
-/* _AP_PS 0x26 */
-#define SET_H2CCMD_AP_WOW_PS_EN(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
-#define SET_H2CCMD_AP_WOW_PS_32K_EN(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
-#define SET_H2CCMD_AP_WOW_PS_RF(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
-#define SET_H2CCMD_AP_WOW_PS_DURATION(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+1, 0, 8, __Value)
-#endif
-
/* _WoWLAN PARAM_CMD_0x80 */
#define SET_H2CCMD_WOWLAN_FUNC_ENABLE(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
#define SET_H2CCMD_WOWLAN_PATTERN_MATCH_ENABLE(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
@@ -230,56 +89,16 @@ enum h2c_cmd {
#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_NEIGHBOR_ADV(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+2, 0, 8, __Value)
#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_RSP(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+3, 0, 8, __Value)
#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_INFO(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+4, 0, 8, __Value)
-#ifdef CONFIG_GTK_OL
-#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_EXT_MEM(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+5, 0, 8, __Value)
-#endif /* CONFIG_GTK_OL */
-#ifdef CONFIG_PNO_SUPPORT
-#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_NLO_INFO(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd), 0, 8, __Value)
-#endif
-
-#ifdef CONFIG_PNO_SUPPORT
-/* D0_Scan_Offload_Info_0x86 */
-#define SET_H2CCMD_AOAC_NLO_FUN_EN(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE((__pH2CCmd), 3, 1, __Value)
-#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_PROBE_PACKET(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+1, 0, 8, __Value)
-#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_SCAN_INFO(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+2, 0, 8, __Value)
-#define SET_H2CCMD_AOAC_RSVDPAGE_LOC_SSID_INFO(__pH2CCmd, __Value) SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+3, 0, 8, __Value)
-#endif /* CONFIG_PNO_SUPPORT */
/* */
/* Structure -------------------------------------------------- */
/* */
-typedef struct _RSVDPAGE_LOC {
+struct rsvdpage_loc {
u8 LocProbeRsp;
u8 LocPsPoll;
u8 LocNullData;
u8 LocQosNull;
u8 LocBTQosNull;
-#ifdef CONFIG_WOWLAN
- u8 LocRemoteCtrlInfo;
- u8 LocArpRsp;
- u8 LocNbrAdv;
- u8 LocGTKRsp;
- u8 LocGTKInfo;
- u8 LocProbeReq;
- u8 LocNetList;
-#ifdef CONFIG_GTK_OL
- u8 LocGTKEXTMEM;
-#endif /* CONFIG_GTK_OL */
-#ifdef CONFIG_PNO_SUPPORT
- u8 LocPNOInfo;
- u8 LocScanInfo;
- u8 LocSSIDInfo;
- u8 LocProbePacket;
-#endif /* CONFIG_PNO_SUPPORT */
-#endif /* CONFIG_WOWLAN */
-#ifdef CONFIG_AP_WOWLAN
- u8 LocApOffloadBCN;
-#endif /* CONFIG_AP_WOWLAN */
-} RSVDPAGE_LOC, *PRSVDPAGE_LOC;
+};
#endif
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-void rtw_get_current_ip_address(struct adapter *padapter, u8 *pcurrentip);
-void rtw_get_sec_iv(struct adapter *padapter, u8*pcur_dot11txpn, u8 *StaAddr);
-void rtw_set_sec_pn(struct adapter *padapter);
-#endif
diff --git a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h
index 9fff4aa36546..73f6cadb5c79 100644
--- a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h
+++ b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h
@@ -12,7 +12,7 @@
#define PathC 0x2
#define PathD 0x3
-enum RATE_SECTION {
+enum rate_section {
CCK = 0,
OFDM,
HT_MCS0_MCS7,
@@ -25,7 +25,7 @@ enum RATE_SECTION {
VHT_4SSMCS0_4SSMCS9,
};
-enum RF_TX_NUM {
+enum {
RF_1TX = 0,
RF_2TX,
RF_3TX,
@@ -36,7 +36,7 @@ enum RF_TX_NUM {
#define MAX_POWER_INDEX 0x3F
-enum _REGULATION_TXPWR_LMT {
+enum {
TXPWR_LMT_FCC = 0,
TXPWR_LMT_MKK,
TXPWR_LMT_ETSI,
@@ -72,11 +72,11 @@ struct bb_register_def {
u8
PHY_GetTxPowerByRateBase(
-struct adapter * Adapter,
+struct adapter *Adapter,
u8 Band,
u8 RfPath,
u8 TxNum,
-enum RATE_SECTION RateSection
+enum rate_section RateSection
);
u8
@@ -92,9 +92,9 @@ struct adapter *padapter,
u32 RegAddr,
u32 BitMask,
u32 Value,
- u8* RateIndex,
- s8* PwrByRateVal,
- u8* RateNum
+u8 *RateIndex,
+s8 *PwrByRateVal,
+u8 *RateNum
);
u8
@@ -104,7 +104,7 @@ u8 Rate
void
PHY_SetTxPowerIndexByRateSection(
-struct adapter * padapter,
+struct adapter *padapter,
u8 RFPath,
u8 Channel,
u8 RateSection
@@ -138,11 +138,11 @@ u8 path
void
PHY_SetTxPowerIndexByRateArray(
-struct adapter * padapter,
+struct adapter *padapter,
u8 RFPath,
-enum CHANNEL_WIDTH BandWidth,
+enum channel_width BandWidth,
u8 Channel,
-u8* Rates,
+u8 *Rates,
u8 RateArraySize
);
@@ -164,21 +164,21 @@ u32 Data
void
PHY_TxPowerByRateConfiguration(
- struct adapter * padapter
+ struct adapter *padapter
);
u8
PHY_GetTxPowerIndexBase(
-struct adapter * padapter,
+struct adapter *padapter,
u8 RFPath,
u8 Rate,
-enum CHANNEL_WIDTH BandWidth,
+enum channel_width BandWidth,
u8 Channel,
bool *bIn24G
);
s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 RegPwrTblSel,
- enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth,
+ enum band_type Band, enum channel_width Bandwidth,
u8 RfPath,
u8 DataRate,
u8 Channel
@@ -186,7 +186,7 @@ u8 Channel
void
PHY_SetTxPowerLimit(
-struct adapter * Adapter,
+struct adapter *Adapter,
u8 *Regulation,
u8 *Band,
u8 *Bandwidth,
@@ -198,12 +198,12 @@ u8 *PowerLimit
void
PHY_ConvertTxPowerLimitToPowerIndex(
-struct adapter * Adapter
+struct adapter *Adapter
);
void
PHY_InitTxPowerLimit(
-struct adapter * Adapter
+struct adapter *Adapter
);
s8
@@ -215,7 +215,7 @@ PHY_GetTxPowerTrackingOffset(
void
Hal_ChannelPlanToRegulation(
-struct adapter * Adapter,
+struct adapter *Adapter,
u16 ChannelPlan
);
diff --git a/drivers/staging/rtl8723bs/include/hal_com_reg.h b/drivers/staging/rtl8723bs/include/hal_com_reg.h
index 37fa59a352d6..b14585cb0233 100644
--- a/drivers/staging/rtl8723bs/include/hal_com_reg.h
+++ b/drivers/staging/rtl8723bs/include/hal_com_reg.h
@@ -707,14 +707,6 @@ Default: 00b.
/* 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
-
#define RATE_BITMAP_ALL 0xFFFFF
/* Only use CCK 1M rate for ACK */
@@ -776,14 +768,14 @@ Default: 00b.
#define IMR_BCNDMAINT3 BIT28 /* Beacon DMA Interrupt 3 */
#define IMR_BCNDMAINT2 BIT27 /* Beacon DMA Interrupt 2 */
#define IMR_BCNDMAINT1 BIT26 /* Beacon DMA Interrupt 1 */
-#define IMR_BCNDOK8 BIT25 /* Beacon Queue DMA OK Interrup 8 */
-#define IMR_BCNDOK7 BIT24 /* Beacon Queue DMA OK Interrup 7 */
-#define IMR_BCNDOK6 BIT23 /* Beacon Queue DMA OK Interrup 6 */
-#define IMR_BCNDOK5 BIT22 /* Beacon Queue DMA OK Interrup 5 */
-#define IMR_BCNDOK4 BIT21 /* Beacon Queue DMA OK Interrup 4 */
-#define IMR_BCNDOK3 BIT20 /* Beacon Queue DMA OK Interrup 3 */
-#define IMR_BCNDOK2 BIT19 /* Beacon Queue DMA OK Interrup 2 */
-#define IMR_BCNDOK1 BIT18 /* Beacon Queue DMA OK Interrup 1 */
+#define IMR_BCNDOK8 BIT25 /* Beacon Queue DMA OK Interrupt 8 */
+#define IMR_BCNDOK7 BIT24 /* Beacon Queue DMA OK Interrupt 7 */
+#define IMR_BCNDOK6 BIT23 /* Beacon Queue DMA OK Interrupt 6 */
+#define IMR_BCNDOK5 BIT22 /* Beacon Queue DMA OK Interrupt 5 */
+#define IMR_BCNDOK4 BIT21 /* Beacon Queue DMA OK Interrupt 4 */
+#define IMR_BCNDOK3 BIT20 /* Beacon Queue DMA OK Interrupt 3 */
+#define IMR_BCNDOK2 BIT19 /* Beacon Queue DMA OK Interrupt 2 */
+#define IMR_BCNDOK1 BIT18 /* Beacon Queue DMA OK Interrupt 1 */
#define IMR_TIMEOUT2 BIT17 /* Timeout interrupt 2 */
#define IMR_TIMEOUT1 BIT16 /* Timeout interrupt 1 */
#define IMR_TXFOVW BIT15 /* Transmit FIFO Overflow */
@@ -792,9 +784,9 @@ Default: 00b.
#define IMR_RXFOVW BIT12 /* Receive FIFO Overflow */
#define IMR_RDU BIT11 /* Receive Descriptor Unavailable */
#define IMR_ATIMEND BIT10 /* For 92C, ATIM Window End Interrupt. For 8723 and later ICs, it also means P2P CTWin End interrupt. */
-#define IMR_BDOK BIT9 /* Beacon Queue DMA OK Interrup */
+#define IMR_BDOK BIT9 /* Beacon Queue DMA OK Interrupt */
#define IMR_HIGHDOK BIT8 /* High Queue DMA OK Interrupt */
-#define IMR_TBDOK BIT7 /* Transmit Beacon OK interrup */
+#define IMR_TBDOK BIT7 /* Transmit Beacon OK interrupt */
#define IMR_MGNTDOK BIT6 /* Management Queue DMA OK Interrupt */
#define IMR_TBDER BIT5 /* For 92C, Transmit Beacon Error Interrupt */
#define IMR_BKDOK BIT4 /* AC_BK DMA OK Interrupt */
@@ -964,13 +956,13 @@ Default: 00b.
#define IMR_BCNDMAINT3_88E BIT23 /* Beacon DMA Interrupt 3 */
#define IMR_BCNDMAINT2_88E BIT22 /* Beacon DMA Interrupt 2 */
#define IMR_BCNDMAINT1_88E BIT21 /* Beacon DMA Interrupt 1 */
-#define IMR_BCNDOK7_88E BIT20 /* Beacon Queue DMA OK Interrup 7 */
-#define IMR_BCNDOK6_88E BIT19 /* Beacon Queue DMA OK Interrup 6 */
-#define IMR_BCNDOK5_88E BIT18 /* Beacon Queue DMA OK Interrup 5 */
-#define IMR_BCNDOK4_88E BIT17 /* Beacon Queue DMA OK Interrup 4 */
-#define IMR_BCNDOK3_88E BIT16 /* Beacon Queue DMA OK Interrup 3 */
-#define IMR_BCNDOK2_88E BIT15 /* Beacon Queue DMA OK Interrup 2 */
-#define IMR_BCNDOK1_88E BIT14 /* Beacon Queue DMA OK Interrup 1 */
+#define IMR_BCNDOK7_88E BIT20 /* Beacon Queue DMA OK Interrupt 7 */
+#define IMR_BCNDOK6_88E BIT19 /* Beacon Queue DMA OK Interrupt 6 */
+#define IMR_BCNDOK5_88E BIT18 /* Beacon Queue DMA OK Interrupt 5 */
+#define IMR_BCNDOK4_88E BIT17 /* Beacon Queue DMA OK Interrupt 4 */
+#define IMR_BCNDOK3_88E BIT16 /* Beacon Queue DMA OK Interrupt 3 */
+#define IMR_BCNDOK2_88E BIT15 /* Beacon Queue DMA OK Interrupt 2 */
+#define IMR_BCNDOK1_88E BIT14 /* Beacon Queue DMA OK Interrupt 1 */
#define IMR_ATIMEND_E_88E BIT13 /* ATIM Window End Extension for Win7 */
#define IMR_TXERR_88E BIT11 /* Tx Error Flag Interrupt Status, write 1 clear. */
#define IMR_RXERR_88E BIT10 /* Rx Error Flag INT Status, Write 1 clear */
@@ -1002,9 +994,9 @@ Current IOREG MAP
/* 8192C (TXPAUSE) transmission pause (Offset 0x522, 8 bits) */
/* */
/* Note: */
-/* The the bits of stoping AC(VO/VI/BE/BK) queue in datasheet RTL8192S/RTL8192C are wrong, */
-/* the correct arragement is VO - Bit0, VI - Bit1, BE - Bit2, and BK - Bit3. */
-/* 8723 and 88E may be not correct either in the eralier version. Confirmed with DD Tim. */
+/* The bits of stopping AC(VO/VI/BE/BK) queue in datasheet RTL8192S/RTL8192C are wrong, */
+/* the correct arrangement is VO - Bit0, VI - Bit1, BE - Bit2, and BK - Bit3. */
+/* 8723 and 88E may be not correct either in the earlier version. Confirmed with DD Tim. */
/* By Bruce, 2011-09-22. */
#define StopBecon BIT6
#define StopHigh BIT5
diff --git a/drivers/staging/rtl8723bs/include/hal_data.h b/drivers/staging/rtl8723bs/include/hal_data.h
index fa5d70016f05..babcb03a7c23 100644
--- a/drivers/staging/rtl8723bs/include/hal_data.h
+++ b/drivers/staging/rtl8723bs/include/hal_data.h
@@ -15,7 +15,7 @@
/* */
/* <Roger_Notes> For RTL8723 WiFi/BT/GPS multi-function configuration. 2010.10.06. */
/* */
-enum RT_MULTI_FUNC {
+enum rt_multi_func {
RT_MULTI_FUNC_NONE = 0x00,
RT_MULTI_FUNC_WIFI = 0x01,
RT_MULTI_FUNC_BT = 0x02,
@@ -24,18 +24,18 @@ enum RT_MULTI_FUNC {
/* */
/* <Roger_Notes> For RTL8723 WiFi PDn/GPIO polarity control configuration. 2010.10.08. */
/* */
-enum RT_POLARITY_CTL {
+enum rt_polarity_ctl {
RT_POLARITY_LOW_ACT = 0,
RT_POLARITY_HIGH_ACT = 1,
};
/* For RTL8723 regulator mode. by tynli. 2011.01.14. */
-enum RT_REGULATOR_MODE {
+enum rt_regulator_mode {
RT_SWITCHING_REGULATOR = 0,
RT_LDO_REGULATOR = 1,
};
-enum RT_AMPDU_BURST {
+enum rt_ampdu_burst {
RT_AMPDU_BURST_NONE = 0,
RT_AMPDU_BURST_92D = 1,
RT_AMPDU_BURST_88E = 2,
@@ -46,16 +46,14 @@ enum RT_AMPDU_BURST {
RT_AMPDU_BURST_8723B = 7,
};
-#define CHANNEL_MAX_NUMBER 14+24+21 /* 14 is the max channel number */
+#define CHANNEL_MAX_NUMBER (14 + 24 + 21) /* 14 is the max channel number */
#define CHANNEL_MAX_NUMBER_2G 14
#define CHANNEL_MAX_NUMBER_5G 54 /* Please refer to "phy_GetChnlGroup8812A" and "Hal_ReadTxPowerInfo8812A" */
#define CHANNEL_MAX_NUMBER_5G_80M 7
-#define CHANNEL_GROUP_MAX 3+9 /* ch1~3, ch4~9, ch10~14 total three groups */
#define MAX_PG_GROUP 13
/* Tx Power Limit Table Size */
#define MAX_REGULATION_NUM 4
-#define MAX_RF_PATH_NUM_IN_POWER_LIMIT_TABLE 4
#define MAX_2_4G_BANDWIDTH_NUM 4
#define MAX_RATE_SECTION_NUM 10
#define MAX_5G_BANDWIDTH_NUM 4
@@ -69,11 +67,6 @@ enum RT_AMPDU_BURST {
/* define IQK_ADDA_REG_NUM 16 */
/* define IQK_BB_REG_NUM 10 */
-#define IQK_BB_REG_NUM_92C 9
-#define IQK_BB_REG_NUM_92D 10
-#define IQK_BB_REG_NUM_test 6
-
-#define IQK_Matrix_Settings_NUM_92D 1+24+21
/* define HP_THERMAL_NUM 8 */
/* duplicate code, will move to ODM ######### */
@@ -176,10 +169,10 @@ struct dm_priv {
struct hal_com_data {
- HAL_VERSION VersionID;
- enum RT_MULTI_FUNC MultiFunc; /* For multi-function consideration. */
- enum RT_POLARITY_CTL PolarityCtl; /* For Wifi PDn Polarity control. */
- enum RT_REGULATOR_MODE RegulatorMode; /* switching regulator or LDO */
+ struct hal_version VersionID;
+ enum rt_multi_func MultiFunc; /* For multi-function consideration. */
+ enum rt_polarity_ctl PolarityCtl; /* For Wifi PDn Polarity control. */
+ enum rt_regulator_mode RegulatorMode; /* switching regulator or LDO */
u16 FirmwareVersion;
u16 FirmwareVersionRev;
@@ -187,10 +180,10 @@ struct hal_com_data {
u16 FirmwareSignature;
/* current WIFI_PHY values */
- enum WIRELESS_MODE CurrentWirelessMode;
- enum CHANNEL_WIDTH CurrentChannelBW;
- enum BAND_TYPE CurrentBandType; /* 0:2.4G, 1:5G */
- enum BAND_TYPE BandSet;
+ enum wireless_mode CurrentWirelessMode;
+ enum channel_width CurrentChannelBW;
+ enum band_type CurrentBandType; /* 0:2.4G, 1:5G */
+ enum band_type BandSet;
u8 CurrentChannel;
u8 CurrentCenterFrequencyIndex1;
u8 nCur40MhzPrimeSC;/* Control channel sub-carrier */
@@ -233,7 +226,7 @@ struct hal_com_data {
bool EepromOrEfuse;
u8 EfuseUsedPercentage;
u16 EfuseUsedBytes;
- EFUSE_HAL EfuseHal;
+ struct efuse_hal EfuseHal;
/* 3 [2.4G] */
u8 Index24G_CCK_Base[MAX_RF_PATH][CHANNEL_MAX_NUMBER];
@@ -396,7 +389,7 @@ struct hal_com_data {
u8 OutEpQueueSel;
u8 OutEpNumber;
- /* 2010/12/10 MH Add for USB aggreation mode dynamic shceme. */
+ /* 2010/12/10 MH Add for USB aggregation mode dynamic scheme. */
bool UsbRxHighSpeedMode;
/* 2010/11/22 MH Add for slim combo debug mode selective. */
@@ -411,7 +404,7 @@ struct hal_com_data {
u8 RegIQKFWOffload;
struct submit_ctx iqk_sctx;
- enum RT_AMPDU_BURST AMPDUBurstMode; /* 92C maybe not use, but for compile successfully */
+ enum rt_ampdu_burst AMPDUBurstMode; /* 92C maybe not use, but for compile successfully */
u32 sdio_himr;
u32 sdio_hisr;
@@ -419,7 +412,7 @@ struct hal_com_data {
/* SDIO Tx FIFO related. */
/* HIQ, MID, LOW, PUB free pages; padapter->xmitpriv.free_txpg */
u8 SdioTxFIFOFreePage[SDIO_TX_FREE_PG_QUEUE];
- _lock SdioTxFIFOFreePageLock;
+ spinlock_t SdioTxFIFOFreePageLock;
u8 SdioTxOQTMaxFreeSpace;
u8 SdioTxOQTFreeSpace;
@@ -431,19 +424,14 @@ struct hal_com_data {
u32 sdio_tx_max_len[SDIO_MAX_TX_QUEUE];/* H, N, L, used for sdio tx aggregation max length per queue */
struct dm_priv dmpriv;
- DM_ODM_T odmpriv;
+ struct dm_odm_t odmpriv;
/* For bluetooth co-existance */
- BT_COEXIST bt_coexist;
+ struct bt_coexist bt_coexist;
/* Interrupt related register information. */
u32 SysIntrStatus;
u32 SysIntrMask;
-
-#ifdef CONFIG_BACKGROUND_NOISE_MONITOR
- s16 noise[ODM_MAX_CHANNEL_NUM];
-#endif
-
};
#define GET_HAL_DATA(__padapter) ((struct hal_com_data *)((__padapter)->HalData))
diff --git a/drivers/staging/rtl8723bs/include/hal_intf.h b/drivers/staging/rtl8723bs/include/hal_intf.h
index 426c8d58c444..45bebbadb7ca 100644
--- a/drivers/staging/rtl8723bs/include/hal_intf.h
+++ b/drivers/staging/rtl8723bs/include/hal_intf.h
@@ -8,14 +8,14 @@
#define __HAL_INTF_H__
-enum RTL871X_HCI_TYPE {
+enum {
RTW_PCIE = BIT0,
RTW_USB = BIT1,
RTW_SDIO = BIT2,
RTW_GSPI = BIT3,
};
-enum HW_VARIABLES {
+enum {
HW_VAR_MEDIA_STATUS,
HW_VAR_MEDIA_STATUS1,
HW_VAR_SET_OPMODE,
@@ -85,14 +85,6 @@ enum HW_VARIABLES {
HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */
/* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */
/* Unit in microsecond. 0 means disable this function. */
-#ifdef CONFIG_WOWLAN
- HW_VAR_WOWLAN,
- HW_VAR_WAKEUP_REASON,
- HW_VAR_RPWM_TOG,
-#endif
-#ifdef CONFIG_AP_WOWLAN
- HW_VAR_AP_WOWLAN,
-#endif
HW_VAR_SYS_CLKR,
HW_VAR_NAV_UPPER,
HW_VAR_C2H_HANDLE,
@@ -120,7 +112,7 @@ enum HW_VARIABLES {
HW_VAR_MACID_WAKEUP,
};
-enum HAL_DEF_VARIABLE {
+enum hal_def_variable {
HAL_DEF_UNDERCORATEDSMOOTHEDPWDB,
HAL_DEF_IS_SUPPORT_ANT_DIV,
HAL_DEF_CURRENT_ANTENNA,
@@ -155,14 +147,14 @@ enum HAL_DEF_VARIABLE {
HAL_DEF_DBG_RX_INFO_DUMP,
};
-enum HAL_ODM_VARIABLE {
+enum hal_odm_variable {
HAL_ODM_STA_INFO,
HAL_ODM_P2P_STATE,
HAL_ODM_WIFI_DISPLAY_STATE,
HAL_ODM_NOISE_MONITOR,
};
-enum HAL_INTF_PS_FUNC {
+enum hal_intf_ps_func {
HAL_USB_SELECT_SUSPEND,
HAL_MAX_ID,
};
@@ -202,9 +194,9 @@ struct hal_ops {
u8 (*check_ips_status)(struct adapter *padapter);
s32 (*interrupt_handler)(struct adapter *padapter);
void (*clear_interrupt)(struct adapter *padapter);
- void (*set_bwmode_handler)(struct adapter *padapter, enum CHANNEL_WIDTH Bandwidth, u8 Offset);
+ void (*set_bwmode_handler)(struct adapter *padapter, enum channel_width Bandwidth, u8 Offset);
void (*set_channel_handler)(struct adapter *padapter, u8 channel);
- void (*set_chnl_bw_handler)(struct adapter *padapter, u8 channel, enum CHANNEL_WIDTH Bandwidth, u8 Offset40, u8 Offset80);
+ void (*set_chnl_bw_handler)(struct adapter *padapter, u8 channel, enum channel_width Bandwidth, u8 Offset40, u8 Offset80);
void (*set_tx_power_level_handler)(struct adapter *padapter, u8 channel);
void (*get_tx_power_level_handler)(struct adapter *padapter, s32 *powerlevel);
@@ -218,11 +210,11 @@ struct hal_ops {
void (*SetHwRegHandlerWithBuf)(struct adapter *padapter, u8 variable, u8 *pbuf, int len);
- u8 (*GetHalDefVarHandler)(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue);
- u8 (*SetHalDefVarHandler)(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue);
+ u8 (*GetHalDefVarHandler)(struct adapter *padapter, enum hal_def_variable eVariable, void *pValue);
+ u8 (*SetHalDefVarHandler)(struct adapter *padapter, enum hal_def_variable eVariable, void *pValue);
- void (*GetHalODMVarHandler)(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, void *pValue2);
- void (*SetHalODMVarHandler)(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, bool bSet);
+ void (*GetHalODMVarHandler)(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, void *pValue2);
+ void (*SetHalODMVarHandler)(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet);
void (*UpdateRAMaskHandler)(struct adapter *padapter, u32 mac_id, u8 rssi_level);
void (*SetBeaconRelatedRegistersHandler)(struct adapter *padapter);
@@ -232,7 +224,7 @@ struct hal_ops {
void (*run_thread)(struct adapter *padapter);
void (*cancel_thread)(struct adapter *padapter);
- u8 (*interface_ps_func)(struct adapter *padapter, enum HAL_INTF_PS_FUNC efunc_id, u8 *val);
+ u8 (*interface_ps_func)(struct adapter *padapter, enum hal_intf_ps_func efunc_id, u8 *val);
s32 (*hal_xmit)(struct adapter *padapter, struct xmit_frame *pxmitframe);
/*
@@ -265,12 +257,6 @@ struct hal_ops {
s32 (*fill_h2c_cmd)(struct adapter *, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer);
};
-enum RT_EEPROM_TYPE {
- EEPROM_93C46,
- EEPROM_93C56,
- EEPROM_BOOT_EFUSE,
-};
-
#define RF_CHANGE_BY_INIT 0
#define RF_CHANGE_BY_IPS BIT28
#define RF_CHANGE_BY_PS BIT29
@@ -280,30 +266,6 @@ enum RT_EEPROM_TYPE {
#define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv)
#define is_boot_from_eeprom(adapter) (adapter->eeprompriv.EepromOrEfuse)
-enum wowlan_subcode {
- WOWLAN_PATTERN_MATCH = 1,
- WOWLAN_MAGIC_PACKET = 2,
- WOWLAN_UNICAST = 3,
- WOWLAN_SET_PATTERN = 4,
- WOWLAN_DUMP_REG = 5,
- WOWLAN_ENABLE = 6,
- WOWLAN_DISABLE = 7,
- WOWLAN_STATUS = 8,
- WOWLAN_DEBUG_RELOAD_FW = 9,
- WOWLAN_DEBUG_1 = 10,
- WOWLAN_DEBUG_2 = 11,
- WOWLAN_AP_ENABLE = 12,
- WOWLAN_AP_DISABLE = 13
-};
-
-struct wowlan_ioctl_param {
- unsigned int subcode;
- unsigned int subcode_value;
- unsigned int wakeup_reason;
- unsigned int len;
- unsigned char pattern[0];
-};
-
#define Rx_Pairwisekey 0x01
#define Rx_GTK 0x02
#define Rx_DisAssoc 0x04
@@ -335,11 +297,11 @@ void rtw_hal_chip_configure(struct adapter *padapter);
void rtw_hal_read_chip_info(struct adapter *padapter);
void rtw_hal_read_chip_version(struct adapter *padapter);
-u8 rtw_hal_set_def_var(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue);
-u8 rtw_hal_get_def_var(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue);
+u8 rtw_hal_set_def_var(struct adapter *padapter, enum hal_def_variable eVariable, void *pValue);
+u8 rtw_hal_get_def_var(struct adapter *padapter, enum hal_def_variable eVariable, void *pValue);
-void rtw_hal_set_odm_var(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, bool bSet);
-void rtw_hal_get_odm_var(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, void *pValue2);
+void rtw_hal_set_odm_var(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet);
+void rtw_hal_get_odm_var(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, void *pValue2);
void rtw_hal_enable_interrupt(struct adapter *padapter);
void rtw_hal_disable_interrupt(struct adapter *padapter);
@@ -378,7 +340,7 @@ void rtw_hal_write_rfreg(struct adapter *padapter, u32 eRFPath, u32 RegAddr, u32
#define PHY_QueryMacReg PHY_QueryBBReg
void rtw_hal_set_chan(struct adapter *padapter, u8 channel);
-void rtw_hal_set_chnl_bw(struct adapter *padapter, u8 channel, enum CHANNEL_WIDTH Bandwidth, u8 Offset40, u8 Offset80);
+void rtw_hal_set_chnl_bw(struct adapter *padapter, u8 channel, enum channel_width Bandwidth, u8 Offset40, u8 Offset80);
void rtw_hal_dm_watchdog(struct adapter *padapter);
void rtw_hal_dm_watchdog_in_lps(struct adapter *padapter);
diff --git a/drivers/staging/rtl8723bs/include/hal_phy.h b/drivers/staging/rtl8723bs/include/hal_phy.h
index ed0caa0574e3..521eb1c2efad 100644
--- a/drivers/staging/rtl8723bs/include/hal_phy.h
+++ b/drivers/staging/rtl8723bs/include/hal_phy.h
@@ -20,17 +20,6 @@
#define HAL_RF_ENABLE 1
#endif
-#define RF6052_MAX_TX_PWR 0x3F
-#define RF6052_MAX_REG_88E 0xFF
-#define RF6052_MAX_REG_92C 0x7F
-
-#define RF6052_MAX_REG \
- (RF6052_MAX_REG_88E > RF6052_MAX_REG_92C) ? RF6052_MAX_REG_88E : RF6052_MAX_REG_92C
-
-#define GET_RF6052_REAL_MAX_REG(_Adapter) RF6052_MAX_REG_92C
-
-#define RF6052_MAX_PATH 2
-
/* */
/* Antenna detection method, i.e., using single tone detection or RSSI reported from each antenna detected. */
/* Added by Roger, 2013.05.22. */
@@ -42,14 +31,14 @@
/*--------------------------Define Parameters-------------------------------*/
-enum BAND_TYPE {
+enum band_type {
BAND_ON_2_4G = 0,
BAND_ON_5G,
BAND_ON_BOTH,
BANDMAX
};
-enum RF_TYPE {
+enum {
RF_TYPE_MIN = 0, /* 0 */
RF_8225 = 1, /* 1 11b/g RF for verification only */
RF_8256 = 2, /* 2 11b/g/n */
@@ -59,7 +48,7 @@ enum RF_TYPE {
RF_TYPE_MAX
};
-enum RF_PATH {
+enum rf_path {
RF_PATH_A = 0,
RF_PATH_B,
RF_PATH_C,
@@ -74,49 +63,7 @@ enum RF_PATH {
#define RF_PATH_MAX_92C_88E 2
#define RF_PATH_MAX_90_8812 4 /* Max RF number 90 support */
-enum ANTENNA_PATH {
- ANTENNA_NONE = 0,
- ANTENNA_D = 1,
- ANTENNA_C = 2,
- ANTENNA_CD = 3,
- ANTENNA_B = 4,
- ANTENNA_BD = 5,
- ANTENNA_BC = 6,
- ANTENNA_BCD = 7,
- ANTENNA_A = 8,
- ANTENNA_AD = 9,
- ANTENNA_AC = 10,
- ANTENNA_ACD = 11,
- ANTENNA_AB = 12,
- ANTENNA_ABD = 13,
- ANTENNA_ABC = 14,
- ANTENNA_ABCD = 15
-};
-
-enum RF_CONTENT {
- radioa_txt = 0x1000,
- radiob_txt = 0x1001,
- radioc_txt = 0x1002,
- radiod_txt = 0x1003
-};
-
-enum BaseBand_Config_Type {
- BaseBand_Config_PHY_REG = 0, /* Radio Path A */
- BaseBand_Config_AGC_TAB = 1, /* Radio Path B */
- BaseBand_Config_AGC_TAB_2G = 2,
- BaseBand_Config_AGC_TAB_5G = 3,
- BaseBand_Config_PHY_REG_PG
-};
-
-enum HW_BLOCK {
- HW_BLOCK_MAC = 0,
- HW_BLOCK_PHY0 = 1,
- HW_BLOCK_PHY1 = 2,
- HW_BLOCK_RF = 3,
- HW_BLOCK_MAXIMUM = 4, /* Never use this */
-};
-
-enum WIRELESS_MODE {
+enum wireless_mode {
WIRELESS_MODE_UNKNOWN = 0x00,
WIRELESS_MODE_A = 0x01,
WIRELESS_MODE_B = 0x02,
@@ -146,30 +93,6 @@ struct SwChnlCmd {
u32 msDelay;
};
-struct R_ANTENNA_SELECT_OFDM {
-#ifdef __LITTLE_ENDIAN
- u32 r_tx_antenna:4;
- u32 r_ant_l:4;
- u32 r_ant_non_ht:4;
- u32 r_ant_ht1:4;
- u32 r_ant_ht2:4;
- u32 r_ant_ht_s1:4;
- u32 r_ant_non_ht_s1:4;
- u32 OFDM_TXSC:2;
- u32 Reserved:2;
-#else
- u32 Reserved:2;
- u32 OFDM_TXSC:2;
- u32 r_ant_non_ht_s1:4;
- u32 r_ant_ht_s1:4;
- u32 r_ant_ht2:4;
- u32 r_ant_ht1:4;
- u32 r_ant_non_ht:4;
- u32 r_ant_l:4;
- u32 r_tx_antenna:4;
-#endif
-};
-
/*--------------------------Exported Function prototype---------------------*/
#endif /* __HAL_COMMON_H__ */
diff --git a/drivers/staging/rtl8723bs/include/hal_phy_cfg.h b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h
index ed3488a09d79..ea494bcf830b 100644
--- a/drivers/staging/rtl8723bs/include/hal_phy_cfg.h
+++ b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h
@@ -47,20 +47,20 @@ void PHY_SetTxPowerIndex(struct adapter *Adapter, u32 PowerIndex,
u8 RFPath, u8 Rate);
u8 PHY_GetTxPowerIndex(struct adapter *padapter, u8 RFPath, u8 Rate,
- enum CHANNEL_WIDTH BandWidth, u8 Channel);
+ enum channel_width BandWidth, u8 Channel);
void PHY_GetTxPowerLevel8723B(struct adapter *Adapter, s32 *powerlevel);
void PHY_SetTxPowerLevel8723B(struct adapter *Adapter, u8 channel);
-void PHY_SetBWMode8723B(struct adapter *Adapter, enum CHANNEL_WIDTH Bandwidth,
+void PHY_SetBWMode8723B(struct adapter *Adapter, enum channel_width Bandwidth,
unsigned char Offset);
/* Call after initialization */
void PHY_SwChnl8723B(struct adapter *Adapter, u8 channel);
void PHY_SetSwChnlBWMode8723B(struct adapter *Adapter, u8 channel,
- enum CHANNEL_WIDTH Bandwidth,
+ enum channel_width Bandwidth,
u8 Offset40, u8 Offset80);
/*--------------------------Exported Function prototype End---------------------*/
diff --git a/drivers/staging/rtl8723bs/include/hal_pwr_seq.h b/drivers/staging/rtl8723bs/include/hal_pwr_seq.h
index 28aca047dce6..0a2e60770668 100644
--- a/drivers/staging/rtl8723bs/include/hal_pwr_seq.h
+++ b/drivers/staging/rtl8723bs/include/hal_pwr_seq.h
@@ -14,7 +14,7 @@
4: LPS--Low Power State
5: SUS--Suspend
- The transision from different states are defined below
+ The transition from different states are defined below
TRANS_CARDEMU_TO_ACT
TRANS_ACT_TO_CARDEMU
TRANS_CARDEMU_TO_SUS
@@ -219,15 +219,15 @@
{0xFFFF, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, 0, PWR_CMD_END, 0, 0},
-extern WLAN_PWR_CFG rtl8723B_power_on_flow[RTL8723B_TRANS_CARDEMU_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_radio_off_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_card_disable_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_card_enable_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_suspend_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_resume_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_hwpdn_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_enter_lps_flow[RTL8723B_TRANS_ACT_TO_LPS_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_leave_lps_flow[RTL8723B_TRANS_LPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_enter_swlps_flow[RTL8723B_TRANS_ACT_TO_SWLPS_STEPS+RTL8723B_TRANS_END_STEPS];
-extern WLAN_PWR_CFG rtl8723B_leave_swlps_flow[RTL8723B_TRANS_SWLPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_power_on_flow[RTL8723B_TRANS_CARDEMU_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_radio_off_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_card_disable_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_card_enable_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_suspend_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_resume_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_hwpdn_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_enter_lps_flow[RTL8723B_TRANS_ACT_TO_LPS_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_leave_lps_flow[RTL8723B_TRANS_LPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_enter_swlps_flow[RTL8723B_TRANS_ACT_TO_SWLPS_STEPS+RTL8723B_TRANS_END_STEPS];
+extern struct wlan_pwr_cfg rtl8723B_leave_swlps_flow[RTL8723B_TRANS_SWLPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS];
#endif
diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h
index f80db2c984a4..6540c7a22938 100644
--- a/drivers/staging/rtl8723bs/include/ieee80211.h
+++ b/drivers/staging/rtl8723bs/include/ieee80211.h
@@ -125,7 +125,7 @@ extern u8 RSN_CIPHER_SUITE_CCMP[];
extern u8 RSN_CIPHER_SUITE_WEP104[];
-typedef enum _RATEID_IDX_ {
+enum {
RATEID_IDX_BGN_40M_2SS = 0,
RATEID_IDX_BGN_40M_1SS = 1,
RATEID_IDX_BGN_20M_2SS_BN = 2,
@@ -137,22 +137,9 @@ typedef enum _RATEID_IDX_ {
RATEID_IDX_B = 8,
RATEID_IDX_VHT_2SS = 9,
RATEID_IDX_VHT_1SS = 10,
-} RATEID_IDX, *PRATEID_IDX;
-
-typedef enum _RATR_TABLE_MODE {
- RATR_INX_WIRELESS_NGB = 0, /* BGN 40 Mhz 2SS 1SS */
- RATR_INX_WIRELESS_NG = 1, /* GN or N */
- RATR_INX_WIRELESS_NB = 2, /* BGN 20 Mhz 2SS 1SS or BN */
- RATR_INX_WIRELESS_N = 3,
- RATR_INX_WIRELESS_GB = 4,
- RATR_INX_WIRELESS_G = 5,
- RATR_INX_WIRELESS_B = 6,
- RATR_INX_WIRELESS_MC = 7,
- RATR_INX_WIRELESS_AC_N = 8,
-} RATR_TABLE_MODE, *PRATR_TABLE_MODE;
-
-
-enum NETWORK_TYPE {
+};
+
+enum network_type {
WIRELESS_INVALID = 0,
/* Sub-Element */
WIRELESS_11B = BIT(0), /* tx: cck only , rx: cck only, hw: cck */
@@ -266,14 +253,6 @@ struct sta_data {
/* this is stolen from ipw2200 driver */
#define IEEE_IBSS_MAC_HASH_SIZE 31
-struct ieee_ibss_seq {
- u8 mac[ETH_ALEN];
- u16 seq_num;
- u16 frag_num;
- unsigned long packet_time;
- struct list_head list;
-};
-
struct eapol {
u8 snap[6];
u16 ethertype;
@@ -282,14 +261,6 @@ struct eapol {
u16 length;
} __attribute__ ((packed));
-enum eap_type {
- EAP_PACKET = 0,
- EAPOL_START,
- EAPOL_LOGOFF,
- EAPOL_KEY,
- EAPOL_ENCAP_ASF_ALERT
-};
-
#define IEEE80211_FCS_LEN 4
#define MIN_FRAG_THRESHOLD 256U
@@ -423,7 +394,7 @@ struct ieee80211_snap_hdr {
#define IEEE80211_OFDM_SHIFT_MASK_A 4
-enum MGN_RATE {
+enum {
MGN_1M = 0x02,
MGN_2M = 0x04,
MGN_5_5M = 0x0B,
@@ -521,16 +492,6 @@ enum MGN_RATE {
/* NOTE: This data is for statistical purposes; not all hardware provides this
* information for frames received. Not setting these will not cause
* any adverse affects. */
-struct ieee80211_rx_stats {
- s8 rssi;
- u8 signal;
- u8 noise;
- u8 received_channel;
- u16 rate; /* in 100 kbps */
- u8 mask;
- u8 freq;
- u16 len;
-};
/* IEEE 802.11 requires that STA supports concurrent reception of at least
* three fragmented frames. This define can be increased to support more
@@ -538,61 +499,6 @@ struct ieee80211_rx_stats {
* 2 kB of RAM and increasing cache size will slow down frame reassembly. */
#define IEEE80211_FRAG_CACHE_LEN 4
-struct ieee80211_frag_entry {
- u32 first_frag_time;
- uint seq;
- uint last_frag;
- uint qos; /* jackson */
- uint tid; /* jackson */
- struct sk_buff *skb;
- u8 src_addr[ETH_ALEN];
- u8 dst_addr[ETH_ALEN];
-};
-
-struct ieee80211_stats {
- uint tx_unicast_frames;
- uint tx_multicast_frames;
- uint tx_fragments;
- uint tx_unicast_octets;
- uint tx_multicast_octets;
- uint tx_deferred_transmissions;
- uint tx_single_retry_frames;
- uint tx_multiple_retry_frames;
- uint tx_retry_limit_exceeded;
- uint tx_discards;
- uint rx_unicast_frames;
- uint rx_multicast_frames;
- uint rx_fragments;
- uint rx_unicast_octets;
- uint rx_multicast_octets;
- uint rx_fcs_errors;
- uint rx_discards_no_buffer;
- uint tx_discards_wrong_sa;
- uint rx_discards_undecryptable;
- uint rx_message_in_msg_fragments;
- uint rx_message_in_bad_msg_fragments;
-};
-
-struct ieee80211_softmac_stats {
- uint rx_ass_ok;
- uint rx_ass_err;
- uint rx_probe_rq;
- uint tx_probe_rs;
- uint tx_beacons;
- uint rx_auth_rq;
- uint rx_auth_rs_ok;
- uint rx_auth_rs_err;
- uint tx_auth_rq;
- uint no_auth_rs;
- uint no_ass_rs;
- uint tx_ass_rq;
- uint rx_ass_rq;
- uint tx_probe_rq;
- uint reassoc;
- uint swtxstop;
- uint swtxawake;
-};
-
#define SEC_KEY_1 (1<<0)
#define SEC_KEY_2 (1<<1)
#define SEC_KEY_3 (1<<2)
@@ -615,18 +521,6 @@ struct ieee80211_softmac_stats {
#define BIP_MAX_KEYID 5
#define BIP_AAD_SIZE 20
-struct ieee80211_security {
- u16 active_key:2,
- enabled:1,
- auth_mode:2,
- auth_algo:4,
- unicast_uses_group:1;
- u8 key_sizes[WEP_KEYS];
- u8 keys[WEP_KEYS][WEP_KEY_LEN];
- u8 level;
- u16 flags;
-} __attribute__ ((packed));
-
/*
802.11 data frame from AP
@@ -642,15 +536,6 @@ Total: 28-2340 bytes
*/
-struct ieee80211_header_data {
- u16 frame_ctl;
- u16 duration_id;
- u8 addr1[6];
- u8 addr2[6];
- u8 addr3[6];
- u16 seq_ctrl;
-};
-
#define BEACON_PROBE_SSID_ID_POSITION 12
/* Management Frame Information Element Types */
@@ -709,45 +594,6 @@ join_res:
> 0: TID
*/
-enum ieee80211_state {
-
- /* the card is not linked at all */
- IEEE80211_NOLINK = 0,
-
- /* IEEE80211_ASSOCIATING* are for BSS client mode
- * the driver shall not perform RX filtering unless
- * the state is LINKED.
- * The driver shall just check for the state LINKED and
- * defaults to NOLINK for ALL the other states (including
- * LINKED_SCANNING)
- */
-
- /* the association procedure will start (wq scheduling)*/
- IEEE80211_ASSOCIATING,
- IEEE80211_ASSOCIATING_RETRY,
-
- /* the association procedure is sending AUTH request*/
- IEEE80211_ASSOCIATING_AUTHENTICATING,
-
- /* the association procedure has successfully authentcated
- * and is sending association request
- */
- IEEE80211_ASSOCIATING_AUTHENTICATED,
-
- /* the link is ok. the card associated to a BSS or linked
- * to a ibss cell or acting as an AP and creating the bss
- */
- IEEE80211_LINKED,
-
- /* same as LINKED, but the driver shall apply RX filter
- * rules as we are in NO_LINK mode. As the card is still
- * logically linked, but it is doing a syncro site survey
- * then it will be back to LINKED state.
- */
- IEEE80211_LINKED_SCANNING,
-
-};
-
#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
#define DEFAULT_FTS 2346
#define MAC_ARG(x) (x)
@@ -781,7 +627,7 @@ static inline int is_zero_mac_addr(const u8 *addr)
#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
/* Action category code */
-enum rtw_ieee80211_category {
+enum {
RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0,
RTW_WLAN_CATEGORY_QOS = 1,
RTW_WLAN_CATEGORY_DLS = 2,
@@ -799,7 +645,7 @@ enum rtw_ieee80211_category {
RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */
};
-enum _PUBLIC_ACTION {
+enum {
ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */
ACT_PUBLIC_DSE_ENABLE = 1,
ACT_PUBLIC_DSE_DEENABLE = 2,
@@ -819,21 +665,6 @@ enum _PUBLIC_ACTION {
ACT_PUBLIC_MAX
};
-/* BACK (block-ack) parties */
-enum rtw_ieee80211_back_parties {
- RTW_WLAN_BACK_RECIPIENT = 0,
- RTW_WLAN_BACK_INITIATOR = 1,
- RTW_WLAN_BACK_TIMER = 2,
-};
-
-/* VHT features action code */
-enum rtw_ieee80211_vht_actioncode {
- RTW_WLAN_ACTION_VHT_COMPRESSED_BEAMFORMING = 0,
- RTW_WLAN_ACTION_VHT_GROUPID_MANAGEMENT = 1,
- RTW_WLAN_ACTION_VHT_OPMODE_NOTIFICATION = 2,
-};
-
-
#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
* 00:50:F2 */
#define WME_OUI_TYPE 2
@@ -983,22 +814,16 @@ struct rtw_ieee802_11_elems {
u8 vht_op_mode_notify_len;
};
-typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes;
+enum ParseRes { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 };
-ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
+enum ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
struct rtw_ieee802_11_elems *elems,
int show_errors);
u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen);
-u8 *rtw_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
-
-enum secondary_ch_offset {
- SCN = 0, /* no secondary channel */
- SCA = 1, /* secondary channel above */
- SCB = 3, /* secondary channel below */
-};
+u8 *rtw_set_ie(u8 *pbuf, signed int index, uint len, u8 *source, uint *frlen);
-u8 *rtw_get_ie(u8*pbuf, sint index, sint *len, sint limit);
+u8 *rtw_get_ie(u8 *pbuf, signed int index, signed int *len, signed int limit);
u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen);
int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len);
@@ -1026,7 +851,8 @@ u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8
* @buf_len:
*/
#define for_each_ie(ie, buf, buf_len) \
- for (ie = (void*)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; ie = (void*)(((u8 *)ie) + *(((u8 *)ie)+1) + 2))
+ for (ie = (void *)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; \
+ ie = (void *)(((u8 *)ie) + *(((u8 *)ie) + 1) + 2))
uint rtw_get_rateset_len(u8 *rateset);
@@ -1046,7 +872,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork);
void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr);
-u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char * MCS_rate);
+u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate);
int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action);
const char *action_public_str(u8 action);
diff --git a/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h b/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h
index 44d0a0982659..993a7b3c3d22 100644
--- a/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h
+++ b/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h
@@ -7,8 +7,6 @@
#ifndef __IOCTL_CFG80211_H__
#define __IOCTL_CFG80211_H__
-#include <linux/version.h>
-
struct rtw_wdev_invit_info {
u8 state; /* 0: req, 1:rep */
u8 peer_mac[ETH_ALEN];
@@ -67,7 +65,7 @@ struct rtw_wdev_priv {
struct adapter *padapter;
struct cfg80211_scan_request *scan_request;
- _lock scan_req_lock;
+ spinlock_t scan_req_lock;
struct net_device *pmon_ndev;/* for monitor interface */
char ifname_mon[IFNAMSIZ + 1]; /* interface name for monitor interface */
@@ -106,7 +104,7 @@ void rtw_cfg80211_indicate_scan_done(struct adapter *adapter, bool aborted);
void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, u8 *pmgmt_frame, uint frame_len);
void rtw_cfg80211_indicate_sta_disassoc(struct adapter *padapter, unsigned char *da, unsigned short reason);
-void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, uint frame_len, const char*msg);
+void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, uint frame_len, const char *msg);
bool rtw_cfg80211_pwr_mgmt(struct adapter *adapter);
diff --git a/drivers/staging/rtl8723bs/include/osdep_intf.h b/drivers/staging/rtl8723bs/include/osdep_intf.h
index c59c1384944b..48c90f00cc2e 100644
--- a/drivers/staging/rtl8723bs/include/osdep_intf.h
+++ b/drivers/staging/rtl8723bs/include/osdep_intf.h
@@ -32,15 +32,9 @@ Under Async. IRP (SDIO/USB)
The protection mechanism is through the pending queue.
*/
- _mutex ioctl_mutex;
+ struct mutex ioctl_mutex;
};
-
-#ifdef CONFIG_R871X_TEST
-int rtw_start_pseudo_adhoc(struct adapter *padapter);
-int rtw_stop_pseudo_adhoc(struct adapter *padapter);
-#endif
-
struct dvobj_priv *devobj_init(void);
void devobj_deinit(struct dvobj_priv *pdvobj);
@@ -70,9 +64,11 @@ int rtw_ips_pwr_up(struct adapter *padapter);
void rtw_ips_pwr_down(struct adapter *padapter);
int rtw_drv_register_netdev(struct adapter *padapter);
-void rtw_ndev_destructor(_nic_hdl ndev);
+void rtw_ndev_destructor(struct net_device *ndev);
int rtw_suspend_common(struct adapter *padapter);
int rtw_resume_common(struct adapter *padapter);
+int netdev_open(struct net_device *pnetdev);
+
#endif /* _OSDEP_INTF_H_ */
diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h
index dcc3cdce6d4b..b49838c7e457 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service.h
@@ -58,43 +58,13 @@
extern int RTW_STATUS_CODE(int error_code);
-/* flags used for rtw_mstat_update() */
-enum mstat_f {
- /* type: 0x00ff */
- MSTAT_TYPE_VIR = 0x00,
- MSTAT_TYPE_PHY = 0x01,
- MSTAT_TYPE_SKB = 0x02,
- MSTAT_TYPE_USB = 0x03,
- MSTAT_TYPE_MAX = 0x04,
-
- /* func: 0xff00 */
- MSTAT_FUNC_UNSPECIFIED = 0x00<<8,
- MSTAT_FUNC_IO = 0x01<<8,
- MSTAT_FUNC_TX_IO = 0x02<<8,
- MSTAT_FUNC_RX_IO = 0x03<<8,
- MSTAT_FUNC_TX = 0x04<<8,
- MSTAT_FUNC_RX = 0x05<<8,
- MSTAT_FUNC_MAX = 0x06<<8,
-};
-
-#define mstat_tf_idx(flags) ((flags)&0xff)
-#define mstat_ff_idx(flags) (((flags)&0xff00) >> 8)
-
-typedef enum mstat_status {
- MSTAT_ALLOC_SUCCESS = 0,
- MSTAT_ALLOC_FAIL,
- MSTAT_FREE
-} MSTAT_STATUS;
-
-#define rtw_mstat_update(flag, status, sz) do {} while (0)
-#define rtw_mstat_dump(sel) do {} while (0)
void *_rtw_zmalloc(u32 sz);
void *_rtw_malloc(u32 sz);
void _kfree(u8 *pbuf, u32 sz);
struct sk_buff *_rtw_skb_alloc(u32 sz);
struct sk_buff *_rtw_skb_copy(const struct sk_buff *skb);
-int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb);
+int _rtw_netif_rx(struct net_device *ndev, struct sk_buff *skb);
#define rtw_malloc(sz) _rtw_malloc((sz))
#define rtw_zmalloc(sz) _rtw_zmalloc((sz))
@@ -136,15 +106,8 @@ static inline int rtw_bug_check(void *parg1, void *parg2, void *parg3, void *par
#define MAC_ARG(x) (x)
#endif
-
-#ifdef CONFIG_AP_WOWLAN
-extern void rtw_softap_lock_suspend(void);
-extern void rtw_softap_unlock_suspend(void);
-#endif
-
extern void rtw_free_netdev(struct net_device * netdev);
-
/* Macros for handling unaligned memory accesses */
void rtw_buf_free(u8 **buf, u32 *buf_len);
diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
index 9194dea217fb..3492ec1efd1e 100644
--- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h
+++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h
@@ -40,30 +40,13 @@
#include <net/ieee80211_radiotap.h>
#include <net/cfg80211.h>
- typedef spinlock_t _lock;
- typedef struct mutex _mutex;
- typedef struct timer_list _timer;
-
struct __queue {
struct list_head queue;
- _lock lock;
+ spinlock_t lock;
};
- typedef struct sk_buff _pkt;
- typedef unsigned char _buffer;
-
- typedef int _OS_STATUS;
- /* typedef u32 _irqL; */
- typedef unsigned long _irqL;
- typedef struct net_device * _nic_hdl;
-
#define thread_exit() complete_and_exit(NULL, 0)
- typedef void timer_hdl_return;
- typedef void* timer_hdl_context;
-
- typedef struct work_struct _workitem;
-
static inline struct list_head *get_next(struct list_head *list)
{
return list->next;
@@ -74,22 +57,22 @@ static inline struct list_head *get_list_head(struct __queue *queue)
return (&(queue->queue));
}
-static inline void _set_timer(_timer *ptimer, u32 delay_time)
+static inline void _set_timer(struct timer_list *ptimer, u32 delay_time)
{
mod_timer(ptimer, (jiffies + (delay_time * HZ / 1000)));
}
-static inline void _init_workitem(_workitem *pwork, void *pfunc, void *cntx)
+static inline void _init_workitem(struct work_struct *pwork, void *pfunc, void *cntx)
{
INIT_WORK(pwork, pfunc);
}
-static inline void _set_workitem(_workitem *pwork)
+static inline void _set_workitem(struct work_struct *pwork)
{
schedule_work(pwork);
}
-static inline void _cancel_workitem_sync(_workitem *pwork)
+static inline void _cancel_workitem_sync(struct work_struct *pwork)
{
cancel_work_sync(pwork);
}
@@ -137,6 +120,6 @@ static inline struct adapter *rtw_netdev_priv(struct net_device *netdev)
}
struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_priv);
-extern struct net_device * rtw_alloc_etherdev(int sizeof_priv);
+extern struct net_device *rtw_alloc_etherdev(int sizeof_priv);
#endif
diff --git a/drivers/staging/rtl8723bs/include/recv_osdep.h b/drivers/staging/rtl8723bs/include/recv_osdep.h
index e85aafc93f6d..83330ea98fbf 100644
--- a/drivers/staging/rtl8723bs/include/recv_osdep.h
+++ b/drivers/staging/rtl8723bs/include/recv_osdep.h
@@ -8,13 +8,13 @@
#define __RECV_OSDEP_H_
-extern sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter);
+extern signed int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter);
extern void _rtw_free_recv_priv(struct recv_priv *precvpriv);
extern s32 rtw_recv_entry(union recv_frame *precv_frame);
extern int rtw_recv_indicatepkt(struct adapter *adapter, union recv_frame *precv_frame);
-extern void rtw_recv_returnpacket(_nic_hdl cnxt, _pkt *preturnedpkt);
+extern void rtw_recv_returnpacket(struct net_device *cnxt, struct sk_buff *preturnedpkt);
extern void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup);
@@ -31,8 +31,8 @@ void rtw_os_free_recvframe(union recv_frame *precvframe);
void rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *precvbuf);
-_pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 *pdata);
-void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt_attrib *pattrib);
+struct sk_buff *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 *pdata);
+void rtw_os_recv_indicate_pkt(struct adapter *padapter, struct sk_buff *pkt, struct rx_pkt_attrib *pattrib);
void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl);
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_cmd.h b/drivers/staging/rtl8723bs/include/rtl8723b_cmd.h
index 3bfb0e9be582..dbcf01bbf051 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_cmd.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_cmd.h
@@ -11,7 +11,7 @@
/* H2C CMD DEFINITION ------------------------------------------------ */
/* */
-enum h2c_cmd_8723B {
+enum {
/* Common Class: 000 */
H2C_8723B_RSVD_PAGE = 0x00,
H2C_8723B_MEDIA_STATUS_RPT = 0x01,
@@ -177,12 +177,6 @@ void rtl8723b_download_BTCoex_AP_mode_rsvd_page(struct adapter *padapter);
void CheckFwRsvdPageContent(struct adapter *padapter);
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-void rtl8723b_set_wowlan_cmd(struct adapter *padapter, u8 enable);
-void rtl8723b_set_ap_wowlan_cmd(struct adapter *padapter, u8 enable);
-void SetFwRelatedForWoWLAN8723b(struct adapter *padapter, u8 bHostIsGoingtoSleep);
-#endif/* CONFIG_WOWLAN */
-
void rtl8723b_set_FwPwrModeInIPS_cmd(struct adapter *padapter, u8 cmd_param);
s32 FillH2CCmd8723B(struct adapter *padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer);
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_hal.h b/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
index 8e6e972dd843..c1d7249e3e9d 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_hal.h
@@ -92,29 +92,11 @@ struct rt_firmware_hdr {
#define BCNQ_PAGE_NUM_8723B 0x08
#define BCNQ1_PAGE_NUM_8723B 0x00
-#ifdef CONFIG_PNO_SUPPORT
-#undef BCNQ1_PAGE_NUM_8723B
-#define BCNQ1_PAGE_NUM_8723B 0x00 /* 0x04 */
-#endif
-
#define MAX_RX_DMA_BUFFER_SIZE_8723B 0x2800 /* RX 10K */
/* For WoWLan, more reserved page */
/* ARP Rsp:1, RWC:1, GTK Info:1, GTK RSP:2, GTK EXT MEM:2, PNO: 6 */
-#ifdef CONFIG_WOWLAN
-#define WOWLAN_PAGE_NUM_8723B 0x07
-#else
#define WOWLAN_PAGE_NUM_8723B 0x00
-#endif
-
-#ifdef CONFIG_PNO_SUPPORT
-#undef WOWLAN_PAGE_NUM_8723B
-#define WOWLAN_PAGE_NUM_8723B 0x0d
-#endif
-
-#ifdef CONFIG_AP_WOWLAN
-#define AP_WOWLAN_PAGE_NUM_8723B 0x02
-#endif
#define TX_TOTAL_PAGE_NUMBER_8723B \
(0xFF - BCNQ_PAGE_NUM_8723B - \
@@ -170,7 +152,7 @@ struct rt_firmware_hdr {
/* Description: Determine the types of C2H events that are the same in driver
* and FW; First constructed by tynli. 2009.10.09.
*/
-typedef enum _C2H_EVT {
+enum {
C2H_DBG = 0,
C2H_TSF = 1,
C2H_AP_RPT_RSP = 2,
@@ -184,21 +166,21 @@ typedef enum _C2H_EVT {
C2H_HW_INFO_EXCH = 10,
C2H_8723B_BT_MP_INFO = 11,
MAX_C2HEVENT
-} C2H_EVT;
+};
-typedef struct _C2H_EVT_HDR {
+struct c2h_evt_hdr_t {
u8 CmdID;
u8 CmdLen;
u8 CmdSeq;
-} __attribute__((__packed__)) C2H_EVT_HDR, *PC2H_EVT_HDR;
+} __attribute__((__packed__));
-typedef enum tag_Package_Definition {
+enum { /* tag_Package_Definition */
PACKAGE_DEFAULT,
PACKAGE_QFN68,
PACKAGE_TFBGA90,
PACKAGE_TFBGA80,
PACKAGE_TFBGA79
-} PACKAGE_TYPE_E;
+};
#define INCLUDE_MULTI_FUNC_BT(_Adapter) \
(GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT)
@@ -245,33 +227,19 @@ void C2HPacketHandler_8723B(struct adapter *padapter, u8 *pbuffer, u16 length);
void rtl8723b_set_hal_ops(struct hal_ops *pHalFunc);
void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val);
void GetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val);
-u8 SetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable,
+u8 SetHalDefVar8723B(struct adapter *padapter, enum hal_def_variable variable,
void *pval);
-u8 GetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable,
+u8 GetHalDefVar8723B(struct adapter *padapter, enum hal_def_variable variable,
void *pval);
/* register */
void rtl8723b_InitBeaconParameters(struct adapter *padapter);
void _InitBurstPktLen_8723BS(struct adapter *adapter);
void _8051Reset8723(struct adapter *padapter);
-#ifdef CONFIG_WOWLAN
-void Hal_DetectWoWMode(struct adapter *padapter);
-#endif /* CONFIG_WOWLAN */
void rtl8723b_start_thread(struct adapter *padapter);
void rtl8723b_stop_thread(struct adapter *padapter);
-#if defined(CONFIG_CHECK_BT_HANG)
-void rtl8723bs_init_checkbthang_workqueue(struct adapter *adapter);
-void rtl8723bs_free_checkbthang_workqueue(struct adapter *adapter);
-void rtl8723bs_cancle_checkbthang_workqueue(struct adapter *adapter);
-void rtl8723bs_hal_check_bt_hang(struct adapter *adapter);
-#endif
-
-#ifdef CONFIG_GPIO_WAKEUP
-void HalSetOutPutGPIO(struct adapter *padapter, u8 index, u8 OutPutValue);
-#endif
-
int FirmwareDownloadBT(struct adapter *adapter, struct rt_firmware *firmware);
void CCX_FwC2HTxRpt_8723b(struct adapter *padapter, u8 *pdata, u8 len);
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_recv.h b/drivers/staging/rtl8723bs/include/rtl8723b_recv.h
index 60a1df703c8e..a108ce89bce4 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_recv.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_recv.h
@@ -81,50 +81,6 @@ struct rxreport_8723b {
u32 tsfl;
};
-struct phystatus_8723b {
- u32 rxgain_a:7;
- u32 trsw_a:1;
- u32 rxgain_b:7;
- u32 trsw_b:1;
- u32 chcorr_l:16;
-
- u32 sigqualcck:8;
- u32 cfo_a:8;
- u32 cfo_b:8;
- u32 chcorr_h:8;
-
- u32 noisepwrdb_h:8;
- u32 cfo_tail_a:8;
- u32 cfo_tail_b:8;
- u32 rsvd0824:8;
-
- u32 rsvd1200:8;
- u32 rxevm_a:8;
- u32 rxevm_b:8;
- u32 rxsnr_a:8;
-
- u32 rxsnr_b:8;
- u32 noisepwrdb_l:8;
- u32 rsvd1616:8;
- u32 postsnr_a:8;
-
- u32 postsnr_b:8;
- u32 csi_a:8;
- u32 csi_b:8;
- u32 targetcsi_a:8;
-
- u32 targetcsi_b:8;
- u32 sigevm:8;
- u32 maxexpwr:8;
- u32 exintflag:1;
- u32 sgien:1;
- u32 rxsc:2;
- u32 idlelong:1;
- u32 anttrainen:1;
- u32 antselb:1;
- u32 antsel:1;
-};
-
s32 rtl8723bs_init_recv_priv(struct adapter *padapter);
void rtl8723bs_free_recv_priv(struct adapter *padapter);
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_rf.h b/drivers/staging/rtl8723bs/include/rtl8723b_rf.h
index d712c6d36a08..525eb2facca0 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_rf.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_rf.h
@@ -12,6 +12,6 @@ int PHY_RF6052_Config8723B(struct adapter *Adapter);
void
PHY_RF6052SetBandwidth8723B(struct adapter *Adapter,
- enum CHANNEL_WIDTH Bandwidth);
+ enum channel_width Bandwidth);
#endif
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_spec.h b/drivers/staging/rtl8723bs/include/rtl8723b_spec.h
index 9149fe598545..999555476ebc 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_spec.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_spec.h
@@ -96,10 +96,6 @@
#define REG_TXPKTBUF_BCNQ_BDNY_8723B 0x0424
#define REG_TXPKTBUF_MGQ_BDNY_8723B 0x0425
#define REG_TXPKTBUF_WMAC_LBK_BF_HD_8723B 0x045D
-#ifdef CONFIG_WOWLAN
-#define REG_TXPKTBUF_IV_LOW 0x0484
-#define REG_TXPKTBUF_IV_HIGH 0x0488
-#endif
#define REG_AMPDU_BURST_MODE_8723B 0x04BC
/* */
@@ -164,12 +160,6 @@
#define BIT_USB_RXDMA_AGG_EN BIT(31)
#define RXDMA_AGG_MODE_EN BIT(1)
-#ifdef CONFIG_WOWLAN
-#define RXPKT_RELEASE_POLL BIT(16)
-#define RXDMA_IDLE BIT(17)
-#define RW_RELEASE_EN BIT(18)
-#endif
-
/* */
/* */
/* 0x0400h ~ 0x047Fh Protocol Configuration */
diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h b/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h
index 243d36d9bc7b..56bdc14af47d 100644
--- a/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h
+++ b/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h
@@ -59,7 +59,7 @@
/* */
/* defined for TX DESC Operation */
/* */
-typedef struct txdesc_8723b {
+struct txdesc_8723b {
/* Offset 0 */
u32 pktlen:16;
u32 offset:8;
@@ -175,7 +175,7 @@ typedef struct txdesc_8723b {
u32 txbf_path:1;
u32 seq:12;
u32 final_data_rate:8;
-} TXDESC_8723B, *PTXDESC_8723B;
+};
#ifndef __INC_HAL8723BDESC_H
#define __INC_HAL8723BDESC_H
@@ -443,7 +443,7 @@ s32 rtl8723bs_xmit_buf_handler(struct adapter *padapter);
int rtl8723bs_xmit_thread(void *context);
#define hal_xmit_handler rtl8723bs_xmit_buf_handler
-u8 BWMapping_8723B(struct adapter * Adapter, struct pkt_attrib *pattrib);
-u8 SCMapping_8723B(struct adapter * Adapter, struct pkt_attrib *pattrib);
+u8 BWMapping_8723B(struct adapter *Adapter, struct pkt_attrib *pattrib);
+u8 SCMapping_8723B(struct adapter *Adapter, struct pkt_attrib *pattrib);
#endif
diff --git a/drivers/staging/rtl8723bs/include/rtw_cmd.h b/drivers/staging/rtl8723bs/include/rtw_cmd.h
index 56c77bc7ca81..28d2d2732374 100644
--- a/drivers/staging/rtl8723bs/include/rtw_cmd.h
+++ b/drivers/staging/rtl8723bs/include/rtw_cmd.h
@@ -53,11 +53,11 @@
/* u8 cmdthd_running; */
u8 stop_req;
struct adapter *padapter;
- _mutex sctx_mutex;
+ struct mutex sctx_mutex;
};
struct evt_priv {
- _workitem c2h_wk;
+ struct work_struct c2h_wk;
bool c2h_wk_alive;
struct rtw_cbuf *c2h_queue;
#define C2H_QUEUE_MAX_LEN 10
@@ -107,21 +107,6 @@ struct c2h_evt_hdr_88xx {
#define c2h_evt_valid(c2h_evt) ((c2h_evt)->id || (c2h_evt)->plen)
-struct P2P_PS_Offload_t {
- u8 Offload_En:1;
- u8 role:1; /* 1: Owner, 0: Client */
- u8 CTWindow_En:1;
- u8 NoA0_En:1;
- u8 NoA1_En:1;
- u8 AllStaSleep:1; /* Only valid in Owner */
- u8 discovery:1;
- u8 rsvd:1;
-};
-
-struct P2P_PS_CTWPeriod_t {
- u8 CTWPeriod; /* TU */
-};
-
int rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
extern struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv);
extern void rtw_free_cmd_obj(struct cmd_obj *pcmd);
@@ -134,7 +119,7 @@ extern void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv);
extern void rtw_free_evt_priv(struct evt_priv *pevtpriv);
extern void rtw_evt_notify_isr(struct evt_priv *pevtpriv);
-enum rtw_drvextra_cmd_id {
+enum {
NONE_WK_CID,
DYNAMIC_CHK_WK_CID,
DM_CTRL_WK_CID,
@@ -151,14 +136,14 @@ enum rtw_drvextra_cmd_id {
RESET_SECURITYPRIV, /* add for CONFIG_IEEE80211W, none 11w also can use */
FREE_ASSOC_RESOURCES, /* add for CONFIG_IEEE80211W, none 11w also can use */
DM_IN_LPS_WK_CID,
- DM_RA_MSK_WK_CID, /* add for STA update RAMask when bandwith change. */
+ DM_RA_MSK_WK_CID, /* add for STA update RAMask when bandwidth change. */
BEAMFORMING_WK_CID,
LPS_CHANGE_DTIM_CID,
BTINFO_WK_CID,
MAX_WK_CID
};
-enum LPS_CTRL_TYPE {
+enum {
LPS_CTRL_SCAN = 0,
LPS_CTRL_JOINBSS = 1,
LPS_CTRL_CONNECT = 2,
@@ -168,25 +153,13 @@ enum LPS_CTRL_TYPE {
LPS_CTRL_TRAFFIC_BUSY = 6,
};
-enum RFINTFS {
+enum {
SWSI,
HWSI,
HWPI,
};
/*
-Caller Mode: Infra, Ad-HoC(C)
-
-Notes: To enter USB suspend mode
-
-Command Mode
-
-*/
-struct usb_suspend_parm {
- u32 action;/* 1: sleep, 0:resume */
-};
-
-/*
Caller Mode: Infra, Ad-HoC
Notes: To join a known BSS.
@@ -265,7 +238,7 @@ Command-Event Mode
#define RTW_SSID_SCAN_AMOUNT 9 /* for WEXT_CSCAN_AMOUNT 9 */
#define RTW_CHANNEL_SCAN_AMOUNT (14+37)
struct sitesurvey_parm {
- sint scan_mode; /* active: 1, passive: 0 */
+ signed int scan_mode; /* active: 1, passive: 0 */
u8 ssid_num;
u8 ch_num;
struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
@@ -399,10 +372,6 @@ struct getbasicrate_parm {
u32 rsvd;
};
-struct getbasicrate_rsp {
- u8 basicrates[NumRates];
-};
-
/*
Caller Mode: Any
@@ -428,10 +397,6 @@ struct getdatarate_parm {
u32 rsvd;
};
-struct getdatarate_rsp {
- u8 datarates[NumRates];
-};
-
/*
Caller Mode: Any
@@ -456,11 +421,6 @@ struct getphyinfo_parm {
u32 rsvd;
};
-struct getphyinfo_rsp {
- struct regulatory_class class_sets[NUM_REGULATORYS];
- u8 status;
-};
-
/*
Caller Mode: Any
@@ -487,46 +447,6 @@ struct getphy_parm {
u32 rsvd;
};
-struct getphy_rsp {
- u8 rfchannel;
- u8 modem;
-};
-
-struct readBB_parm {
- u8 offset;
-};
-struct readBB_rsp {
- u8 value;
-};
-
-struct readTSSI_parm {
- u8 offset;
-};
-struct readTSSI_rsp {
- u8 value;
-};
-
-struct writeBB_parm {
- u8 offset;
- u8 value;
-};
-
-struct readRF_parm {
- u8 offset;
-};
-struct readRF_rsp {
- u32 value;
-};
-
-struct writeRF_parm {
- u32 offset;
- u32 value;
-};
-
-struct getrfintfs_parm {
- u8 rfintfs;
-};
-
struct Tx_Beacon_param {
struct wlan_bssid_ex network;
@@ -594,163 +514,12 @@ struct drvextra_cmd_parm {
unsigned char *pbuf;
};
-/*------------------- Below are used for RF/BB tunning ---------------------*/
-
-struct setantenna_parm {
- u8 tx_antset;
- u8 rx_antset;
- u8 tx_antenna;
- u8 rx_antenna;
-};
-
-struct enrateadaptive_parm {
- u32 en;
-};
-
-struct settxagctbl_parm {
- u32 txagc[MAX_RATES_LENGTH];
-};
-
-struct gettxagctbl_parm {
- u32 rsvd;
-};
-struct gettxagctbl_rsp {
- u32 txagc[MAX_RATES_LENGTH];
-};
-
-struct setagcctrl_parm {
- u32 agcctrl; /* 0: pure hw, 1: fw */
-};
-
-
-struct setssup_parm {
- u32 ss_ForceUp[MAX_RATES_LENGTH];
-};
+/*------------------- Below are used for RF/BB tuning ---------------------*/
-struct getssup_parm {
- u32 rsvd;
-};
-struct getssup_rsp {
- u8 ss_ForceUp[MAX_RATES_LENGTH];
-};
-
-
-struct setssdlevel_parm {
- u8 ss_DLevel[MAX_RATES_LENGTH];
-};
-
-struct getssdlevel_parm {
- u32 rsvd;
-};
-struct getssdlevel_rsp {
- u8 ss_DLevel[MAX_RATES_LENGTH];
-};
-
-struct setssulevel_parm {
- u8 ss_ULevel[MAX_RATES_LENGTH];
-};
-
-struct getssulevel_parm {
- u32 rsvd;
-};
-struct getssulevel_rsp {
- u8 ss_ULevel[MAX_RATES_LENGTH];
-};
-
-
-struct setcountjudge_parm {
- u8 count_judge[MAX_RATES_LENGTH];
-};
-
-struct getcountjudge_parm {
- u32 rsvd;
-};
struct getcountjudge_rsp {
u8 count_judge[MAX_RATES_LENGTH];
};
-
-struct setratable_parm {
- u8 ss_ForceUp[NumRates];
- u8 ss_ULevel[NumRates];
- u8 ss_DLevel[NumRates];
- u8 count_judge[NumRates];
-};
-
-struct getratable_parm {
- uint rsvd;
-};
-struct getratable_rsp {
- u8 ss_ForceUp[NumRates];
- u8 ss_ULevel[NumRates];
- u8 ss_DLevel[NumRates];
- u8 count_judge[NumRates];
-};
-
-
-/* to get TX, RX retry count */
-struct gettxretrycnt_parm {
- unsigned int rsvd;
-};
-struct gettxretrycnt_rsp {
- unsigned long tx_retrycnt;
-};
-
-struct getrxretrycnt_parm {
- unsigned int rsvd;
-};
-struct getrxretrycnt_rsp {
- unsigned long rx_retrycnt;
-};
-
-/* to get BCNOK, BCNERR count */
-struct getbcnokcnt_parm {
- unsigned int rsvd;
-};
-struct getbcnokcnt_rsp {
- unsigned long bcnokcnt;
-};
-
-struct getbcnerrcnt_parm {
- unsigned int rsvd;
-};
-struct getbcnerrcnt_rsp {
- unsigned long bcnerrcnt;
-};
-
-/* to get current TX power level */
-struct getcurtxpwrlevel_parm {
- unsigned int rsvd;
-};
-struct getcurtxpwrlevel_rsp {
- unsigned short tx_power;
-};
-
-struct setprobereqextraie_parm {
- unsigned char e_id;
- unsigned char ie_len;
- unsigned char ie[0];
-};
-
-struct setassocreqextraie_parm {
- unsigned char e_id;
- unsigned char ie_len;
- unsigned char ie[0];
-};
-
-struct setproberspextraie_parm {
- unsigned char e_id;
- unsigned char ie_len;
- unsigned char ie[0];
-};
-
-struct setassocrspextraie_parm {
- unsigned char e_id;
- unsigned char ie_len;
- unsigned char ie[0];
-};
-
-
struct addBaReq_parm {
unsigned int tid;
u8 addr[ETH_ALEN];
@@ -768,11 +537,6 @@ struct SetChannelPlan_param {
u8 channel_plan;
};
-/*H2C Handler index: 60 */
-struct LedBlink_param {
- void *pLed;
-};
-
/*H2C Handler index: 61 */
struct SetChannelSwitch_param {
u8 new_ch_no;
@@ -786,7 +550,7 @@ struct TDLSoption_param {
/*H2C Handler index: 64 */
struct RunInThread_param {
- void (*func)(void*);
+ void (*func)(void *);
void *context;
};
@@ -798,7 +562,7 @@ struct RunInThread_param {
Result:
0x00: success
-0x01: sucess, and check Response.
+0x01: success, and check Response.
0x02: cmd ignored due to duplicated sequcne number
0x03: cmd dropped due to invalid cmd code
0x04: reserved.
@@ -824,9 +588,9 @@ struct sta_info;
extern u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_key, bool enqueue);
extern u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueue);
-extern u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network* pnetwork);
+extern u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork);
u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue);
-extern u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype, bool enqueue);
+extern u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infrastructure networktype, bool enqueue);
extern u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset);
extern u8 rtw_setrfintfs_cmd(struct adapter *padapter, u8 mode);
@@ -872,7 +636,7 @@ struct _cmd_callback {
void (*callback)(struct adapter *padapter, struct cmd_obj *cmd);
};
-enum rtw_h2c_cmd {
+enum {
GEN_CMD_CODE(_Read_MACREG), /*0*/
GEN_CMD_CODE(_Write_MACREG),
GEN_CMD_CODE(_Read_BBREG),
@@ -940,13 +704,12 @@ enum rtw_h2c_cmd {
GEN_CMD_CODE(_Set_H2C_MSG), /*58*/
GEN_CMD_CODE(_SetChannelPlan), /*59*/
- GEN_CMD_CODE(_LedBlink), /*60*/
- GEN_CMD_CODE(_SetChannelSwitch), /*61*/
- GEN_CMD_CODE(_TDLS), /*62*/
- GEN_CMD_CODE(_ChkBMCSleepq), /*63*/
+ GEN_CMD_CODE(_SetChannelSwitch), /*60*/
+ GEN_CMD_CODE(_TDLS), /*61*/
+ GEN_CMD_CODE(_ChkBMCSleepq), /*62*/
- GEN_CMD_CODE(_RunInThreadCMD), /*64*/
+ GEN_CMD_CODE(_RunInThreadCMD), /*63*/
MAX_H2CCMD
};
diff --git a/drivers/staging/rtl8723bs/include/rtw_debug.h b/drivers/staging/rtl8723bs/include/rtw_debug.h
index c90adfb87261..23f4cb4711d4 100644
--- a/drivers/staging/rtl8723bs/include/rtw_debug.h
+++ b/drivers/staging/rtl8723bs/include/rtw_debug.h
@@ -131,14 +131,6 @@
#define _MODULE_DEFINE_ _module_efuse_
#endif
-#define RT_TRACE(_Comp, _Level, Fmt) do {} while (0)
-#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) do {} while (0)
-
-#define DBG_871X(x, ...) do {} while (0)
-#define MSG_8192C(x, ...) do {} while (0)
-#define DBG_8192C(x, ...) do {} while (0)
-#define DBG_871X_LEVEL(x, ...) do {} while (0)
-
#undef _dbgdump
#ifndef _RTL871X_DEBUG_C_
@@ -152,18 +144,6 @@
#if defined(_dbgdump)
-/* with driver-defined prefix */
-#undef DBG_871X_LEVEL
-#define DBG_871X_LEVEL(level, fmt, arg...) \
- do {\
- if (level <= GlobalDebugLevel) {\
- if (level <= _drv_err_ && level > _drv_always_) \
- _dbgdump(DRIVER_PREFIX"ERROR " fmt, ##arg);\
- else \
- _dbgdump(DRIVER_PREFIX fmt, ##arg);\
- } \
- } while (0)
-
/* without driver-defined prefix */
#undef _DBG_871X_LEVEL
#define _DBG_871X_LEVEL(level, fmt, arg...) \
@@ -187,80 +167,8 @@
seq_printf(sel, fmt, ##arg); \
} while (0)
-/* dump message to selected 'stream' with driver-defined prefix */
-#define DBG_871X_SEL_NL(sel, fmt, arg...) \
- do { \
- if (sel == RTW_DBGDUMP) \
- DBG_871X_LEVEL(_drv_always_, fmt, ##arg); \
- else \
- seq_printf(sel, fmt, ##arg); \
- } while (0)
-
#endif /* defined(_dbgdump) */
-#ifdef DEBUG
-#if defined(_dbgdump)
- #undef DBG_871X
- #define DBG_871X(...) do {\
- _dbgdump(DRIVER_PREFIX __VA_ARGS__);\
- } while (0)
-
- #undef MSG_8192C
- #define MSG_8192C(...) do {\
- _dbgdump(DRIVER_PREFIX __VA_ARGS__);\
- } while (0)
-
- #undef DBG_8192C
- #define DBG_8192C(...) do {\
- _dbgdump(DRIVER_PREFIX __VA_ARGS__);\
- } while (0)
-#endif /* defined(_dbgdump) */
-#endif /* DEBUG */
-
-#ifdef DEBUG_RTL871X
-
-#if defined(_dbgdump) && defined(_MODULE_DEFINE_)
-
- #undef RT_TRACE
- #define RT_TRACE(_Comp, _Level, Fmt)\
- do {\
- if ((_Comp & GlobalDebugComponents) && (_Level <= GlobalDebugLevel)) {\
- _dbgdump("%s [0x%08x,%d]", DRIVER_PREFIX, (unsigned int)_Comp, _Level);\
- _dbgdump Fmt;\
- } \
- } while (0)
-
-#endif /* defined(_dbgdump) && defined(_MODULE_DEFINE_) */
-
-
-#if defined(_dbgdump)
- #undef RT_PRINT_DATA
- #define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) \
- if (((_Comp) & GlobalDebugComponents) && (_Level <= GlobalDebugLevel)) \
- { \
- int __i; \
- u8 *ptr = (u8 *)_HexData; \
- _dbgdump("%s", DRIVER_PREFIX); \
- _dbgdump(_TitleString); \
- for (__i = 0; __i < (int)_HexDataLen; __i++) \
- { \
- _dbgdump("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" "); \
- if (((__i + 1) % 16) == 0) _dbgdump("\n"); \
- } \
- _dbgdump("\n"); \
- }
-#endif /* defined(_dbgdump) */
-#endif /* DEBUG_RTL871X */
-
-#ifdef CONFIG_DBG_COUNTER
-#define DBG_COUNTER(counter) counter++
-#else
-#define DBG_COUNTER(counter) do {} while (0)
-#endif
-
-void dump_drv_version(void *sel);
-void dump_log_level(void *sel);
-
void sd_f0_reg_dump(void *sel, struct adapter *adapter);
void mac_reg_dump(void *sel, struct adapter *adapter);
diff --git a/drivers/staging/rtl8723bs/include/rtw_eeprom.h b/drivers/staging/rtl8723bs/include/rtw_eeprom.h
index 78f34f6cebb4..9b84105af816 100644
--- a/drivers/staging/rtl8723bs/include/rtw_eeprom.h
+++ b/drivers/staging/rtl8723bs/include/rtw_eeprom.h
@@ -42,7 +42,7 @@
/* Besides, CustomerID of registry has precedence of that of EEPROM. */
/* defined below. 060703, by rcnjko. */
/* */
-typedef enum _RT_CUSTOMER_ID {
+enum {
RT_CID_DEFAULT = 0,
RT_CID_8187_ALPHA0 = 1,
RT_CID_8187_SERCOMM_PS = 2,
@@ -90,7 +90,7 @@ typedef enum _RT_CUSTOMER_ID {
RT_CID_819x_ALPHA_Dlink = 44,/* add by ylb 20121012 for customer led for alpha */
RT_CID_WNC_NEC = 45,/* add by page for NEC */
RT_CID_DNI_BUFFALO = 46,/* add by page for NEC */
-} RT_CUSTOMER_ID, *PRT_CUSTOMER_ID;
+};
struct eeprom_priv {
u8 bautoload_fail_flag;
diff --git a/drivers/staging/rtl8723bs/include/rtw_efuse.h b/drivers/staging/rtl8723bs/include/rtw_efuse.h
index 4abcbbc8f513..5938a6bfb573 100644
--- a/drivers/staging/rtl8723bs/include/rtw_efuse.h
+++ b/drivers/staging/rtl8723bs/include/rtw_efuse.h
@@ -25,7 +25,7 @@
#define EFUSE_WIFI 0
#define EFUSE_BT 1
-enum _EFUSE_DEF_TYPE {
+enum {
TYPE_EFUSE_MAX_SECTION = 0,
TYPE_EFUSE_REAL_CONTENT_LEN = 1,
TYPE_AVAILABLE_EFUSE_BYTES_BANK = 2,
@@ -57,15 +57,15 @@ enum _EFUSE_DEF_TYPE {
#define EFUSE_MAX_WORD_UNIT 4
/*------------------------------Define structure----------------------------*/
-typedef struct PG_PKT_STRUCT_A {
+struct pgpkt_struct {
u8 offset;
u8 word_en;
u8 data[8];
u8 word_cnts;
-} PGPKT_STRUCT, *PPGPKT_STRUCT;
+};
/*------------------------------Define structure----------------------------*/
-typedef struct _EFUSE_HAL {
+struct efuse_hal {
u8 fakeEfuseBank;
u32 fakeEfuseUsedBytes;
u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE];
@@ -82,7 +82,7 @@ typedef struct _EFUSE_HAL {
u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN];
u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN];
-} EFUSE_HAL, *PEFUSE_HAL;
+};
/*------------------------Export global variable----------------------------*/
diff --git a/drivers/staging/rtl8723bs/include/rtw_event.h b/drivers/staging/rtl8723bs/include/rtw_event.h
index 560521c80ace..d48bae5416fe 100644
--- a/drivers/staging/rtl8723bs/include/rtw_event.h
+++ b/drivers/staging/rtl8723bs/include/rtw_event.h
@@ -60,10 +60,6 @@ struct stadel_event {
int mac_id;
};
-struct addba_event {
- unsigned int tid;
-};
-
struct wmm_event {
unsigned char wmm;
};
@@ -88,13 +84,6 @@ struct event_node {
int caller_ff_sz;
};
-struct c2hevent_queue {
- volatile int head;
- volatile int tail;
- struct event_node nodes[C2HEVENT_SZ];
- unsigned char seq;
-};
-
#define NETWORK_QUEUE_SZ 4
struct network_queue {
diff --git a/drivers/staging/rtl8723bs/include/rtw_ht.h b/drivers/staging/rtl8723bs/include/rtw_ht.h
index a72f51031f89..e3f353fe1e47 100644
--- a/drivers/staging/rtl8723bs/include/rtw_ht.h
+++ b/drivers/staging/rtl8723bs/include/rtw_ht.h
@@ -37,7 +37,7 @@ struct ht_priv {
};
-typedef enum AGGRE_SIZE {
+enum {
HT_AGG_SIZE_8K = 0,
HT_AGG_SIZE_16K = 1,
HT_AGG_SIZE_32K = 2,
@@ -46,9 +46,9 @@ typedef enum AGGRE_SIZE {
VHT_AGG_SIZE_256K = 5,
VHT_AGG_SIZE_512K = 6,
VHT_AGG_SIZE_1024K = 7,
-} AGGRE_SIZE_E, *PAGGRE_SIZE_E;
+};
-typedef enum _RT_HT_INF0_CAP {
+enum {
RT_HT_CAP_USE_TURBO_AGGR = 0x01,
RT_HT_CAP_USE_LONG_PREAMBLE = 0x02,
RT_HT_CAP_USE_AMPDU = 0x04,
@@ -57,13 +57,13 @@ typedef enum _RT_HT_INF0_CAP {
RT_HT_CAP_USE_92SE = 0x20,
RT_HT_CAP_USE_88C_92C = 0x40,
RT_HT_CAP_USE_AP_CLIENT_MODE = 0x80, /* AP team request to reserve this bit, by Emily */
-} RT_HT_INF0_CAPBILITY, *PRT_HT_INF0_CAPBILITY;
+};
-typedef enum _RT_HT_INF1_CAP {
+enum {
RT_HT_CAP_USE_VIDEO_CLIENT = 0x01,
RT_HT_CAP_USE_JAGUAR_BCUT = 0x02,
RT_HT_CAP_USE_JAGUAR_CCUT = 0x04,
-} RT_HT_INF1_CAPBILITY, *PRT_HT_INF1_CAPBILITY;
+};
#define LDPC_HT_ENABLE_RX BIT0
#define LDPC_HT_ENABLE_TX BIT1
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index b7076b590d84..fbb73e698e09 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -127,117 +127,6 @@ struct intf_hdl {
struct _io_ops io_ops;
};
-struct reg_protocol_rd {
-
-#ifdef __LITTLE_ENDIAN
-
- /* DW1 */
- u32 NumOfTrans:4;
- u32 Reserved1:4;
- u32 Reserved2:24;
- /* DW2 */
- u32 ByteCount:7;
- u32 WriteEnable:1; /* 0:read, 1:write */
- u32 FixOrContinuous:1; /* 0:continuous, 1: Fix */
- u32 BurstMode:1;
- u32 Byte1Access:1;
- u32 Byte2Access:1;
- u32 Byte4Access:1;
- u32 Reserved3:3;
- u32 Reserved4:16;
- /* DW3 */
- u32 BusAddress;
- /* DW4 */
- /* u32 Value; */
-#else
-
-
-/* DW1 */
- u32 Reserved1 :4;
- u32 NumOfTrans :4;
-
- u32 Reserved2 :24;
-
- /* DW2 */
- u32 WriteEnable : 1;
- u32 ByteCount :7;
-
-
- u32 Reserved3 : 3;
- u32 Byte4Access : 1;
-
- u32 Byte2Access : 1;
- u32 Byte1Access : 1;
- u32 BurstMode :1;
- u32 FixOrContinuous : 1;
-
- u32 Reserved4 : 16;
-
- /* DW3 */
- u32 BusAddress;
-
- /* DW4 */
- /* u32 Value; */
-
-#endif
-
-};
-
-
-struct reg_protocol_wt {
-
-
-#ifdef __LITTLE_ENDIAN
-
- /* DW1 */
- u32 NumOfTrans:4;
- u32 Reserved1:4;
- u32 Reserved2:24;
- /* DW2 */
- u32 ByteCount:7;
- u32 WriteEnable:1; /* 0:read, 1:write */
- u32 FixOrContinuous:1; /* 0:continuous, 1: Fix */
- u32 BurstMode:1;
- u32 Byte1Access:1;
- u32 Byte2Access:1;
- u32 Byte4Access:1;
- u32 Reserved3:3;
- u32 Reserved4:16;
- /* DW3 */
- u32 BusAddress;
- /* DW4 */
- u32 Value;
-
-#else
- /* DW1 */
- u32 Reserved1 :4;
- u32 NumOfTrans :4;
-
- u32 Reserved2 :24;
-
- /* DW2 */
- u32 WriteEnable : 1;
- u32 ByteCount :7;
-
- u32 Reserved3 : 3;
- u32 Byte4Access : 1;
-
- u32 Byte2Access : 1;
- u32 Byte1Access : 1;
- u32 BurstMode :1;
- u32 FixOrContinuous : 1;
-
- u32 Reserved4 : 16;
-
- /* DW3 */
- u32 BusAddress;
-
- /* DW4 */
- u32 Value;
-
-#endif
-
-};
#define SD_IO_TRY_CNT (8)
#define MAX_CONTINUAL_IO_ERR SD_IO_TRY_CNT
@@ -250,7 +139,7 @@ Below is the data structure used by _io_handler
*/
struct io_queue {
- _lock lock;
+ spinlock_t lock;
struct list_head free_ioreqs;
struct list_head pending; /* The io_req list that will be served in the single protocol read/write. */
struct list_head processing;
diff --git a/drivers/staging/rtl8723bs/include/rtw_ioctl_set.h b/drivers/staging/rtl8723bs/include/rtw_ioctl_set.h
index f0457e91d00f..31424bf2d926 100644
--- a/drivers/staging/rtl8723bs/include/rtw_ioctl_set.h
+++ b/drivers/staging/rtl8723bs/include/rtw_ioctl_set.h
@@ -10,24 +10,20 @@
typedef u8 NDIS_802_11_PMKID_VALUE[16];
-typedef struct _BSSIDInfo {
- NDIS_802_11_MAC_ADDRESS BSSID;
- NDIS_802_11_PMKID_VALUE PMKID;
-} BSSIDInfo, *PBSSIDInfo;
-
-
-u8 rtw_set_802_11_authentication_mode(struct adapter *pdapter, enum NDIS_802_11_AUTHENTICATION_MODE authmode);
+u8 rtw_set_802_11_authentication_mode(struct adapter *pdapter, enum ndis_802_11_authentication_mode authmode);
u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid);
-u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep * wep);
+u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep);
u8 rtw_set_802_11_disassociate(struct adapter *padapter);
u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_ssid *pssid, int ssid_max_num);
-u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
-u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid * ssid);
+u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, enum ndis_802_11_network_infrastructure networktype);
+u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid);
u8 rtw_set_802_11_connect(struct adapter *padapter, u8 *bssid, struct ndis_802_11_ssid *ssid);
u8 rtw_validate_bssid(u8 *bssid);
u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid);
+u8 rtw_do_join(struct adapter *padapter);
+
u16 rtw_get_cur_max_rate(struct adapter *adapter);
#endif
diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme.h b/drivers/staging/rtl8723bs/include/rtw_mlme.h
index d8655cb619a1..5deb73fe3885 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mlme.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mlme.h
@@ -57,11 +57,11 @@
/* ifdef UNDER_MPTEST */
#define WIFI_MP_STATE 0x00010000
-#define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in continous tx background */
-#define WIFI_MP_CTX_ST 0x00040000 /* in continous tx with single-tone */
-#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in continous tx background due to out of skb */
-#define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continous tx */
-#define WIFI_MP_CTX_CCK_CS 0x00200000 /* in continous tx with carrier suppression */
+#define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in continuous tx background */
+#define WIFI_MP_CTX_ST 0x00040000 /* in continuous tx with single-tone */
+#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in continuous tx background due to out of skb */
+#define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continuous tx */
+#define WIFI_MP_CTX_CCK_CS 0x00200000 /* in continuous tx with carrier suppression */
#define WIFI_MP_LPBK_STATE 0x00400000
/* endif */
@@ -71,7 +71,7 @@
#define _FW_UNDER_SURVEY WIFI_SITE_MONITOR
-enum dot11AuthAlgrthmNum {
+enum {
dot11AuthAlgrthm_Open = 0,
dot11AuthAlgrthm_Shared,
dot11AuthAlgrthm_8021X,
@@ -81,13 +81,13 @@ enum dot11AuthAlgrthmNum {
};
/* Scan type including active and passive scan. */
-typedef enum _RT_SCAN_TYPE {
+enum rt_scan_type {
SCAN_PASSIVE,
SCAN_ACTIVE,
SCAN_MIX,
-} RT_SCAN_TYPE, *PRT_SCAN_TYPE;
+};
-enum _BAND {
+enum {
GHZ24_50 = 0,
GHZ_50,
GHZ_24,
@@ -96,18 +96,6 @@ enum _BAND {
#define rtw_band_valid(band) ((band) >= GHZ24_50 && (band) < GHZ_MAX)
-enum DriverInterface {
- DRIVER_WEXT = 1,
- DRIVER_CFG80211 = 2
-};
-
-enum SCAN_RESULT_TYPE {
- SCAN_RESULT_P2P_ONLY = 0, /* Will return all the P2P devices. */
- SCAN_RESULT_ALL = 1, /* Will return all the scanned device, include AP. */
- SCAN_RESULT_WFD_TYPE = 2 /* Will just return the correct WFD device. */
- /* If this device is Miracast sink device, it will just return all the Miracast source devices. */
-};
-
/*
there are several "locks" in mlme_priv,
@@ -130,11 +118,11 @@ SHALL not lock up more than one locks at a time!
struct sitesurvey_ctrl {
u64 last_tx_pkts;
uint last_rx_pkts;
- sint traffic_busy;
- _timer sitesurvey_ctrl_timer;
+ signed int traffic_busy;
+ struct timer_list sitesurvey_ctrl_timer;
};
-typedef struct _RT_LINK_DETECT_T {
+struct rt_link_detect_t {
u32 NumTxOkInPeriod;
u32 NumRxOkInPeriod;
u32 NumRxUnicastOkInPeriod;
@@ -147,7 +135,7 @@ typedef struct _RT_LINK_DETECT_T {
/* u8 TrafficBusyState; */
u8 TrafficTransitionCount;
u32 LowPowerTransitionCount;
-} RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
+};
struct profile_info {
u8 ssidlen;
@@ -180,7 +168,7 @@ struct tx_provdisc_req_info {
u8 benable; /* This provision discovery request frame is trigger to send or not */
};
-struct rx_provdisc_req_info { /* When peer device issue prov_disc_req first, we should store the following informations */
+struct rx_provdisc_req_info { /* When peer device issue prov_disc_req first, we should store the following information */
u8 peerDevAddr[ETH_ALEN]; /* Peer device address */
u8 strconfig_method_desc_of_prov_disc_req[4]; /* description for the config method located in the provisioning discovery request frame. */
/* The UI must know this information to know which config method the remote p2p device is requiring. */
@@ -189,7 +177,7 @@ struct rx_provdisc_req_info { /* When peer device issue prov_disc_req first, we
struct tx_nego_req_info {
u16 peer_channel_num[2]; /* The channel number which the receiver stands. */
u8 peerDevAddr[ETH_ALEN]; /* Peer device address */
- u8 benable; /* This negoitation request frame is trigger to send or not */
+ u8 benable; /* This negotiation request frame is trigger to send or not */
};
struct group_id_info {
@@ -202,25 +190,15 @@ struct scan_limit_info {
u8 operation_ch[2]; /* Store the operation channel of invitation request frame */
};
-struct cfg80211_wifidirect_info {
- _timer remain_on_ch_timer;
- u8 restore_channel;
- struct ieee80211_channel remain_on_ch_channel;
- enum nl80211_channel_type remain_on_ch_type;
- u64 remain_on_ch_cookie;
- bool is_ro_ch;
- unsigned long last_ro_ch_time; /* this will be updated at the beginning and end of ro_ch */
-};
-
struct wifidirect_info {
struct adapter *padapter;
- _timer find_phase_timer;
- _timer restore_p2p_state_timer;
+ struct timer_list find_phase_timer;
+ struct timer_list restore_p2p_state_timer;
/* Used to do the scanning. After confirming the peer is availalble, the driver transmits the P2P frame to peer. */
- _timer pre_tx_scan_timer;
- _timer reset_ch_sitesurvey;
- _timer reset_ch_sitesurvey2; /* Just for resetting the scan limit function by using p2p nego */
+ struct timer_list pre_tx_scan_timer;
+ struct timer_list reset_ch_sitesurvey;
+ struct timer_list reset_ch_sitesurvey2; /* Just for resetting the scan limit function by using p2p nego */
struct tx_provdisc_req_info tx_prov_disc_info;
struct rx_provdisc_req_info rx_prov_disc_info;
struct tx_invite_req_info invitereq_info;
@@ -230,9 +208,9 @@ struct wifidirect_info {
struct group_id_info groupid_info; /* Store the group id information when doing the group negotiation handshake. */
struct scan_limit_info rx_invitereq_info; /* Used for get the limit scan channel from the Invitation procedure */
struct scan_limit_info p2p_info; /* Used for get the limit scan channel from the P2P negotiation handshake */
- enum P2P_ROLE role;
- enum P2P_STATE pre_p2p_state;
- enum P2P_STATE p2p_state;
+ enum p2p_role role;
+ enum p2p_state pre_p2p_state;
+ enum p2p_state p2p_state;
u8 device_addr[ETH_ALEN]; /* The device address should be the mac address of this device. */
u8 interface_addr[ETH_ALEN];
u8 social_chan[4];
@@ -250,9 +228,9 @@ struct wifidirect_info {
u8 profileindex; /* Used to point to the index of profileinfo array */
u8 peer_operating_ch;
u8 find_phase_state_exchange_cnt;
- u16 device_password_id_for_nego; /* The device password ID for group negotation */
+ u16 device_password_id_for_nego; /* The device password ID for group negotiation */
u8 negotiation_dialog_token;
- u8 nego_ssid[WLAN_SSID_MAXLEN]; /* SSID information for group negotitation */
+ u8 nego_ssid[WLAN_SSID_MAXLEN]; /* SSID information for group negotiation */
u8 nego_ssidlen;
u8 p2p_group_ssid[WLAN_SSID_MAXLEN];
u8 p2p_group_ssid_len;
@@ -275,7 +253,7 @@ struct wifidirect_info {
/* In this case, the driver can issue the tdls setup request frame */
/* even the current security is weak security. */
- enum P2P_WPSINFO ui_got_wps_info; /* This field will store the WPS value (PIN value or PBC) that UI had got from the user. */
+ enum p2p_wpsinfo ui_got_wps_info; /* This field will store the WPS value (PIN value or PBC) that UI had got from the user. */
u16 supported_wps_cm; /* This field describes the WPS config method which this driver supported. */
/* The value should be the combination of config method defined in page104 of WPS v2.0 spec. */
u8 external_uuid; /* UUID flag */
@@ -292,34 +270,6 @@ struct tdls_ss_record { /* signal strength record */
u8 is_tdls_sta; /* true: direct link sta, false: else */
};
-struct tdls_info {
- u8 ap_prohibited;
- u8 link_established;
- u8 sta_cnt;
- u8 sta_maximum; /* 1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else; */
- struct tdls_ss_record ss_record;
- u8 ch_sensing;
- u8 cur_channel;
- u8 candidate_ch;
- u8 collect_pkt_num[MAX_CHANNEL_NUM];
- _lock cmd_lock;
- _lock hdl_lock;
- u8 watchdog_count;
- u8 dev_discovered; /* WFD_TDLS: for sigma test */
- u8 tdls_enable;
- u8 external_setup; /* true: setup is handled by wpa_supplicant */
-};
-
-struct tdls_txmgmt {
- u8 peer[ETH_ALEN];
- u8 action_code;
- u8 dialog_token;
- u16 status_code;
- u8 *buf;
- size_t len;
- u8 external_support;
-};
-
/* used for mlme_priv.roam_flags */
enum {
RTW_ROAM_ON_EXPIRED = BIT0,
@@ -329,8 +279,8 @@ enum {
struct mlme_priv {
- _lock lock;
- sint fw_state; /* shall we protect this variable? maybe not necessarily... */
+ spinlock_t lock;
+ signed int fw_state; /* shall we protect this variable? maybe not necessarily... */
u8 bScanInProcess;
u8 to_join; /* flag */
@@ -361,15 +311,15 @@ struct mlme_priv {
u32 auto_scan_int_ms;
- _timer assoc_timer;
+ struct timer_list assoc_timer;
uint assoc_by_bssid;
uint assoc_by_rssi;
- _timer scan_to_timer; /* driver itself handles scan_timeout status. */
+ struct timer_list scan_to_timer; /* driver itself handles scan_timeout status. */
unsigned long scan_start_time; /* used to evaluate the time spent in scanning */
- _timer set_scan_deny_timer;
+ struct timer_list set_scan_deny_timer;
atomic_t set_scan_deny; /* 0: allowed, 1: deny */
struct qos_priv qospriv;
@@ -385,12 +335,12 @@ struct mlme_priv {
struct ht_priv htpriv;
- RT_LINK_DETECT_T LinkDetectInfo;
- _timer dynamic_chk_timer; /* dynamic/periodic check timer */
+ struct rt_link_detect_t LinkDetectInfo;
+ struct timer_list dynamic_chk_timer; /* dynamic/periodic check timer */
u8 acm_mask; /* for wmm acm mask */
u8 ChannelPlan;
- RT_SCAN_TYPE scan_mode; /* active: 1, passive: 0 */
+ enum rt_scan_type scan_mode; /* active: 1, passive: 0 */
u8 *wps_probe_req_ie;
u32 wps_probe_req_ie_len;
@@ -448,7 +398,7 @@ struct mlme_priv {
u32 p2p_go_probe_resp_ie_len; /* for GO */
u32 p2p_assoc_req_ie_len;
- _lock bcn_update_lock;
+ spinlock_t bcn_update_lock;
u8 update_bcn;
u8 NumOfBcnInfoChkFail;
@@ -490,9 +440,9 @@ extern int rtw_init_mlme_priv(struct adapter *adapter);/* (struct mlme_priv *pm
extern void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
-extern sint rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
-extern sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, sint keyid, u8 set_tx, bool enqueue);
-extern sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv);
+extern signed int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
+extern signed int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, signed int keyid, u8 set_tx, bool enqueue);
+extern signed int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv);
static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
{ /* if sta_mode:pmlmepriv->cur_network.network.MacAddress => bssid */
@@ -500,7 +450,7 @@ static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
return pmlmepriv->cur_network.network.MacAddress;
}
-static inline sint check_fwstate(struct mlme_priv *pmlmepriv, sint state)
+static inline signed int check_fwstate(struct mlme_priv *pmlmepriv, signed int state)
{
if (pmlmepriv->fw_state & state)
return true;
@@ -508,7 +458,7 @@ static inline sint check_fwstate(struct mlme_priv *pmlmepriv, sint state)
return false;
}
-static inline sint get_fwstate(struct mlme_priv *pmlmepriv)
+static inline signed int get_fwstate(struct mlme_priv *pmlmepriv)
{
return pmlmepriv->fw_state;
}
@@ -520,7 +470,7 @@ static inline sint get_fwstate(struct mlme_priv *pmlmepriv)
* ### NOTE:#### (!!!!)
* MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
*/
-static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
+static inline void set_fwstate(struct mlme_priv *pmlmepriv, signed int state)
{
pmlmepriv->fw_state |= state;
/* FOR HW integration */
@@ -528,7 +478,7 @@ static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
pmlmepriv->bScanInProcess = true;
}
-static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
+static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, signed int state)
{
pmlmepriv->fw_state &= ~state;
/* FOR HW integration */
@@ -540,7 +490,7 @@ static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
* No Limit on the calling context,
* therefore set it to be the critical section...
*/
-static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
+static inline void clr_fwstate(struct mlme_priv *pmlmepriv, signed int state)
{
spin_lock_bh(&pmlmepriv->lock);
if (check_fwstate(pmlmepriv, state) == true)
@@ -548,7 +498,7 @@ static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
spin_unlock_bh(&pmlmepriv->lock);
}
-static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv, sint val)
+static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv, signed int val)
{
spin_lock_bh(&pmlmepriv->lock);
pmlmepriv->num_of_scanned = val;
@@ -600,9 +550,9 @@ extern void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_ne
extern struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr);
-extern sint rtw_if_up(struct adapter *padapter);
+extern signed int rtw_if_up(struct adapter *padapter);
-sint rtw_linked_check(struct adapter *padapter);
+signed int rtw_linked_check(struct adapter *padapter);
u8 *rtw_get_capability_from_ie(u8 *ie);
u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
index 1567831caf91..472818c5fd83 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
@@ -112,10 +112,10 @@ extern unsigned char WMM_PARA_OUI[];
/* Note: */
/* We just add new channel plan when the new channel plan is different from any of the following */
/* channel plan. */
-/* If you just wnat to customize the acitions(scan period or join actions) about one of the channel plan, */
-/* customize them in RT_CHANNEL_INFO in the RT_CHANNEL_LIST. */
+/* If you just want to customize the actions(scan period or join actions) about one of the channel plan, */
+/* customize them in rt_channel_info in the RT_CHANNEL_LIST. */
/* */
-typedef enum _RT_CHANNEL_DOMAIN {
+enum {
/* old channel plan mapping ===== */
RT_CHANNEL_DOMAIN_FCC = 0x00,
RT_CHANNEL_DOMAIN_IC = 0x01,
@@ -181,9 +181,9 @@ typedef enum _RT_CHANNEL_DOMAIN {
/* Add new channel plan above this line =============== */
RT_CHANNEL_DOMAIN_MAX,
RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F,
-} RT_CHANNEL_DOMAIN, *PRT_CHANNEL_DOMAIN;
+};
-typedef enum _RT_CHANNEL_DOMAIN_2G {
+enum {
RT_CHANNEL_DOMAIN_2G_WORLD = 0x00, /* Worldwird 13 */
RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01, /* Europe */
RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02, /* US */
@@ -193,9 +193,9 @@ typedef enum _RT_CHANNEL_DOMAIN_2G {
RT_CHANNEL_DOMAIN_2G_NULL = 0x06,
/* Add new channel plan above this line =============== */
RT_CHANNEL_DOMAIN_2G_MAX,
-} RT_CHANNEL_DOMAIN_2G, *PRT_CHANNEL_DOMAIN_2G;
+};
-typedef enum _RT_CHANNEL_DOMAIN_5G {
+enum {
RT_CHANNEL_DOMAIN_5G_NULL = 0x00,
RT_CHANNEL_DOMAIN_5G_ETSI1 = 0x01, /* Europe */
RT_CHANNEL_DOMAIN_5G_ETSI2 = 0x02, /* Australia, New Zealand */
@@ -234,43 +234,31 @@ typedef enum _RT_CHANNEL_DOMAIN_5G {
RT_CHANNEL_DOMAIN_5G_JAPAN_NO_DFS = 0x21,
RT_CHANNEL_DOMAIN_5G_FCC4_NO_DFS = 0x22,
RT_CHANNEL_DOMAIN_5G_MAX,
-} RT_CHANNEL_DOMAIN_5G, *PRT_CHANNEL_DOMAIN_5G;
+};
#define rtw_is_channel_plan_valid(chplan) (chplan < RT_CHANNEL_DOMAIN_MAX || chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE)
-typedef struct _RT_CHANNEL_PLAN {
+struct rt_channel_plan {
unsigned char Channel[MAX_CHANNEL_NUM];
unsigned char Len;
-} RT_CHANNEL_PLAN, *PRT_CHANNEL_PLAN;
+};
-typedef struct _RT_CHANNEL_PLAN_2G {
+struct rt_channel_plan_2g {
unsigned char Channel[MAX_CHANNEL_NUM_2G];
unsigned char Len;
-} RT_CHANNEL_PLAN_2G, *PRT_CHANNEL_PLAN_2G;
+};
-typedef struct _RT_CHANNEL_PLAN_5G {
+struct rt_channel_plan_5g {
unsigned char Channel[MAX_CHANNEL_NUM_5G];
unsigned char Len;
-} RT_CHANNEL_PLAN_5G, *PRT_CHANNEL_PLAN_5G;
+};
-typedef struct _RT_CHANNEL_PLAN_MAP {
+struct rt_channel_plan_map {
unsigned char Index2G;
unsigned char Index5G;
-} RT_CHANNEL_PLAN_MAP, *PRT_CHANNEL_PLAN_MAP;
-
-enum Associated_AP {
- atherosAP = 0,
- broadcomAP = 1,
- ciscoAP = 2,
- marvellAP = 3,
- ralinkAP = 4,
- realtekAP = 5,
- airgocapAP = 6,
- unknownAP = 7,
- maxAP,
};
-typedef enum _HT_IOT_PEER {
+enum {
HT_IOT_PEER_UNKNOWN = 0,
HT_IOT_PEER_REALTEK = 1,
HT_IOT_PEER_REALTEK_92SE = 2,
@@ -290,10 +278,10 @@ typedef enum _HT_IOT_PEER {
HT_IOT_PEER_REALTEK_JAGUAR_BCUTAP = 16,
HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP = 17,
HT_IOT_PEER_MAX = 18
-} HT_IOT_PEER_E, *PHTIOT_PEER_E;
+};
-enum SCAN_STATE {
+enum {
SCAN_DISABLE = 0,
SCAN_START = 1,
SCAN_TXNULL = 2,
@@ -304,13 +292,13 @@ enum SCAN_STATE {
struct mlme_handler {
unsigned int num;
- char* str;
+ char *str;
unsigned int (*func)(struct adapter *padapter, union recv_frame *precv_frame);
};
struct action_handler {
unsigned int num;
- char* str;
+ char *str;
unsigned int (*func)(struct adapter *padapter, union recv_frame *precv_frame);
};
@@ -417,12 +405,12 @@ struct mlme_ext_info {
};
/* The channel information about this channel including joining, scanning, and power constraints. */
-typedef struct _RT_CHANNEL_INFO {
+struct rt_channel_info {
u8 ChannelNum; /* The channel number. */
- RT_SCAN_TYPE ScanType; /* Scan type such as passive or active scan. */
-} RT_CHANNEL_INFO, *PRT_CHANNEL_INFO;
+ enum rt_scan_type ScanType; /* Scan type such as passive or active scan. */
+};
-int rtw_ch_set_search_ch(RT_CHANNEL_INFO *ch_set, const u32 ch);
+int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch);
bool rtw_mlme_band_check(struct adapter *adapter, const u32 ch);
/* P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */
@@ -474,7 +462,7 @@ struct mlme_ext_priv {
unsigned char cur_wireless_mode; /* NETWORK_TYPE */
unsigned char max_chan_nums;
- RT_CHANNEL_INFO channel_set[MAX_CHANNEL_NUM];
+ struct rt_channel_info channel_set[MAX_CHANNEL_NUM];
struct p2p_channels channel_list;
unsigned char basicrate[NumRates];
unsigned char datarate[NumRates];
@@ -483,10 +471,10 @@ struct mlme_ext_priv {
struct ss_res sitesurvey_res;
struct mlme_ext_info mlmext_info;/* for sta/adhoc mode, including current scanning/connecting/connected related info. */
/* for ap mode, network includes ap's cap_info */
- _timer survey_timer;
- _timer link_timer;
- _timer sa_query_timer;
- /* _timer ADDBA_timer; */
+ struct timer_list survey_timer;
+ struct timer_list link_timer;
+ struct timer_list sa_query_timer;
+ /* struct timer_list ADDBA_timer; */
u16 chan_scan_time;
unsigned long last_scan_time;
u8 scan_abort;
@@ -589,21 +577,21 @@ int is_IBSS_empty(struct adapter *padapter);
unsigned char check_assoc_AP(u8 *pframe, uint len);
-int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE);
+int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
void WMMOnAssocRsp(struct adapter *padapter);
-void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE);
-void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE);
+void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
+void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
void HTOnAssocRsp(struct adapter *padapter);
-void ERP_IE_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE);
+void ERP_IE_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
void VCS_update(struct adapter *padapter, struct sta_info *psta);
void update_ldpc_stbc_cap(struct sta_info *psta);
void update_beacon_info(struct adapter *padapter, u8 *pframe, uint len, struct sta_info *psta);
int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len);
void update_IOT_info(struct adapter *padapter);
-void update_capinfo(struct adapter * Adapter, u16 updateCap);
+void update_capinfo(struct adapter *Adapter, u16 updateCap);
void update_wireless_mode(struct adapter *padapter);
void update_sta_basic_rate(struct sta_info *psta, u8 wireless_mode);
int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx);
@@ -630,8 +618,8 @@ extern u8 rtw_search_max_mac_id(struct adapter *padapter);
void report_join_res(struct adapter *padapter, int res);
void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame);
void report_surveydone_event(struct adapter *padapter);
-void report_del_sta_event(struct adapter *padapter, unsigned char* MacAddr, unsigned short reason);
-void report_add_sta_event(struct adapter *padapter, unsigned char* MacAddr, int cam_idx);
+void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason);
+void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx);
void report_wmm_edca_update(struct adapter *padapter);
u8 chk_bmc_sleepq_cmd(struct adapter *padapter);
@@ -702,18 +690,15 @@ void sa_query_timer_hdl(struct timer_list *t);
#define set_survey_timer(mlmeext, ms) \
do { \
- /*DBG_871X("%s set_survey_timer(%p, %d)\n", __func__, (mlmeext), (ms));*/ \
_set_timer(&(mlmeext)->survey_timer, (ms)); \
} while (0)
#define set_link_timer(mlmeext, ms) \
do { \
- /*DBG_871X("%s set_link_timer(%p, %d)\n", __func__, (mlmeext), (ms));*/ \
_set_timer(&(mlmeext)->link_timer, (ms)); \
} while (0)
#define set_sa_query_timer(mlmeext, ms) \
do { \
- DBG_871X("%s set_sa_query_timer(%p, %d)\n", __func__, (mlmeext), (ms)); \
_set_timer(&(mlmeext)->sa_query_timer, (ms)); \
} while (0)
@@ -760,7 +745,6 @@ u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf);
u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf);
u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf);
u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf);
-u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf);
u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf); /* Kurt: Handling DFS channel switch announcement ie. */
u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf);
u8 run_in_thread_hdl(struct adapter *padapter, u8 *pbuf);
@@ -787,7 +771,7 @@ struct C2HEvent_Header {
void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf);
void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf);
-enum rtw_c2h_event {
+enum {
GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/
GEN_EVT_CODE(_Read_BBREG),
GEN_EVT_CODE(_Read_RFREG),
diff --git a/drivers/staging/rtl8723bs/include/rtw_mp.h b/drivers/staging/rtl8723bs/include/rtw_mp.h
index ab7cd51ce681..2788ad80b114 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mp.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mp.h
@@ -15,7 +15,7 @@ struct mp_xmit_frame {
struct pkt_attrib attrib;
- _pkt *pkt;
+ struct sk_buff *pkt;
int frame_tag;
@@ -31,8 +31,6 @@ struct mp_wiparam {
u32 io_value;
};
-typedef void(*wi_act_func)(void *padapter);
-
struct mp_tx {
u8 stop;
u32 count, sended;
@@ -51,14 +49,14 @@ struct mp_tx {
#define MP_MAX_LINES_BYTES 256
typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter);
-typedef struct _MPT_CONTEXT {
+struct mpt_context {
/* Indicate if we have started Mass Production Test. */
bool bMassProdTest;
/* Indicate if the driver is unloading or unloaded. */
bool bMptDrvUnload;
- _timer MPh2c_timeout_timer;
+ struct timer_list MPh2c_timeout_timer;
/* Event used to sync H2c for BT control */
bool MptH2cRspEvent;
@@ -91,7 +89,7 @@ typedef struct _MPT_CONTEXT {
/* The RfPath of IO operation is depend of MptActType. */
u32 MptRfPath;
- enum WIRELESS_MODE MptWirelessModeToSw; /* Wireless mode to switch. */
+ enum wireless_mode MptWirelessModeToSw; /* Wireless mode to switch. */
u8 MptChannelToSw; /* Channel to switch. */
u8 MptInitGainToSet; /* Initial gain to set. */
u32 MptBandWidth; /* bandwidth to switch. */
@@ -103,7 +101,7 @@ typedef struct _MPT_CONTEXT {
/* For MP Tx Power index */
u8 TxPwrLevel[2]; /* rf-A, rf-B */
u32 RegTxPwrLimit;
- /* Content of RCR Regsiter for Mass Production Test. */
+ /* Content of RCR Register for Mass Production Test. */
u32 MptRCR;
/* true if we only receive packets with specific pattern. */
bool bMptFilterPattern;
@@ -150,7 +148,7 @@ typedef struct _MPT_CONTEXT {
u32 mptOutLen;
u8 mptOutBuf[100];
-} MPT_CONTEXT, *PMPT_CONTEXT;
+};
/* endif */
/* E-Fuse */
@@ -191,12 +189,6 @@ enum {
CTA_TEST,
MP_DISABLE_BT_COEXIST,
MP_PwrCtlDM,
-#ifdef CONFIG_WOWLAN
- MP_WOW_ENABLE,
-#endif
-#ifdef CONFIG_AP_WOWLAN
- MP_AP_WOW_ENABLE,
-#endif
MP_NULL,
MP_GET_TXPOWER_INX,
};
@@ -262,125 +254,23 @@ struct mp_priv {
bool bSetRxBssid;
bool bTxBufCkFail;
- MPT_CONTEXT MptCtx;
+ struct mpt_context MptCtx;
u8 *TXradomBuffer;
};
-typedef struct _IOCMD_STRUCT_ {
- u8 cmdclass;
- u16 value;
- u8 index;
-} IOCMD_STRUCT;
-
-struct rf_reg_param {
- u32 path;
- u32 offset;
- u32 value;
-};
-
-struct bb_reg_param {
- u32 offset;
- u32 value;
-};
-
#define LOWER true
#define RAISE false
/* Hardware Registers */
#define BB_REG_BASE_ADDR 0x800
-/* MP variables */
-enum MP_MODE {
- MP_OFF,
- MP_ON,
- MP_ERR,
- MP_CONTINUOUS_TX,
- MP_SINGLE_CARRIER_TX,
- MP_CARRIER_SUPPRISSION_TX,
- MP_SINGLE_TONE_TX,
- MP_PACKET_TX,
- MP_PACKET_RX
-};
-
#define MAX_RF_PATH_NUMS RF_PATH_MAX
extern u8 mpdatarate[NumRates];
-/* MP set force data rate base on the definition. */
-enum MPT_RATE_INDEX {
- /* CCK rate. */
- MPT_RATE_1M = 0, /* 0 */
- MPT_RATE_2M,
- MPT_RATE_55M,
- MPT_RATE_11M, /* 3 */
-
- /* OFDM rate. */
- MPT_RATE_6M, /* 4 */
- MPT_RATE_9M,
- MPT_RATE_12M,
- MPT_RATE_18M,
- MPT_RATE_24M,
- MPT_RATE_36M,
- MPT_RATE_48M,
- MPT_RATE_54M, /* 11 */
-
- /* HT rate. */
- MPT_RATE_MCS0, /* 12 */
- MPT_RATE_MCS1,
- MPT_RATE_MCS2,
- MPT_RATE_MCS3,
- MPT_RATE_MCS4,
- MPT_RATE_MCS5,
- MPT_RATE_MCS6,
- MPT_RATE_MCS7, /* 19 */
- MPT_RATE_MCS8,
- MPT_RATE_MCS9,
- MPT_RATE_MCS10,
- MPT_RATE_MCS11,
- MPT_RATE_MCS12,
- MPT_RATE_MCS13,
- MPT_RATE_MCS14,
- MPT_RATE_MCS15, /* 27 */
- /* VHT rate. Total: 20*/
- MPT_RATE_VHT1SS_MCS0 = 100,/* To reserve MCS16~MCS31, the index starts from #100. */
- MPT_RATE_VHT1SS_MCS1, /* #101 */
- MPT_RATE_VHT1SS_MCS2,
- MPT_RATE_VHT1SS_MCS3,
- MPT_RATE_VHT1SS_MCS4,
- MPT_RATE_VHT1SS_MCS5,
- MPT_RATE_VHT1SS_MCS6, /* #106 */
- MPT_RATE_VHT1SS_MCS7,
- MPT_RATE_VHT1SS_MCS8,
- MPT_RATE_VHT1SS_MCS9,
- MPT_RATE_VHT2SS_MCS0,
- MPT_RATE_VHT2SS_MCS1, /* #111 */
- MPT_RATE_VHT2SS_MCS2,
- MPT_RATE_VHT2SS_MCS3,
- MPT_RATE_VHT2SS_MCS4,
- MPT_RATE_VHT2SS_MCS5,
- MPT_RATE_VHT2SS_MCS6, /* #116 */
- MPT_RATE_VHT2SS_MCS7,
- MPT_RATE_VHT2SS_MCS8,
- MPT_RATE_VHT2SS_MCS9,
- MPT_RATE_LAST
-};
-
#define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */
-enum POWER_MODE {
- POWER_LOW = 0,
- POWER_NORMAL
-};
-
-/* The following enumeration is used to define the value of Reg0xD00[30:28] or JaguarReg0x914[18:16]. */
-enum OFDM_TX_MODE {
- OFDM_ALL_OFF = 0,
- OFDM_ContinuousTx = 1,
- OFDM_SingleCarrier = 2,
- OFDM_SingleTone = 4,
-};
-
#define RX_PKT_BROADCAST 1
#define RX_PKT_DEST_ADDR 2
#define RX_PKT_PHY_MATCH 3
@@ -396,19 +286,6 @@ enum OFDM_TX_MODE {
#define Mac_HT_FasleAlarm 0x90000000
#define Mac_DropPacket 0xA0000000
-enum ENCRY_CTRL_STATE {
- HW_CONTROL, /* hw encryption& decryption */
- SW_CONTROL, /* sw encryption& decryption */
- HW_ENCRY_SW_DECRY, /* hw encryption & sw decryption */
- SW_ENCRY_HW_DECRY /* sw encryption & hw decryption */
-};
-
-enum MPT_TXPWR_DEF {
- MPT_CCK,
- MPT_OFDM, /* L and HT OFDM */
- MPT_VHT_OFDM
-};
-
#define REG_RF_BB_GAIN_OFFSET 0x7f
#define RF_GAIN_OFFSET_MASK 0xfffff
diff --git a/drivers/staging/rtl8723bs/include/rtw_odm.h b/drivers/staging/rtl8723bs/include/rtw_odm.h
index 263e92cfea96..94fc68a5c424 100644
--- a/drivers/staging/rtl8723bs/include/rtw_odm.h
+++ b/drivers/staging/rtl8723bs/include/rtw_odm.h
@@ -13,7 +13,7 @@
* This file provides utilities/wrappers for rtw driver to use ODM
*/
-void rtw_odm_dbg_comp_msg(void *sel, struct adapter *adapter);
+void rtw_odm_dbg_comp_msg(struct adapter *adapter);
void rtw_odm_dbg_comp_set(struct adapter *adapter, u64 comps);
void rtw_odm_dbg_level_msg(void *sel, struct adapter *adapter);
void rtw_odm_dbg_level_set(struct adapter *adapter, u32 level);
diff --git a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
index 0987891e85ae..0767dbb84199 100644
--- a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
+++ b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h
@@ -31,7 +31,7 @@
#define BTCOEX_ALIVE BIT(4)
-enum Power_Mgnt {
+enum {
PS_MODE_ACTIVE = 0,
PS_MODE_MIN,
PS_MODE_MAX,
@@ -46,11 +46,6 @@ enum Power_Mgnt {
PS_MODE_NUM,
};
-#ifdef CONFIG_PNO_SUPPORT
-#define MAX_PNO_LIST_COUNT 16
-#define MAX_SCAN_LIST_COUNT 14 /* 2.4G only */
-#endif
-
/*
BIT[2:0] = HW state
BIT[3] = Protocol PS state, 0: register active state , 1: register sleep state
@@ -94,7 +89,7 @@ struct reportpwrstate_parm {
unsigned short rsvd;
};
-#define LPS_DELAY_TIME 1*HZ /* 1 sec */
+#define LPS_DELAY_TIME (1 * HZ) /* 1 sec */
#define EXE_PWR_NONE 0x01
#define EXE_PWR_IPS 0x02
@@ -117,7 +112,7 @@ enum rt_rf_power_state {
#define RT_RF_OFF_LEVL_FREE_FW BIT(4) /* FW free, re-download the FW */
#define RT_RF_OFF_LEVL_FW_32K BIT(5) /* FW in 32k */
#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT(6) /* Always enable ASPM and Clock Req in initialization. */
-#define RT_RF_LPS_DISALBE_2R BIT(30) /* When LPS is on, disable 2R if no packet is received or transmittd. */
+#define RT_RF_LPS_DISALBE_2R BIT(30) /* When LPS is on, disable 2R if no packet is received or transmitted. */
#define RT_RF_LPS_LEVEL_ASPM BIT(31) /* LPS with ASPM */
#define RT_IN_PS_LEVEL(ppsc, _PS_FLAG) ((ppsc->cur_ps_level & _PS_FLAG) ? true : false)
@@ -129,8 +124,7 @@ enum rt_rf_power_state {
#define RT_PCI_ASPM_OSC_ENABLE BIT0 /* PCI ASPM controlled by OS according to ACPI Spec 5.0 */
#define RT_PCI_ASPM_OSC_DISABLE BIT1 /* PCI ASPM controlled by driver or BIOS, i.e., force enable ASPM */
-
-enum _PS_BBRegBackup_ {
+enum {
PSBBREG_RF0 = 0,
PSBBREG_RF1,
PSBBREG_RF2,
@@ -146,7 +140,7 @@ enum { /* for ips_mode */
};
/* Design for pwrctrl_priv.ips_deny, 32 bits for 32 reasons at most */
-enum PS_DENY_REASON {
+enum ps_deny_reason {
PS_DENY_DRV_INITIAL = 0,
PS_DENY_SCAN,
PS_DENY_JOIN,
@@ -158,47 +152,6 @@ enum PS_DENY_REASON {
PS_DENY_OTHERS = 31
};
-#ifdef CONFIG_PNO_SUPPORT
-struct pno_nlo_info {
- u32 fast_scan_period; /* Fast scan period */
- u32 ssid_num; /* number of entry */
- u32 slow_scan_period; /* slow scan period */
- u32 fast_scan_iterations; /* Fast scan iterations */
- u8 ssid_length[MAX_PNO_LIST_COUNT]; /* SSID Length Array */
- u8 ssid_cipher_info[MAX_PNO_LIST_COUNT]; /* Cipher information for security */
- u8 ssid_channel_info[MAX_PNO_LIST_COUNT]; /* channel information */
-};
-
-struct pno_ssid {
- u32 SSID_len;
- u8 SSID[32];
-};
-
-struct pno_ssid_list {
- struct pno_ssid node[MAX_PNO_LIST_COUNT];
-};
-
-struct pno_scan_channel_info {
- u8 channel;
- u8 tx_power;
- u8 timeout;
- u8 active; /* set 1 means active scan, or pasivite scan. */
-};
-
-struct pno_scan_info {
- u8 enableRFE; /* Enable RFE */
- u8 period_scan_time; /* exclusive with fast_scan_period and slow_scan_period */
- u8 periodScan; /* exclusive with fast_scan_period and slow_scan_period */
- u8 orig_80_offset; /* original channel 80 offset */
- u8 orig_40_offset; /* original channel 40 offset */
- u8 orig_bw; /* original bandwidth */
- u8 orig_ch; /* original channel */
- u8 channel_num; /* number of channel */
- u64 rfe_type; /* rfe_type && 0x00000000000000ff */
- struct pno_scan_channel_info ssid_channel_info[MAX_SCAN_LIST_COUNT];
-};
-#endif /* CONFIG_PNO_SUPPORT */
-
struct pwrctrl_priv {
struct mutex lock;
volatile u8 rpwm; /* requested power state for fw */
@@ -212,10 +165,10 @@ struct pwrctrl_priv {
u8 dtim;
u32 alives;
- _workitem cpwm_event;
+ struct work_struct cpwm_event;
u8 brpwmtimeout;
- _workitem rpwmtimeoutwi;
- _timer pwr_rpwm_timer;
+ struct work_struct rpwmtimeoutwi;
+ struct timer_list pwr_rpwm_timer;
u8 bpower_saving; /* for LPS/IPS */
u8 b_hw_radio_off;
@@ -238,7 +191,7 @@ struct pwrctrl_priv {
u8 pre_ips_type;/* 0: default flow, 1: carddisbale flow */
/* ps_deny: if 0, power save is free to go; otherwise deny all kinds of power save. */
- /* Use PS_DENY_REASON to decide reason. */
+ /* Use enum ps_deny_reason to decide reason. */
/* Don't access this variable directly without control function, */
/* and this variable should be protected by lock. */
u32 ps_deny;
@@ -250,7 +203,7 @@ struct pwrctrl_priv {
u8 LpsIdleCount;
u8 power_mgnt;
u8 org_power_mgnt;
- u8 bFwCurrentInPSMode;
+ bool fw_current_in_ps_mode;
unsigned long DelayLPSLastTimeStamp;
s32 pnp_current_pwr_state;
u8 pnp_bstop_trx;
@@ -266,23 +219,7 @@ struct pwrctrl_priv {
u8 wowlan_wake_reason;
u8 wowlan_ap_mode;
u8 wowlan_mode;
-#ifdef CONFIG_WOWLAN
- u8 wowlan_pattern;
- u8 wowlan_magic;
- u8 wowlan_unicast;
- u8 wowlan_pattern_idx;
- u8 wowlan_pno_enable;
-#ifdef CONFIG_PNO_SUPPORT
- u8 pno_in_resume;
- u8 pno_inited;
- struct pno_nlo_info *pnlo_info;
- struct pno_scan_info *pscan_info;
- struct pno_ssid_list *pno_ssid_list;
-#endif
- u32 wowlan_pattern_context[8][5];
- u64 wowlan_fw_iv;
-#endif /* CONFIG_WOWLAN */
- _timer pwr_state_check_timer;
+ struct timer_list pwr_state_check_timer;
struct adapter *adapter;
int pwr_state_check_interval;
u8 pwr_state_check_cnts;
@@ -300,17 +237,13 @@ struct pwrctrl_priv {
unsigned long PS_BBRegBackup[PSBBREG_TOTALCNT];
};
-#define rtw_get_ips_mode_req(pwrctl) \
- (pwrctl)->ips_mode_req
-
#define rtw_ips_mode_req(pwrctl, ips_mode) \
- (pwrctl)->ips_mode_req = (ips_mode)
+ ((pwrctl)->ips_mode_req = (ips_mode))
#define RTW_PWR_STATE_CHK_INTERVAL 2000
#define _rtw_set_pwr_state_check_timer(pwrctl, ms) \
do { \
- /*DBG_871X("%s _rtw_set_pwr_state_check_timer(%p, %d)\n", __func__, (pwrctl), (ms));*/ \
_set_timer(&(pwrctl)->pwr_state_check_timer, (ms)); \
} while (0)
@@ -352,8 +285,8 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal
int rtw_pm_set_ips(struct adapter *padapter, u8 mode);
int rtw_pm_set_lps(struct adapter *padapter, u8 mode);
-void rtw_ps_deny(struct adapter *padapter, enum PS_DENY_REASON reason);
-void rtw_ps_deny_cancel(struct adapter *padapter, enum PS_DENY_REASON reason);
+void rtw_ps_deny(struct adapter *padapter, enum ps_deny_reason reason);
+void rtw_ps_deny_cancel(struct adapter *padapter, enum ps_deny_reason reason);
u32 rtw_ps_deny_get(struct adapter *padapter);
#endif /* __RTL871X_PWRCTRL_H_ */
diff --git a/drivers/staging/rtl8723bs/include/rtw_recv.h b/drivers/staging/rtl8723bs/include/rtw_recv.h
index b4aeb44d5d6e..9c3cdcc990fa 100644
--- a/drivers/staging/rtl8723bs/include/rtw_recv.h
+++ b/drivers/staging/rtl8723bs/include/rtw_recv.h
@@ -7,13 +7,9 @@
#ifndef _RTW_RECV_H_
#define _RTW_RECV_H_
- #ifdef CONFIG_SINGLE_RECV_BUF
- #define NR_RECVBUFF (1)
- #else
- #define NR_RECVBUFF (8)
- #endif /* CONFIG_SINGLE_RECV_BUF */
+#define NR_RECVBUFF (8)
- #define NR_PREALLOC_RECV_SKB (8)
+#define NR_PREALLOC_RECV_SKB (8)
#define NR_RECVFRAME 256
@@ -47,7 +43,7 @@ struct recv_reorder_ctrl {
u16 wend_b;
u8 wsize_b;
struct __queue pending_recvframe_queue;
- _timer reordering_ctrl_timer;
+ struct timer_list reordering_ctrl_timer;
};
struct stainfo_rxcache {
@@ -73,13 +69,6 @@ struct stainfo_rxcache {
};
-struct smooth_rssi_data {
- u32 elements[100]; /* array to store values */
- u32 index; /* index to current array to store */
- u32 total_num; /* num of valid elements */
- u32 total_val; /* sum of valid elements */
-};
-
struct signal_stat {
u8 update_req; /* used to indicate */
u8 avg_val; /* avg of valid elements */
@@ -143,7 +132,7 @@ struct rx_pkt_attrib {
u8 order;
u8 privacy; /* in frame_ctrl field */
u8 bdecrypted;
- u8 encrypt; /* when 0 indicate no encrypt. when non-zero, indicate the encrypt algorith */
+ u8 encrypt; /* when 0 indicates no encryption; when non-zero, indicates the encryption algorithm */
u8 iv_len;
u8 icv_len;
u8 crc_err;
@@ -159,11 +148,6 @@ struct rx_pkt_attrib {
u8 ack_policy;
-/* ifdef CONFIG_TCP_CSUM_OFFLOAD_RX */
- u8 tcpchk_valid; /* 0: invalid, 1: valid */
- u8 ip_chkrpt; /* 0: incorrect, 1: correct */
- u8 tcp_chkrpt; /* 0: incorrect, 1: correct */
-/* endif */
u8 key_index;
u8 data_rate;
@@ -214,7 +198,7 @@ accesser of recv_priv: rtw_recv_entry(dispatch / passive level); recv_thread(pas
using enter_critical section to protect
*/
struct recv_priv {
- _lock lock;
+ spinlock_t lock;
struct __queue free_recv_queue;
struct __queue recv_pending_queue;
struct __queue uc_swdec_pending_queue;
@@ -235,10 +219,6 @@ struct recv_priv {
struct tasklet_struct recv_tasklet;
struct sk_buff_head free_recv_skb_queue;
struct sk_buff_head rx_skb_queue;
-#ifdef CONFIG_RX_INDICATE_QUEUE
- struct task rx_indicate_tasklet;
- struct ifqueue rx_indicate_queue;
-#endif /* CONFIG_RX_INDICATE_QUEUE */
u8 *pallocated_recv_buf;
u8 *precv_buf; /* 4 alignment */
@@ -247,7 +227,7 @@ struct recv_priv {
struct __queue recv_buf_pending_queue;
- /* For display the phy informatiom */
+ /* For display the phy information */
u8 is_signal_dbg; /* for debug */
u8 signal_strength_dbg; /* for debug */
@@ -264,7 +244,7 @@ struct recv_priv {
/* int FalseAlmCnt_all; */
- _timer signal_stat_timer;
+ struct timer_list signal_stat_timer;
u32 signal_stat_sampling_interval;
/* u32 signal_stat_converging_constant; */
struct signal_stat signal_qual_data;
@@ -275,8 +255,8 @@ struct recv_priv {
struct sta_recv_priv {
- _lock lock;
- sint option;
+ spinlock_t lock;
+ signed int option;
/* struct __queue blk_strms[MAX_RX_NUMBLKS]; */
struct __queue defrag_q; /* keeping the fragment frame until defrag */
@@ -293,7 +273,7 @@ struct sta_recv_priv {
struct recv_buf {
struct list_head list;
- _lock recvbuf_lock;
+ spinlock_t recvbuf_lock;
u32 ref_cnt;
@@ -308,7 +288,7 @@ struct recv_buf {
u8 *ptail;
u8 *pend;
- _pkt *pskb;
+ struct sk_buff *pskb;
u8 reuse;
};
@@ -330,13 +310,8 @@ struct recv_buf {
*/
struct recv_frame_hdr {
struct list_head list;
-#ifndef CONFIG_BSD_RX_USE_MBUF
struct sk_buff *pkt;
struct sk_buff *pkt_newalloc;
-#else /* CONFIG_BSD_RX_USE_MBUF */
- _pkt *pkt;
- _pkt *pkt_newalloc;
-#endif /* CONFIG_BSD_RX_USE_MBUF */
struct adapter *adapter;
@@ -374,7 +349,7 @@ union recv_frame {
};
-enum RX_PACKET_TYPE {
+enum {
NORMAL_RX,/* Normal rx packet */
TX_REPORT1,/* CCX */
TX_REPORT2,/* TX RPT */
@@ -393,8 +368,8 @@ extern int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *q
extern void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue);
u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter);
-sint rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue);
-sint rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue);
+signed int rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue);
+signed int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue);
struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue);
void rtw_reordering_ctrl_timeout_handler(struct timer_list *t);
@@ -419,7 +394,7 @@ static inline u8 *get_recvframe_data(union recv_frame *precvframe)
}
-static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz)
+static inline u8 *recvframe_pull(union recv_frame *precvframe, signed int sz)
{
/* rx_data += sz; move rx_data sz bytes hereafter */
@@ -444,7 +419,7 @@ static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz)
}
-static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz)
+static inline u8 *recvframe_put(union recv_frame *precvframe, signed int sz)
{
/* rx_tai += sz; move rx_tail sz bytes hereafter */
@@ -473,7 +448,7 @@ static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz)
-static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz)
+static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, signed int sz)
{
/* rmv data from rx_tail (by yitsen) */
@@ -507,7 +482,7 @@ static inline union recv_frame *rxmem_to_recvframe(u8 *rxmem)
}
-static inline sint get_recvframe_len(union recv_frame *precvframe)
+static inline signed int get_recvframe_len(union recv_frame *precvframe)
{
return precvframe->u.hdr.len;
}
@@ -517,14 +492,9 @@ static inline s32 translate_percentage_to_dbm(u32 SignalStrengthIndex)
{
s32 SignalPower; /* in dBm. */
-#ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
- /* Translate to dBm (x =y-100) */
- SignalPower = SignalStrengthIndex - 100;
-#else
/* Translate to dBm (x = 0.5y-95). */
SignalPower = (s32)((SignalStrengthIndex + 1) >> 1);
SignalPower -= 95;
-#endif
return SignalPower;
}
diff --git a/drivers/staging/rtl8723bs/include/rtw_rf.h b/drivers/staging/rtl8723bs/include/rtw_rf.h
index d3a8e4b7069a..cb6beccd3d23 100644
--- a/drivers/staging/rtl8723bs/include/rtw_rf.h
+++ b/drivers/staging/rtl8723bs/include/rtw_rf.h
@@ -49,7 +49,7 @@ struct regulatory_class {
u8 modem;
};
-enum CAPABILITY {
+enum {
cESS = 0x0001,
cIBSS = 0x0002,
cPollable = 0x0004,
@@ -68,37 +68,19 @@ enum CAPABILITY {
cImmediateBA = 0x8000,
};
-enum _REG_PREAMBLE_MODE {
+enum {
PREAMBLE_LONG = 1,
PREAMBLE_AUTO = 2,
PREAMBLE_SHORT = 3,
};
-enum _RTL8712_RF_MIMO_CONFIG_ {
- RTL8712_RFCONFIG_1T = 0x10,
- RTL8712_RFCONFIG_2T = 0x20,
- RTL8712_RFCONFIG_1R = 0x01,
- RTL8712_RFCONFIG_2R = 0x02,
- RTL8712_RFCONFIG_1T1R = 0x11,
- RTL8712_RFCONFIG_1T2R = 0x12,
- RTL8712_RFCONFIG_TURBO = 0x92,
- RTL8712_RFCONFIG_2T2R = 0x22
-};
-
-enum RF90_RADIO_PATH {
- RF90_PATH_A = 0, /* Radio Path A */
- RF90_PATH_B = 1, /* Radio Path B */
- RF90_PATH_C = 2, /* Radio Path C */
- RF90_PATH_D = 3 /* Radio Path D */
-};
-
/* Bandwidth Offset */
#define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0
#define HAL_PRIME_CHNL_OFFSET_LOWER 1
#define HAL_PRIME_CHNL_OFFSET_UPPER 2
/* Represent Channel Width in HT Capabilities */
-enum CHANNEL_WIDTH {
+enum channel_width {
CHANNEL_WIDTH_20 = 0,
CHANNEL_WIDTH_40 = 1,
CHANNEL_WIDTH_80 = 2,
@@ -109,14 +91,14 @@ enum CHANNEL_WIDTH {
/* Represent Extension Channel Offset in HT Capabilities */
/* This is available only in 40Mhz mode. */
-enum EXTCHNL_OFFSET {
+enum extchnl_offset {
EXTCHNL_OFFSET_NO_EXT = 0,
EXTCHNL_OFFSET_UPPER = 1,
EXTCHNL_OFFSET_NO_DEF = 2,
EXTCHNL_OFFSET_LOWER = 3,
};
-enum VHT_DATA_SC {
+enum {
VHT_DATA_SC_DONOT_CARE = 0,
VHT_DATA_SC_20_UPPER_OF_80MHZ = 1,
VHT_DATA_SC_20_LOWER_OF_80MHZ = 2,
@@ -130,14 +112,8 @@ enum VHT_DATA_SC {
VHT_DATA_SC_40_LOWER_OF_80MHZ = 10,
};
-enum PROTECTION_MODE {
- PROTECTION_MODE_AUTO = 0,
- PROTECTION_MODE_FORCE_ENABLE = 1,
- PROTECTION_MODE_FORCE_DISABLE = 2,
-};
-
/* 2007/11/15 MH Define different RF type. */
-enum RT_RF_TYPE_DEFINITION {
+enum {
RF_1T2R = 0,
RF_2T4R = 1,
RF_2T2R = 2,
diff --git a/drivers/staging/rtl8723bs/include/rtw_security.h b/drivers/staging/rtl8723bs/include/rtw_security.h
index 85ffd4ec4ce5..5c787e999aab 100644
--- a/drivers/staging/rtl8723bs/include/rtw_security.h
+++ b/drivers/staging/rtl8723bs/include/rtw_security.h
@@ -84,14 +84,14 @@ union Keytype {
};
-typedef struct _RT_PMKID_LIST {
+struct rt_pmkid_list {
u8 bUsed;
u8 Bssid[6];
u8 PMKID[16];
u8 SsidBuf[33];
u8 *ssid_octet;
u16 ssid_length;
-} RT_PMKID_LIST, *PRT_PMKID_LIST;
+};
struct security_priv {
@@ -129,9 +129,6 @@ struct security_priv {
u8 binstallGrpkey;
-#ifdef CONFIG_GTK_OL
- u8 binstallKCK_KEK;
-#endif /* CONFIG_GTK_OL */
u8 binstallBIPkey;
u8 busetkipkey;
/* _timer tkip_timer; */
@@ -145,7 +142,7 @@ struct security_priv {
/* keeps the auth_type & enc_status from upper layer ioctl(wpa_supplicant or wzc) */
- u32 ndisauthtype; /* enum NDIS_802_11_AUTHENTICATION_MODE */
+ u32 ndisauthtype; /* enum ndis_802_11_authentication_mode */
u32 ndisencryptstatus; /* NDIS_802_11_ENCRYPTION_STATUS */
struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */
@@ -166,40 +163,11 @@ struct security_priv {
u32 btkip_countermeasure_time;
/* For WPA2 Pre-Authentication. */
- RT_PMKID_LIST PMKIDList[NUM_PMKID_CACHE]; /* Renamed from PreAuthKey[NUM_PRE_AUTH_KEY]. Annie, 2006-10-13. */
+ struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE]; /* Renamed from PreAuthKey[NUM_PRE_AUTH_KEY]. Annie, 2006-10-13. */
u8 PMKIDIndex;
u8 bWepDefaultKeyIdxSet;
-#define DBG_SW_SEC_CNT
-#ifdef DBG_SW_SEC_CNT
- u64 wep_sw_enc_cnt_bc;
- u64 wep_sw_enc_cnt_mc;
- u64 wep_sw_enc_cnt_uc;
- u64 wep_sw_dec_cnt_bc;
- u64 wep_sw_dec_cnt_mc;
- u64 wep_sw_dec_cnt_uc;
-
- u64 tkip_sw_enc_cnt_bc;
- u64 tkip_sw_enc_cnt_mc;
- u64 tkip_sw_enc_cnt_uc;
- u64 tkip_sw_dec_cnt_bc;
- u64 tkip_sw_dec_cnt_mc;
- u64 tkip_sw_dec_cnt_uc;
-
- u64 aes_sw_enc_cnt_bc;
- u64 aes_sw_enc_cnt_mc;
- u64 aes_sw_enc_cnt_uc;
- u64 aes_sw_dec_cnt_bc;
- u64 aes_sw_dec_cnt_mc;
- u64 aes_sw_dec_cnt_uc;
-#endif /* DBG_SW_SEC_CNT */
-};
-
-struct sha256_state {
- u64 length;
- u32 state[8], curlen;
- u8 buf[64];
};
#define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst)\
@@ -364,24 +332,6 @@ static inline u32 rotr(u32 val, int bits)
/* This is based on SHA256 implementation in LibTomCrypt that was released into
* public domain by Tom St Denis. */
-/* the K array */
-static const unsigned long K[64] = {
- 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
- 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
- 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL,
- 0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
- 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL,
- 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL,
- 0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL,
- 0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
- 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL,
- 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL,
- 0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL,
- 0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
- 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
-};
-
-
/* Various logical functions */
#define RORc(x, y) \
(((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
diff --git a/drivers/staging/rtl8723bs/include/rtw_wifi_regd.h b/drivers/staging/rtl8723bs/include/rtw_wifi_regd.h
index f798b0c744a4..e611651cb40b 100644
--- a/drivers/staging/rtl8723bs/include/rtw_wifi_regd.h
+++ b/drivers/staging/rtl8723bs/include/rtw_wifi_regd.h
@@ -8,18 +8,6 @@
#ifndef __RTW_WIFI_REGD_H__
#define __RTW_WIFI_REGD_H__
-struct country_code_to_enum_rd {
- u16 countrycode;
- const char *iso_name;
-};
-
-enum country_code_type_t {
- COUNTRY_CODE_USER = 0,
-
- /*add new channel plan above this line */
- COUNTRY_CODE_MAX
-};
-
void rtw_regd_init(struct wiphy *wiphy,
void (*reg_notifier)(struct wiphy *wiphy,
struct regulatory_request *request));
diff --git a/drivers/staging/rtl8723bs/include/rtw_xmit.h b/drivers/staging/rtl8723bs/include/rtw_xmit.h
index c04318573f8f..e45753d17313 100644
--- a/drivers/staging/rtl8723bs/include/rtw_xmit.h
+++ b/drivers/staging/rtl8723bs/include/rtw_xmit.h
@@ -83,13 +83,6 @@ do {\
#define TXDESC_OFFSET TXDESC_SIZE
-enum TXDESC_SC {
- SC_DONT_CARE = 0x00,
- SC_UPPER = 0x01,
- SC_LOWER = 0x02,
- SC_DUPLICATE = 0x03
-};
-
#define TXDESC_40_BYTES
struct tx_desc {
@@ -128,11 +121,11 @@ union txdesc {
};
struct hw_xmit {
- /* _lock xmit_lock; */
+ /* spinlock_t xmit_lock; */
/* struct list_head pending; */
struct __queue *sta_queue;
/* struct hw_txqueue *phwtxqueue; */
- /* sint txcmdcnt; */
+ /* signed int txcmdcnt; */
int accnt;
};
@@ -149,7 +142,7 @@ struct pkt_attrib {
u32 pktlen; /* the original 802.3 pkt raw_data len (not include ether_hdr data) */
u32 last_txcmdsz;
u8 nr_frags;
- u8 encrypt; /* when 0 indicate no encrypt. when non-zero, indicate the encrypt algorith */
+ u8 encrypt; /* when 0 indicates no encryption; when non-zero, indicates the encryption algorithm */
u8 iv_len;
u8 icv_len;
u8 iv[18];
@@ -284,7 +277,7 @@ struct xmit_frame {
struct pkt_attrib attrib;
- _pkt *pkt;
+ struct sk_buff *pkt;
int frame_tag;
@@ -312,9 +305,9 @@ struct tx_servq {
struct sta_xmit_priv {
- _lock lock;
- sint option;
- sint apsd_setting; /* When bit mask is on, the associated edca queue supports APSD. */
+ spinlock_t lock;
+ signed int option;
+ signed int apsd_setting; /* When bit mask is on, the associated edca queue supports APSD. */
/* struct tx_servq blk_q[MAX_NUMBLKS]; */
@@ -336,19 +329,14 @@ struct sta_xmit_priv {
struct hw_txqueue {
- volatile sint head;
- volatile sint tail;
- volatile sint free_sz; /* in units of 64 bytes */
- volatile sint free_cmdsz;
- volatile sint txsz[8];
+ volatile signed int head;
+ volatile signed int tail;
+ volatile signed int free_sz; /* in units of 64 bytes */
+ volatile signed int free_cmdsz;
+ volatile signed int txsz[8];
uint ff_hwaddr;
uint cmd_hwaddr;
- sint ac_tag;
-};
-
-struct agg_pkt_info {
- u16 offset;
- u16 pkt_len;
+ signed int ac_tag;
};
enum cmdbuf_type {
@@ -359,7 +347,7 @@ enum cmdbuf_type {
struct xmit_priv {
- _lock lock;
+ spinlock_t lock;
struct completion xmit_comp;
struct completion terminate_xmitthread_comp;
@@ -412,13 +400,9 @@ struct xmit_priv {
u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength from large to small. it's value is 0->vo, 1->vi, 2->be, 3->bk. */
-#ifdef CONFIG_SDIO_TX_TASKLET
- struct tasklet_struct xmit_tasklet;
-#else
void *SdioXmitThread;
struct completion SdioXmitStart;
struct completion SdioXmitTerminate;
-#endif /* CONFIG_SDIO_TX_TASKLET */
struct __queue free_xmitbuf_queue;
struct __queue pending_xmitbuf_queue;
@@ -436,10 +420,10 @@ struct xmit_priv {
u16 nqos_ssn;
int ack_tx;
- _mutex ack_tx_mutex;
+ struct mutex ack_tx_mutex;
struct submit_ctx ack_tx_ops;
u8 seq_no;
- _lock lock_sctx;
+ spinlock_t lock_sctx;
};
extern struct xmit_frame *__rtw_alloc_cmdxmitframe(struct xmit_priv *pxmitpriv,
@@ -463,20 +447,20 @@ struct xmit_frame *rtw_alloc_xmitframe_ext(struct xmit_priv *pxmitpriv);
struct xmit_frame *rtw_alloc_xmitframe_once(struct xmit_priv *pxmitpriv);
extern s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe);
extern void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pframequeue);
-struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, sint up, u8 *ac);
+struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, signed int up, u8 *ac);
extern s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe);
extern s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe);
extern u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib);
#define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue(&f->attrib)
-extern s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe);
-extern s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe);
+extern s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe);
+extern s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe);
s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag);
void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv);
s32 rtw_txframes_pending(struct adapter *padapter);
-void rtw_init_hwxmits(struct hw_xmit *phwxmit, sint entry);
+void rtw_init_hwxmits(struct hw_xmit *phwxmit, signed int entry);
s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter);
@@ -487,10 +471,10 @@ s32 rtw_alloc_hwxmits(struct adapter *padapter);
void rtw_free_hwxmits(struct adapter *padapter);
-s32 rtw_xmit(struct adapter *padapter, _pkt **pkt);
+s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt);
bool xmitframe_hiq_filter(struct xmit_frame *xmitframe);
-sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe);
+signed int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe);
void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta);
void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta);
void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta);
@@ -503,7 +487,7 @@ void enqueue_pending_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmit
void enqueue_pending_xmitbuf_to_head(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf);
struct xmit_buf *dequeue_pending_xmitbuf(struct xmit_priv *pxmitpriv);
struct xmit_buf *dequeue_pending_xmitbuf_under_survey(struct xmit_priv *pxmitpriv);
-sint check_pending_xmitbuf(struct xmit_priv *pxmitpriv);
+signed int check_pending_xmitbuf(struct xmit_priv *pxmitpriv);
int rtw_xmit_thread(void *context);
u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe);
diff --git a/drivers/staging/rtl8723bs/include/sdio_ops.h b/drivers/staging/rtl8723bs/include/sdio_ops.h
index 6b0446be6d19..c7559a884608 100644
--- a/drivers/staging/rtl8723bs/include/sdio_ops.h
+++ b/drivers/staging/rtl8723bs/include/sdio_ops.h
@@ -25,17 +25,10 @@ s32 _sdio_write32(struct adapter *padapter, u32 addr, u32 val);
extern void sd_int_hdl(struct adapter *padapter);
extern u8 CheckIPSStatus(struct adapter *padapter);
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-extern u8 RecvOnePkt(struct adapter *padapter, u32 size);
-#endif /* CONFIG_WOWLAN */
extern void InitInterrupt8723BSdio(struct adapter *padapter);
extern void InitSysInterrupt8723BSdio(struct adapter *padapter);
extern void EnableInterrupt8723BSdio(struct adapter *padapter);
extern void DisableInterrupt8723BSdio(struct adapter *padapter);
extern u8 HalQueryTxBufferStatus8723BSdio(struct adapter *padapter);
extern void HalQueryTxOQTBufferStatus8723BSdio(struct adapter *padapter);
-#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
-extern void ClearInterrupt8723BSdio(struct adapter *padapter);
-#endif /* CONFIG_WOWLAN */
-
#endif /* !__SDIO_OPS_H__ */
diff --git a/drivers/staging/rtl8723bs/include/sta_info.h b/drivers/staging/rtl8723bs/include/sta_info.h
index 734f4e2ecd66..69c377eeeaf0 100644
--- a/drivers/staging/rtl8723bs/include/sta_info.h
+++ b/drivers/staging/rtl8723bs/include/sta_info.h
@@ -31,13 +31,13 @@ struct wlan_acl_pool {
struct __queue acl_node_q;
};
-typedef struct _RSSI_STA {
+struct rssi_sta {
s32 UndecoratedSmoothedPWDB;
s32 UndecoratedSmoothedCCK;
s32 UndecoratedSmoothedOFDM;
u64 PacketMap;
u8 ValidBit;
-} RSSI_STA, *PRSSI_STA;
+};
struct stainfo_stats {
@@ -69,7 +69,7 @@ struct stainfo_stats {
struct sta_info {
- _lock lock;
+ spinlock_t lock;
struct list_head list; /* free_sta_queue */
struct list_head hash_list; /* sta_hash */
struct adapter *padapter;
@@ -92,11 +92,6 @@ struct sta_info {
union Keytype dot11tkiprxmickey;
union Keytype dot118021x_UncstKey;
union pn48 dot11txpn; /* PN48 used for Unicast xmit */
-#ifdef CONFIG_GTK_OL
- u8 kek[RTW_KEK_LEN];
- u8 kck[RTW_KCK_LEN];
- u8 replay_ctr[RTW_REPLAY_CTR_LEN];
-#endif /* CONFIG_GTK_OL */
union pn48 dot11wtxpn; /* PN48 used for Unicast mgmt xmit. */
union pn48 dot11rxpn; /* PN48 used for Unicast recv. */
@@ -121,7 +116,7 @@ struct sta_info {
struct stainfo_stats sta_stats;
/* for A-MPDU TX, ADDBA timeout check */
- _timer addba_retry_timer;
+ struct timer_list addba_retry_timer;
/* for A-MPDU Rx reordering buffer control */
struct recv_reorder_ctrl recvreorder_ctrl[16];
@@ -187,16 +182,11 @@ struct sta_info {
u8 keep_alive_trycnt;
-#ifdef CONFIG_AUTO_AP_MODE
- u8 isrc; /* this device is rc */
- u16 pid; /* pairing id */
-#endif
-
u8 *passoc_req;
u32 assoc_req_len;
/* for DM */
- RSSI_STA rssi_stat;
+ struct rssi_sta rssi_stat;
/* ODM_STA_INFO_T */
/* ================ODM Relative Info ======================= */
@@ -314,7 +304,7 @@ struct sta_priv {
u8 *pstainfo_buf;
struct __queue free_sta_queue;
- _lock sta_hash_lock;
+ spinlock_t sta_hash_lock;
struct list_head sta_hash[NUM_STA];
int asoc_sta_count;
struct __queue sleep_q;
@@ -324,8 +314,8 @@ struct sta_priv {
struct list_head asoc_list;
struct list_head auth_list;
- _lock asoc_list_lock;
- _lock auth_list_lock;
+ spinlock_t asoc_list_lock;
+ spinlock_t auth_list_lock;
u8 asoc_list_cnt;
u8 auth_list_cnt;
@@ -339,7 +329,7 @@ struct sta_priv {
*/
struct sta_info *sta_aid[NUM_STA];
- u16 sta_dz_bitmap;/* only support 15 stations, staion aid bitmap for sleeping sta. */
+ u16 sta_dz_bitmap;/* only support for 15 stations, aid bitmap for sleeping stations. */
u16 tim_bitmap;/* only support 15 stations, aid = 0~15 mapping bit0~bit15 */
u16 max_num_sta;
diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h
index fe984fcb66a9..036cf57c65a9 100644
--- a/drivers/staging/rtl8723bs/include/wifi.h
+++ b/drivers/staging/rtl8723bs/include/wifi.h
@@ -43,14 +43,14 @@
/* This test verifies the WLAN NIC can update the NAV through sending the CTS with large duration. */
#define WiFiNavUpperUs 30000 /* 30 ms */
-enum WIFI_FRAME_TYPE {
+enum {
WIFI_MGT_TYPE = (0),
WIFI_CTRL_TYPE = (BIT(2)),
WIFI_DATA_TYPE = (BIT(3)),
WIFI_QOS_DATA_TYPE = (BIT(7)|BIT(3)), /* QoS Data */
};
-enum WIFI_FRAME_SUBTYPE {
+enum {
/* below is for mgt frame */
WIFI_ASSOCREQ = (0 | WIFI_MGT_TYPE),
@@ -88,20 +88,6 @@ enum WIFI_FRAME_SUBTYPE {
WIFI_QOS_DATA_NULL = (BIT(6) | WIFI_QOS_DATA_TYPE),
};
-enum WIFI_REG_DOMAIN {
- DOMAIN_FCC = 1,
- DOMAIN_IC = 2,
- DOMAIN_ETSI = 3,
- DOMAIN_SPAIN = 4,
- DOMAIN_FRANCE = 5,
- DOMAIN_MKK = 6,
- DOMAIN_ISRAEL = 7,
- DOMAIN_MKK1 = 8,
- DOMAIN_MKK2 = 9,
- DOMAIN_MKK3 = 10,
- DOMAIN_MAX
-};
-
#define _TO_DS_ BIT(8)
#define _FROM_DS_ BIT(9)
#define _MORE_FRAG_ BIT(10)
@@ -112,65 +98,52 @@ enum WIFI_REG_DOMAIN {
#define _ORDER_ BIT(15)
#define SetToDs(pbuf) \
- *(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_)
+ (*(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_))
#define GetToDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0)
-#define ClearToDs(pbuf) \
- *(__le16 *)(pbuf) &= (~cpu_to_le16(_TO_DS_))
-
#define SetFrDs(pbuf) \
- *(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_)
+ (*(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_))
#define GetFrDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0)
-#define ClearFrDs(pbuf) \
- *(__le16 *)(pbuf) &= (~cpu_to_le16(_FROM_DS_))
-
#define get_tofr_ds(pframe) ((GetToDs(pframe) << 1) | GetFrDs(pframe))
#define SetMFrag(pbuf) \
- *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_)
+ (*(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_))
#define GetMFrag(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_FRAG_)) != 0)
#define ClearMFrag(pbuf) \
- *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_))
-
-#define SetRetry(pbuf) \
- *(__le16 *)(pbuf) |= cpu_to_le16(_RETRY_)
+ (*(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)))
#define GetRetry(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0)
#define ClearRetry(pbuf) \
- *(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_))
+ (*(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_)))
#define SetPwrMgt(pbuf) \
- *(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_)
+ (*(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_))
#define GetPwrMgt(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_PWRMGT_)) != 0)
#define ClearPwrMgt(pbuf) \
- *(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_))
+ (*(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)))
#define SetMData(pbuf) \
- *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_)
+ (*(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_))
#define GetMData(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_DATA_)) != 0)
#define ClearMData(pbuf) \
- *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_))
+ (*(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)))
#define SetPrivacy(pbuf) \
- *(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_)
+ (*(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_))
#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)
@@ -218,33 +191,26 @@ enum WIFI_REG_DOMAIN {
} while (0)
#define SetDuration(pbuf, dur) \
- *(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur))
+ (*(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur)))
#define SetPriority(pbuf, tid) \
- *(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf)
+ (*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf))
#define GetPriority(pbuf) ((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf)
#define SetEOSP(pbuf, eosp) \
- *(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4)
+ (*(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4))
#define SetAckpolicy(pbuf, ack) \
- *(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5)
+ (*(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5))
#define GetAckpolicy(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3)
#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))
@@ -436,21 +402,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe)
#define ACT_CAT_VENDOR 0x7F/* 127 */
/**
- * struct rtw_ieee80211_bar - HT Block Ack Request
- *
- * This structure refers to "HT BlockAckReq" as
- * described in 802.11n draft section 7.2.1.7.1
- */
-struct rtw_ieee80211_bar {
- __le16 frame_control;
- __le16 duration;
- unsigned char ra[6];
- unsigned char ta[6];
- __le16 control;
- __le16 start_seq_num;
-} __attribute__((packed));
-
-/**
* struct rtw_ieee80211_ht_cap - HT additional information
*
* This structure refers to "HT information element" as
@@ -719,7 +670,7 @@ struct ADDBA_request {
#define P2P_WILDCARD_SSID_LEN 7
-#define P2P_FINDPHASE_EX_NONE 0 /* default value, used when: (1)p2p disabed or (2)p2p enabled but only do 1 scan phase */
+#define P2P_FINDPHASE_EX_NONE 0 /* default value, used when: (1)p2p disabled or (2)p2p enabled but only do 1 scan phase */
#define P2P_FINDPHASE_EX_FULL 1 /* used when p2p enabled and want to do 1 scan phase and P2P_FINDPHASE_EX_MAX-1 find phase */
#define P2P_FINDPHASE_EX_SOCIAL_FIRST (P2P_FINDPHASE_EX_FULL+1)
#define P2P_FINDPHASE_EX_MAX 4
@@ -727,7 +678,7 @@ struct ADDBA_request {
#define P2P_PROVISION_TIMEOUT 5000 /* 5 seconds timeout for sending the provision discovery request */
#define P2P_CONCURRENT_PROVISION_TIMEOUT 3000 /* 3 seconds timeout for sending the provision discovery request under concurrent mode */
-#define P2P_GO_NEGO_TIMEOUT 5000 /* 5 seconds timeout for receiving the group negotation response */
+#define P2P_GO_NEGO_TIMEOUT 5000 /* 5 seconds timeout for receiving the group negotiation response */
#define P2P_CONCURRENT_GO_NEGO_TIMEOUT 3000 /* 3 seconds timeout for sending the negotiation request under concurrent mode */
#define P2P_TX_PRESCAN_TIMEOUT 100 /* 100ms */
#define P2P_INVITE_TIMEOUT 5000 /* 5 seconds timeout for sending the invitation request */
@@ -751,14 +702,14 @@ struct ADDBA_request {
#define WPS_CM_SW_DISPLAY_PIN 0x2008
#define WPS_CM_LCD_DISPLAY_PIN 0x4008
-enum P2P_ROLE {
+enum p2p_role {
P2P_ROLE_DISABLE = 0,
P2P_ROLE_DEVICE = 1,
P2P_ROLE_CLIENT = 2,
P2P_ROLE_GO = 3
};
-enum P2P_STATE {
+enum p2p_state {
P2P_STATE_NONE = 0, /* P2P disable */
P2P_STATE_IDLE = 1, /* P2P had enabled and do nothing */
P2P_STATE_LISTEN = 2, /* In pure listen state */
@@ -784,7 +735,7 @@ enum P2P_STATE {
P2P_STATE_TX_INFOR_NOREADY = 22, /* sending p2p negotiation response with information is not available */
};
-enum P2P_WPSINFO {
+enum p2p_wpsinfo {
P2P_NO_WPSINFO = 0,
P2P_GOT_WPSINFO_PEER_DISPLAY_PIN = 1,
P2P_GOT_WPSINFO_SELF_DISPLAY_PIN = 2,
@@ -793,16 +744,6 @@ enum P2P_WPSINFO {
#define P2P_PRIVATE_IOCTL_SET_LEN 64
-enum P2P_PROTO_WK_ID {
- P2P_FIND_PHASE_WK = 0,
- P2P_RESTORE_STATE_WK = 1,
- P2P_PRE_TX_PROVDISC_PROCESS_WK = 2,
- P2P_PRE_TX_NEGOREQ_PROCESS_WK = 3,
- P2P_PRE_TX_INVITEREQ_PROCESS_WK = 4,
- P2P_AP_P2P_CH_SWITCH_PROCESS_WK = 5,
- P2P_RO_CH_WK = 6,
-};
-
/* =====================WFD Section ===================== */
/* For Wi-Fi Display */
#define WFD_ATTR_DEVICE_INFO 0x00
diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h
index 27cd2c5d90af..a45990bed80c 100644
--- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h
+++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h
@@ -24,7 +24,7 @@ struct ndis_802_11_ssid {
u8 Ssid[32];
};
-enum NDIS_802_11_NETWORK_TYPE {
+enum ndis_802_11_network_type {
Ndis802_11FH,
Ndis802_11DS,
Ndis802_11OFDM5,
@@ -51,7 +51,7 @@ struct ndis_802_11_conf {
struct ndis_802_11_conf_fh FHConfig;
};
-enum NDIS_802_11_NETWORK_INFRASTRUCTURE {
+enum ndis_802_11_network_infrastructure {
Ndis802_11IBSS,
Ndis802_11Infrastructure,
Ndis802_11AutoUnknown,
@@ -74,13 +74,13 @@ struct ndis_80211_var_ie {
/* Length is the 4 bytes multiples of the sum of
* sizeof (NDIS_802_11_MAC_ADDRESS) + 2 +
* sizeof (struct ndis_802_11_ssid) + sizeof (u32) +
- * sizeof (long) + sizeof (enum NDIS_802_11_NETWORK_TYPE) +
+ * sizeof (long) + sizeof (enum ndis_802_11_network_type) +
* sizeof (struct ndis_802_11_conf) + sizeof (NDIS_802_11_RATES_EX) + IELength
*
* Except for IELength, all other fields are fixed length. Therefore, we can
* define a macro to present the partial sum.
*/
-enum NDIS_802_11_AUTHENTICATION_MODE {
+enum ndis_802_11_authentication_mode {
Ndis802_11AuthModeOpen,
Ndis802_11AuthModeShared,
Ndis802_11AuthModeAutoSwitch,
@@ -91,7 +91,7 @@ enum NDIS_802_11_AUTHENTICATION_MODE {
Ndis802_11AuthModeMax /* Not a real mode, defined as upper bound */
};
-enum NDIS_802_11_WEP_STATUS {
+enum {
Ndis802_11WEPEnabled,
Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
Ndis802_11WEPDisabled,
@@ -127,38 +127,7 @@ struct ndis_801_11_ai_resfi {
u16 AssociationId;
};
-typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION {
- u32 Length;
- u16 AvailableRequestFixedIEs;
- struct ndis_802_11_ai_reqfi RequestFixedIEs;
- u32 RequestIELength;
- u32 OffsetRequestIEs;
- u16 AvailableResponseFixedIEs;
- struct ndis_801_11_ai_resfi ResponseFixedIEs;
- u32 ResponseIELength;
- u32 OffsetResponseIEs;
-} NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
-
-enum NDIS_802_11_RELOAD_DEFAULTS {
- Ndis802_11ReloadWEPKeys
-};
-
-
/* Key mapping keys require a BSSID */
-typedef struct _NDIS_802_11_KEY {
- u32 Length; /* Length of this structure */
- u32 KeyIndex;
- u32 KeyLength; /* length of key in bytes */
- NDIS_802_11_MAC_ADDRESS BSSID;
- unsigned long long KeyRSC;
- u8 KeyMaterial[32]; /* variable length depending on above field */
-} NDIS_802_11_KEY, *PNDIS_802_11_KEY;
-
-typedef struct _NDIS_802_11_REMOVE_KEY {
- u32 Length; /* Length of this structure */
- u32 KeyIndex;
- NDIS_802_11_MAC_ADDRESS BSSID;
-} NDIS_802_11_REMOVE_KEY, *PNDIS_802_11_REMOVE_KEY;
struct ndis_802_11_wep {
u32 Length; /* Length of this structure */
@@ -211,9 +180,9 @@ struct wlan_bssid_ex {
struct ndis_802_11_ssid Ssid;
u32 Privacy;
long Rssi;/* in dBM, raw data , get from PHY) */
- enum NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
+ enum ndis_802_11_network_type NetworkTypeInUse;
struct ndis_802_11_conf Configuration;
- enum NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
+ enum ndis_802_11_network_infrastructure InfrastructureMode;
NDIS_802_11_RATES_EX SupportedRates;
struct wlan_phy_info PhyInfo;
u32 IELength;
@@ -236,13 +205,13 @@ struct wlan_network {
struct wlan_bcn_info BcnInfo;
};
-enum VRTL_CARRIER_SENSE {
+enum {
DISABLE_VCS,
ENABLE_VCS,
AUTO_VCS
};
-enum VCS_TYPE {
+enum {
NONE_VCS,
RTS_CTS,
CTS_TO_SELF
@@ -254,7 +223,7 @@ enum VCS_TYPE {
#define PWR_UAPSD 3
#define PWR_VOIP 4
-enum UAPSD_MAX_SP {
+enum {
NO_LIMIT,
TWO_MSDU,
FOUR_MSDU,
diff --git a/drivers/staging/rtl8723bs/include/xmit_osdep.h b/drivers/staging/rtl8723bs/include/xmit_osdep.h
index e9ff274f7474..e781cd5dfd01 100644
--- a/drivers/staging/rtl8723bs/include/xmit_osdep.h
+++ b/drivers/staging/rtl8723bs/include/xmit_osdep.h
@@ -9,9 +9,9 @@
struct pkt_file {
- _pkt *pkt;
+ struct sk_buff *pkt;
__kernel_size_t pkt_len; /* the remainder length of the open_file */
- _buffer *cur_buffer;
+ unsigned char *cur_buffer;
u8 *buf_start;
u8 *cur_addr;
__kernel_size_t buf_len;
@@ -25,8 +25,8 @@ struct sta_xmit_priv;
struct xmit_frame;
struct xmit_buf;
-extern int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev);
-extern int rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev);
+extern int _rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev);
+extern int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev);
void rtw_os_xmit_schedule(struct adapter *padapter);
@@ -34,11 +34,11 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb
void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 free_sz, u8 flag);
extern uint rtw_remainder_len(struct pkt_file *pfile);
-extern void _rtw_open_pktfile(_pkt *pkt, struct pkt_file *pfile);
+extern void _rtw_open_pktfile(struct sk_buff *pkt, struct pkt_file *pfile);
extern uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen);
-extern sint rtw_endofpktfile(struct pkt_file *pfile);
+extern signed int rtw_endofpktfile(struct pkt_file *pfile);
-extern void rtw_os_pkt_complete(struct adapter *padapter, _pkt *pkt);
+extern void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt);
extern void rtw_os_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe);
#endif /* __XMIT_OSDEP_H_ */
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index ff164a8c8679..c1dac6eec59f 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -235,14 +235,9 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl
struct wiphy *wiphy = wdev->wiphy;
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
-
- /* DBG_8192C("%s\n", __func__); */
-
bssinf_len = pnetwork->network.IELength + sizeof(struct ieee80211_hdr_3addr);
- if (bssinf_len > MAX_BSSINFO_LEN) {
- DBG_871X("%s IE Length too long > %d byte\n", __func__, MAX_BSSINFO_LEN);
+ if (bssinf_len > MAX_BSSINFO_LEN)
goto exit;
- }
{
u16 wapi_len = 0;
@@ -250,10 +245,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl
if (rtw_get_wapi_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &wapi_len) > 0)
{
if (wapi_len > 0)
- {
- DBG_871X("%s, no support wapi!\n", __func__);
goto exit;
- }
}
}
@@ -277,16 +269,9 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl
{
if (request->n_ssids == 1 && request->n_channels == 1) /* it means under processing WPS */
{
- DBG_8192C("ssid =%s, len =%d\n", pssid->Ssid, pssid->SsidLength);
-
- if (ssids[0].ssid_len == 0) {
- }
- else if (pssid->SsidLength == ssids[0].ssid_len &&
- !memcmp(pssid->Ssid, ssids[0].ssid, ssids[0].ssid_len))
- {
- DBG_871X("%s, got sr and ssid match!\n", __func__);
- }
- else
+ if (ssids[0].ssid_len != 0 &&
+ (pssid->SsidLength != ssids[0].ssid_len ||
+ memcmp(pssid->Ssid, ssids[0].ssid, ssids[0].ssid_len)))
{
if (psr)
*psr = 0; /* clear sr */
@@ -347,10 +332,8 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl
bss = cfg80211_inform_bss_frame(wiphy, notify_channel, (struct ieee80211_mgmt *)buf,
len, notify_signal, GFP_ATOMIC);
- if (unlikely(!bss)) {
- DBG_8192C(FUNC_ADPT_FMT" bss NULL\n", FUNC_ADPT_ARG(padapter));
+ if (unlikely(!bss))
goto exit;
- }
cfg80211_put_bss(wiphy, bss);
kfree(buf);
@@ -398,7 +381,6 @@ void rtw_cfg80211_ibss_indicate_connect(struct adapter *padapter)
int freq = (int)cur_network->network.Configuration.DSConfig;
struct ieee80211_channel *chan;
- DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
if (pwdev->iftype != NL80211_IFTYPE_ADHOC)
{
return;
@@ -412,10 +394,7 @@ void rtw_cfg80211_ibss_indicate_connect(struct adapter *padapter)
{
memcpy(&cur_network->network, pnetwork, sizeof(struct wlan_bssid_ex));
- if (!rtw_cfg80211_inform_bss(padapter, cur_network))
- DBG_871X(FUNC_ADPT_FMT" inform fail !!\n", FUNC_ADPT_ARG(padapter));
- else
- DBG_871X(FUNC_ADPT_FMT" inform success !!\n", FUNC_ADPT_ARG(padapter));
+ rtw_cfg80211_inform_bss(padapter, cur_network);
}
else
{
@@ -425,20 +404,16 @@ void rtw_cfg80211_ibss_indicate_connect(struct adapter *padapter)
}
if (!memcmp(&(scanned->network.Ssid), &(pnetwork->Ssid), sizeof(struct ndis_802_11_ssid))
&& !memcmp(scanned->network.MacAddress, pnetwork->MacAddress, sizeof(NDIS_802_11_MAC_ADDRESS))
- ) {
- if (!rtw_cfg80211_inform_bss(padapter, scanned)) {
- DBG_871X(FUNC_ADPT_FMT" inform fail !!\n", FUNC_ADPT_ARG(padapter));
- } else {
- /* DBG_871X(FUNC_ADPT_FMT" inform success !!\n", FUNC_ADPT_ARG(padapter)); */
- }
- } else {
- DBG_871X("scanned & pnetwork compare fail\n");
+ )
+ rtw_cfg80211_inform_bss(padapter, scanned);
+ else
rtw_warn_on(1);
- }
}
if (!rtw_cfg80211_check_bss(padapter))
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" BSS not found !!\n", FUNC_ADPT_ARG(padapter));
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " BSS not found !!\n",
+ FUNC_ADPT_ARG(padapter));
}
/* notify cfg80211 that device joined an IBSS */
chan = ieee80211_get_channel(wiphy, freq);
@@ -451,7 +426,6 @@ void rtw_cfg80211_indicate_connect(struct adapter *padapter)
struct wlan_network *cur_network = &(pmlmepriv->cur_network);
struct wireless_dev *pwdev = padapter->rtw_wdev;
- DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
if (pwdev->iftype != NL80211_IFTYPE_STATION
&& pwdev->iftype != NL80211_IFTYPE_P2P_CLIENT
) {
@@ -465,8 +439,6 @@ void rtw_cfg80211_indicate_connect(struct adapter *padapter)
struct wlan_bssid_ex *pnetwork = &(padapter->mlmeextpriv.mlmext_info.network);
struct wlan_network *scanned = pmlmepriv->cur_network_scanned;
- /* DBG_871X(FUNC_ADPT_FMT" BSS not found\n", FUNC_ADPT_ARG(padapter)); */
-
if (scanned == NULL) {
rtw_warn_on(1);
goto check_bss;
@@ -474,24 +446,17 @@ void rtw_cfg80211_indicate_connect(struct adapter *padapter)
if (!memcmp(scanned->network.MacAddress, pnetwork->MacAddress, sizeof(NDIS_802_11_MAC_ADDRESS))
&& !memcmp(&(scanned->network.Ssid), &(pnetwork->Ssid), sizeof(struct ndis_802_11_ssid))
- ) {
- if (!rtw_cfg80211_inform_bss(padapter, scanned)) {
- DBG_871X(FUNC_ADPT_FMT" inform fail !!\n", FUNC_ADPT_ARG(padapter));
- } else {
- /* DBG_871X(FUNC_ADPT_FMT" inform success !!\n", FUNC_ADPT_ARG(padapter)); */
- }
- } else {
- DBG_871X("scanned: %s(%pM), cur: %s(%pM)\n",
- scanned->network.Ssid.Ssid, MAC_ARG(scanned->network.MacAddress),
- pnetwork->Ssid.Ssid, MAC_ARG(pnetwork->MacAddress)
- );
+ )
+ rtw_cfg80211_inform_bss(padapter, scanned);
+ else
rtw_warn_on(1);
- }
}
check_bss:
if (!rtw_cfg80211_check_bss(padapter))
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" BSS not found !!\n", FUNC_ADPT_ARG(padapter));
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " BSS not found !!\n",
+ FUNC_ADPT_ARG(padapter));
if (rtw_to_roam(padapter) > 0) {
struct wiphy *wiphy = pwdev->wiphy;
@@ -504,7 +469,6 @@ check_bss:
notify_channel = ieee80211_get_channel(wiphy, freq);
- DBG_871X(FUNC_ADPT_FMT" call cfg80211_roamed\n", FUNC_ADPT_ARG(padapter));
roam_info.channel = notify_channel;
roam_info.bssid = cur_network->network.MacAddress;
roam_info.req_ie =
@@ -533,8 +497,6 @@ void rtw_cfg80211_indicate_disconnect(struct adapter *padapter)
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wireless_dev *pwdev = padapter->rtw_wdev;
- DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
-
if (pwdev->iftype != NL80211_IFTYPE_STATION
&& pwdev->iftype != NL80211_IFTYPE_P2P_CLIENT
) {
@@ -566,8 +528,6 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
struct security_priv *psecuritypriv = &(padapter->securitypriv);
struct sta_priv *pstapriv = &padapter->stapriv;
- DBG_8192C("%s\n", __func__);
-
param->u.crypt.err = 0;
param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
@@ -591,32 +551,18 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
{
psta = rtw_get_stainfo(pstapriv, param->sta_addr);
if (!psta)
- {
/* ret = -EINVAL; */
- DBG_8192C("rtw_set_encryption(), sta has already been removed or never been added\n");
goto exit;
- }
}
if (strcmp(param->u.crypt.alg, "none") == 0 && (psta == NULL))
- {
- /* todo:clear default encryption keys */
-
- DBG_8192C("clear default encryption keys, keyid =%d\n", param->u.crypt.idx);
-
goto exit;
- }
-
if (strcmp(param->u.crypt.alg, "WEP") == 0 && (psta == NULL))
{
- DBG_8192C("r871x_set_encryption, crypt.alg = WEP\n");
-
wep_key_idx = param->u.crypt.idx;
wep_key_len = param->u.crypt.key_len;
- DBG_8192C("r871x_set_encryption, wep_key_idx =%d, len =%d\n", wep_key_idx, wep_key_len);
-
if ((wep_key_idx >= WEP_KEYS) || (wep_key_len <= 0))
{
ret = -EINVAL;
@@ -663,8 +609,6 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
{
if (strcmp(param->u.crypt.alg, "WEP") == 0)
{
- DBG_8192C("%s, set group_key, WEP\n", __func__);
-
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
@@ -676,8 +620,6 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
}
else if (strcmp(param->u.crypt.alg, "TKIP") == 0)
{
- DBG_8192C("%s, set group_key, TKIP\n", __func__);
-
psecuritypriv->dot118021XGrpPrivacy = _TKIP_;
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
@@ -692,16 +634,12 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
}
else if (strcmp(param->u.crypt.alg, "CCMP") == 0)
{
- DBG_8192C("%s, set group_key, CCMP\n", __func__);
-
psecuritypriv->dot118021XGrpPrivacy = _AES_;
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
}
else
{
- DBG_8192C("%s, set group_key, none\n", __func__);
-
psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
}
@@ -736,8 +674,6 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
if (strcmp(param->u.crypt.alg, "WEP") == 0)
{
- DBG_8192C("%s, set pairwise key, WEP\n", __func__);
-
psta->dot118021XPrivacy = _WEP40_;
if (param->u.crypt.key_len == 13)
{
@@ -746,8 +682,6 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
}
else if (strcmp(param->u.crypt.alg, "TKIP") == 0)
{
- DBG_8192C("%s, set pairwise key, TKIP\n", __func__);
-
psta->dot118021XPrivacy = _TKIP_;
/* DEBUG_ERR("set key length :param->u.crypt.key_len =%d\n", param->u.crypt.key_len); */
@@ -761,14 +695,10 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa
else if (strcmp(param->u.crypt.alg, "CCMP") == 0)
{
- DBG_8192C("%s, set pairwise key, CCMP\n", __func__);
-
psta->dot118021XPrivacy = _AES_;
}
else
{
- DBG_8192C("%s, set pairwise key, none\n", __func__);
-
psta->dot118021XPrivacy = _NO_PRIVACY_;
}
@@ -851,8 +781,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct security_priv *psecuritypriv = &padapter->securitypriv;
- DBG_8192C("%s\n", __func__);
-
param->u.crypt.err = 0;
param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
@@ -882,9 +810,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param
if (strcmp(param->u.crypt.alg, "WEP") == 0)
{
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("wpa_set_encryption, crypt.alg = WEP\n"));
- DBG_8192C("wpa_set_encryption, crypt.alg = WEP\n");
-
wep_key_idx = param->u.crypt.idx;
wep_key_len = param->u.crypt.key_len;
@@ -927,17 +852,10 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param
struct sta_info *psta, *pbcmc_sta;
struct sta_priv *pstapriv = &padapter->stapriv;
- /* DBG_8192C("%s, : dot11AuthAlgrthm == dot11AuthAlgrthm_8021X\n", __func__); */
-
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE) == true) /* sta mode */
{
psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv));
- if (psta == NULL) {
- /* DEBUG_ERR(("Set wpa_set_encryption: Obtain Sta_info fail\n")); */
- DBG_8192C("%s, : Obtain Sta_info fail\n", __func__);
- }
- else
- {
+ if (psta) {
/* Jeff: don't disable ieee8021x_blocked while clearing key */
if (strcmp(param->u.crypt.alg, "none") != 0)
psta->ieee8021x_blocked = false;
@@ -952,8 +870,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param
if (param->u.crypt.set_tx == 1)/* pairwise key */
{
- DBG_8192C("%s, : param->u.crypt.set_tx == 1\n", __func__);
-
memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
if (strcmp(param->u.crypt.alg, "TKIP") == 0)/* set mic key */
@@ -966,9 +882,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param
/* _set_timer(&padapter->securitypriv.tkip_timer, 50); */
}
- /* DEBUG_ERR((" param->u.crypt.key_len =%d\n", param->u.crypt.key_len)); */
- DBG_871X(" ~~~~set sta key:unicastkey\n");
-
rtw_setstakey_cmd(padapter, psta, true, true);
}
else/* group key */
@@ -979,24 +892,20 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param
memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8);
memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8);
padapter->securitypriv.binstallGrpkey = true;
- /* DEBUG_ERR((" param->u.crypt.key_len =%d\n", param->u.crypt.key_len)); */
- DBG_871X(" ~~~~set sta key:groupkey\n");
padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx;
rtw_set_key(padapter, &padapter->securitypriv, param->u.crypt.idx, 1, true);
}
else if (strcmp(param->u.crypt.alg, "BIP") == 0)
{
- /* DBG_871X("BIP key_len =%d , index =%d @@@@@@@@@@@@@@@@@@\n", param->u.crypt.key_len, param->u.crypt.idx); */
/* save the IGTK key, length 16 bytes */
memcpy(padapter->securitypriv.dot11wBIPKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
- /*DBG_871X("IGTK key below:\n");
+ /*
for (no = 0;no<16;no++)
printk(" %02x ", padapter->securitypriv.dot11wBIPKey[param->u.crypt.idx].skey[no]);
- DBG_871X("\n");*/
+ */
padapter->securitypriv.dot11wBIPKeyid = param->u.crypt.idx;
padapter->securitypriv.binstallBIPkey = true;
- DBG_871X(" ~~~~set sta key:IGKT\n");
}
}
}
@@ -1026,8 +935,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param
exit:
- DBG_8192C("%s, ret =%d\n", __func__, ret);
-
return ret;
}
@@ -1042,13 +949,6 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev,
struct adapter *padapter = rtw_netdev_priv(ndev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- DBG_871X(FUNC_NDEV_FMT" adding key for %pM\n", FUNC_NDEV_ARG(ndev), mac_addr);
- DBG_871X("cipher = 0x%x\n", params->cipher);
- DBG_871X("key_len = 0x%x\n", params->key_len);
- DBG_871X("seq_len = 0x%x\n", params->seq_len);
- DBG_871X("key_index =%d\n", key_index);
- DBG_871X("pairwise =%d\n", pairwise);
-
param_len = sizeof(struct ieee_param) + params->key_len;
param = rtw_malloc(param_len);
if (param == NULL)
@@ -1120,14 +1020,8 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev,
else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true
|| check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)
{
- /* DBG_8192C("@@@@@@@@@@ fw_state = 0x%x, iftype =%d\n", pmlmepriv->fw_state, rtw_wdev->iftype); */
ret = rtw_cfg80211_set_encryption(ndev, param, param_len);
}
- else
- {
- DBG_8192C("error!\n");
-
- }
addkey_end:
kfree(param);
@@ -1142,7 +1036,6 @@ static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev,
void (*callback)(void *cookie,
struct key_params*))
{
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
return 0;
}
@@ -1152,8 +1045,6 @@ static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev,
struct adapter *padapter = rtw_netdev_priv(ndev);
struct security_priv *psecuritypriv = &padapter->securitypriv;
- DBG_871X(FUNC_NDEV_FMT" key_index =%d\n", FUNC_NDEV_ARG(ndev), key_index);
-
if (key_index == psecuritypriv->dot11PrivacyKeyIndex)
{
/* clear the flag of wep default key set. */
@@ -1171,9 +1062,6 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy,
struct adapter *padapter = rtw_netdev_priv(ndev);
struct security_priv *psecuritypriv = &padapter->securitypriv;
- DBG_871X(FUNC_NDEV_FMT" key_index =%d, unicast =%d, multicast =%d\n",
- FUNC_NDEV_ARG(ndev), key_index, unicast, multicast);
-
if ((key_index < WEP_KEYS) && ((psecuritypriv->dot11PrivacyAlgrthm == _WEP40_) || (psecuritypriv->dot11PrivacyAlgrthm == _WEP104_))) /* set wep default key */
{
psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled;
@@ -1209,22 +1097,16 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy,
sinfo->filled = 0;
if (!mac) {
- DBG_871X(FUNC_NDEV_FMT" mac ==%p\n", FUNC_NDEV_ARG(ndev), mac);
ret = -ENOENT;
goto exit;
}
psta = rtw_get_stainfo(pstapriv, (u8 *)mac);
if (psta == NULL) {
- DBG_8192C("%s, sta_info is null\n", __func__);
ret = -ENOENT;
goto exit;
}
-#ifdef DEBUG_CFG80211
- DBG_871X(FUNC_NDEV_FMT" mac =%pM\n", FUNC_NDEV_ARG(ndev), MAC_ARG(mac));
-#endif
-
/* for infra./P2PClient mode */
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)
&& check_fwstate(pmlmepriv, _FW_LINKED)
@@ -1233,7 +1115,6 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy,
struct wlan_network *cur_network = &(pmlmepriv->cur_network);
if (memcmp((u8 *)mac, cur_network->network.MacAddress, ETH_ALEN)) {
- DBG_871X("%s, mismatch bssid =%pM\n", __func__, MAC_ARG(cur_network->network.MacAddress));
ret = -ENOENT;
goto exit;
}
@@ -1266,22 +1147,18 @@ exit:
return ret;
}
-extern int netdev_open(struct net_device *pnetdev);
-
static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
struct net_device *ndev,
enum nl80211_iftype type,
struct vif_params *params)
{
enum nl80211_iftype old_type;
- enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType;
+ enum ndis_802_11_network_infrastructure networkType;
struct adapter *padapter = rtw_netdev_priv(ndev);
struct wireless_dev *rtw_wdev = padapter->rtw_wdev;
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
int ret = 0;
- DBG_871X(FUNC_NDEV_FMT" type =%d\n", FUNC_NDEV_ARG(ndev), type);
-
if (adapter_to_dvobj(padapter)->processing_dev_remove == true)
{
ret = -EPERM;
@@ -1289,23 +1166,18 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
}
{
- DBG_871X(FUNC_NDEV_FMT" call netdev_open\n", FUNC_NDEV_ARG(ndev));
if (netdev_open(ndev) != 0) {
- DBG_871X(FUNC_NDEV_FMT" call netdev_open fail\n", FUNC_NDEV_ARG(ndev));
ret = -EPERM;
goto exit;
}
}
if (_FAIL == rtw_pwr_wakeup(padapter)) {
- DBG_871X(FUNC_NDEV_FMT" call rtw_pwr_wakeup fail\n", FUNC_NDEV_ARG(ndev));
ret = -EPERM;
goto exit;
}
old_type = rtw_wdev->iftype;
- DBG_871X(FUNC_NDEV_FMT" old_iftype =%d, new_iftype =%d\n",
- FUNC_NDEV_ARG(ndev), old_type, type);
if (old_type != type)
{
@@ -1341,7 +1213,6 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
exit:
- DBG_871X(FUNC_NDEV_FMT" ret:%d\n", FUNC_NDEV_ARG(ndev), ret);
return ret;
}
@@ -1354,25 +1225,11 @@ void rtw_cfg80211_indicate_scan_done(struct adapter *adapter, bool aborted)
spin_lock_bh(&pwdev_priv->scan_req_lock);
if (pwdev_priv->scan_request) {
- #ifdef DEBUG_CFG80211
- DBG_871X("%s with scan req\n", __func__);
- #endif
-
/* avoid WARN_ON(request != wiphy_to_dev(request->wiphy)->scan_req); */
- if (pwdev_priv->scan_request->wiphy != pwdev_priv->rtw_wdev->wiphy)
- {
- DBG_8192C("error wiphy compare\n");
- }
- else
- {
+ if (pwdev_priv->scan_request->wiphy == pwdev_priv->rtw_wdev->wiphy)
cfg80211_scan_done(pwdev_priv->scan_request, &info);
- }
pwdev_priv->scan_request = NULL;
- } else {
- #ifdef DEBUG_CFG80211
- DBG_871X("%s without scan req\n", __func__);
- #endif
}
spin_unlock_bh(&pwdev_priv->scan_req_lock);
}
@@ -1391,8 +1248,6 @@ void rtw_cfg80211_unlink_bss(struct adapter *padapter, struct wlan_network *pnet
if (bss) {
cfg80211_unlink_bss(wiphy, bss);
- DBG_8192C("%s(): cfg80211_unlink %s!! () ", __func__,
- select_network->Ssid.Ssid);
cfg80211_put_bss(padapter->rtw_wdev->wiphy, bss);
}
}
@@ -1404,10 +1259,6 @@ void rtw_cfg80211_surveydone_event_callback(struct adapter *padapter)
struct __queue *queue = &(pmlmepriv->scanned_queue);
struct wlan_network *pnetwork = NULL;
-#ifdef DEBUG_CFG80211
- DBG_8192C("%s\n", __func__);
-#endif
-
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
phead = get_list_head(queue);
@@ -1444,18 +1295,11 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct adapter *padapter, char *b
u8 *wps_ie;
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
-#ifdef DEBUG_CFG80211
- DBG_8192C("%s, ielen =%d\n", __func__, len);
-#endif
-
if (len > 0)
{
- if ((wps_ie = rtw_get_wps_ie(buf, len, NULL, &wps_ielen)))
+ wps_ie = rtw_get_wps_ie(buf, len, NULL, &wps_ielen);
+ if (wps_ie)
{
- #ifdef DEBUG_CFG80211
- DBG_8192C("probe_req_wps_ielen =%d\n", wps_ielen);
- #endif
-
if (pmlmepriv->wps_probe_req_ie)
{
pmlmepriv->wps_probe_req_ie_len = 0;
@@ -1464,11 +1308,9 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct adapter *padapter, char *b
}
pmlmepriv->wps_probe_req_ie = rtw_malloc(wps_ielen);
- if (pmlmepriv->wps_probe_req_ie == NULL) {
- DBG_8192C("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__);
+ if (!pmlmepriv->wps_probe_req_ie)
return -EINVAL;
- }
memcpy(pmlmepriv->wps_probe_req_ie, wps_ie, wps_ielen);
pmlmepriv->wps_probe_req_ie_len = wps_ielen;
}
@@ -1505,9 +1347,6 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy
padapter = rtw_netdev_priv(ndev);
pwdev_priv = adapter_wdev_data(padapter);
pmlmepriv = &padapter->mlmepriv;
-
-/* ifdef DEBUG_CFG80211 */
- DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
/* endif */
spin_lock_bh(&pwdev_priv->scan_req_lock);
@@ -1516,19 +1355,8 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
{
-#ifdef DEBUG_CFG80211
- DBG_871X("%s under WIFI_AP_STATE\n", __func__);
-#endif
-
if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS|_FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true)
{
- DBG_8192C("%s, fwstate = 0x%x\n", __func__, pmlmepriv->fw_state);
-
- if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS))
- {
- DBG_8192C("AP mode process WPS\n");
- }
-
need_indicate_scan_done = true;
goto check_need_indicate_scan_done;
}
@@ -1541,16 +1369,12 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy
}
if (request->ie && request->ie_len > 0)
- {
rtw_cfg80211_set_probe_req_wpsp2pie(padapter, (u8 *)request->ie, request->ie_len);
- }
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) {
- DBG_8192C("%s, fwstate = 0x%x\n", __func__, pmlmepriv->fw_state);
need_indicate_scan_done = true;
goto check_need_indicate_scan_done;
} else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) {
- DBG_8192C("%s, fwstate = 0x%x\n", __func__, pmlmepriv->fw_state);
ret = -EBUSY;
goto check_need_indicate_scan_done;
}
@@ -1564,14 +1388,12 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy
lastscantime = jiffies;
if (passtime > 12000)
{
- DBG_871X("%s: bBusyTraffic == true\n", __func__);
need_indicate_scan_done = true;
goto check_need_indicate_scan_done;
}
}
if (rtw_is_scan_deny(padapter)) {
- DBG_871X(FUNC_ADPT_FMT ": scan deny\n", FUNC_ADPT_ARG(padapter));
need_indicate_scan_done = true;
goto check_need_indicate_scan_done;
}
@@ -1585,9 +1407,6 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy
/* parsing request ssids, n_ssids */
for (i = 0; i < request->n_ssids && i < RTW_SSID_SCAN_AMOUNT; i++) {
- #ifdef DEBUG_CFG80211
- DBG_8192C("ssid =%s, len =%d\n", ssids[i].ssid, ssids[i].ssid_len);
- #endif
memcpy(ssid[i].Ssid, ssids[i].ssid, ssids[i].ssid_len);
ssid[i].SsidLength = ssids[i].ssid_len;
}
@@ -1595,9 +1414,6 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy
/* parsing channels, n_channels */
memset(ch, 0, sizeof(struct rtw_ieee80211_channel)*RTW_CHANNEL_SCAN_AMOUNT);
for (i = 0; i < request->n_channels && i < RTW_CHANNEL_SCAN_AMOUNT; i++) {
- #ifdef DEBUG_CFG80211
- DBG_871X(FUNC_ADPT_FMT CHAN_FMT"\n", FUNC_ADPT_ARG(padapter), CHAN_ARG(request->channels[i]));
- #endif
ch[i].hw_value = request->channels[i]->hw_value;
ch[i].flags = request->channels[i]->flags;
}
@@ -1642,16 +1458,11 @@ exit:
static int cfg80211_rtw_set_wiphy_params(struct wiphy *wiphy, u32 changed)
{
- DBG_8192C("%s\n", __func__);
return 0;
}
-
-
static int rtw_cfg80211_set_wpa_version(struct security_priv *psecuritypriv, u32 wpa_version)
{
- DBG_8192C("%s, wpa_version =%d\n", __func__, wpa_version);
-
if (!wpa_version) {
psecuritypriv->ndisauthtype = Ndis802_11AuthModeOpen;
return 0;
@@ -1670,9 +1481,6 @@ static int rtw_cfg80211_set_wpa_version(struct security_priv *psecuritypriv, u32
static int rtw_cfg80211_set_auth_type(struct security_priv *psecuritypriv,
enum nl80211_auth_type sme_auth_type)
{
- DBG_8192C("%s, nl80211_auth_type =%d\n", __func__, sme_auth_type);
-
-
switch (sme_auth_type) {
case NL80211_AUTHTYPE_AUTOMATIC:
@@ -1711,8 +1519,6 @@ static int rtw_cfg80211_set_cipher(struct security_priv *psecuritypriv, u32 ciph
u32 *profile_cipher = ucast ? &psecuritypriv->dot11PrivacyAlgrthm :
&psecuritypriv->dot118021XGrpPrivacy;
- DBG_8192C("%s, ucast =%d, cipher = 0x%x\n", __func__, ucast, cipher);
-
if (!cipher) {
*profile_cipher = _NO_PRIVACY_;
@@ -1742,7 +1548,6 @@ static int rtw_cfg80211_set_cipher(struct security_priv *psecuritypriv, u32 ciph
ndisencryptstatus = Ndis802_11Encryption3Enabled;
break;
default:
- DBG_8192C("Unsupported cipher: 0x%x\n", cipher);
return -ENOTSUPP;
}
@@ -1758,18 +1563,12 @@ static int rtw_cfg80211_set_cipher(struct security_priv *psecuritypriv, u32 ciph
static int rtw_cfg80211_set_key_mgt(struct security_priv *psecuritypriv, u32 key_mgt)
{
- DBG_8192C("%s, key_mgt = 0x%x\n", __func__, key_mgt);
-
if (key_mgt == WLAN_AKM_SUITE_8021X)
/* auth_type = UMAC_AUTH_TYPE_8021X; */
psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
else if (key_mgt == WLAN_AKM_SUITE_PSK) {
psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
}
- else {
- DBG_8192C("Invalid key mgt: 0x%x\n", key_mgt);
- /* return -EINVAL; */
- }
return 0;
}
@@ -1803,16 +1602,7 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel
memcpy(buf, pie, ielen);
- /* dump */
- {
- int i;
- DBG_8192C("set wpa_ie(length:%zu):\n", ielen);
- for (i = 0; i < ielen; i = i + 8)
- DBG_8192C("0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", buf[i], buf[i+1], buf[i+2], buf[i+3], buf[i+4], buf[i+5], buf[i+6], buf[i+7]);
- }
-
if (ielen < RSN_HEADER_LEN) {
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("Ie len too short %d\n", ielen));
ret = -1;
goto exit;
}
@@ -1823,8 +1613,6 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK;
memcpy(padapter->securitypriv.supplicant_ie, &pwpa[0], wpa_ielen+2);
-
- DBG_8192C("got wpa_ie, wpa_ielen:%u\n", wpa_ielen);
}
}
@@ -1834,8 +1622,6 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK;
memcpy(padapter->securitypriv.supplicant_ie, &pwpa2[0], wpa2_ielen+2);
-
- DBG_8192C("got wpa2_ie, wpa2_ielen:%u\n", wpa2_ielen);
}
}
@@ -1899,7 +1685,6 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel
wps_ie = rtw_get_wps_ie(buf, ielen, NULL, &wps_ielen);
if (wps_ie && wps_ielen > 0) {
- DBG_8192C("got wps_ie, wps_ielen:%u\n", wps_ielen);
padapter->securitypriv.wps_ie_len = wps_ielen < MAX_WPS_IE_LEN ? wps_ielen : MAX_WPS_IE_LEN;
memcpy(padapter->securitypriv.wps_ie, wps_ie, padapter->securitypriv.wps_ie_len);
set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS);
@@ -1916,10 +1701,6 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel
/* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true) */
rtw_hal_set_hwreg(padapter, HW_VAR_OFF_RCR_AM, null_addr);
- 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));
-
exit:
kfree(buf);
if (ret)
@@ -1961,8 +1742,6 @@ static int cfg80211_rtw_join_ibss(struct wiphy *wiphy, struct net_device *ndev,
ndis_ssid.SsidLength = params->ssid_len;
memcpy(ndis_ssid.Ssid, (u8 *)params->ssid, params->ssid_len);
- /* DBG_8192C("ssid =%s, len =%zu\n", ndis_ssid.Ssid, params->ssid_len); */
-
psecuritypriv->ndisencryptstatus = Ndis802_11EncryptionDisabled;
psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
@@ -1988,8 +1767,6 @@ static int cfg80211_rtw_leave_ibss(struct wiphy *wiphy, struct net_device *ndev)
enum nl80211_iftype old_type;
int ret = 0;
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
-
old_type = rtw_wdev->iftype;
rtw_set_to_roam(padapter, 0);
@@ -2017,7 +1794,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
struct cfg80211_connect_params *sme)
{
int ret = 0;
- enum NDIS_802_11_AUTHENTICATION_MODE authmode;
+ enum ndis_802_11_authentication_mode authmode;
struct ndis_802_11_ssid ndis_ssid;
struct adapter *padapter = rtw_netdev_priv(ndev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -2025,14 +1802,9 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
padapter->mlmepriv.not_indic_disco = true;
- DBG_871X("=>"FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
- DBG_871X("privacy =%d, key =%p, key_len =%d, key_idx =%d\n",
- sme->privacy, sme->key, sme->key_len, sme->key_idx);
-
if (adapter_wdev_data(padapter)->block == true) {
ret = -EBUSY;
- DBG_871X("%s wdev_priv.block is set\n", __func__);
goto exit;
}
@@ -2062,16 +1834,8 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
ndis_ssid.SsidLength = sme->ssid_len;
memcpy(ndis_ssid.Ssid, (u8 *)sme->ssid, sme->ssid_len);
- DBG_8192C("ssid =%s, len =%zu\n", ndis_ssid.Ssid, sme->ssid_len);
-
-
- if (sme->bssid)
- DBG_8192C("bssid =%pM\n", MAC_ARG(sme->bssid));
-
-
if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) {
ret = -EBUSY;
- DBG_8192C("%s, fw_state = 0x%x, goto exit\n", __func__, pmlmepriv->fw_state);
goto exit;
}
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) {
@@ -2093,8 +1857,6 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
if (ret < 0)
goto exit;
- DBG_8192C("%s, ie_len =%zu\n", __func__, sme->ie_len);
-
ret = rtw_cfg80211_set_wpa_ie(padapter, (u8 *)sme->ie, sme->ie_len);
if (ret < 0)
goto exit;
@@ -2110,7 +1872,6 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_Auto) && sme->key) {
u32 wep_key_idx, wep_key_len, wep_total_len;
struct ndis_802_11_wep *pwep = NULL;
- DBG_871X("%s(): Shared/Auto WEP\n", __func__);
wep_key_idx = sme->key_idx;
wep_key_len = sme->key_len;
@@ -2125,7 +1886,6 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
pwep = rtw_malloc(wep_total_len);
if (pwep == NULL) {
- DBG_871X(" wpa_set_encryption: pwep allocate fail !!!\n");
ret = -ENOMEM;
goto exit;
}
@@ -2178,14 +1938,10 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
goto exit;
}
- DBG_8192C("set ssid:dot11AuthAlgrthm =%d, dot11PrivacyAlgrthm =%d, dot118021XGrpPrivacy =%d\n", psecuritypriv->dot11AuthAlgrthm, psecuritypriv->dot11PrivacyAlgrthm, psecuritypriv->dot118021XGrpPrivacy);
-
exit:
rtw_ps_deny_cancel(padapter, PS_DENY_JOIN);
- DBG_8192C("<=%s, ret %d\n", __func__, ret);
-
padapter->mlmepriv.not_indic_disco = false;
return ret;
@@ -2196,22 +1952,17 @@ static int cfg80211_rtw_disconnect(struct wiphy *wiphy, struct net_device *ndev,
{
struct adapter *padapter = rtw_netdev_priv(ndev);
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
-
rtw_set_to_roam(padapter, 0);
rtw_scan_abort(padapter);
LeaveAllPowerSaveMode(padapter);
rtw_disassoc_cmd(padapter, 500, false);
- DBG_871X("%s...call rtw_indicate_disconnect\n", __func__);
-
rtw_indicate_disconnect(padapter);
rtw_free_assoc_resources(padapter, 1);
rtw_pwr_wakeup(padapter);
- DBG_871X(FUNC_NDEV_FMT" return 0\n", FUNC_NDEV_ARG(ndev));
return 0;
}
@@ -2219,7 +1970,6 @@ static int cfg80211_rtw_set_txpower(struct wiphy *wiphy,
struct wireless_dev *wdev,
enum nl80211_tx_power_setting type, int mbm)
{
- DBG_8192C("%s\n", __func__);
return 0;
}
@@ -2227,8 +1977,6 @@ static int cfg80211_rtw_get_txpower(struct wiphy *wiphy,
struct wireless_dev *wdev,
int *dbm)
{
- DBG_8192C("%s\n", __func__);
-
*dbm = (12);
return 0;
@@ -2247,9 +1995,6 @@ static int cfg80211_rtw_set_power_mgmt(struct wiphy *wiphy,
struct adapter *padapter = rtw_netdev_priv(ndev);
struct rtw_wdev_priv *rtw_wdev_priv = adapter_wdev_data(padapter);
- DBG_871X(FUNC_NDEV_FMT" enabled:%u, timeout:%d\n", FUNC_NDEV_ARG(ndev),
- enabled, timeout);
-
rtw_wdev_priv->power_mgmt = enabled;
if (!enabled)
@@ -2267,8 +2012,6 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy,
struct security_priv *psecuritypriv = &padapter->securitypriv;
u8 strZeroMacAddress[ETH_ALEN] = { 0x00 };
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
-
if (!memcmp((u8 *)pmksa->bssid, strZeroMacAddress, ETH_ALEN))
return -EINVAL;
@@ -2277,8 +2020,6 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy,
/* overwrite PMKID */
for (index = 0 ; index < NUM_PMKID_CACHE; index++) {
if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, (u8 *)pmksa->bssid, ETH_ALEN)) {
- /* BSSID is matched, the same AP => rewrite with new PMKID. */
- DBG_871X(FUNC_NDEV_FMT" BSSID exists in the PMKList.\n", FUNC_NDEV_ARG(ndev));
memcpy(psecuritypriv->PMKIDList[index].PMKID, (u8 *)pmksa->pmkid, WLAN_PMKID_LEN);
psecuritypriv->PMKIDList[index].bUsed = true;
@@ -2289,9 +2030,6 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy,
}
if (!blInserted) {
- /* Find a new entry */
- DBG_871X(FUNC_NDEV_FMT" Use the new entry index = %d for this PMKID.\n",
- FUNC_NDEV_ARG(ndev), psecuritypriv->PMKIDIndex);
memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].Bssid, (u8 *)pmksa->bssid, ETH_ALEN);
memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].PMKID, (u8 *)pmksa->pmkid, WLAN_PMKID_LEN);
@@ -2313,8 +2051,6 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy,
struct adapter *padapter = rtw_netdev_priv(ndev);
struct security_priv *psecuritypriv = &padapter->securitypriv;
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
-
for (index = 0 ; index < NUM_PMKID_CACHE; index++) {
if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, (u8 *)pmksa->bssid, ETH_ALEN)) {
/*
@@ -2329,11 +2065,8 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy,
}
}
- if (false == bMatched) {
- DBG_871X(FUNC_NDEV_FMT" do not have matched BSSID\n"
- , FUNC_NDEV_ARG(ndev));
+ if (!bMatched)
return -EINVAL;
- }
return 0;
}
@@ -2344,9 +2077,7 @@ static int cfg80211_rtw_flush_pmksa(struct wiphy *wiphy,
struct adapter *padapter = rtw_netdev_priv(ndev);
struct security_priv *psecuritypriv = &padapter->securitypriv;
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
-
- memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
+ memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
psecuritypriv->PMKIDIndex = 0;
return 0;
@@ -2356,8 +2087,6 @@ void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, u8 *pmgmt_frame,
{
struct net_device *ndev = padapter->pnetdev;
- DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
-
{
struct station_info sinfo;
u8 ie_offset;
@@ -2377,8 +2106,6 @@ void rtw_cfg80211_indicate_sta_disassoc(struct adapter *padapter, unsigned char
{
struct net_device *ndev = padapter->pnetdev;
- DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
-
cfg80211_del_sta(ndev, da, GFP_ATOMIC);
}
@@ -2398,13 +2125,9 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc
struct ieee80211_radiotap_header *rtap_hdr;
struct adapter *padapter = rtw_netdev_priv(ndev);
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
-
if (!skb)
goto fail;
- rtw_mstat_update(MSTAT_TYPE_SKB, MSTAT_ALLOC_SUCCESS, skb->truesize);
-
if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header)))
goto fail;
@@ -2416,10 +2139,8 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc
if (unlikely(skb->len < rtap_len))
goto fail;
- if (rtap_len != 14) {
- DBG_8192C("radiotap len (should be 14): %d\n", rtap_len);
+ if (rtap_len != 14)
goto fail;
- }
/* Skip the ratio tap header */
skb_pull(skb, rtap_len);
@@ -2447,8 +2168,6 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc
memcpy(pdata, dst_mac_addr, sizeof(dst_mac_addr));
memcpy(pdata + sizeof(dst_mac_addr), src_mac_addr, sizeof(src_mac_addr));
- DBG_8192C("should be eapol packet\n");
-
/* Use the real net device to transmit the packet */
return _rtw_xmit_entry(skb, padapter->pnetdev);
@@ -2467,21 +2186,12 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc
u32 len = skb->len;
u8 category, action;
- if (rtw_action_frame_parse(buf, len, &category, &action) == false) {
- DBG_8192C(FUNC_NDEV_FMT" frame_control:0x%x\n", FUNC_NDEV_ARG(ndev),
- le16_to_cpu(((struct ieee80211_hdr_3addr *)buf)->frame_control));
+ if (rtw_action_frame_parse(buf, len, &category, &action) == false)
goto fail;
- }
-
- DBG_8192C("RTW_Tx:da =%pM via "FUNC_NDEV_FMT"\n",
- MAC_ARG(GetAddr1Ptr(buf)), FUNC_NDEV_ARG(ndev));
- if (category == RTW_WLAN_CATEGORY_PUBLIC)
- DBG_871X("RTW_Tx:%s\n", action_public_str(action));
- else
- DBG_871X("RTW_Tx:category(%u), action(%u)\n", category, action);
/* starting alloc mgmt frame to dump it */
- if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL)
+ pmgntframe = alloc_mgtxmitframe(pxmitpriv);
+ if (!pmgntframe)
goto fail;
/* update attribute */
@@ -2507,11 +2217,8 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc
dump_mgntframe(padapter, pmgntframe);
- } else {
- DBG_8192C("frame_control = 0x%x\n", frame_control & (IEEE80211_FCTL_FTYPE|IEEE80211_FCTL_STYPE));
}
-
fail:
dev_kfree_skb_any(skb);
@@ -2535,21 +2242,17 @@ static int rtw_cfg80211_add_monitor_if(struct adapter *padapter, char *name, str
struct rtw_wdev_priv *pwdev_priv = adapter_wdev_data(padapter);
if (!name) {
- DBG_871X(FUNC_ADPT_FMT" without specific name\n", FUNC_ADPT_ARG(padapter));
ret = -EINVAL;
goto out;
}
if (pwdev_priv->pmon_ndev) {
- DBG_871X(FUNC_ADPT_FMT" monitor interface exist: %s\n",
- FUNC_ADPT_ARG(padapter), NDEV_ARG(pwdev_priv->pmon_ndev));
ret = -EBUSY;
goto out;
}
mon_ndev = alloc_etherdev(sizeof(struct rtw_netdev_priv_indicator));
if (!mon_ndev) {
- DBG_871X(FUNC_ADPT_FMT" allocate ndev fail\n", FUNC_ADPT_ARG(padapter));
ret = -ENOMEM;
goto out;
}
@@ -2569,7 +2272,6 @@ static int rtw_cfg80211_add_monitor_if(struct adapter *padapter, char *name, str
/* wdev */
mon_wdev = rtw_zmalloc(sizeof(struct wireless_dev));
if (!mon_wdev) {
- DBG_871X(FUNC_ADPT_FMT" allocate mon_wdev fail\n", FUNC_ADPT_ARG(padapter));
ret = -ENOMEM;
goto out;
}
@@ -2612,9 +2314,6 @@ static struct wireless_dev *
struct net_device *ndev = NULL;
struct adapter *padapter = wiphy_to_adapter(wiphy);
- DBG_871X(FUNC_ADPT_FMT " wiphy:%s, name:%s, type:%d\n",
- FUNC_ADPT_ARG(padapter), wiphy_name(wiphy), name, type);
-
switch (type) {
case NL80211_IFTYPE_ADHOC:
case NL80211_IFTYPE_AP_VLAN:
@@ -2635,12 +2334,9 @@ static struct wireless_dev *
break;
default:
ret = -ENODEV;
- DBG_871X("Unsupported interface type\n");
break;
}
- DBG_871X(FUNC_ADPT_FMT" ndev:%p, ret:%d\n", FUNC_ADPT_ARG(padapter), ndev, ret);
-
return ndev ? ndev->ieee80211_ptr : ERR_PTR(ret);
}
@@ -2666,7 +2362,6 @@ static int cfg80211_rtw_del_virtual_intf(struct wiphy *wiphy,
if (ndev == pwdev_priv->pmon_ndev) {
pwdev_priv->pmon_ndev = NULL;
pwdev_priv->ifname_mon[0] = '\0';
- DBG_871X(FUNC_NDEV_FMT" remove monitor interface\n", FUNC_NDEV_ARG(ndev));
}
exit:
@@ -2680,8 +2375,6 @@ static int rtw_add_beacon(struct adapter *adapter, const u8 *head, size_t head_l
uint len, wps_ielen = 0;
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
- DBG_8192C("%s beacon_head_len =%zu, beacon_tail_len =%zu\n", __func__, head_len, tail_len);
-
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
return -EINVAL;
@@ -2698,8 +2391,7 @@ static int rtw_add_beacon(struct adapter *adapter, const u8 *head, size_t head_l
len = head_len+tail_len-24;
/* check wps ie if inclued */
- if (rtw_get_wps_ie(pbuf+_FIXED_IE_LENGTH_, len-_FIXED_IE_LENGTH_, NULL, &wps_ielen))
- DBG_8192C("add bcn, wps_ielen =%d\n", wps_ielen);
+ rtw_get_wps_ie(pbuf + _FIXED_IE_LENGTH_, len - _FIXED_IE_LENGTH_, NULL, &wps_ielen);
/* pbss_network->IEs will not include p2p_ie, wfd ie */
rtw_ies_remove_ie(pbuf, &len, _BEACON_IE_OFFSET_, WLAN_EID_VENDOR_SPECIFIC, P2P_OUI, 4);
@@ -2723,9 +2415,6 @@ static int cfg80211_rtw_start_ap(struct wiphy *wiphy, struct net_device *ndev,
int ret = 0;
struct adapter *adapter = rtw_netdev_priv(ndev);
- DBG_871X(FUNC_NDEV_FMT" hidden_ssid:%d, auth_type:%d\n", FUNC_NDEV_ARG(ndev),
- settings->hidden_ssid, settings->auth_type);
-
ret = rtw_add_beacon(adapter, settings->beacon.head, settings->beacon.head_len,
settings->beacon.tail, settings->beacon.tail_len);
@@ -2749,14 +2438,11 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *nd
{
struct adapter *adapter = rtw_netdev_priv(ndev);
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
-
return rtw_add_beacon(adapter, info->head, info->head_len, info->tail, info->tail_len);
}
static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev)
{
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
return 0;
}
@@ -2764,8 +2450,6 @@ static int cfg80211_rtw_add_station(struct wiphy *wiphy, struct net_device *ndev
const u8 *mac,
struct station_parameters *params)
{
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
-
return 0;
}
@@ -2781,17 +2465,10 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev
struct sta_priv *pstapriv = &padapter->stapriv;
const u8 *mac = params->mac;
- DBG_871X("+"FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
-
- if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) {
- DBG_8192C("%s, fw_state != FW_LINKED|WIFI_AP_STATE\n", __func__);
+ if (check_fwstate(pmlmepriv, (_FW_LINKED | WIFI_AP_STATE)) != true)
return -EINVAL;
- }
-
if (!mac) {
- DBG_8192C("flush all sta, and cam_entry\n");
-
flush_all_cam_entry(padapter); /* clear CAM */
rtw_sta_flush(padapter);
@@ -2799,9 +2476,6 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev
return 0;
}
-
- DBG_8192C("free sta macaddr =%pM\n", MAC_ARG(mac));
-
if (mac[0] == 0xff && mac[1] == 0xff &&
mac[2] == 0xff && mac[3] == 0xff &&
mac[4] == 0xff && mac[5] == 0xff) {
@@ -2821,11 +2495,7 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev
plist = get_next(plist);
if (!memcmp((u8 *)mac, psta->hwaddr, ETH_ALEN)) {
- if (psta->dot8021xalg == 1 && psta->bpairwise_key_installed == false) {
- DBG_8192C("%s, sta's dot8021xalg = 1 and key_installed = false\n", __func__);
- } else {
- DBG_8192C("free psta =%p, aid =%d\n", psta, psta->aid);
-
+ if (psta->dot8021xalg != 1 || psta->bpairwise_key_installed) {
list_del_init(&psta->asoc_list);
pstapriv->asoc_list_cnt--;
@@ -2844,8 +2514,6 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev
associated_clients_update(padapter, updated);
- DBG_871X("-"FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
-
return ret;
}
@@ -2853,8 +2521,6 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev
static int cfg80211_rtw_change_station(struct wiphy *wiphy, struct net_device *ndev,
const u8 *mac, struct station_parameters *params)
{
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
-
return 0;
}
@@ -2886,13 +2552,11 @@ static int cfg80211_rtw_dump_station(struct wiphy *wiphy, struct net_device *nde
struct adapter *padapter = rtw_netdev_priv(ndev);
struct sta_info *psta = NULL;
struct sta_priv *pstapriv = &padapter->stapriv;
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
spin_lock_bh(&pstapriv->asoc_list_lock);
psta = rtw_sta_info_get_by_idx(idx, pstapriv);
spin_unlock_bh(&pstapriv->asoc_list_lock);
if (NULL == psta) {
- DBG_871X("Station is not found\n");
ret = -ENOENT;
goto exit;
}
@@ -2907,7 +2571,6 @@ exit:
static int cfg80211_rtw_change_bss(struct wiphy *wiphy, struct net_device *ndev,
struct bss_parameters *params)
{
- DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
return 0;
}
@@ -2921,12 +2584,6 @@ void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, uint frame_len,
rtw_action_frame_parse(frame, frame_len, &category, &action);
- DBG_8192C("RTW_Rx:cur_ch =%d\n", channel);
- if (msg)
- DBG_871X("RTW_Rx:%s\n", msg);
- else
- DBG_871X("RTW_Rx:category(%u), action(%u)\n", category, action);
-
freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ);
rtw_cfg80211_rx_mgmt(adapter, freq, 0, frame, frame_len, GFP_ATOMIC);
@@ -2953,7 +2610,8 @@ static int _cfg80211_rtw_mgmt_tx(struct adapter *padapter, u8 tx_ch, const u8 *b
}
/* starting alloc mgmt frame to dump it */
- if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) {
+ pmgntframe = alloc_mgtxmitframe(pxmitpriv);
+ if (!pmgntframe) {
/* ret = -ENOMEM; */
ret = _FAIL;
goto exit;
@@ -2983,24 +2641,14 @@ static int _cfg80211_rtw_mgmt_tx(struct adapter *padapter, u8 tx_ch, const u8 *b
ack = false;
ret = _FAIL;
- #ifdef DEBUG_CFG80211
- DBG_8192C("%s, ack == _FAIL\n", __func__);
- #endif
} else {
msleep(50);
- #ifdef DEBUG_CFG80211
- DBG_8192C("%s, ack =%d, ok!\n", __func__, ack);
- #endif
ret = _SUCCESS;
}
exit:
- #ifdef DEBUG_CFG80211
- DBG_8192C("%s, ret =%d\n", __func__, ret);
- #endif
-
return ret;
}
@@ -3036,27 +2684,11 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy,
/* cookie generation */
*cookie = (unsigned long) buf;
-#ifdef DEBUG_CFG80211
- DBG_871X(FUNC_ADPT_FMT" len =%zu, ch =%d"
- "\n", FUNC_ADPT_ARG(padapter),
- len, tx_ch
- );
-#endif /* DEBUG_CFG80211 */
-
/* indicate ack before issue frame to avoid racing with rsp frame */
rtw_cfg80211_mgmt_tx_status(padapter, *cookie, buf, len, ack, GFP_KERNEL);
- if (rtw_action_frame_parse(buf, len, &category, &action) == false) {
- DBG_8192C(FUNC_ADPT_FMT" frame_control:0x%x\n", FUNC_ADPT_ARG(padapter),
- le16_to_cpu(((struct ieee80211_hdr_3addr *)buf)->frame_control));
+ if (rtw_action_frame_parse(buf, len, &category, &action) == false)
goto exit;
- }
-
- DBG_8192C("RTW_Tx:tx_ch =%d, da =%pM\n", tx_ch, MAC_ARG(GetAddr1Ptr(buf)));
- if (category == RTW_WLAN_CATEGORY_PUBLIC)
- DBG_871X("RTW_Tx:%s\n", action_public_str(action));
- else
- DBG_871X("RTW_Tx:category(%u), action(%u)\n", category, action);
rtw_ps_deny(padapter, PS_DENY_MGNT_TX);
if (_FAIL == rtw_pwr_wakeup(padapter)) {
@@ -3069,19 +2701,12 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy,
tx_ret = _cfg80211_rtw_mgmt_tx(padapter, tx_ch, buf, len);
} while (dump_cnt < dump_limit && tx_ret != _SUCCESS);
- if (tx_ret != _SUCCESS || dump_cnt > 1) {
- DBG_871X(FUNC_ADPT_FMT" %s (%d/%d)\n", FUNC_ADPT_ARG(padapter),
- tx_ret == _SUCCESS?"OK":"FAIL", dump_cnt, dump_limit);
- }
-
switch (type) {
case P2P_GO_NEGO_CONF:
rtw_clear_scan_deny(padapter);
break;
case P2P_INVIT_RESP:
if (pwdev_priv->invit_info.flags & BIT(0) && pwdev_priv->invit_info.status == 0) {
- DBG_871X(FUNC_ADPT_FMT" agree with invitation of persistent group\n",
- FUNC_ADPT_ARG(padapter));
rtw_set_scan_deny(padapter, 5000);
rtw_pwr_wakeup_ex(padapter, 5000);
rtw_clear_scan_deny(padapter);
@@ -3095,54 +2720,6 @@ exit:
return ret;
}
-#if defined(CONFIG_PNO_SUPPORT)
-static int cfg80211_rtw_sched_scan_start(struct wiphy *wiphy, struct net_device *dev,
- struct cfg80211_sched_scan_request *request)
-{
- struct adapter *padapter = rtw_netdev_priv(dev);
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
- int ret;
-
- if (padapter->bup == false) {
- DBG_871X("%s: net device is down.\n", __func__);
- return -EIO;
- }
-
- if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true ||
- check_fwstate(pmlmepriv, _FW_LINKED) == true ||
- check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) {
- DBG_871X("%s: device is busy.\n", __func__);
- rtw_scan_abort(padapter);
- }
-
- if (request == NULL) {
- DBG_871X("%s: invalid cfg80211_requests parameters.\n", __func__);
- return -EINVAL;
- }
-
- ret = rtw_android_cfg80211_pno_setup(dev, request->ssids,
- request->n_ssids, request->interval);
-
- if (ret < 0) {
- DBG_871X("%s ret: %d\n", __func__, ret);
- goto exit;
- }
-
- ret = rtw_android_pno_enable(dev, true);
- if (ret < 0) {
- DBG_871X("%s ret: %d\n", __func__, ret);
- goto exit;
- }
-exit:
- return ret;
-}
-
-static int cfg80211_rtw_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
-{
- return rtw_android_pno_enable(dev, false);
-}
-#endif /* CONFIG_PNO_SUPPORT */
-
static void rtw_cfg80211_init_ht_capab(struct ieee80211_sta_ht_cap *ht_cap, enum nl80211_band band, u8 rf_type)
{
@@ -3188,10 +2765,7 @@ static void rtw_cfg80211_init_ht_capab(struct ieee80211_sta_ht_cap *ht_cap, enum
ht_cap->mcs.rx_mask[4] = 0x01;
ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15);
- } else {
- DBG_8192C("%s, error rf_type =%d\n", __func__, rf_type);
}
-
}
void rtw_cfg80211_init_wiphy(struct adapter *padapter)
@@ -3203,8 +2777,6 @@ void rtw_cfg80211_init_wiphy(struct adapter *padapter)
rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
- DBG_8192C("%s:rf_type =%d\n", __func__, rf_type);
-
{
bands = wiphy->bands[NL80211_BAND_2GHZ];
if (bands)
@@ -3248,9 +2820,6 @@ static void rtw_cfg80211_preinit_wiphy(struct adapter *padapter, struct wiphy *w
#if defined(CONFIG_PM)
wiphy->max_sched_scan_reqs = 1;
-#ifdef CONFIG_PNO_SUPPORT
- wiphy->max_sched_scan_ssids = MAX_PNO_LIST_COUNT;
-#endif
#endif
#if defined(CONFIG_PM)
@@ -3297,11 +2866,6 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
.change_bss = cfg80211_rtw_change_bss,
.mgmt_tx = cfg80211_rtw_mgmt_tx,
-
-#if defined(CONFIG_PNO_SUPPORT)
- .sched_scan_start = cfg80211_rtw_sched_scan_start,
- .sched_scan_stop = cfg80211_rtw_sched_scan_stop,
-#endif /* CONFIG_PNO_SUPPORT */
};
int rtw_wdev_alloc(struct adapter *padapter, struct device *dev)
@@ -3312,12 +2876,9 @@ int rtw_wdev_alloc(struct adapter *padapter, struct device *dev)
struct rtw_wdev_priv *pwdev_priv;
struct net_device *pnetdev = padapter->pnetdev;
- DBG_8192C("%s(padapter =%p)\n", __func__, padapter);
-
/* wiphy */
wiphy = wiphy_new(&rtw_cfg80211_ops, sizeof(struct adapter *));
if (!wiphy) {
- DBG_8192C("Couldn't allocate wiphy device\n");
ret = -ENOMEM;
goto exit;
}
@@ -3329,15 +2890,12 @@ int rtw_wdev_alloc(struct adapter *padapter, struct device *dev)
rtw_regd_init(wiphy, rtw_reg_notifier);
ret = wiphy_register(wiphy);
- if (ret < 0) {
- DBG_8192C("Couldn't register wiphy device\n");
+ if (ret < 0)
goto free_wiphy;
- }
/* wdev */
wdev = rtw_zmalloc(sizeof(struct wireless_dev));
if (!wdev) {
- DBG_8192C("Couldn't allocate wireless device\n");
ret = -ENOMEM;
goto unregister_wiphy;
}
@@ -3384,8 +2942,6 @@ exit:
void rtw_wdev_free(struct wireless_dev *wdev)
{
- DBG_8192C("%s(wdev =%p)\n", __func__, wdev);
-
if (!wdev)
return;
@@ -3402,12 +2958,10 @@ void rtw_wdev_unregister(struct wireless_dev *wdev)
struct adapter *adapter;
struct rtw_wdev_priv *pwdev_priv;
- DBG_8192C("%s(wdev =%p)\n", __func__, wdev);
-
if (!wdev)
return;
-
- if (!(ndev = wdev_to_ndev(wdev)))
+ ndev = wdev_to_ndev(wdev);
+ if (!ndev)
return;
adapter = rtw_netdev_priv(ndev);
@@ -3415,10 +2969,8 @@ void rtw_wdev_unregister(struct wireless_dev *wdev)
rtw_cfg80211_indicate_scan_done(adapter, true);
- if (pwdev_priv->pmon_ndev) {
- DBG_8192C("%s, unregister monitor interface\n", __func__);
+ if (pwdev_priv->pmon_ndev)
unregister_netdev(pwdev_priv->pmon_ndev);
- }
wiphy_unregister(wdev->wiphy);
}
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index 41389e266f54..e98e5388d5c7 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -33,17 +33,11 @@
static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000,
6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000};
-static const char * const iw_operation_mode[] = {
- "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", "Secondary", "Monitor"
-};
-
void indicate_wx_scan_complete_event(struct adapter *padapter)
{
union iwreq_data wrqu;
memset(&wrqu, 0, sizeof(union iwreq_data));
-
- /* DBG_871X("+rtw_indicate_wx_scan_complete_event\n"); */
}
@@ -64,7 +58,7 @@ void rtw_indicate_wx_assoc_event(struct adapter *padapter)
else
memcpy(wrqu.ap_addr.sa_data, pmlmepriv->cur_network.network.MacAddress, ETH_ALEN);
- DBG_871X_LEVEL(_drv_always_, "assoc success\n");
+ netdev_dbg(padapter->pnetdev, "assoc success\n");
}
void rtw_indicate_wx_disassoc_event(struct adapter *padapter)
@@ -210,12 +204,10 @@ static char *translate_scan(struct adapter *padapter,
if (vht_cap) {
max_rate = vht_data_rate;
} else if (ht_cap) {
- if (mcs_rate&0x8000) { /* MCS15 */
+ if (mcs_rate & 0x8000) /* MCS15 */
max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130);
- } else { /* default MCS7 */
- /* DBG_871X("wx_get_scan, mcs_rate_bitmap = 0x%x\n", mcs_rate); */
+ else /* default MCS7 */
max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65);
- }
max_rate = max_rate*2;/* Mbps/2; */
}
@@ -232,17 +224,16 @@ static char *translate_scan(struct adapter *padapter,
u16 wpa_len = 0, rsn_len = 0;
u8 *p;
rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, rsn_ie, &rsn_len, wpa_ie, &wpa_len);
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: ssid =%s\n", pnetwork->network.Ssid.Ssid));
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len));
buf = kzalloc(MAX_WPA_IE_LEN*2, GFP_ATOMIC);
if (!buf)
return start;
if (wpa_len > 0) {
p = buf;
- p += sprintf(p, "wpa_ie =");
+ p += scnprintf(p, (MAX_WPA_IE_LEN * 2) - (p - buf), "wpa_ie =");
for (i = 0; i < wpa_len; i++)
- p += sprintf(p, "%02x", wpa_ie[i]);
+ p += scnprintf(p, (MAX_WPA_IE_LEN * 2) - (p - buf),
+ "%02x", wpa_ie[i]);
if (wpa_len > 100) {
printk("-----------------Len %d----------------\n", wpa_len);
@@ -265,9 +256,10 @@ static char *translate_scan(struct adapter *padapter,
if (rsn_len > 0) {
p = buf;
memset(buf, 0, MAX_WPA_IE_LEN*2);
- p += sprintf(p, "rsn_ie =");
+ p += scnprintf(p, (MAX_WPA_IE_LEN * 2) - (p - buf), "rsn_ie =");
for (i = 0; i < rsn_len; i++)
- p += sprintf(p, "%02x", rsn_ie[i]);
+ p += scnprintf(p, (MAX_WPA_IE_LEN * 2) - (p - buf),
+ "%02x", rsn_ie[i]);
memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVCUSTOM;
iwe.u.data.length = strlen(buf);
@@ -311,15 +303,7 @@ static char *translate_scan(struct adapter *padapter,
/* Add quality statistics */
iwe.cmd = IWEVQUAL;
iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED
- #if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
- | IW_QUAL_NOISE_UPDATED
- #else
- | IW_QUAL_NOISE_INVALID
- #endif
- #ifdef CONFIG_SIGNAL_DISPLAY_DBM
- | IW_QUAL_DBM
- #endif
- ;
+ | IW_QUAL_NOISE_INVALID;
if (check_fwstate(pmlmepriv, _FW_LINKED) == true &&
is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network, 0)) {
@@ -331,51 +315,26 @@ static char *translate_scan(struct adapter *padapter,
}
- #ifdef CONFIG_SIGNAL_DISPLAY_DBM
- iwe.u.qual.level = (u8)translate_percentage_to_dbm(ss);/* dbm */
- #else
- #ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
- {
- /* Do signal scale mapping when using percentage as the unit of signal strength, since the scale mapping is skipped in odm */
-
- struct hal_com_data *pHal = GET_HAL_DATA(padapter);
-
- iwe.u.qual.level = (u8)odm_SignalScaleMapping(&pHal->odmpriv, ss);
- }
- #else
iwe.u.qual.level = (u8)ss;/* */
- #endif
- #endif
iwe.u.qual.qual = (u8)sq; /* signal quality */
- #if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
- {
- s16 tmp_noise = 0;
- rtw_hal_get_odm_var(padapter, HAL_ODM_NOISE_MONITOR, &(pnetwork->network.Configuration.DSConfig), &(tmp_noise));
- iwe.u.qual.noise = tmp_noise;
- }
- #else
iwe.u.qual.noise = 0; /* noise level */
- #endif
-
- /* DBG_871X("iqual =%d, ilevel =%d, inoise =%d, iupdated =%d\n", iwe.u.qual.qual, iwe.u.qual.level , iwe.u.qual.noise, iwe.u.qual.updated); */
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN);
{
u8 *buf;
- u8 *p, *pos;
+ u8 *pos;
buf = kzalloc(MAX_WPA_IE_LEN, GFP_ATOMIC);
if (!buf)
goto exit;
- p = buf;
+
pos = pnetwork->network.Reserved;
- p += sprintf(p, "fm =%02X%02X", pos[1], pos[0]);
memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVCUSTOM;
- iwe.u.data.length = strlen(buf);
+ iwe.u.data.length = scnprintf(buf, MAX_WPA_IE_LEN, "fm =%02X%02X", pos[1], pos[0]);
start = iwe_stream_add_point(info, start, stop, &iwe, buf);
kfree(buf);
}
@@ -391,27 +350,21 @@ static int wpa_set_auth_algs(struct net_device *dev, u32 value)
int ret = 0;
if ((value & WLAN_AUTH_SHARED_KEY) && (value & WLAN_AUTH_OPEN)) {
- DBG_871X("wpa_set_auth_algs, WLAN_AUTH_SHARED_KEY and WLAN_AUTH_OPEN [value:0x%x]\n", value);
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeAutoSwitch;
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Auto;
} else if (value & WLAN_AUTH_SHARED_KEY) {
- DBG_871X("wpa_set_auth_algs, WLAN_AUTH_SHARED_KEY [value:0x%x]\n", value);
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeShared;
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared;
} else if (value & WLAN_AUTH_OPEN) {
- DBG_871X("wpa_set_auth_algs, WLAN_AUTH_OPEN\n");
/* padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; */
if (padapter->securitypriv.ndisauthtype < Ndis802_11AuthModeWPAPSK) {
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
}
- } else if (value & WLAN_AUTH_LEAP) {
- DBG_871X("wpa_set_auth_algs, WLAN_AUTH_LEAP\n");
} else {
- DBG_871X("wpa_set_auth_algs, error!\n");
ret = -EINVAL;
}
@@ -452,8 +405,6 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
}
if (strcmp(param->u.crypt.alg, "WEP") == 0) {
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("wpa_set_encryption, crypt.alg = WEP\n"));
- DBG_871X("wpa_set_encryption, crypt.alg = WEP\n");
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_;
@@ -462,22 +413,15 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
wep_key_idx = param->u.crypt.idx;
wep_key_len = param->u.crypt.key_len;
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(1)wep_key_idx =%d\n", wep_key_idx));
- DBG_871X("(1)wep_key_idx =%d\n", wep_key_idx);
-
if (wep_key_idx > WEP_KEYS)
return -EINVAL;
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(2)wep_key_idx =%d\n", wep_key_idx));
-
if (wep_key_len > 0) {
wep_key_len = wep_key_len <= 5 ? 5 : 13;
wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
pwep = kzalloc(wep_total_len, GFP_KERNEL);
- if (pwep == NULL) {
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n"));
+ if (!pwep)
goto exit;
- }
pwep->KeyLength = wep_key_len;
pwep->Length = wep_total_len;
@@ -497,13 +441,9 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength);
if (param->u.crypt.set_tx) {
- DBG_871X("wep, set_tx = 1\n");
-
if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL)
ret = -EOPNOTSUPP;
} else {
- DBG_871X("wep, set_tx = 0\n");
-
/* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */
/* psecuritypriv->dot11PrivacyKeyIndex =keyid", but can rtw_set_key to fw/cam */
@@ -550,9 +490,6 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
/* _set_timer(&padapter->securitypriv.tkip_timer, 50); */
}
- /* DEBUG_ERR((" param->u.crypt.key_len =%d\n", param->u.crypt.key_len)); */
- DBG_871X(" ~~~~set sta key:unicastkey\n");
-
rtw_setstakey_cmd(padapter, psta, true, true);
} else { /* group key */
if (strcmp(param->u.crypt.alg, "TKIP") == 0 || strcmp(param->u.crypt.alg, "CCMP") == 0) {
@@ -563,8 +500,6 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8);
}
padapter->securitypriv.binstallGrpkey = true;
- /* DEBUG_ERR((" param->u.crypt.key_len =%d\n", param->u.crypt.key_len)); */
- DBG_871X(" ~~~~set sta key:groupkey\n");
padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx;
@@ -579,7 +514,6 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
printk("\n");*/
padapter->securitypriv.dot11wBIPKeyid = param->u.crypt.idx;
padapter->securitypriv.binstallBIPkey = true;
- DBG_871X(" ~~~~set sta key:IGKT\n");
}
}
}
@@ -632,16 +566,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
memcpy(buf, pie, ielen);
- /* dump */
- {
- int i;
- DBG_871X("\n wpa_ie(length:%d):\n", ielen);
- for (i = 0; i < ielen; i = i + 8)
- DBG_871X("0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", buf[i], buf[i+1], buf[i+2], buf[i+3], buf[i+4], buf[i+5], buf[i+6], buf[i+7]);
- }
-
if (ielen < RSN_HEADER_LEN) {
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("Ie len too short %d\n", ielen));
ret = -1;
goto exit;
}
@@ -718,8 +643,6 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
eid = buf[cnt];
if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&buf[cnt+2], wps_oui, 4))) {
- DBG_871X("SET WPS_IE\n");
-
padapter->securitypriv.wps_ie_len = ((buf[cnt+1]+2) < MAX_WPS_IE_LEN) ? (buf[cnt+1]+2):MAX_WPS_IE_LEN;
memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len);
@@ -744,10 +667,6 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
/* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true) */
rtw_hal_set_hwreg(padapter, HW_VAR_OFF_RCR_AM, null_addr);
- 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));
-
exit:
kfree(buf);
@@ -767,8 +686,6 @@ static int rtw_wx_get_name(struct net_device *dev,
struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
NDIS_802_11_RATES_EX *prates = NULL;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("cmd_code =%x\n", info->cmd));
-
if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) {
/* parsing HT_CAP_IE */
p = rtw_get_ie(&pcur_bss->IEs[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pcur_bss->IELength-12);
@@ -814,8 +731,6 @@ static int rtw_wx_set_freq(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_wx_set_freq\n"));
-
return 0;
}
@@ -846,7 +761,7 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
union iwreq_data *wrqu, char *b)
{
struct adapter *padapter = rtw_netdev_priv(dev);
- enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType;
+ enum ndis_802_11_network_infrastructure networkType;
int ret = 0;
if (_FAIL == rtw_pwr_wakeup(padapter)) {
@@ -862,24 +777,19 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
switch (wrqu->mode) {
case IW_MODE_AUTO:
networkType = Ndis802_11AutoUnknown;
- DBG_871X("set_mode = IW_MODE_AUTO\n");
break;
case IW_MODE_ADHOC:
networkType = Ndis802_11IBSS;
- DBG_871X("set_mode = IW_MODE_ADHOC\n");
break;
case IW_MODE_MASTER:
networkType = Ndis802_11APMode;
- DBG_871X("set_mode = IW_MODE_MASTER\n");
/* rtw_setopmode_cmd(padapter, networkType, true); */
break;
case IW_MODE_INFRA:
networkType = Ndis802_11Infrastructure;
- DBG_871X("set_mode = IW_MODE_INFRA\n");
break;
default:
ret = -EINVAL;
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("\n Mode: %s is not supported \n", iw_operation_mode[wrqu->mode]));
goto exit;
}
@@ -913,8 +823,6 @@ static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
struct adapter *padapter = rtw_netdev_priv(dev);
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_get_mode\n"));
-
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
wrqu->mode = IW_MODE_INFRA;
} else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
@@ -950,7 +858,6 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN);
if (pPMK->cmd == IW_PMKSA_ADD) {
- DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_ADD!\n");
if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN))
return intReturn;
else
@@ -961,8 +868,6 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
/* overwrite PMKID */
for (j = 0; j < NUM_PMKID_CACHE; j++) {
if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) {
- /* BSSID is matched, the same AP => rewrite with new PMKID. */
- DBG_871X("[rtw_wx_set_pmkid] BSSID exists in the PMKList.\n");
memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN);
psecuritypriv->PMKIDList[j].bUsed = true;
@@ -973,9 +878,6 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
}
if (!blInserted) {
- /* Find a new entry */
- DBG_871X("[rtw_wx_set_pmkid] Use the new entry index = %d for this PMKID.\n",
- psecuritypriv->PMKIDIndex);
memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].Bssid, strIssueBssid, ETH_ALEN);
memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].PMKID, pPMK->pmkid, IW_PMKID_LEN);
@@ -986,7 +888,6 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
psecuritypriv->PMKIDIndex = 0;
}
} else if (pPMK->cmd == IW_PMKSA_REMOVE) {
- DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n");
intReturn = true;
for (j = 0; j < NUM_PMKID_CACHE; j++) {
if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) {
@@ -997,8 +898,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
}
}
} else if (pPMK->cmd == IW_PMKSA_FLUSH) {
- DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n");
- memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
+ memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
psecuritypriv->PMKIDIndex = 0;
intReturn = true;
}
@@ -1028,8 +928,6 @@ static int rtw_wx_get_range(struct net_device *dev,
u16 val;
int i;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_range. cmd_code =%x\n", info->cmd));
-
wrqu->data.length = sizeof(*range);
memset(range, 0, sizeof(*range));
@@ -1132,7 +1030,7 @@ static int rtw_wx_set_wap(struct net_device *dev,
u8 *dst_bssid, *src_bssid;
struct __queue *queue = &(pmlmepriv->scanned_queue);
struct wlan_network *pnetwork = NULL;
- enum NDIS_802_11_AUTHENTICATION_MODE authmode;
+ enum ndis_802_11_authentication_mode authmode;
rtw_ps_deny(padapter, PS_DENY_JOIN);
if (_FAIL == rtw_pwr_wakeup(padapter)) {
@@ -1207,8 +1105,6 @@ static int rtw_wx_get_wap(struct net_device *dev,
eth_zero_addr(wrqu->ap_addr.sa_data);
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_wap\n"));
-
if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) ||
((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) ||
((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) {
@@ -1225,7 +1121,6 @@ static int rtw_wx_set_mlme(struct net_device *dev,
union iwreq_data *wrqu, char *extra)
{
int ret = 0;
- u16 reason;
struct adapter *padapter = rtw_netdev_priv(dev);
struct iw_mlme *mlme = (struct iw_mlme *)extra;
@@ -1233,12 +1128,6 @@ static int rtw_wx_set_mlme(struct net_device *dev,
if (mlme == NULL)
return -1;
- DBG_871X("%s\n", __func__);
-
- reason = mlme->reason_code;
-
- DBG_871X("%s, cmd =%d, reason =%d\n", __func__, mlme->cmd, reason);
-
switch (mlme->cmd) {
case IW_MLME_DEAUTH:
if (!rtw_set_802_11_disassociate(padapter))
@@ -1263,11 +1152,6 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
struct adapter *padapter = rtw_netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_set_scan\n"));
-
- #ifdef DBG_IOCTL
- DBG_871X("DBG_IOCTL %s:%d\n", __func__, __LINE__);
- #endif
rtw_ps_deny(padapter, PS_DENY_SCAN);
if (_FAIL == rtw_pwr_wakeup(padapter)) {
@@ -1276,7 +1160,6 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
}
if (padapter->bDriverStopped) {
- DBG_871X("bDriverStopped =%d\n", padapter->bDriverStopped);
ret = -1;
goto exit;
}
@@ -1315,16 +1198,12 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
memcpy(ssid[0].Ssid, req->essid, len);
ssid[0].SsidLength = len;
- DBG_871X("IW_SCAN_THIS_ESSID, ssid =%s, len =%d\n", req->essid, req->essid_len);
-
spin_lock_bh(&pmlmepriv->lock);
_status = rtw_sitesurvey_cmd(padapter, ssid, 1, NULL, 0);
spin_unlock_bh(&pmlmepriv->lock);
- } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) {
- DBG_871X("rtw_wx_set_scan, req->scan_type == IW_SCAN_TYPE_PASSIVE\n");
}
} else if (wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE
@@ -1335,14 +1214,11 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
char sec_len;
int ssid_index = 0;
- /* DBG_871X("%s COMBO_SCAN header is recognized\n", __func__); */
-
while (len >= 1) {
section = *(pos++); len -= 1;
switch (section) {
case WEXT_CSCAN_SSID_SECTION:
- /* DBG_871X("WEXT_CSCAN_SSID_SECTION\n"); */
if (len < 1) {
len = 0;
break;
@@ -1353,8 +1229,6 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
if (sec_len > 0 && sec_len <= len) {
ssid[ssid_index].SsidLength = sec_len;
memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength);
- /* DBG_871X("%s COMBO_SCAN with specific ssid:%s, %d\n", __func__ */
- /* , ssid[ssid_index].Ssid, ssid[ssid_index].SsidLength); */
ssid_index++;
}
@@ -1363,31 +1237,23 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
case WEXT_CSCAN_CHANNEL_SECTION:
- /* DBG_871X("WEXT_CSCAN_CHANNEL_SECTION\n"); */
pos += 1; len -= 1;
break;
case WEXT_CSCAN_ACTV_DWELL_SECTION:
- /* DBG_871X("WEXT_CSCAN_ACTV_DWELL_SECTION\n"); */
pos += 2; len -= 2;
break;
case WEXT_CSCAN_PASV_DWELL_SECTION:
- /* DBG_871X("WEXT_CSCAN_PASV_DWELL_SECTION\n"); */
pos += 2; len -= 2;
break;
case WEXT_CSCAN_HOME_DWELL_SECTION:
- /* DBG_871X("WEXT_CSCAN_HOME_DWELL_SECTION\n"); */
pos += 2; len -= 2;
break;
case WEXT_CSCAN_TYPE_SECTION:
- /* DBG_871X("WEXT_CSCAN_TYPE_SECTION\n"); */
pos += 1; len -= 1;
break;
default:
- /* DBG_871X("Unknown CSCAN section %c\n", section); */
len = 0; /* stop parsing */
}
- /* DBG_871X("len:%d\n", len); */
-
}
/* jeff: it has still some scan parameter to parse, we only do this now... */
@@ -1404,10 +1270,6 @@ exit:
rtw_ps_deny_cancel(padapter, PS_DENY_SCAN);
- #ifdef DBG_IOCTL
- DBG_871X("DBG_IOCTL %s:%d return %d\n", __func__, __LINE__, ret);
- #endif
-
return ret;
}
@@ -1422,14 +1284,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
char *ev = extra;
char *stop = ev + wrqu->data.length;
u32 ret = 0;
- sint wait_status;
-
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan\n"));
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, (" Start of Query SIOCGIWSCAN .\n"));
-
- #ifdef DBG_IOCTL
- DBG_871X("DBG_IOCTL %s:%d\n", __func__, __LINE__);
- #endif
+ signed int wait_status;
if (adapter_to_pwrctl(padapter)->brfoffbyhw && padapter->bDriverStopped) {
ret = -EINVAL;
@@ -1476,10 +1331,6 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
exit:
- #ifdef DBG_IOCTL
- DBG_871X("DBG_IOCTL %s:%d return %d\n", __func__, __LINE__, ret);
- #endif
-
return ret;
}
@@ -1498,19 +1349,12 @@ static int rtw_wx_set_essid(struct net_device *dev,
struct __queue *queue = &pmlmepriv->scanned_queue;
struct list_head *phead;
struct wlan_network *pnetwork = NULL;
- enum NDIS_802_11_AUTHENTICATION_MODE authmode;
+ enum ndis_802_11_authentication_mode authmode;
struct ndis_802_11_ssid ndis_ssid;
u8 *dst_ssid, *src_ssid;
uint ret = 0, len;
- #ifdef DBG_IOCTL
- DBG_871X("DBG_IOCTL %s:%d\n", __func__, __LINE__);
- #endif
-
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
- ("+rtw_wx_set_essid: fw_state = 0x%08x\n", get_fwstate(pmlmepriv)));
-
rtw_ps_deny(padapter, PS_DENY_JOIN);
if (_FAIL == rtw_pwr_wakeup(padapter)) {
ret = -1;
@@ -1533,30 +1377,21 @@ static int rtw_wx_set_essid(struct net_device *dev,
}
authmode = padapter->securitypriv.ndisauthtype;
- DBG_871X("=>%s\n", __func__);
if (wrqu->essid.flags && wrqu->essid.length) {
len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE;
- if (wrqu->essid.length != 33)
- DBG_871X("ssid =%s, len =%d\n", extra, wrqu->essid.length);
-
memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid));
ndis_ssid.SsidLength = len;
memcpy(ndis_ssid.Ssid, extra, len);
src_ssid = ndis_ssid.Ssid;
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_wx_set_essid: ssid =[%s]\n", src_ssid));
spin_lock_bh(&queue->lock);
phead = get_list_head(queue);
pmlmepriv->pscanned = get_next(phead);
while (1) {
- if (phead == pmlmepriv->pscanned) {
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_warning_,
- ("rtw_wx_set_essid: scan_q is empty, set ssid to check if scanning again!\n"));
-
+ if (phead == pmlmepriv->pscanned)
break;
- }
pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list);
@@ -1564,15 +1399,8 @@ static int rtw_wx_set_essid(struct net_device *dev,
dst_ssid = pnetwork->network.Ssid.Ssid;
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
- ("rtw_wx_set_essid: dst_ssid =%s\n",
- pnetwork->network.Ssid.Ssid));
-
if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) &&
(pnetwork->network.Ssid.SsidLength == ndis_ssid.SsidLength)) {
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
- ("rtw_wx_set_essid: find match, set infra mode\n"));
-
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) {
if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode)
continue;
@@ -1588,8 +1416,6 @@ static int rtw_wx_set_essid(struct net_device *dev,
}
}
spin_unlock_bh(&queue->lock);
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
- ("set ssid: set_802_11_auth. mode =%d\n", authmode));
rtw_set_802_11_authentication_mode(padapter, authmode);
/* set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); */
if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false) {
@@ -1602,12 +1428,6 @@ exit:
rtw_ps_deny_cancel(padapter, PS_DENY_JOIN);
- DBG_871X("<=%s, ret %d\n", __func__, ret);
-
- #ifdef DBG_IOCTL
- DBG_871X("DBG_IOCTL %s:%d return %d\n", __func__, __LINE__, ret);
- #endif
-
return ret;
}
@@ -1620,8 +1440,6 @@ static int rtw_wx_get_essid(struct net_device *dev,
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_essid\n"));
-
if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
len = pcur_bss->Ssid.SsidLength;
@@ -1652,9 +1470,6 @@ static int rtw_wx_set_rate(struct net_device *dev,
u32 ratevalue = 0;
u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff};
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_set_rate\n"));
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("target_rate = %d, fixed = %d\n", target_rate, fixed));
-
if (target_rate == -1) {
ratevalue = 11;
goto set_rate;
@@ -1713,14 +1528,11 @@ set_rate:
} else {
datarates[i] = 0xff;
}
-
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("datarate_inx =%d\n", datarates[i]));
}
- if (rtw_setdatarate_cmd(padapter, datarates) != _SUCCESS) {
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("rtw_wx_set_rate Fail!!!\n"));
+ if (rtw_setdatarate_cmd(padapter, datarates) != _SUCCESS)
ret = -1;
- }
+
return ret;
}
@@ -1757,8 +1569,6 @@ static int rtw_wx_set_rts(struct net_device *dev,
padapter->registrypriv.rts_thresh = wrqu->rts.value;
}
- DBG_871X("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh);
-
return 0;
}
@@ -1768,8 +1578,6 @@ static int rtw_wx_get_rts(struct net_device *dev,
{
struct adapter *padapter = rtw_netdev_priv(dev);
- DBG_871X("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh);
-
wrqu->rts.value = padapter->registrypriv.rts_thresh;
wrqu->rts.fixed = 0; /* no auto select */
/* wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); */
@@ -1793,8 +1601,6 @@ static int rtw_wx_set_frag(struct net_device *dev,
padapter->xmitpriv.frag_len = wrqu->frag.value & ~0x1;
}
- DBG_871X("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len);
-
return 0;
}
@@ -1805,8 +1611,6 @@ static int rtw_wx_get_frag(struct net_device *dev,
{
struct adapter *padapter = rtw_netdev_priv(dev);
- DBG_871X("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len);
-
wrqu->frag.value = padapter->xmitpriv.frag_len;
wrqu->frag.fixed = 0; /* no auto select */
/* wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FRAG_THRESHOLD); */
@@ -1836,19 +1640,17 @@ static int rtw_wx_set_enc(struct net_device *dev,
u32 key, ret = 0;
u32 keyindex_provided;
struct ndis_802_11_wep wep;
- enum NDIS_802_11_AUTHENTICATION_MODE authmode;
+ enum ndis_802_11_authentication_mode authmode;
struct iw_point *erq = &(wrqu->encoding);
struct adapter *padapter = rtw_netdev_priv(dev);
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
- DBG_871X("+rtw_wx_set_enc, flags = 0x%x\n", erq->flags);
memset(&wep, 0, sizeof(struct ndis_802_11_wep));
key = erq->flags & IW_ENCODE_INDEX;
if (erq->flags & IW_ENCODE_DISABLED) {
- DBG_871X("EncryptionDisabled\n");
padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled;
padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_;
@@ -1867,12 +1669,10 @@ static int rtw_wx_set_enc(struct net_device *dev,
} else {
keyindex_provided = 0;
key = padapter->securitypriv.dot11PrivacyKeyIndex;
- DBG_871X("rtw_wx_set_enc, key =%d\n", key);
}
/* set authentication mode */
if (erq->flags & IW_ENCODE_OPEN) {
- DBG_871X("rtw_wx_set_enc():IW_ENCODE_OPEN\n");
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
@@ -1882,7 +1682,6 @@ static int rtw_wx_set_enc(struct net_device *dev,
authmode = Ndis802_11AuthModeOpen;
padapter->securitypriv.ndisauthtype = authmode;
} else if (erq->flags & IW_ENCODE_RESTRICTED) {
- DBG_871X("rtw_wx_set_enc():IW_ENCODE_RESTRICTED\n");
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared;
@@ -1892,8 +1691,6 @@ static int rtw_wx_set_enc(struct net_device *dev,
authmode = Ndis802_11AuthModeShared;
padapter->securitypriv.ndisauthtype = authmode;
} else {
- DBG_871X("rtw_wx_set_enc():erq->flags = 0x%x\n", erq->flags);
-
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
@@ -1913,8 +1710,6 @@ static int rtw_wx_set_enc(struct net_device *dev,
if (keyindex_provided == 1) { /* set key_id only, no given KeyMaterial(erq->length == 0). */
padapter->securitypriv.dot11PrivacyKeyIndex = key;
- DBG_871X("(keyindex_provided == 1), keyid =%d, key_len =%d\n", key, padapter->securitypriv.dot11DefKeylen[key]);
-
switch (padapter->securitypriv.dot11DefKeylen[key]) {
case 5:
padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_;
@@ -2103,7 +1898,6 @@ static int rtw_wx_set_auth(struct net_device *dev,
if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) {
LeaveAllPowerSaveMode(padapter);
rtw_disassoc_cmd(padapter, 500, false);
- DBG_871X("%s...call rtw_indicate_disconnect\n ", __func__);
rtw_indicate_disconnect(padapter);
rtw_free_assoc_resources(padapter, 1);
}
@@ -2269,11 +2063,9 @@ static int rtw_wx_read32(struct net_device *dev,
sprintf(extra, "0x%08X", data32);
break;
default:
- DBG_871X(KERN_INFO "%s: usage> read [bytes],[address(hex)]\n", __func__);
ret = -EINVAL;
goto exit;
}
- DBG_871X(KERN_INFO "%s: addr = 0x%08X data =%s\n", __func__, addr, extra);
exit:
kfree(ptmp);
@@ -2300,18 +2092,14 @@ static int rtw_wx_write32(struct net_device *dev,
switch (bytes) {
case 1:
rtw_write8(padapter, addr, (u8)data32);
- DBG_871X(KERN_INFO "%s: addr = 0x%08X data = 0x%02X\n", __func__, addr, (u8)data32);
break;
case 2:
rtw_write16(padapter, addr, (u16)data32);
- DBG_871X(KERN_INFO "%s: addr = 0x%08X data = 0x%04X\n", __func__, addr, (u16)data32);
break;
case 4:
rtw_write32(padapter, addr, data32);
- DBG_871X(KERN_INFO "%s: addr = 0x%08X data = 0x%08X\n", __func__, addr, data32);
break;
default:
- DBG_871X(KERN_INFO "%s: usage> write [bytes],[address(hex)],[data(hex)]\n", __func__);
return -EINVAL;
}
@@ -2350,7 +2138,6 @@ static int rtw_wx_write_rf(struct net_device *dev,
path = *(u32 *)extra;
addr = *((u32 *)extra + 1);
data32 = *((u32 *)extra + 2);
-/* DBG_871X("%s: path =%d addr = 0x%02x data = 0x%05x\n", __func__, path, addr, data32); */
rtw_hal_write_rfreg(padapter, path, addr, 0xFFFFF, data32);
return 0;
@@ -2368,8 +2155,6 @@ static int dummy(struct net_device *dev, struct iw_request_info *a,
/* struct adapter *padapter = rtw_netdev_priv(dev); */
/* struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); */
- /* DBG_871X("cmd_code =%x, fwstate = 0x%x\n", a->cmd, get_fwstate(pmlmepriv)); */
-
return -1;
}
@@ -2381,9 +2166,7 @@ static int rtw_wx_set_channel_plan(struct net_device *dev,
struct adapter *padapter = rtw_netdev_priv(dev);
u8 channel_plan_req = (u8)(*((int *)wrqu));
- if (_SUCCESS == rtw_set_chplan_cmd(padapter, channel_plan_req, 1, 1))
- DBG_871X("%s set channel_plan = 0x%02X\n", __func__, channel_plan_req);
- else
+ if (rtw_set_chplan_cmd(padapter, channel_plan_req, 1, 1) != _SUCCESS)
return -EPERM;
return 0;
@@ -2441,8 +2224,6 @@ static int rtw_get_ap_info(struct net_device *dev,
struct __queue *queue = &(pmlmepriv->scanned_queue);
struct iw_point *pdata = &wrqu->data;
- DBG_871X("+rtw_get_aplist_info\n");
-
if ((padapter->bDriverStopped) || (pdata == NULL)) {
ret = -EINVAL;
goto exit;
@@ -2481,14 +2262,12 @@ static int rtw_get_ap_info(struct net_device *dev,
pnetwork = container_of(plist, struct wlan_network, list);
if (!mac_pton(data, bssid)) {
- DBG_871X("Invalid BSSID '%s'.\n", (u8 *)data);
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
return -EINVAL;
}
if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) { /* BSSID match, then check if supporting wpa/wpa2 */
- DBG_871X("BSSID:%pM\n", MAC_ARG(bssid));
pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12);
if (pbuf && (wpa_ielen > 0)) {
@@ -2538,12 +2317,8 @@ static int rtw_set_pid(struct net_device *dev,
}
selector = *pdata;
- if (selector < 3 && selector >= 0) {
+ if (selector < 3 && selector >= 0)
padapter->pid[selector] = *(pdata+1);
- DBG_871X("%s set pid[%d]=%d\n", __func__, selector, padapter->pid[selector]);
- }
- else
- DBG_871X("%s selector %d error\n", __func__, selector);
exit:
@@ -2573,8 +2348,6 @@ static int rtw_wps_start(struct net_device *dev,
if (u32wps_start == 0)
u32wps_start = *extra;
- DBG_871X("[%s] wps_start = %d\n", __func__, u32wps_start);
-
exit:
return ret;
@@ -2625,7 +2398,6 @@ static int rtw_rereg_nd_name(struct net_device *dev,
rereg_priv->old_ifname[IFNAMSIZ-1] = 0;
}
- /* DBG_871X("%s wrqu->data.length:%d\n", __func__, wrqu->data.length); */
if (wrqu->data.length > IFNAMSIZ)
return -EFAULT;
@@ -2635,21 +2407,18 @@ static int rtw_rereg_nd_name(struct net_device *dev,
if (0 == strcmp(rereg_priv->old_ifname, new_ifname))
return ret;
- DBG_871X("%s new_ifname:%s\n", __func__, new_ifname);
- if (0 != (ret = rtw_change_ifname(padapter, new_ifname)))
+ ret = rtw_change_ifname(padapter, new_ifname);
+ if (ret != 0)
goto exit;
strncpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ);
rereg_priv->old_ifname[IFNAMSIZ-1] = 0;
if (!memcmp(new_ifname, "disable%d", 9)) {
-
- DBG_871X("%s disable\n", __func__);
/* free network queue for Android's timming issue */
rtw_free_network_queue(padapter, true);
/* the interface is being "disabled", we can do deeper IPS */
- /* rereg_priv->old_ips_mode = rtw_get_ips_mode_req(&padapter->pwrctrlpriv); */
/* rtw_ips_mode_req(&padapter->pwrctrlpriv, IPS_NORMAL); */
}
exit:
@@ -2664,14 +2433,9 @@ static int rtw_dbg_port(struct net_device *dev,
u8 major_cmd, minor_cmd;
u16 arg;
u32 extra_arg, *pdata, val32;
- struct sta_info *psta;
struct adapter *padapter = rtw_netdev_priv(dev);
- struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- struct wlan_network *cur_network = &(pmlmepriv->cur_network);
- struct sta_priv *pstapriv = &padapter->stapriv;
-
pdata = (u32 *)&wrqu->data;
@@ -2686,13 +2450,10 @@ static int rtw_dbg_port(struct net_device *dev,
case 0x70:/* read_reg */
switch (minor_cmd) {
case 1:
- DBG_871X("rtw_read8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg));
break;
case 2:
- DBG_871X("rtw_read16(0x%x) = 0x%04x\n", arg, rtw_read16(padapter, arg));
break;
case 4:
- DBG_871X("rtw_read32(0x%x) = 0x%08x\n", arg, rtw_read32(padapter, arg));
break;
}
break;
@@ -2700,31 +2461,24 @@ static int rtw_dbg_port(struct net_device *dev,
switch (minor_cmd) {
case 1:
rtw_write8(padapter, arg, extra_arg);
- DBG_871X("rtw_write8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg));
break;
case 2:
rtw_write16(padapter, arg, extra_arg);
- DBG_871X("rtw_write16(0x%x) = 0x%04x\n", arg, rtw_read16(padapter, arg));
break;
case 4:
rtw_write32(padapter, arg, extra_arg);
- DBG_871X("rtw_write32(0x%x) = 0x%08x\n", arg, rtw_read32(padapter, arg));
break;
}
break;
case 0x72:/* read_bb */
- DBG_871X("read_bbreg(0x%x) = 0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff));
break;
case 0x73:/* write_bb */
rtw_hal_write_bbreg(padapter, arg, 0xffffffff, extra_arg);
- DBG_871X("write_bbreg(0x%x) = 0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff));
break;
case 0x74:/* read_rf */
- DBG_871X("read RF_reg path(0x%02x), offset(0x%x), value(0x%08x)\n", minor_cmd, arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff));
break;
case 0x75:/* write_rf */
rtw_hal_write_rfreg(padapter, minor_cmd, arg, 0xffffffff, extra_arg);
- DBG_871X("write RF_reg path(0x%02x), offset(0x%x), value(0x%08x)\n", minor_cmd, arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff));
break;
case 0x76:
@@ -2751,8 +2505,6 @@ static int rtw_dbg_port(struct net_device *dev,
u8 sign = minor_cmd;
u16 write_value = 0;
- DBG_871X("%s set RESP_TXAGC to %s %u\n", __func__, sign?"minus":"plus", value);
-
if (sign)
value = value | 0x10;
@@ -2767,124 +2519,33 @@ static int rtw_dbg_port(struct net_device *dev,
case 0x7F:
switch (minor_cmd) {
case 0x0:
- DBG_871X("fwstate = 0x%x\n", get_fwstate(pmlmepriv));
break;
case 0x01:
- DBG_871X("minor_cmd 0x%x\n", minor_cmd);
break;
case 0x02:
- DBG_871X("pmlmeinfo->state = 0x%x\n", pmlmeinfo->state);
- DBG_871X("DrvBcnEarly =%d\n", pmlmeext->DrvBcnEarly);
- DBG_871X("DrvBcnTimeOut =%d\n", pmlmeext->DrvBcnTimeOut);
break;
case 0x03:
- DBG_871X("qos_option =%d\n", pmlmepriv->qospriv.qos_option);
- DBG_871X("ht_option =%d\n", pmlmepriv->htpriv.ht_option);
break;
case 0x04:
- DBG_871X("cur_ch =%d\n", pmlmeext->cur_channel);
- DBG_871X("cur_bw =%d\n", pmlmeext->cur_bwmode);
- DBG_871X("cur_ch_off =%d\n", pmlmeext->cur_ch_offset);
-
- DBG_871X("oper_ch =%d\n", rtw_get_oper_ch(padapter));
- DBG_871X("oper_bw =%d\n", rtw_get_oper_bw(padapter));
- DBG_871X("oper_ch_offset =%d\n", rtw_get_oper_choffset(padapter));
break;
case 0x05:
- psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress);
- if (psta) {
- int i;
- struct recv_reorder_ctrl *preorder_ctrl;
-
- DBG_871X("SSID =%s\n", cur_network->network.Ssid.Ssid);
- DBG_871X("sta's macaddr:%pM\n", MAC_ARG(psta->hwaddr));
- DBG_871X("cur_channel =%d, cur_bwmode =%d, cur_ch_offset =%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset);
- DBG_871X("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self);
- DBG_871X("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid);
- DBG_871X("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate);
- DBG_871X("bwmode =%d, ch_offset =%d, sgi_20m =%d, sgi_40m =%d\n", psta->bw_mode, psta->htpriv.ch_offset, psta->htpriv.sgi_20m, psta->htpriv.sgi_40m);
- DBG_871X("ampdu_enable = %d\n", psta->htpriv.ampdu_enable);
- DBG_871X("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap);
-
- for (i = 0; i < 16; i++) {
- preorder_ctrl = &psta->recvreorder_ctrl[i];
- if (preorder_ctrl->enable)
- DBG_871X("tid =%d, indicate_seq =%d\n", i, preorder_ctrl->indicate_seq);
- }
-
- } else {
- DBG_871X("can't get sta's macaddr, cur_network's macaddr:%pM\n", MAC_ARG(cur_network->network.MacAddress));
- }
break;
case 0x06:
{
u32 ODMFlag;
rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag));
- DBG_871X("(B)DMFlag = 0x%x, arg = 0x%x\n", ODMFlag, arg);
ODMFlag = (u32)(0x0f&arg);
- DBG_871X("(A)DMFlag = 0x%x\n", ODMFlag);
rtw_hal_set_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag));
}
break;
case 0x07:
- DBG_871X("bSurpriseRemoved =%d, bDriverStopped =%d\n",
- padapter->bSurpriseRemoved, padapter->bDriverStopped);
break;
case 0x08:
{
- DBG_871X("minor_cmd 0x%x\n", minor_cmd);
}
break;
case 0x09:
- {
- int i, j;
- struct list_head *plist, *phead;
- struct recv_reorder_ctrl *preorder_ctrl;
-
- DBG_871X("sta_dz_bitmap = 0x%x, tim_bitmap = 0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap);
-
- spin_lock_bh(&pstapriv->sta_hash_lock);
-
- for (i = 0; i < NUM_STA; i++) {
- phead = &(pstapriv->sta_hash[i]);
- plist = get_next(phead);
-
- while (phead != plist) {
- psta = container_of(plist, struct sta_info, hash_list);
-
- plist = get_next(plist);
-
- if (extra_arg == psta->aid) {
- DBG_871X("sta's macaddr:%pM\n", MAC_ARG(psta->hwaddr));
- DBG_871X("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self);
- DBG_871X("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid);
- DBG_871X("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate);
- DBG_871X("bwmode =%d, ch_offset =%d, sgi_20m =%d, sgi_40m =%d\n", psta->bw_mode, psta->htpriv.ch_offset, psta->htpriv.sgi_20m, psta->htpriv.sgi_40m);
- DBG_871X("ampdu_enable = %d\n", psta->htpriv.ampdu_enable);
- DBG_871X("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap);
- DBG_871X("capability = 0x%x\n", psta->capability);
- DBG_871X("flags = 0x%x\n", psta->flags);
- DBG_871X("wpa_psk = 0x%x\n", psta->wpa_psk);
- DBG_871X("wpa2_group_cipher = 0x%x\n", psta->wpa2_group_cipher);
- DBG_871X("wpa2_pairwise_cipher = 0x%x\n", psta->wpa2_pairwise_cipher);
- DBG_871X("qos_info = 0x%x\n", psta->qos_info);
- DBG_871X("dot118021XPrivacy = 0x%x\n", psta->dot118021XPrivacy);
-
-
-
- for (j = 0; j < 16; j++) {
- preorder_ctrl = &psta->recvreorder_ctrl[j];
- if (preorder_ctrl->enable)
- DBG_871X("tid =%d, indicate_seq =%d\n", j, preorder_ctrl->indicate_seq);
- }
- }
- }
- }
-
- spin_unlock_bh(&pstapriv->sta_hash_lock);
-
- }
break;
case 0x0a:
{
@@ -2895,10 +2556,8 @@ static int rtw_dbg_port(struct net_device *dev,
break;
case 0x0b: /* Enable = 1, Disable = 0 driver control vrtl_carrier_sense. */
if (arg == 0) {
- DBG_871X("disable driver ctrl vcs\n");
padapter->driver_vcs_en = 0;
} else if (arg == 1) {
- DBG_871X("enable driver ctrl vcs = %d\n", extra_arg);
padapter->driver_vcs_en = 1;
if (extra_arg > 2)
@@ -2909,25 +2568,19 @@ static int rtw_dbg_port(struct net_device *dev,
break;
case 0x0c:/* dump rx/tx packet */
{
- if (arg == 0) {
- DBG_871X("dump rx packet (%d)\n", extra_arg);
+ if (arg == 0)
/* pHalData->bDumpRxPkt =extra_arg; */
rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_RXPKT, &(extra_arg));
- } else if (arg == 1) {
- DBG_871X("dump tx packet (%d)\n", extra_arg);
+ else if (arg == 1)
rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(extra_arg));
- }
}
break;
case 0x0e:
{
if (arg == 0) {
- DBG_871X("disable driver ctrl rx_ampdu_factor\n");
padapter->driver_rx_ampdu_factor = 0xFF;
} else if (arg == 1) {
- DBG_871X("enable driver ctrl rx_ampdu_factor = %d\n", extra_arg);
-
if ((extra_arg & 0x03) > 0x03)
padapter->driver_rx_ampdu_factor = 0xFF;
else
@@ -2937,7 +2590,7 @@ static int rtw_dbg_port(struct net_device *dev,
break;
case 0x10:/* driver version display */
- dump_drv_version(RTW_DBGDUMP);
+ netdev_dbg(dev, "%s %s\n", "rtl8723bs", DRIVERVERSION);
break;
case 0x11:/* dump linked status */
{
@@ -2949,35 +2602,27 @@ static int rtw_dbg_port(struct net_device *dev,
struct registry_priv *pregpriv = &padapter->registrypriv;
/* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */
/* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */
- if (extra_arg == 0 || extra_arg == 1 || extra_arg == 2 || extra_arg == 3) {
+ if (extra_arg == 0 || extra_arg == 1 ||
+ extra_arg == 2 || extra_arg == 3)
pregpriv->rx_stbc = extra_arg;
- DBG_871X("set rx_stbc =%d\n", pregpriv->rx_stbc);
- } else
- DBG_871X("get rx_stbc =%d\n", pregpriv->rx_stbc);
-
}
break;
case 0x13: /* set ampdu_enable */
{
struct registry_priv *pregpriv = &padapter->registrypriv;
/* 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */
- if (extra_arg < 3) {
+ if (extra_arg < 3)
pregpriv->ampdu_enable = extra_arg;
- DBG_871X("set ampdu_enable =%d\n", pregpriv->ampdu_enable);
- } else
- DBG_871X("get ampdu_enable =%d\n", pregpriv->ampdu_enable);
-
}
break;
case 0x14:
{
- DBG_871X("minor_cmd 0x%x\n", minor_cmd);
}
break;
case 0x16:
{
if (arg == 0xff) {
- rtw_odm_dbg_comp_msg(RTW_DBGDUMP, padapter);
+ rtw_odm_dbg_comp_msg(padapter);
} else {
u64 dbg_comp = (u64)extra_arg;
rtw_odm_dbg_comp_set(padapter, dbg_comp);
@@ -3006,13 +2651,10 @@ static int rtw_dbg_port(struct net_device *dev,
/* extra_arg : */
/* BIT0: Enable VHT LDPC Rx, BIT1: Enable VHT LDPC Tx, */
/* BIT4: Enable HT LDPC Rx, BIT5: Enable HT LDPC Tx */
- if (arg == 0) {
- DBG_871X("driver disable LDPC\n");
+ if (arg == 0)
pregistrypriv->ldpc_cap = 0x00;
- } else if (arg == 1) {
- DBG_871X("driver set LDPC cap = 0x%x\n", extra_arg);
+ else if (arg == 1)
pregistrypriv->ldpc_cap = (u8)(extra_arg&0x33);
- }
}
break;
case 0x1a:
@@ -3021,13 +2663,10 @@ static int rtw_dbg_port(struct net_device *dev,
/* extra_arg : */
/* BIT0: Enable VHT STBC Rx, BIT1: Enable VHT STBC Tx, */
/* BIT4: Enable HT STBC Rx, BIT5: Enable HT STBC Tx */
- if (arg == 0) {
- DBG_871X("driver disable STBC\n");
+ if (arg == 0)
pregistrypriv->stbc_cap = 0x00;
- } else if (arg == 1) {
- DBG_871X("driver set STBC cap = 0x%x\n", extra_arg);
+ else if (arg == 1)
pregistrypriv->stbc_cap = (u8)(extra_arg&0x33);
- }
}
break;
case 0x1b:
@@ -3035,7 +2674,6 @@ static int rtw_dbg_port(struct net_device *dev,
struct registry_priv *pregistrypriv = &padapter->registrypriv;
if (arg == 0) {
- DBG_871X("disable driver ctrl max_rx_rate, reset to default_rate_set\n");
init_mlme_default_rate_set(padapter);
pregistrypriv->ht_enable = (u8)rtw_ht_enable;
} else if (arg == 1) {
@@ -3043,8 +2681,6 @@ static int rtw_dbg_port(struct net_device *dev,
int i;
u8 max_rx_rate;
- DBG_871X("enable driver ctrl max_rx_rate = 0x%x\n", extra_arg);
-
max_rx_rate = (u8)extra_arg;
if (max_rx_rate < 0xc) { /* max_rx_rate < MSC0 -> B or G -> disable HT */
@@ -3069,12 +2705,9 @@ static int rtw_dbg_port(struct net_device *dev,
case 0x1c: /* enable/disable driver control AMPDU Density for peer sta's rx */
{
if (arg == 0) {
- DBG_871X("disable driver ctrl ampdu density\n");
padapter->driver_ampdu_spacing = 0xFF;
} else if (arg == 1) {
- DBG_871X("enable driver ctrl ampdu density = %d\n", extra_arg);
-
if (extra_arg > 0x07)
padapter->driver_ampdu_spacing = 0xFF;
else
@@ -3082,26 +2715,8 @@ static int rtw_dbg_port(struct net_device *dev,
}
}
break;
-#ifdef CONFIG_BACKGROUND_NOISE_MONITOR
- case 0x1e:
- {
- struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
- PDM_ODM_T pDM_Odm = &pHalData->odmpriv;
- u8 chan = rtw_get_oper_ch(padapter);
- DBG_871X("===========================================\n");
- ODM_InbandNoise_Monitor(pDM_Odm, true, 0x1e, 100);
- DBG_871X("channel(%d), noise_a = %d, noise_b = %d , noise_all:%d\n",
- chan, pDM_Odm->noise_level.noise[ODM_RF_PATH_A],
- pDM_Odm->noise_level.noise[ODM_RF_PATH_B],
- pDM_Odm->noise_level.noise_all);
- DBG_871X("===========================================\n");
-
- }
- break;
-#endif
case 0x23:
{
- DBG_871X("turn %s the bNotifyChannelChange Variable\n", (extra_arg == 1)?"on":"off");
padapter->bNotifyChannelChange = extra_arg;
break;
}
@@ -3109,51 +2724,10 @@ static int rtw_dbg_port(struct net_device *dev,
{
break;
}
-#ifdef CONFIG_GPIO_API
- case 0x25: /* Get GPIO register */
- {
- /*
- * dbg 0x7f250000 [gpio_num], Get gpio value, gpio_num:0~7
- */
-
- int value;
- DBG_871X("Read GPIO Value extra_arg = %d\n", extra_arg);
- value = rtw_get_gpio(dev, extra_arg);
- DBG_871X("Read GPIO Value = %d\n", value);
- break;
- }
- case 0x26: /* Set GPIO direction */
- {
-
- /* dbg 0x7f26000x [y], Set gpio direction,
- * x: gpio_num, 4~7 y: indicate direction, 0~1
- */
-
- int value;
- DBG_871X("Set GPIO Direction! arg = %d , extra_arg =%d\n", arg, extra_arg);
- value = rtw_config_gpio(dev, arg, extra_arg);
- DBG_871X("Set GPIO Direction %s\n", (value == -1) ? "Fail!!!" : "Success");
- break;
- }
- case 0x27: /* Set GPIO output direction value */
- {
- /*
- * dbg 0x7f27000x [y], Set gpio output direction value,
- * x: gpio_num, 4~7 y: indicate direction, 0~1
- */
-
- int value;
- DBG_871X("Set GPIO Value! arg = %d , extra_arg =%d\n", arg, extra_arg);
- value = rtw_set_gpio_output_value(dev, arg, extra_arg);
- DBG_871X("Set GPIO Value %s\n", (value == -1) ? "Fail!!!" : "Success");
- break;
- }
-#endif
case 0xaa:
{
if ((extra_arg & 0x7F) > 0x3F)
extra_arg = 0xFF;
- DBG_871X("chang data rate to :0x%02x\n", extra_arg);
padapter->fix_rate = extra_arg;
}
break;
@@ -3174,14 +2748,6 @@ static int rtw_dbg_port(struct net_device *dev,
if (0xf == extra_arg) {
rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag);
- DBG_871X(" === DMFlag(0x%08x) ===\n", odm_flag);
- DBG_871X("extra_arg = 0 - disable all dynamic func\n");
- DBG_871X("extra_arg = 1 - disable DIG- BIT(0)\n");
- DBG_871X("extra_arg = 2 - disable High power - BIT(1)\n");
- DBG_871X("extra_arg = 3 - disable tx power tracking - BIT(2)\n");
- DBG_871X("extra_arg = 4 - disable BT coexistence - BIT(3)\n");
- DBG_871X("extra_arg = 5 - disable antenna diversity - BIT(4)\n");
- DBG_871X("extra_arg = 6 - enable all dynamic func\n");
} else {
/*extra_arg = 0 - disable all dynamic func
extra_arg = 1 - disable DIG
@@ -3190,54 +2756,23 @@ static int rtw_dbg_port(struct net_device *dev,
*/
rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &(extra_arg));
rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag);
- DBG_871X(" === DMFlag(0x%08x) ===\n", odm_flag);
}
}
break;
case 0xfd:
rtw_write8(padapter, 0xc50, arg);
- DBG_871X("wr(0xc50) = 0x%x\n", rtw_read8(padapter, 0xc50));
rtw_write8(padapter, 0xc58, arg);
- DBG_871X("wr(0xc58) = 0x%x\n", rtw_read8(padapter, 0xc58));
break;
case 0xfe:
- DBG_871X("rd(0xc50) = 0x%x\n", rtw_read8(padapter, 0xc50));
- DBG_871X("rd(0xc58) = 0x%x\n", rtw_read8(padapter, 0xc58));
break;
case 0xff:
{
- DBG_871X("dbg(0x210) = 0x%x\n", rtw_read32(padapter, 0x210));
- DBG_871X("dbg(0x608) = 0x%x\n", rtw_read32(padapter, 0x608));
- DBG_871X("dbg(0x280) = 0x%x\n", rtw_read32(padapter, 0x280));
- DBG_871X("dbg(0x284) = 0x%x\n", rtw_read32(padapter, 0x284));
- DBG_871X("dbg(0x288) = 0x%x\n", rtw_read32(padapter, 0x288));
-
- DBG_871X("dbg(0x664) = 0x%x\n", rtw_read32(padapter, 0x664));
-
-
- DBG_871X("\n");
-
- DBG_871X("dbg(0x430) = 0x%x\n", rtw_read32(padapter, 0x430));
- DBG_871X("dbg(0x438) = 0x%x\n", rtw_read32(padapter, 0x438));
-
- DBG_871X("dbg(0x440) = 0x%x\n", rtw_read32(padapter, 0x440));
-
- DBG_871X("dbg(0x458) = 0x%x\n", rtw_read32(padapter, 0x458));
-
- DBG_871X("dbg(0x484) = 0x%x\n", rtw_read32(padapter, 0x484));
- DBG_871X("dbg(0x488) = 0x%x\n", rtw_read32(padapter, 0x488));
-
- DBG_871X("dbg(0x444) = 0x%x\n", rtw_read32(padapter, 0x444));
- DBG_871X("dbg(0x448) = 0x%x\n", rtw_read32(padapter, 0x448));
- DBG_871X("dbg(0x44c) = 0x%x\n", rtw_read32(padapter, 0x44c));
- DBG_871X("dbg(0x450) = 0x%x\n", rtw_read32(padapter, 0x450));
}
break;
}
break;
default:
- DBG_871X("error dbg cmd!\n");
break;
}
@@ -3269,8 +2804,6 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value)
break;
}
- RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("wpa_set_param:padapter->securitypriv.ndisauthtype =%d\n", padapter->securitypriv.ndisauthtype));
-
break;
case IEEE_PARAM_TKIP_COUNTERMEASURES:
@@ -3314,7 +2847,6 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value)
case IEEE_PARAM_WPAX_SELECT:
/* added for WPA2 mixed mode */
- /* DBG_871X(KERN_WARNING "------------------------>wpax value = %x\n", value); */
/*
spin_lock_irqsave(&ieee->wpax_suitlist_lock, flags);
ieee->wpax_type_set = 1;
@@ -3407,7 +2939,6 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
break;
default:
- DBG_871X("Unknown WPA supplicant request: %d\n", param->cmd);
ret = -EOPNOTSUPP;
break;
@@ -3433,8 +2964,6 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
struct security_priv *psecuritypriv = &(padapter->securitypriv);
struct sta_priv *pstapriv = &padapter->stapriv;
- DBG_871X("%s\n", __func__);
-
param->u.crypt.err = 0;
param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
@@ -3454,11 +2983,9 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
}
} else {
psta = rtw_get_stainfo(pstapriv, param->sta_addr);
- if (!psta) {
+ if (!psta)
/* ret = -EINVAL; */
- DBG_871X("rtw_set_encryption(), sta has already been removed or never been added\n");
goto exit;
- }
}
if (strcmp(param->u.crypt.alg, "none") == 0 && (psta == NULL)) {
@@ -3469,20 +2996,14 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
- DBG_871X("clear default encryption keys, keyid =%d\n", param->u.crypt.idx);
-
goto exit;
}
if (strcmp(param->u.crypt.alg, "WEP") == 0 && (psta == NULL)) {
- DBG_871X("r871x_set_encryption, crypt.alg = WEP\n");
-
wep_key_idx = param->u.crypt.idx;
wep_key_len = param->u.crypt.key_len;
- DBG_871X("r871x_set_encryption, wep_key_idx =%d, len =%d\n", wep_key_idx, wep_key_len);
-
if ((wep_key_idx >= WEP_KEYS) || (wep_key_len <= 0)) {
ret = -EINVAL;
goto exit;
@@ -3493,10 +3014,8 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
wep_key_len = wep_key_len <= 5 ? 5 : 13;
wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
pwep = kzalloc(wep_total_len, GFP_KERNEL);
- if (pwep == NULL) {
- DBG_871X(" r871x_set_encryption: pwep allocate fail !!!\n");
+ if (!pwep)
goto exit;
- }
pwep->KeyLength = wep_key_len;
pwep->Length = wep_total_len;
@@ -3508,8 +3027,6 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength);
if (param->u.crypt.set_tx) {
- DBG_871X("wep, set_tx = 1\n");
-
psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Auto;
psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled;
psecuritypriv->dot11PrivacyAlgrthm = _WEP40_;
@@ -3529,8 +3046,6 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
rtw_ap_set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx, 1);
} else {
- DBG_871X("wep, set_tx = 0\n");
-
/* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */
/* psecuritypriv->dot11PrivacyKeyIndex =keyid", but can rtw_set_key to cam */
@@ -3549,8 +3064,6 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* group key */
if (param->u.crypt.set_tx == 1) {
if (strcmp(param->u.crypt.alg, "WEP") == 0) {
- DBG_871X("%s, set group_key, WEP\n", __func__);
-
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
@@ -3558,8 +3071,6 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
psecuritypriv->dot118021XGrpPrivacy = _WEP104_;
} else if (strcmp(param->u.crypt.alg, "TKIP") == 0) {
- DBG_871X("%s, set group_key, TKIP\n", __func__);
-
psecuritypriv->dot118021XGrpPrivacy = _TKIP_;
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
@@ -3573,14 +3084,10 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
}
else if (strcmp(param->u.crypt.alg, "CCMP") == 0) {
- DBG_871X("%s, set group_key, CCMP\n", __func__);
-
psecuritypriv->dot118021XGrpPrivacy = _AES_;
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
} else {
- DBG_871X("%s, set group_key, none\n", __func__);
-
psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
}
@@ -3609,14 +3116,10 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len));
if (strcmp(param->u.crypt.alg, "WEP") == 0) {
- DBG_871X("%s, set pairwise key, WEP\n", __func__);
-
psta->dot118021XPrivacy = _WEP40_;
if (param->u.crypt.key_len == 13)
psta->dot118021XPrivacy = _WEP104_;
} else if (strcmp(param->u.crypt.alg, "TKIP") == 0) {
- DBG_871X("%s, set pairwise key, TKIP\n", __func__);
-
psta->dot118021XPrivacy = _TKIP_;
/* DEBUG_ERR("set key length :param->u.crypt.key_len =%d\n", param->u.crypt.key_len); */
@@ -3628,12 +3131,8 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param,
} else if (strcmp(param->u.crypt.alg, "CCMP") == 0) {
- DBG_871X("%s, set pairwise key, CCMP\n", __func__);
-
psta->dot118021XPrivacy = _AES_;
} else {
- DBG_871X("%s, set pairwise key, none\n", __func__);
-
psta->dot118021XPrivacy = _NO_PRIVACY_;
}
@@ -3700,9 +3199,6 @@ static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int
struct sta_priv *pstapriv = &padapter->stapriv;
unsigned char *pbuf = param->u.bcn_ie.buf;
-
- DBG_871X("%s, len =%d\n", __func__, len);
-
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
return -EINVAL;
@@ -3730,8 +3226,6 @@ static void rtw_hostapd_sta_flush(struct net_device *dev)
struct adapter *padapter = rtw_netdev_priv(dev);
/* struct sta_priv *pstapriv = &padapter->stapriv; */
- DBG_871X("%s\n", __func__);
-
flush_all_cam_entry(padapter); /* clear CAM */
rtw_sta_flush(padapter);
@@ -3745,8 +3239,6 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
struct sta_priv *pstapriv = &padapter->stapriv;
- DBG_871X("rtw_add_sta(aid =%d) =%pM\n", param->u.add_sta.aid, MAC_ARG(param->sta_addr));
-
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
return -EINVAL;
@@ -3760,7 +3252,6 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
psta = rtw_get_stainfo(pstapriv, param->sta_addr);
if (psta)
{
- DBG_871X("rtw_add_sta(), free has been added psta =%p\n", psta);
spin_lock_bh(&(pstapriv->sta_hash_lock));
rtw_free_stainfo(padapter, psta);
spin_unlock_bh(&(pstapriv->sta_hash_lock));
@@ -3773,8 +3264,6 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
if (psta) {
int flags = param->u.add_sta.flags;
- /* DBG_871X("rtw_add_sta(), init sta's variables, psta =%p\n", psta); */
-
psta->aid = param->u.add_sta.aid;/* aid = 1~2007 */
memcpy(psta->bssrateset, param->u.add_sta.tx_supp_rates, 16);
@@ -3820,8 +3309,6 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param)
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
struct sta_priv *pstapriv = &padapter->stapriv;
- DBG_871X("rtw_del_sta =%pM\n", MAC_ARG(param->sta_addr));
-
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
return -EINVAL;
@@ -3835,8 +3322,6 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param)
if (psta) {
u8 updated = false;
- /* DBG_871X("free psta =%p, aid =%d\n", psta, psta->aid); */
-
spin_lock_bh(&pstapriv->asoc_list_lock);
if (list_empty(&psta->asoc_list) == false) {
list_del_init(&psta->asoc_list);
@@ -3850,13 +3335,8 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param)
psta = NULL;
- } else {
- DBG_871X("rtw_del_sta(), sta has already been removed or never been added\n");
-
- /* ret = -1; */
}
-
return ret;
}
@@ -3871,8 +3351,6 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par
struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param;
struct sta_data *psta_data = (struct sta_data *)param_ex->data;
- DBG_871X("rtw_ioctl_get_sta_info, sta_addr: %pM\n", MAC_ARG(param_ex->sta_addr));
-
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
return -EINVAL;
@@ -3932,8 +3410,6 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param)
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
struct sta_priv *pstapriv = &padapter->stapriv;
- DBG_871X("rtw_get_sta_wpaie, sta_addr: %pM\n", MAC_ARG(param->sta_addr));
-
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
return -EINVAL;
@@ -3956,9 +3432,6 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param)
param->u.wpa_ie.len = copy_len;
memcpy(param->u.wpa_ie.reserved, psta->wpa_ie, copy_len);
- } else {
- /* ret = -1; */
- DBG_871X("sta's wpa_ie is NONE\n");
}
} else {
ret = -1;
@@ -3977,8 +3450,6 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param,
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
int ie_len;
- DBG_871X("%s, len =%d\n", __func__, len);
-
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
return -EINVAL;
@@ -3991,10 +3462,8 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param,
if (ie_len > 0) {
pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len);
pmlmepriv->wps_beacon_ie_len = ie_len;
- if (pmlmepriv->wps_beacon_ie == NULL) {
- DBG_871X("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__);
+ if (!pmlmepriv->wps_beacon_ie)
return -EINVAL;
- }
memcpy(pmlmepriv->wps_beacon_ie, param->u.bcn_ie.buf, ie_len);
@@ -4015,8 +3484,6 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
int ie_len;
- DBG_871X("%s, len =%d\n", __func__, len);
-
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
return -EINVAL;
@@ -4029,10 +3496,9 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par
if (ie_len > 0) {
pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len);
pmlmepriv->wps_probe_resp_ie_len = ie_len;
- if (pmlmepriv->wps_probe_resp_ie == NULL) {
- DBG_871X("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__);
+ if (!pmlmepriv->wps_probe_resp_ie)
return -EINVAL;
- }
+
memcpy(pmlmepriv->wps_probe_resp_ie, param->u.bcn_ie.buf, ie_len);
}
@@ -4048,8 +3514,6 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
int ie_len;
- DBG_871X("%s, len =%d\n", __func__, len);
-
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
return -EINVAL;
@@ -4062,10 +3526,8 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par
if (ie_len > 0) {
pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len);
pmlmepriv->wps_assoc_resp_ie_len = ie_len;
- if (pmlmepriv->wps_assoc_resp_ie == NULL) {
- DBG_871X("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__);
+ if (!pmlmepriv->wps_assoc_resp_ie)
return -EINVAL;
- }
memcpy(pmlmepriv->wps_assoc_resp_ie, param->u.bcn_ie.buf, ie_len);
}
@@ -4085,7 +3547,7 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param,
int ie_len;
u8 *ssid_ie;
char ssid[NDIS_802_11_LENGTH_SSID + 1];
- sint ssid_len;
+ signed int ssid_len;
u8 ignore_broadcast_ssid;
if (check_fwstate(mlmepriv, WIFI_AP_STATE) != true)
@@ -4106,26 +3568,12 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param,
memcpy(ssid, ssid_ie+2, ssid_len);
ssid[ssid_len] = 0x0;
- if (0)
- DBG_871X(FUNC_ADPT_FMT" ssid:(%s,%d), from ie:(%s,%d), (%s,%d)\n", FUNC_ADPT_ARG(adapter),
- ssid, ssid_len,
- pbss_network->Ssid.Ssid, pbss_network->Ssid.SsidLength,
- pbss_network_ext->Ssid.Ssid, pbss_network_ext->Ssid.SsidLength);
-
memcpy(pbss_network->Ssid.Ssid, (void *)ssid, ssid_len);
pbss_network->Ssid.SsidLength = ssid_len;
memcpy(pbss_network_ext->Ssid.Ssid, (void *)ssid, ssid_len);
pbss_network_ext->Ssid.SsidLength = ssid_len;
-
- if (0)
- DBG_871X(FUNC_ADPT_FMT" after ssid:(%s,%d), (%s,%d)\n", FUNC_ADPT_ARG(adapter),
- pbss_network->Ssid.Ssid, pbss_network->Ssid.SsidLength,
- pbss_network_ext->Ssid.Ssid, pbss_network_ext->Ssid.SsidLength);
}
- DBG_871X(FUNC_ADPT_FMT" ignore_broadcast_ssid:%d, %s,%d\n", FUNC_ADPT_ARG(adapter),
- ignore_broadcast_ssid, ssid, ssid_len);
-
return ret;
}
@@ -4186,8 +3634,6 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
int ret = 0;
struct adapter *padapter = rtw_netdev_priv(dev);
- /* DBG_871X("%s\n", __func__); */
-
/*
* this function is expect to call in master mode, which allows no power saving
* so, we just check hw_init_completed
@@ -4208,8 +3654,6 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
return -EFAULT;
}
- /* DBG_871X("%s, cmd =%d\n", __func__, param->cmd); */
-
switch (param->cmd) {
case RTL871X_HOSTAPD_FLUSH:
@@ -4296,7 +3740,6 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
break;
default:
- DBG_871X("Unknown hostapd request: %d\n", param->cmd);
ret = -EOPNOTSUPP;
break;
@@ -4326,12 +3769,12 @@ static int rtw_wx_set_priv(struct net_device *dev,
struct adapter *padapter = rtw_netdev_priv(dev);
struct iw_point *dwrq = (struct iw_point *)awrq;
- /* RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_notice_, ("+rtw_wx_set_priv\n")); */
if (dwrq->length == 0)
return -EFAULT;
len = dwrq->length;
- if (!(ext = vmalloc(len)))
+ ext = vmalloc(len);
+ if (!ext)
return -ENOMEM;
if (copy_from_user(ext, dwrq->pointer, len)) {
@@ -4339,13 +3782,9 @@ static int rtw_wx_set_priv(struct net_device *dev,
return -EFAULT;
}
-
- /* RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_notice_, */
- /* ("rtw_wx_set_priv: %s req =%s\n", */
- /* dev->name, ext)); */
-
#ifdef DEBUG_RTW_WX_SET_PRIV
- if (!(ext_dbg = vmalloc(len))) {
+ ext_dbg = vmalloc(len);
+ if (!ext_dbg) {
vfree(ext, len);
return -ENOMEM;
}
@@ -4401,9 +3840,6 @@ FREE_EXT:
vfree(ext_dbg);
#endif
- /* DBG_871X("rtw_wx_set_priv: (SIOCSIWPRIV) %s ret =%d\n", */
- /* dev->name, ret); */
-
return ret;
}
@@ -4416,8 +3852,6 @@ static int rtw_pm_set(struct net_device *dev,
unsigned mode = 0;
struct adapter *padapter = rtw_netdev_priv(dev);
- DBG_871X("[%s] extra = %s\n", __func__, extra);
-
if (!memcmp(extra, "lps =", 4)) {
sscanf(extra+4, "%u", &mode);
ret = rtw_pm_set_lps(padapter, mode);
@@ -4443,27 +3877,21 @@ static int rtw_test(
struct adapter *padapter = rtw_netdev_priv(dev);
- DBG_871X("+%s\n", __func__);
len = wrqu->data.length;
pbuf = rtw_zmalloc(len);
- if (pbuf == NULL) {
- DBG_871X("%s: no memory!\n", __func__);
+ if (!pbuf)
return -ENOMEM;
- }
if (copy_from_user(pbuf, wrqu->data.pointer, len)) {
kfree(pbuf);
- DBG_871X("%s: copy from user fail!\n", __func__);
return -EFAULT;
}
- DBG_871X("%s: string =\"%s\"\n", __func__, pbuf);
ptmp = (char *)pbuf;
pch = strsep(&ptmp, delim);
if ((pch == NULL) || (strlen(pch) == 0)) {
kfree(pbuf);
- DBG_871X("%s: parameter error(level 1)!\n", __func__);
return -EFAULT;
}
@@ -4493,7 +3921,6 @@ static int rtw_test(
if (count == 0) {
kfree(pbuf);
- DBG_871X("%s: parameter error(level 2)!\n", __func__);
return -EFAULT;
}
@@ -4667,13 +4094,6 @@ static const struct iw_priv_args rtw_private_args[] = {
SIOCIWFIRSTPRIV + 0x1D,
IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 0x7FF, "test"
},
-
-#ifdef CONFIG_WOWLAN
- { MP_WOW_ENABLE, IW_PRIV_TYPE_CHAR | 1024, 0, "wow_mode" }, /* set */
-#endif
-#ifdef CONFIG_AP_WOWLAN
- { MP_AP_WOW_ENABLE, IW_PRIV_TYPE_CHAR | 1024, 0, "ap_wow_mode" }, /* set */
-#endif
};
static iw_handler rtw_private_handler[] = {
@@ -4732,45 +4152,10 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev)
piwstats->qual.qual = 0;
piwstats->qual.level = 0;
piwstats->qual.noise = 0;
- /* DBG_871X("No link level:%d, qual:%d, noise:%d\n", tmp_level, tmp_qual, tmp_noise); */
} else {
- #ifdef CONFIG_SIGNAL_DISPLAY_DBM
- tmp_level = translate_percentage_to_dbm(padapter->recvpriv.signal_strength);
- #else
- #ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
- {
- /* Do signal scale mapping when using percentage as the unit of signal strength, since the scale mapping is skipped in odm */
-
- struct hal_com_data *pHal = GET_HAL_DATA(padapter);
-
- tmp_level = (u8)odm_SignalScaleMapping(&pHal->odmpriv, padapter->recvpriv.signal_strength);
- }
- #else
tmp_level = padapter->recvpriv.signal_strength;
- #endif
- #endif
-
tmp_qual = padapter->recvpriv.signal_qual;
-#if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR)
- if (rtw_linked_check(padapter)) {
- struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
- struct noise_info info;
- info.bPauseDIG = true;
- info.IGIValue = 0x1e;
- info.max_time = 100;/* ms */
- info.chan = pmlmeext->cur_channel ;/* rtw_get_oper_ch(padapter); */
- rtw_ps_deny(padapter, PS_DENY_IOCTL);
- LeaveAllPowerSaveModeDirect(padapter);
-
- rtw_hal_set_odm_var(padapter, HAL_ODM_NOISE_MONITOR, &info, false);
- /* ODM_InbandNoise_Monitor(podmpriv, true, 0x20, 100); */
- rtw_ps_deny_cancel(padapter, PS_DENY_IOCTL);
- rtw_hal_get_odm_var(padapter, HAL_ODM_NOISE_MONITOR, &(info.chan), &(padapter->recvpriv.noise));
- DBG_871X("chan:%d, noise_level:%d\n", info.chan, padapter->recvpriv.noise);
- }
-#endif
tmp_noise = padapter->recvpriv.noise;
- DBG_871X("level:%d, qual:%d, noise:%d, rssi (%d)\n", tmp_level, tmp_qual, tmp_noise, padapter->recvpriv.rssi);
piwstats->qual.level = tmp_level;
piwstats->qual.qual = tmp_qual;
@@ -4778,10 +4163,6 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev)
}
piwstats->qual.updated = IW_QUAL_ALL_UPDATED ;/* IW_QUAL_DBM; */
- #ifdef CONFIG_SIGNAL_DISPLAY_DBM
- piwstats->qual.updated = piwstats->qual.updated | IW_QUAL_DBM;
- #endif
-
return &padapter->iwstats;
}
@@ -4867,14 +4248,12 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
sscanf(ptr, "%16s", cmdname);
cmdlen = strlen(cmdname);
- DBG_8192C("%s: cmd =%s\n", __func__, cmdname);
/* skip command string */
if (cmdlen > 0)
cmdlen += 1; /* skip one space */
ptr += cmdlen;
len -= cmdlen;
- DBG_8192C("%s: parameters =%s\n", __func__, ptr);
priv = rtw_private_handler;
priv_args = rtw_private_args;
@@ -4985,15 +4364,12 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
break;
default:
- DBG_8192C("%s: Not yet implemented...\n", __func__);
err = -1;
goto exit;
}
if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) &&
(wdata.data.length != (priv_args[k].set_args & IW_PRIV_SIZE_MASK))) {
- DBG_8192C("%s: The command %s needs exactly %d argument(s)...\n",
- __func__, cmdname, priv_args[k].set_args & IW_PRIV_SIZE_MASK);
err = -EINVAL;
goto exit;
}
@@ -5082,8 +4458,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
case IW_PRIV_TYPE_BYTE:
/* Display args */
for (j = 0; j < n; j++) {
- sprintf(str, "%d ", extra[j]);
- len = strlen(str);
+ len = scnprintf(str, sizeof(str), "%d ", extra[j]);
output_len = strlen(output);
if ((output_len + len + 1) > 4096) {
err = -E2BIG;
@@ -5096,8 +4471,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
case IW_PRIV_TYPE_INT:
/* Display args */
for (j = 0; j < n; j++) {
- sprintf(str, "%d ", ((__s32 *)extra)[j]);
- len = strlen(str);
+ len = scnprintf(str, sizeof(str), "%d ", ((__s32 *)extra)[j]);
output_len = strlen(output);
if ((output_len + len + 1) > 4096) {
err = -E2BIG;
@@ -5113,7 +4487,6 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
break;
default:
- DBG_8192C("%s: Not yet implemented...\n", __func__);
err = -1;
goto exit;
}
diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
index d46c65ab384b..0a16752f805b 100644
--- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
@@ -65,7 +65,7 @@ void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted)
indicate_wx_scan_complete_event(padapter);
}
-static RT_PMKID_LIST backupPMKIDList[NUM_PMKID_CACHE];
+static struct rt_pmkid_list backupPMKIDList[NUM_PMKID_CACHE];
void rtw_reset_securitypriv(struct adapter *adapter)
{
u8 backupPMKIDIndex = 0;
@@ -84,7 +84,7 @@ void rtw_reset_securitypriv(struct adapter *adapter)
/* Backup the btkip_countermeasure information. */
/* When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */
- memcpy(&backupPMKIDList[0], &adapter->securitypriv.PMKIDList[0], sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
+ memcpy(&backupPMKIDList[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
backupPMKIDIndex = adapter->securitypriv.PMKIDIndex;
backupTKIPCountermeasure = adapter->securitypriv.btkip_countermeasure;
backupTKIPcountermeasure_time = adapter->securitypriv.btkip_countermeasure_time;
@@ -96,7 +96,7 @@ void rtw_reset_securitypriv(struct adapter *adapter)
/* Added by Albert 2009/02/18 */
/* Restore the PMK information to securitypriv structure for the following connection. */
- memcpy(&adapter->securitypriv.PMKIDList[0], &backupPMKIDList[0], sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE);
+ memcpy(&adapter->securitypriv.PMKIDList[0], &backupPMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
adapter->securitypriv.PMKIDIndex = backupPMKIDIndex;
adapter->securitypriv.btkip_countermeasure = backupTKIPCountermeasure;
adapter->securitypriv.btkip_countermeasure_time = backupTKIPcountermeasure_time;
@@ -127,7 +127,7 @@ void rtw_reset_securitypriv(struct adapter *adapter)
void rtw_os_indicate_disconnect(struct adapter *adapter)
{
- /* RT_PMKID_LIST backupPMKIDList[ NUM_PMKID_CACHE ]; */
+ /* struct rt_pmkid_list backupPMKIDList[ NUM_PMKID_CACHE ]; */
netif_carrier_off(adapter->pnetdev); /* Do it first for tx broadcast pkt after disconnection issue! */
@@ -145,29 +145,23 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
u8 *buff, *p, i;
union iwreq_data wrqu;
- RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("+rtw_report_sec_ie, authmode =%d\n", authmode));
-
buff = NULL;
if (authmode == WLAN_EID_VENDOR_SPECIFIC) {
- RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("rtw_report_sec_ie, authmode =%d\n", authmode));
-
buff = rtw_zmalloc(IW_CUSTOM_MAX);
- if (NULL == buff) {
- DBG_871X(FUNC_ADPT_FMT ": alloc memory FAIL!!\n",
- FUNC_ADPT_ARG(adapter));
+ if (!buff)
return;
- }
+
p = buff;
- p += sprintf(p, "ASSOCINFO(ReqIEs =");
+ p += scnprintf(p, IW_CUSTOM_MAX - (p - buff), "ASSOCINFO(ReqIEs =");
len = sec_ie[1] + 2;
len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
for (i = 0; i < len; i++)
- p += sprintf(p, "%02x", sec_ie[i]);
+ p += scnprintf(p, IW_CUSTOM_MAX - (p - buff), "%02x", sec_ie[i]);
- p += sprintf(p, ")");
+ p += scnprintf(p, IW_CUSTOM_MAX - (p - buff), ")");
memset(&wrqu, 0, sizeof(wrqu));
diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index b62fe9238e6d..160f624612c7 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -113,11 +113,7 @@ static int rtw_enusbss;/* 0:disable, 1:enable */
static int rtw_hwpdn_mode = 2;/* 0:disable, 1:enable, 2: by EFUSE config */
-#ifdef CONFIG_HW_PWRP_DETECTION
-static int rtw_hwpwrp_detect = 1;
-#else
static int rtw_hwpwrp_detect; /* HW power ping detect 0:disable , 1:enable */
-#endif
static int rtw_hw_wps_pbc;
@@ -125,11 +121,7 @@ int rtw_mc2u_disable = 0;
static int rtw_80211d;
-#ifdef CONFIG_QOS_OPTIMIZATION
-static int rtw_qos_opt_enable = 1;/* 0: disable, 1:enable */
-#else
static int rtw_qos_opt_enable;/* 0: disable, 1:enable */
-#endif
module_param(rtw_qos_opt_enable, int, 0644);
static char *ifname = "wlan%d";
@@ -201,11 +193,9 @@ MODULE_PARM_DESC(rtw_tx_pwr_lmt_enable, "0:Disable, 1:Enable, 2: Depend on efuse
module_param(rtw_tx_pwr_by_rate, int, 0644);
MODULE_PARM_DESC(rtw_tx_pwr_by_rate, "0:Disable, 1:Enable, 2: Depend on efuse");
-int _netdev_open(struct net_device *pnetdev);
-int netdev_open(struct net_device *pnetdev);
static int netdev_close(struct net_device *pnetdev);
-static void loadparam(struct adapter *padapter, _nic_hdl pnetdev)
+static void loadparam(struct adapter *padapter, struct net_device *pnetdev)
{
struct registry_priv *registry_par = &padapter->registrypriv;
@@ -314,7 +304,6 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
struct sockaddr *addr = p;
if (!padapter->bup) {
- /* DBG_871X("r8711_net_set_mac_address(), MAC =%x:%x:%x:%x:%x:%x\n", addr->sa_data[0], addr->sa_data[1], addr->sa_data[2], addr->sa_data[3], */
/* addr->sa_data[4], addr->sa_data[5]); */
memcpy(padapter->eeprompriv.mac_addr, addr->sa_data, ETH_ALEN);
/* memcpy(pnetdev->dev_addr, addr->sa_data, ETH_ALEN); */
@@ -423,7 +412,8 @@ static int rtw_ndev_notifier_call(struct notifier_block *nb, unsigned long state
if (dev->netdev_ops->ndo_do_ioctl != rtw_ioctl)
return NOTIFY_DONE;
- DBG_871X_LEVEL(_drv_info_, FUNC_NDEV_FMT " state:%lu\n", FUNC_NDEV_ARG(dev), state);
+ netdev_info(dev, FUNC_NDEV_FMT " state:%lu\n", FUNC_NDEV_ARG(dev),
+ state);
return NOTIFY_DONE;
}
@@ -447,7 +437,7 @@ static int rtw_ndev_init(struct net_device *dev)
{
struct adapter *adapter = rtw_netdev_priv(dev);
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(adapter));
+ netdev_dbg(dev, FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(adapter));
strncpy(adapter->old_ifname, dev->name, IFNAMSIZ);
return 0;
@@ -457,7 +447,7 @@ static void rtw_ndev_uninit(struct net_device *dev)
{
struct adapter *adapter = rtw_netdev_priv(dev);
- DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(adapter));
+ netdev_dbg(dev, FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(adapter));
}
static const struct net_device_ops rtw_netdev_ops = {
@@ -489,8 +479,6 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter)
struct adapter *padapter;
struct net_device *pnetdev;
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n"));
-
if (old_padapter)
pnetdev = rtw_alloc_etherdev_with_old_priv(sizeof(struct adapter), (void *)old_padapter);
else
@@ -505,7 +493,6 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter)
/* pnetdev->init = NULL; */
- DBG_871X("register rtw_netdev_ops to netdev_ops\n");
pnetdev->netdev_ops = &rtw_netdev_ops;
/* pnetdev->tx_timeout = NULL; */
@@ -539,7 +526,6 @@ u32 rtw_start_drv_threads(struct adapter *padapter)
{
u32 _status = _SUCCESS;
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_start_drv_threads\n"));
padapter->xmitThread = kthread_run(rtw_xmit_thread, padapter, "RTW_XMIT_THREAD");
if (IS_ERR(padapter->xmitThread))
_status = _FAIL;
@@ -556,14 +542,11 @@ u32 rtw_start_drv_threads(struct adapter *padapter)
void rtw_stop_drv_threads(struct adapter *padapter)
{
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads\n"));
-
rtw_stop_cmd_thread(padapter);
/* Below is to termindate tx_thread... */
complete(&padapter->xmitpriv.xmit_comp);
wait_for_completion(&padapter->xmitpriv.terminate_xmitthread_comp);
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("\n drv_halt: rtw_xmit_thread can be terminated !\n"));
rtw_hal_stop_thread(padapter);
}
@@ -596,9 +579,6 @@ static void rtw_init_default_value(struct adapter *padapter)
/* security_priv */
/* rtw_get_encrypt_decrypt_from_registrypriv(padapter); */
psecuritypriv->binstallGrpkey = _FAIL;
-#ifdef CONFIG_GTK_OL
- psecuritypriv->binstallKCK_KEK = _FAIL;
-#endif /* CONFIG_GTK_OL */
psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt;
psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt;
@@ -710,14 +690,11 @@ u8 rtw_init_drv_sw(struct adapter *padapter)
{
u8 ret8 = _SUCCESS;
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw\n"));
-
rtw_init_default_value(padapter);
rtw_init_hal_com_default_value(padapter);
if (rtw_init_cmd_priv(&padapter->cmdpriv)) {
- RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init cmd_priv\n"));
ret8 = _FAIL;
goto exit;
}
@@ -725,14 +702,12 @@ u8 rtw_init_drv_sw(struct adapter *padapter)
padapter->cmdpriv.padapter = padapter;
if (rtw_init_evt_priv(&padapter->evtpriv)) {
- RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init evt_priv\n"));
ret8 = _FAIL;
goto exit;
}
if (rtw_init_mlme_priv(padapter) == _FAIL) {
- RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init mlme_priv\n"));
ret8 = _FAIL;
goto exit;
}
@@ -740,13 +715,11 @@ u8 rtw_init_drv_sw(struct adapter *padapter)
init_mlme_ext_priv(padapter);
if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter) == _FAIL) {
- DBG_871X("Can't _rtw_init_xmit_priv\n");
ret8 = _FAIL;
goto exit;
}
if (_rtw_init_recv_priv(&padapter->recvpriv, padapter) == _FAIL) {
- DBG_871X("Can't _rtw_init_recv_priv\n");
ret8 = _FAIL;
goto exit;
}
@@ -757,7 +730,6 @@ u8 rtw_init_drv_sw(struct adapter *padapter)
/* memset((unsigned char *)&padapter->securitypriv, 0, sizeof (struct security_priv)); */
if (_rtw_init_sta_priv(&padapter->stapriv) == _FAIL) {
- DBG_871X("Can't _rtw_init_sta_priv\n");
ret8 = _FAIL;
goto exit;
}
@@ -773,29 +745,21 @@ u8 rtw_init_drv_sw(struct adapter *padapter)
exit:
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_init_drv_sw\n"));
-
return ret8;
}
void rtw_cancel_all_timer(struct adapter *padapter)
{
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_cancel_all_timer\n"));
-
del_timer_sync(&padapter->mlmepriv.assoc_timer);
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel association timer complete!\n"));
del_timer_sync(&padapter->mlmepriv.scan_to_timer);
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel scan_to_timer!\n"));
del_timer_sync(&padapter->mlmepriv.dynamic_chk_timer);
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel dynamic_chk_timer!\n"));
del_timer_sync(&(adapter_to_pwrctl(padapter)->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_, ("rtw_cancel_all_timer:cancel set_scan_deny_timer!\n"));
del_timer_sync(&padapter->recvpriv.signal_stat_timer);
@@ -805,8 +769,6 @@ void rtw_cancel_all_timer(struct adapter *padapter)
u8 rtw_free_drv_sw(struct adapter *padapter)
{
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("==>rtw_free_drv_sw"));
-
free_mlme_ext_priv(&padapter->mlmeextpriv);
rtw_free_cmd_priv(&padapter->cmdpriv);
@@ -829,8 +791,6 @@ u8 rtw_free_drv_sw(struct adapter *padapter)
rtw_hal_free_data(padapter);
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("<==rtw_free_drv_sw\n"));
-
/* free the old_pnetdev */
if (padapter->rereg_nd_name_priv.old_pnetdev) {
free_netdev(padapter->rereg_nd_name_priv.old_pnetdev);
@@ -841,8 +801,6 @@ u8 rtw_free_drv_sw(struct adapter *padapter)
if (padapter->pbuddy_adapter)
padapter->pbuddy_adapter->pbuddy_adapter = NULL;
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_free_drv_sw\n"));
-
return _SUCCESS;
}
@@ -859,13 +817,10 @@ static int _rtw_drv_register_netdev(struct adapter *padapter, char *name)
/* Tell the network stack we exist */
if (register_netdev(pnetdev) != 0) {
- DBG_871X(FUNC_NDEV_FMT "Failed!\n", FUNC_NDEV_ARG(pnetdev));
ret = _FAIL;
goto error_register_netdev;
}
- DBG_871X("%s, MAC Address (if%d) = %pM\n", __func__, (padapter->iface_id + 1), MAC_ARG(pnetdev->dev_addr));
-
return ret;
error_register_netdev:
@@ -886,15 +841,12 @@ int rtw_drv_register_netdev(struct adapter *if1)
return _rtw_drv_register_netdev(padapter, name);
}
-int _netdev_open(struct net_device *pnetdev)
+static int _netdev_open(struct net_device *pnetdev)
{
uint status;
struct adapter *padapter = rtw_netdev_priv(pnetdev);
struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter);
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+871x_drv - dev_open\n"));
- DBG_871X("+871x_drv - drv_open, bup =%d\n", padapter->bup);
-
padapter->netif_up = true;
if (pwrctrlpriv->ps_flag) {
@@ -908,18 +860,12 @@ int _netdev_open(struct net_device *pnetdev)
padapter->bCardDisableWOHSM = false;
status = rtw_hal_init(padapter);
- if (status == _FAIL) {
- RT_TRACE(_module_os_intfs_c_, _drv_err_, ("rtl871x_hal_init(): Can't init h/w!\n"));
+ if (status == _FAIL)
goto netdev_open_error;
- }
-
- DBG_871X("MAC Address = %pM\n", MAC_ARG(pnetdev->dev_addr));
status = rtw_start_drv_threads(padapter);
- if (status == _FAIL) {
- DBG_871X("Initialize driver software resource Failed!\n");
+ if (status == _FAIL)
goto netdev_open_error;
- }
if (padapter->intf_start)
padapter->intf_start(padapter);
@@ -940,9 +886,6 @@ int _netdev_open(struct net_device *pnetdev)
netdev_open_normal_process:
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-871x_drv - dev_open\n"));
- DBG_871X("-871x_drv - drv_open, bup =%d\n", padapter->bup);
-
return 0;
netdev_open_error:
@@ -952,9 +895,6 @@ netdev_open_error:
netif_carrier_off(pnetdev);
rtw_netif_stop_queue(pnetdev);
- RT_TRACE(_module_os_intfs_c_, _drv_err_, ("-871x_drv - dev_open, fail!\n"));
- DBG_871X("-871x_drv - drv_open fail, bup =%d\n", padapter->bup);
-
return (-1);
}
@@ -964,10 +904,8 @@ int netdev_open(struct net_device *pnetdev)
struct adapter *padapter = rtw_netdev_priv(pnetdev);
struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter);
- if (pwrctrlpriv->bInSuspend) {
- DBG_871X("+871x_drv - drv_open, bInSuspend =%d\n", pwrctrlpriv->bInSuspend);
+ if (pwrctrlpriv->bInSuspend)
return 0;
- }
if (mutex_lock_interruptible(&(adapter_to_dvobj(padapter)->hw_init_mutex)))
return -1;
@@ -985,18 +923,13 @@ static int ips_netdrv_open(struct adapter *padapter)
padapter->net_closed = false;
- DBG_871X("===> %s.........\n", __func__);
-
-
padapter->bDriverStopped = false;
padapter->bCardDisableWOHSM = false;
/* padapter->bup = true; */
status = rtw_hal_init(padapter);
- if (status == _FAIL) {
- RT_TRACE(_module_os_intfs_c_, _drv_err_, ("ips_netdrv_open(): Can't init h/w!\n"));
+ if (status == _FAIL)
goto netdev_open_error;
- }
if (padapter->intf_start)
padapter->intf_start(padapter);
@@ -1006,8 +939,6 @@ static int ips_netdrv_open(struct adapter *padapter)
return _SUCCESS;
netdev_open_error:
- /* padapter->bup = false; */
- DBG_871X("-ips_netdrv_open - drv_open failure, bup =%d\n", padapter->bup);
return _FAIL;
}
@@ -1016,36 +947,28 @@ netdev_open_error:
int rtw_ips_pwr_up(struct adapter *padapter)
{
int result;
- DBG_871X("===> rtw_ips_pwr_up..............\n");
result = ips_netdrv_open(padapter);
- DBG_871X("<=== rtw_ips_pwr_up..............\n");
return result;
}
void rtw_ips_pwr_down(struct adapter *padapter)
{
- DBG_871X("===> rtw_ips_pwr_down...................\n");
-
padapter->bCardDisableWOHSM = true;
padapter->net_closed = true;
rtw_ips_dev_unload(padapter);
padapter->bCardDisableWOHSM = false;
- DBG_871X("<=== rtw_ips_pwr_down.....................\n");
}
void rtw_ips_dev_unload(struct adapter *padapter)
{
- DBG_871X("====> %s...\n", __func__);
-
if (!padapter->bSurpriseRemoved)
rtw_hal_deinit(padapter);
}
-
static int pm_netdev_open(struct net_device *pnetdev, u8 bnormal)
{
int status = -1;
@@ -1069,8 +992,6 @@ static int netdev_close(struct net_device *pnetdev)
struct adapter *padapter = rtw_netdev_priv(pnetdev);
struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+871x_drv - drv_close\n"));
-
if (pwrctl->bInternalAutoSuspend) {
/* rtw_pwr_wakeup(padapter); */
if (pwrctl->rf_pwrstate == rf_off)
@@ -1081,7 +1002,6 @@ static int netdev_close(struct net_device *pnetdev)
/*if (!padapter->hw_init_completed)
{
- DBG_871X("(1)871x_drv - drv_close, bup =%d, hw_init_completed =%d\n", padapter->bup, padapter->hw_init_completed);
padapter->bDriverStopped = true;
@@ -1089,8 +1009,6 @@ static int netdev_close(struct net_device *pnetdev)
}
else*/
if (pwrctl->rf_pwrstate == rf_on) {
- DBG_871X("(2)871x_drv - drv_close, bup =%d, hw_init_completed =%d\n", padapter->bup, padapter->hw_init_completed);
-
/* s1. */
if (pnetdev) {
if (!rtw_netif_queue_stopped(pnetdev))
@@ -1111,16 +1029,11 @@ static int netdev_close(struct net_device *pnetdev)
rtw_scan_abort(padapter);
adapter_wdev_data(padapter)->bandroid_scan = false;
- RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-871x_drv - drv_close\n"));
- DBG_871X("-871x_drv - drv_close, bup =%d\n", padapter->bup);
-
return 0;
}
void rtw_ndev_destructor(struct net_device *ndev)
{
- DBG_871X(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev));
-
kfree(ndev->ieee80211_ptr);
}
@@ -1132,10 +1045,7 @@ void rtw_dev_unload(struct adapter *padapter)
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
u8 cnt = 0;
- RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("+%s\n", __func__));
-
if (padapter->bup) {
- DBG_871X("===> %s\n", __func__);
padapter->bDriverStopped = true;
if (padapter->xmitpriv.ack_tx)
@@ -1144,76 +1054,51 @@ void rtw_dev_unload(struct adapter *padapter)
if (padapter->intf_stop)
padapter->intf_stop(padapter);
- RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("@ rtw_dev_unload: stop intf complete!\n"));
-
if (!pwrctl->bInternalAutoSuspend)
rtw_stop_drv_threads(padapter);
while (atomic_read(&pcmdpriv->cmdthd_running)) {
if (cnt > 5) {
- DBG_871X("stop cmdthd timeout\n");
break;
} else {
cnt++;
- DBG_871X("cmdthd is running(%d)\n", cnt);
msleep(10);
}
}
- RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("@ %s: stop thread complete!\n", __func__));
-
/* check the status of IPS */
if (rtw_hal_check_ips_status(padapter) || pwrctl->rf_pwrstate == rf_off) {
/* check HW status and SW state */
- DBG_871X_LEVEL(_drv_always_, "%s: driver in IPS-FWLPS\n", __func__);
+ netdev_dbg(padapter->pnetdev,
+ "%s: driver in IPS-FWLPS\n", __func__);
pdbgpriv->dbg_dev_unload_inIPS_cnt++;
LeaveAllPowerSaveMode(padapter);
} else {
- DBG_871X_LEVEL(_drv_always_, "%s: driver not in IPS\n", __func__);
+ netdev_dbg(padapter->pnetdev,
+ "%s: driver not in IPS\n", __func__);
}
if (!padapter->bSurpriseRemoved) {
hal_btcoex_IpsNotify(padapter, pwrctl->ips_mode_req);
-#ifdef CONFIG_WOWLAN
- if (pwrctl->bSupportRemoteWakeup && pwrctl->wowlan_mode) {
- DBG_871X_LEVEL(_drv_always_, "%s bSupportRemoteWakeup ==true do not run rtw_hal_deinit()\n", __func__);
- }
- else
-#endif
- {
- /* amy modify 20120221 for power seq is different between driver open and ips */
- rtw_hal_deinit(padapter);
- }
+
+ /* amy modify 20120221 for power seq is different between driver open and ips */
+ rtw_hal_deinit(padapter);
+
padapter->bSurpriseRemoved = true;
}
- RT_TRACE(_module_hci_intfs_c_, _drv_notice_,
- ("@ %s: deinit hal complete!\n", __func__));
padapter->bup = false;
- DBG_871X("<=== %s\n", __func__);
- } else {
- RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("%s: bup ==false\n", __func__));
- DBG_871X("%s: bup ==false\n", __func__);
}
-
- RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("-%s\n", __func__));
}
static int rtw_suspend_free_assoc_resource(struct adapter *padapter)
{
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
-
if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) {
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)
&& check_fwstate(pmlmepriv, _FW_LINKED)) {
- DBG_871X("%s %s(%pM), length:%d assoc_ssid.length:%d\n", __func__,
- pmlmepriv->cur_network.network.Ssid.Ssid,
- MAC_ARG(pmlmepriv->cur_network.network.MacAddress),
- pmlmepriv->cur_network.network.Ssid.SsidLength,
- pmlmepriv->assoc_ssid.SsidLength);
rtw_set_to_roam(padapter, 1);
}
}
@@ -1236,146 +1121,18 @@ static int rtw_suspend_free_assoc_resource(struct adapter *padapter)
rtw_indicate_scan_done(padapter, 1);
if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
- DBG_871X_LEVEL(_drv_always_, "%s: fw_under_linking\n", __func__);
+ netdev_dbg(padapter->pnetdev, "%s: fw_under_linking\n",
+ __func__);
rtw_indicate_disconnect(padapter);
}
- DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
return _SUCCESS;
}
-#ifdef CONFIG_WOWLAN
-void rtw_suspend_wow(struct adapter *padapter)
-{
- u8 ch, bw, offset;
- struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- struct net_device *pnetdev = padapter->pnetdev;
- struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
- struct wowlan_ioctl_param poidparam;
-
- DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
-
-
- DBG_871X("wowlan_mode: %d\n", pwrpriv->wowlan_mode);
- DBG_871X("wowlan_pno_enable: %d\n", pwrpriv->wowlan_pno_enable);
-
- if (pwrpriv->wowlan_mode) {
- if (pnetdev)
- rtw_netif_stop_queue(pnetdev);
- /* 1. stop thread */
- padapter->bDriverStopped = true; /* for stop thread */
- rtw_stop_drv_threads(padapter);
- padapter->bDriverStopped = false; /* for 32k command */
-
- /* 2. disable interrupt */
- if (padapter->intf_stop)
- padapter->intf_stop(padapter);
-
- /* 2.1 clean interrupt */
- if (padapter->HalFunc.clear_interrupt)
- padapter->HalFunc.clear_interrupt(padapter);
-
- /* 2.2 free irq */
- /* sdio_free_irq(adapter_to_dvobj(padapter)); */
- if (padapter->intf_free_irq)
- padapter->intf_free_irq(adapter_to_dvobj(padapter));
-
- poidparam.subcode = WOWLAN_ENABLE;
- padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_WOWLAN, (u8 *)&poidparam);
- if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) {
- if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED)) {
- DBG_871X("%s %s(%pM), length:%d assoc_ssid.length:%d\n", __func__,
- pmlmepriv->cur_network.network.Ssid.Ssid,
- MAC_ARG(pmlmepriv->cur_network.network.MacAddress),
- pmlmepriv->cur_network.network.Ssid.SsidLength,
- pmlmepriv->assoc_ssid.SsidLength);
-
- rtw_set_to_roam(padapter, 0);
- }
- }
-
- DBG_871X_LEVEL(_drv_always_, "%s: wowmode suspending\n", __func__);
-
- if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) {
- DBG_871X_LEVEL(_drv_always_, "%s: fw_under_survey\n", __func__);
- rtw_indicate_scan_done(padapter, 1);
- clr_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
- }
-
- if (rtw_get_ch_setting_union(padapter, &ch, &bw, &offset) != 0) {
- DBG_871X(FUNC_ADPT_FMT " back to linked/linking union - ch:%u, bw:%u, offset:%u\n",
- FUNC_ADPT_ARG(padapter), ch, bw, offset);
- set_channel_bwmode(padapter, ch, offset, bw);
- }
-
- if (pwrpriv->wowlan_pno_enable)
- DBG_871X_LEVEL(_drv_always_, "%s: pno: %d\n", __func__, pwrpriv->wowlan_pno_enable);
- else
- rtw_set_ps_mode(padapter, PS_MODE_DTIM, 0, 0, "WOWLAN");
- } else {
- DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR ### wowlan_mode =%d\n", __func__, pwrpriv->wowlan_mode);
- }
- DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
-}
-#endif /* ifdef CONFIG_WOWLAN */
-
-#ifdef CONFIG_AP_WOWLAN
-void rtw_suspend_ap_wow(struct adapter *padapter)
-{
- u8 ch, bw, offset;
- struct net_device *pnetdev = padapter->pnetdev;
- struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
- struct wowlan_ioctl_param poidparam;
-
- DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
-
- pwrpriv->wowlan_ap_mode = true;
-
- DBG_871X("wowlan_ap_mode: %d\n", pwrpriv->wowlan_ap_mode);
-
- if (pnetdev)
- rtw_netif_stop_queue(pnetdev);
- /* 1. stop thread */
- padapter->bDriverStopped = true; /* for stop thread */
- rtw_stop_drv_threads(padapter);
- padapter->bDriverStopped = false; /* for 32k command */
-
- /* 2. disable interrupt */
- rtw_hal_disable_interrupt(padapter); /* It need wait for leaving 32K. */
-
- /* 2.1 clean interrupt */
- if (padapter->HalFunc.clear_interrupt)
- padapter->HalFunc.clear_interrupt(padapter);
-
- /* 2.2 free irq */
- /* sdio_free_irq(adapter_to_dvobj(padapter)); */
- if (padapter->intf_free_irq)
- padapter->intf_free_irq(adapter_to_dvobj(padapter));
-
- poidparam.subcode = WOWLAN_AP_ENABLE;
- padapter->HalFunc.SetHwRegHandler(padapter,
- HW_VAR_AP_WOWLAN, (u8 *)&poidparam);
-
- DBG_871X_LEVEL(_drv_always_, "%s: wowmode suspending\n", __func__);
-
- if (rtw_get_ch_setting_union(padapter, &ch, &bw, &offset) != 0) {
- DBG_871X(FUNC_ADPT_FMT " back to linked/linking union - ch:%u, bw:%u, offset:%u\n",
- FUNC_ADPT_ARG(padapter), ch, bw, offset);
- set_channel_bwmode(padapter, ch, offset, bw);
- }
-
- rtw_set_ps_mode(padapter, PS_MODE_MIN, 0, 0, "AP-WOWLAN");
-
- DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
-}
-#endif /* ifdef CONFIG_AP_WOWLAN */
-
-
static void rtw_suspend_normal(struct adapter *padapter)
{
struct net_device *pnetdev = padapter->pnetdev;
- DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
if (pnetdev) {
netif_carrier_off(pnetdev);
rtw_netif_stop_queue(pnetdev);
@@ -1384,15 +1141,15 @@ static void rtw_suspend_normal(struct adapter *padapter)
rtw_suspend_free_assoc_resource(padapter);
if ((rtw_hal_check_ips_status(padapter)) || (adapter_to_pwrctl(padapter)->rf_pwrstate == rf_off))
- DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR #### driver in IPS ####ERROR###!!!\n", __func__);
+ netdev_dbg(padapter->pnetdev,
+ "%s: ### ERROR #### driver in IPS ####ERROR###!!!\n",
+ __func__);
rtw_dev_unload(padapter);
/* sdio_deinit(adapter_to_dvobj(padapter)); */
if (padapter->intf_deinit)
padapter->intf_deinit(adapter_to_dvobj(padapter));
-
- DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
}
int rtw_suspend_common(struct adapter *padapter)
@@ -1405,8 +1162,7 @@ int rtw_suspend_common(struct adapter *padapter)
int ret = 0;
unsigned long start_time = jiffies;
- DBG_871X_LEVEL(_drv_always_, " suspend start\n");
- DBG_871X("==> %s (%s:%d)\n", __func__, current->comm, current->pid);
+ netdev_dbg(padapter->pnetdev, " suspend start\n");
pdbgpriv->dbg_suspend_cnt++;
pwrpriv->bInSuspend = true;
@@ -1415,8 +1171,6 @@ int rtw_suspend_common(struct adapter *padapter)
msleep(1);
if ((!padapter->bup) || (padapter->bDriverStopped) || (padapter->bSurpriseRemoved)) {
- DBG_871X("%s bup =%d bDriverStopped =%d bSurpriseRemoved = %d\n", __func__
- , padapter->bup, padapter->bDriverStopped, padapter->bSurpriseRemoved);
pdbgpriv->dbg_suspend_error_cnt++;
goto exit;
}
@@ -1429,247 +1183,28 @@ int rtw_suspend_common(struct adapter *padapter)
rtw_stop_cmd_thread(padapter);
/* wait for the latest FW to remove this condition. */
- if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
hal_btcoex_SuspendNotify(padapter, 0);
- DBG_871X("WIFI_AP_STATE\n");
- } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
+ else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
hal_btcoex_SuspendNotify(padapter, 1);
- DBG_871X("STATION\n");
- }
rtw_ps_deny_cancel(padapter, PS_DENY_SUSPEND);
- if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
- #ifdef CONFIG_WOWLAN
- if (check_fwstate(pmlmepriv, _FW_LINKED))
- pwrpriv->wowlan_mode = true;
- else if (pwrpriv->wowlan_pno_enable)
- pwrpriv->wowlan_mode |= pwrpriv->wowlan_pno_enable;
-
- if (pwrpriv->wowlan_mode)
- rtw_suspend_wow(padapter);
- else
- rtw_suspend_normal(padapter);
-
- #else /* CONFIG_WOWLAN */
+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
rtw_suspend_normal(padapter);
- #endif /* CONFIG_WOWLAN */
- } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
- #ifdef CONFIG_AP_WOWLAN
- rtw_suspend_ap_wow(padapter);
- #else
+ else if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
rtw_suspend_normal(padapter);
- #endif /* CONFIG_AP_WOWLAN */
- } else {
+ else
rtw_suspend_normal(padapter);
- }
- DBG_871X_LEVEL(_drv_always_, "rtw suspend success in %d ms\n",
- jiffies_to_msecs(jiffies - start_time));
+ netdev_dbg(padapter->pnetdev, "rtw suspend success in %d ms\n",
+ jiffies_to_msecs(jiffies - start_time));
exit:
- DBG_871X("<=== %s return %d.............. in %dms\n", __func__
- , ret, jiffies_to_msecs(jiffies - start_time));
return ret;
}
-#ifdef CONFIG_WOWLAN
-int rtw_resume_process_wow(struct adapter *padapter)
-{
- struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- struct net_device *pnetdev = padapter->pnetdev;
- struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
- struct dvobj_priv *psdpriv = padapter->dvobj;
- struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
- struct wowlan_ioctl_param poidparam;
- struct sta_info *psta = NULL;
- int ret = _SUCCESS;
-
- DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
-
- if (padapter) {
- pnetdev = padapter->pnetdev;
- pwrpriv = adapter_to_pwrctl(padapter);
- } else {
- pdbgpriv->dbg_resume_error_cnt++;
- ret = -1;
- goto exit;
- }
-
- if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {
- DBG_871X("%s pdapter %p bDriverStopped %d bSurpriseRemoved %d\n",
- __func__, padapter, padapter->bDriverStopped,
- padapter->bSurpriseRemoved);
- goto exit;
- }
-
-#ifdef CONFIG_PNO_SUPPORT
- pwrpriv->pno_in_resume = true;
-#endif
-
- if (pwrpriv->wowlan_mode) {
- rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "WOWLAN");
-
- pwrpriv->bFwCurrentInPSMode = false;
-
- if (padapter->intf_stop)
- padapter->intf_stop(padapter);
-
- if (padapter->HalFunc.clear_interrupt)
- padapter->HalFunc.clear_interrupt(padapter);
-
- /* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) { */
- if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) {
- ret = -1;
- RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: sdio_alloc_irq Failed!!\n", __func__));
- goto exit;
- }
-
- /* Disable WOW, set H2C command */
- poidparam.subcode = WOWLAN_DISABLE;
- padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_WOWLAN, (u8 *)&poidparam);
-
- psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv));
- if (psta)
- set_sta_rate(padapter, psta);
-
- padapter->bDriverStopped = false;
- DBG_871X("%s: wowmode resuming, DriverStopped:%d\n", __func__, padapter->bDriverStopped);
- rtw_start_drv_threads(padapter);
-
- if (padapter->intf_start)
- padapter->intf_start(padapter);
-
- /* start netif queue */
- if (pnetdev) {
- if (!rtw_netif_queue_stopped(pnetdev))
- rtw_netif_start_queue(pnetdev);
- else
- rtw_netif_wake_queue(pnetdev);
- }
- } else {
- DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR ### wowlan_mode =%d\n", __func__, pwrpriv->wowlan_mode);
- }
-
- if (padapter->pid[1] != 0) {
- DBG_871X("pid[1]:%d\n", padapter->pid[1]);
- rtw_signal_process(padapter->pid[1], SIGUSR2);
- }
-
- if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) {
- if (pwrpriv->wowlan_wake_reason == FWDecisionDisconnect ||
- pwrpriv->wowlan_wake_reason == Rx_DisAssoc ||
- pwrpriv->wowlan_wake_reason == Rx_DeAuth) {
- DBG_871X("%s: disconnect reason: %02x\n", __func__,
- pwrpriv->wowlan_wake_reason);
- rtw_indicate_disconnect(padapter);
-
- rtw_sta_media_status_rpt(padapter,
- rtw_get_stainfo(&padapter->stapriv,
- get_bssid(&padapter->mlmepriv)), 0);
-
- rtw_free_assoc_resources(padapter, 1);
- pmlmeinfo->state = WIFI_FW_NULL_STATE;
-
- } else {
- DBG_871X("%s: do roaming\n", __func__);
- rtw_roaming(padapter, NULL);
- }
- }
-
- if (pwrpriv->wowlan_mode) {
- pwrpriv->bips_processing = false;
- _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000);
- } else {
- DBG_871X_LEVEL(_drv_always_, "do not reset timer\n");
- }
-
- pwrpriv->wowlan_mode = false;
-
- /* clean driver side wake up reason. */
- pwrpriv->wowlan_wake_reason = 0;
-exit:
- DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
- return ret;
-}
-#endif /* ifdef CONFIG_WOWLAN */
-
-#ifdef CONFIG_AP_WOWLAN
-int rtw_resume_process_ap_wow(struct adapter *padapter)
-{
- struct net_device *pnetdev = padapter->pnetdev;
- struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
- struct dvobj_priv *psdpriv = padapter->dvobj;
- struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
- struct wowlan_ioctl_param poidparam;
- int ret = _SUCCESS;
-
- DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
-
- if (padapter) {
- pnetdev = padapter->pnetdev;
- pwrpriv = adapter_to_pwrctl(padapter);
- } else {
- pdbgpriv->dbg_resume_error_cnt++;
- ret = -1;
- goto exit;
- }
-
- rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "AP-WOWLAN");
-
- pwrpriv->bFwCurrentInPSMode = false;
-
- rtw_hal_disable_interrupt(padapter);
-
- if (padapter->HalFunc.clear_interrupt)
- padapter->HalFunc.clear_interrupt(padapter);
-
- /* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) { */
- if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) {
- ret = -1;
- RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: sdio_alloc_irq Failed!!\n", __func__));
- goto exit;
- }
-
- /* Disable WOW, set H2C command */
- poidparam.subcode = WOWLAN_AP_DISABLE;
- padapter->HalFunc.SetHwRegHandler(padapter,
- HW_VAR_AP_WOWLAN, (u8 *)&poidparam);
- pwrpriv->wowlan_ap_mode = false;
-
- padapter->bDriverStopped = false;
- DBG_871X("%s: wowmode resuming, DriverStopped:%d\n", __func__, padapter->bDriverStopped);
- rtw_start_drv_threads(padapter);
-
- if (padapter->intf_start)
- padapter->intf_start(padapter);
-
- /* start netif queue */
- if (pnetdev) {
- if (!rtw_netif_queue_stopped(pnetdev))
- rtw_netif_start_queue(pnetdev);
- else
- rtw_netif_wake_queue(pnetdev);
- }
-
- if (padapter->pid[1] != 0) {
- DBG_871X("pid[1]:%d\n", padapter->pid[1]);
- rtw_signal_process(padapter->pid[1], SIGUSR2);
- }
-
- pwrpriv->bips_processing = false;
- _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000);
-
- /* clean driver side wake up reason. */
- pwrpriv->wowlan_wake_reason = 0;
-exit:
- DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
- return ret;
-}
-#endif /* ifdef CONFIG_APWOWLAN */
-
static int rtw_resume_process_normal(struct adapter *padapter)
{
struct net_device *pnetdev;
@@ -1690,27 +1225,22 @@ static int rtw_resume_process_normal(struct adapter *padapter)
pmlmepriv = &padapter->mlmepriv;
psdpriv = padapter->dvobj;
pdbgpriv = &psdpriv->drv_dbg;
-
- DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter));
/* interface init */
/* if (sdio_init(adapter_to_dvobj(padapter)) != _SUCCESS) */
if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS)) {
ret = -1;
- RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: initialize SDIO Failed!!\n", __func__));
goto exit;
}
rtw_hal_disable_interrupt(padapter);
/* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) */
if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) {
ret = -1;
- RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: sdio_alloc_irq Failed!!\n", __func__));
goto exit;
}
rtw_reset_drv_sw(padapter);
pwrpriv->bkeepfwalive = false;
- DBG_871X("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive);
if (pm_netdev_open(pnetdev, true) != 0) {
ret = -1;
pdbgpriv->dbg_resume_error_cnt++;
@@ -1720,28 +1250,16 @@ static int rtw_resume_process_normal(struct adapter *padapter)
netif_device_attach(pnetdev);
netif_carrier_on(pnetdev);
- if (padapter->pid[1] != 0) {
- DBG_871X("pid[1]:%d\n", padapter->pid[1]);
+ if (padapter->pid[1] != 0)
rtw_signal_process(padapter->pid[1], SIGUSR2);
- }
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
- DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_STATION_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv));
-
if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME))
rtw_roaming(padapter, NULL);
-
} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
- DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_AP_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv));
rtw_ap_restore_network(padapter);
- } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
- DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_ADHOC_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv));
- } else {
- DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - ???\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv));
}
- DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter));
-
exit:
return ret;
}
@@ -1753,25 +1271,12 @@ int rtw_resume_common(struct adapter *padapter)
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- DBG_871X_LEVEL(_drv_always_, "resume start\n");
- DBG_871X("==> %s (%s:%d)\n", __func__, current->comm, current->pid);
+ netdev_dbg(padapter->pnetdev, "resume start\n");
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
- #ifdef CONFIG_WOWLAN
- if (pwrpriv->wowlan_mode)
- rtw_resume_process_wow(padapter);
- else
- rtw_resume_process_normal(padapter);
- #else
rtw_resume_process_normal(padapter);
- #endif
-
} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
- #ifdef CONFIG_AP_WOWLAN
- rtw_resume_process_ap_wow(padapter);
- #else
rtw_resume_process_normal(padapter);
- #endif /* CONFIG_AP_WOWLAN */
} else {
rtw_resume_process_normal(padapter);
}
@@ -1780,12 +1285,9 @@ int rtw_resume_common(struct adapter *padapter)
if (pwrpriv) {
pwrpriv->bInSuspend = false;
- #ifdef CONFIG_PNO_SUPPORT
- pwrpriv->pno_in_resume = false;
- #endif
}
- DBG_871X_LEVEL(_drv_always_, "%s:%d in %d ms\n", __func__, ret,
- jiffies_to_msecs(jiffies - start_time));
+ netdev_dbg(padapter->pnetdev, "%s:%d in %d ms\n", __func__, ret,
+ jiffies_to_msecs(jiffies - start_time));
return ret;
}
diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
index 3c71d2fafabf..9c6b1666df13 100644
--- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
@@ -47,7 +47,7 @@ inline struct sk_buff *_rtw_skb_copy(const struct sk_buff *skb)
return skb_copy(skb, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
}
-inline int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb)
+inline int _rtw_netif_rx(struct net_device *ndev, struct sk_buff *skb)
{
skb->dev = ndev;
return netif_rx(skb);
@@ -160,10 +160,8 @@ int rtw_change_ifname(struct adapter *padapter, const char *ifname)
else
ret = register_netdevice(pnetdev);
- if (ret != 0) {
- RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("register_netdev() failed\n"));
+ if (ret != 0)
goto error;
- }
return 0;
@@ -252,7 +250,6 @@ bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf)
if (rtw_cbuf_full(cbuf))
return _FAIL;
- DBG_871X("%s on %u\n", __func__, cbuf->write);
cbuf->bufs[cbuf->write] = buf;
cbuf->write = (cbuf->write + 1) % cbuf->size;
@@ -272,7 +269,6 @@ void *rtw_cbuf_pop(struct rtw_cbuf *cbuf)
if (rtw_cbuf_empty(cbuf))
return NULL;
- DBG_871X("%s on %u\n", __func__, cbuf->read);
buf = cbuf->bufs[cbuf->read];
cbuf->read = (cbuf->read + 1) % cbuf->size;
diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
index ac35277fbacd..cd51430d4618 100644
--- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
@@ -30,7 +30,7 @@ void rtw_os_recv_resource_alloc(struct adapter *padapter, union recv_frame *prec
/* free os related resource in union recv_frame */
void rtw_os_recv_resource_free(struct recv_priv *precvpriv)
{
- sint i;
+ signed int i;
union recv_frame *precvframe;
precvframe = (union recv_frame *) precvpriv->precv_frame_buf;
@@ -53,19 +53,17 @@ void rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *pre
}
}
-_pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 *pdata)
+struct sk_buff *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 *pdata)
{
u16 eth_type;
- _pkt *sub_skb;
+ struct sk_buff *sub_skb;
struct rx_pkt_attrib *pattrib;
pattrib = &prframe->u.hdr.attrib;
sub_skb = rtw_skb_alloc(nSubframe_Length + 12);
- if (!sub_skb) {
- DBG_871X("%s(): rtw_skb_alloc() Fail!!!\n", __func__);
+ if (!sub_skb)
return NULL;
- }
skb_reserve(sub_skb, 12);
skb_put_data(sub_skb, (pdata + ETH_HLEN), nSubframe_Length);
@@ -95,15 +93,14 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8
return sub_skb;
}
-void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt_attrib *pattrib)
+void rtw_os_recv_indicate_pkt(struct adapter *padapter, struct sk_buff *pkt, struct rx_pkt_attrib *pattrib)
{
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
- int ret;
/* Indicate the packets to upper layer */
if (pkt) {
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
- _pkt *pskb2 = NULL;
+ struct sk_buff *pskb2 = NULL;
struct sta_info *psta = NULL;
struct sta_priv *pstapriv = &padapter->stapriv;
int bmcast = IS_MCAST(pattrib->dst);
@@ -124,39 +121,22 @@ void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt
_rtw_xmit_entry(pkt, pnetdev);
- if (bmcast && pskb2) {
+ if (bmcast && pskb2)
pkt = pskb2;
- DBG_COUNTER(padapter->rx_logs.os_indicate_ap_mcast);
- } else {
- DBG_COUNTER(padapter->rx_logs.os_indicate_ap_forward);
+ else
return;
- }
}
} else {
/* to APself */
- /* DBG_871X("to APSelf\n"); */
- DBG_COUNTER(padapter->rx_logs.os_indicate_ap_self);
}
}
pkt->protocol = eth_type_trans(pkt, padapter->pnetdev);
pkt->dev = padapter->pnetdev;
-#ifdef CONFIG_TCP_CSUM_OFFLOAD_RX
- if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1))
- pkt->ip_summed = CHECKSUM_UNNECESSARY;
- else
- pkt->ip_summed = CHECKSUM_NONE;
-
-#else /* !CONFIG_TCP_CSUM_OFFLOAD_RX */
pkt->ip_summed = CHECKSUM_NONE;
-#endif /* CONFIG_TCP_CSUM_OFFLOAD_RX */
- ret = rtw_netif_rx(padapter->pnetdev, pkt);
- if (ret == NET_RX_SUCCESS)
- DBG_COUNTER(padapter->rx_logs.os_netif_ok);
- else
- DBG_COUNTER(padapter->rx_logs.os_netif_err);
+ rtw_netif_rx(padapter->pnetdev, pkt);
}
}
@@ -206,60 +186,19 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup)
wrqu.data.length = sizeof(ev);
}
-#ifdef CONFIG_AUTO_AP_MODE
-static void rtw_os_ksocket_send(struct adapter *padapter, union recv_frame *precv_frame)
-{
- _pkt *skb = precv_frame->u.hdr.pkt;
- struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
- struct sta_info *psta = precv_frame->u.hdr.psta;
-
- DBG_871X("eth rx: got eth_type = 0x%x\n", pattrib->eth_type);
-
- if (psta && psta->isrc && psta->pid > 0) {
- u16 rx_pid;
-
- rx_pid = *(u16 *)(skb->data+ETH_HLEN);
-
- DBG_871X("eth rx(pid = 0x%x): sta(%pM) pid = 0x%x\n",
- rx_pid, MAC_ARG(psta->hwaddr), psta->pid);
-
- if (rx_pid == psta->pid) {
- int i;
- u16 len = *(u16 *)(skb->data+ETH_HLEN+2);
- DBG_871X("eth, RC: len = 0x%x\n", len);
-
- for (i = 0; i < len; i++)
- DBG_871X("0x%x\n", *(skb->data+ETH_HLEN+4+i));
-
- DBG_871X("eth, RC-end\n");
- }
-
- }
-
-}
-#endif /* CONFIG_AUTO_AP_MODE */
-
int rtw_recv_indicatepkt(struct adapter *padapter, union recv_frame *precv_frame)
{
struct recv_priv *precvpriv;
struct __queue *pfree_recv_queue;
- _pkt *skb;
+ struct sk_buff *skb;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
- DBG_COUNTER(padapter->rx_logs.os_indicate);
-
precvpriv = &(padapter->recvpriv);
pfree_recv_queue = &(precvpriv->free_recv_queue);
skb = precv_frame->u.hdr.pkt;
- if (skb == NULL) {
- RT_TRACE(_module_recv_osdep_c_, _drv_err_, ("rtw_recv_indicatepkt():skb == NULL something wrong!!!!\n"));
+ if (!skb)
goto _recv_indicatepkt_drop;
- }
-
- RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("rtw_recv_indicatepkt():skb != NULL !!!\n"));
- RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("rtw_recv_indicatepkt():precv_frame->u.hdr.rx_head =%p precv_frame->hdr.rx_data =%p\n", precv_frame->u.hdr.rx_head, precv_frame->u.hdr.rx_data));
- RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("precv_frame->hdr.rx_tail =%p precv_frame->u.hdr.rx_end =%p precv_frame->hdr.len =%d\n", precv_frame->u.hdr.rx_tail, precv_frame->u.hdr.rx_end, precv_frame->u.hdr.len));
skb->data = precv_frame->u.hdr.rx_data;
@@ -267,16 +206,6 @@ int rtw_recv_indicatepkt(struct adapter *padapter, union recv_frame *precv_frame
skb->len = precv_frame->u.hdr.len;
- 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));
-
-#ifdef CONFIG_AUTO_AP_MODE
- if (0x8899 == pattrib->eth_type) {
- rtw_os_ksocket_send(padapter, precv_frame);
-
- /* goto _recv_indicatepkt_drop; */
- }
-#endif /* CONFIG_AUTO_AP_MODE */
-
rtw_os_recv_indicate_pkt(padapter, skb, pattrib);
/* pointers to NULL before rtw_free_recvframe() */
@@ -284,8 +213,6 @@ int rtw_recv_indicatepkt(struct adapter *padapter, union recv_frame *precv_frame
rtw_free_recvframe(precv_frame, pfree_recv_queue);
- RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("\n rtw_recv_indicatepkt :after rtw_os_recv_indicate_pkt!!!!\n"));
-
return _SUCCESS;
_recv_indicatepkt_drop:
@@ -293,7 +220,6 @@ _recv_indicatepkt_drop:
/* enqueue back to free_recv_queue */
rtw_free_recvframe(precv_frame, pfree_recv_queue);
- DBG_COUNTER(padapter->rx_logs.os_indicate_err);
return _FAIL;
}
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
index 301ffff12e82..d2bf444117b8 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
@@ -36,17 +36,12 @@ static const struct dev_pm_ops rtw_sdio_pm_ops = {
.resume = rtw_sdio_resume,
};
-struct sdio_drv_priv {
- struct sdio_driver r871xs_drv;
- int drv_registered;
-};
-
-static struct sdio_drv_priv sdio_drvpriv = {
- .r871xs_drv.probe = rtw_drv_init,
- .r871xs_drv.remove = rtw_dev_remove,
- .r871xs_drv.name = "rtl8723bs",
- .r871xs_drv.id_table = sdio_ids,
- .r871xs_drv.drv = {
+static struct sdio_driver rtl8723bs_sdio_driver = {
+ .probe = rtw_drv_init,
+ .remove = rtw_dev_remove,
+ .name = "rtl8723bs",
+ .id_table = sdio_ids,
+ .drv = {
.pm = &rtw_sdio_pm_ops,
}
};
@@ -58,10 +53,8 @@ static void sd_sync_int_hdl(struct sdio_func *func)
psdpriv = sdio_get_drvdata(func);
- if (!psdpriv->if1) {
- DBG_871X("%s if1 == NULL\n", __func__);
+ if (!psdpriv->if1)
return;
- }
rtw_sdio_set_irq_thd(psdpriv, current);
sd_int_hdl(psdpriv->if1);
@@ -108,7 +101,9 @@ static void sdio_free_irq(struct dvobj_priv *dvobj)
err = sdio_release_irq(func);
if (err) {
dvobj->drv_dbg.dbg_sdio_free_irq_error_cnt++;
- DBG_871X_LEVEL(_drv_err_, "%s: sdio_release_irq FAIL(%d)!\n", __func__, err);
+ netdev_err(dvobj->if1->pnetdev,
+ "%s: sdio_release_irq FAIL(%d)!\n",
+ __func__, err);
} else
dvobj->drv_dbg.dbg_sdio_free_irq_cnt++;
sdio_release_host(func);
@@ -117,55 +112,6 @@ static void sdio_free_irq(struct dvobj_priv *dvobj)
}
}
-#ifdef CONFIG_GPIO_WAKEUP
-extern unsigned int oob_irq;
-static irqreturn_t gpio_hostwakeup_irq_thread(int irq, void *data)
-{
- struct adapter *padapter = data;
- DBG_871X_LEVEL(_drv_always_, "gpio_hostwakeup_irq_thread\n");
- /* Disable interrupt before calling handler */
- /* disable_irq_nosync(oob_irq); */
- rtw_lock_suspend_timeout(HZ/2);
- return IRQ_HANDLED;
-}
-
-static u8 gpio_hostwakeup_alloc_irq(struct adapter *padapter)
-{
- int err;
-
- if (oob_irq == 0) {
- DBG_871X("oob_irq ZERO!\n");
- return _FAIL;
- }
- /* dont set it IRQF_TRIGGER_LOW, or wowlan */
- /* power is high after suspend */
- /* and failing can prevent can not sleep issue if */
- /* wifi gpio12 pin is not linked with CPU */
- err = request_threaded_irq(oob_irq, gpio_hostwakeup_irq_thread, NULL,
- /* IRQF_TRIGGER_LOW | IRQF_ONESHOT, */
- IRQF_TRIGGER_FALLING,
- "rtw_wifi_gpio_wakeup", padapter);
- if (err < 0) {
- DBG_871X("Oops: can't allocate gpio irq %d err:%d\n", oob_irq, err);
- return false;
- } else {
- DBG_871X("allocate gpio irq %d ok\n", oob_irq);
- }
-
- enable_irq_wake(oob_irq);
- return _SUCCESS;
-}
-
-static void gpio_hostwakeup_free_irq(struct adapter *padapter)
-{
- if (oob_irq == 0)
- return;
-
- disable_irq_wake(oob_irq);
- free_irq(oob_irq, padapter);
-}
-#endif
-
static u32 sdio_init(struct dvobj_priv *dvobj)
{
struct sdio_data *psdio_data;
@@ -181,14 +127,12 @@ static u32 sdio_init(struct dvobj_priv *dvobj)
err = sdio_enable_func(func);
if (err) {
dvobj->drv_dbg.dbg_sdio_init_error_cnt++;
- DBG_8192C(KERN_CRIT "%s: sdio_enable_func FAIL(%d)!\n", __func__, err);
goto release;
}
err = sdio_set_block_size(func, 512);
if (err) {
dvobj->drv_dbg.dbg_sdio_init_error_cnt++;
- DBG_8192C(KERN_CRIT "%s: sdio_set_block_size FAIL(%d)!\n", __func__, err);
goto release;
}
psdio_data->block_transfer_len = 512;
@@ -208,25 +152,19 @@ static void sdio_deinit(struct dvobj_priv *dvobj)
struct sdio_func *func;
int err;
-
- RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("+sdio_deinit\n"));
-
func = dvobj->intf_data.func;
if (func) {
sdio_claim_host(func);
err = sdio_disable_func(func);
- if (err) {
+ if (err)
dvobj->drv_dbg.dbg_sdio_deinit_error_cnt++;
- DBG_8192C(KERN_ERR "%s: sdio_disable_func(%d)\n", __func__, err);
- }
if (dvobj->irq_alloc) {
err = sdio_release_irq(func);
- if (err) {
+ if (err)
dvobj->drv_dbg.dbg_sdio_free_irq_error_cnt++;
- DBG_8192C(KERN_ERR "%s: sdio_release_irq(%d)\n", __func__, err);
- } else
+ else
dvobj->drv_dbg.dbg_sdio_free_irq_cnt++;
}
@@ -240,19 +178,17 @@ static struct dvobj_priv *sdio_dvobj_init(struct sdio_func *func)
struct sdio_data *psdio;
dvobj = devobj_init();
- if (dvobj == NULL) {
+ if (!dvobj)
goto exit;
- }
sdio_set_drvdata(func, dvobj);
psdio = &dvobj->intf_data;
psdio->func = func;
- if (sdio_init(dvobj) != _SUCCESS) {
- RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: initialize SDIO Failed!\n", __func__));
+ if (sdio_init(dvobj) != _SUCCESS)
goto free_dvobj;
- }
+
rtw_reset_continual_io_error(dvobj);
status = _SUCCESS;
@@ -289,10 +225,8 @@ void rtw_set_hal_ops(struct adapter *padapter)
static void sd_intf_start(struct adapter *padapter)
{
- if (padapter == NULL) {
- DBG_8192C(KERN_ERR "%s: padapter is NULL!\n", __func__);
+ if (!padapter)
return;
- }
/* hal dep */
rtw_hal_enable_interrupt(padapter);
@@ -300,10 +234,8 @@ static void sd_intf_start(struct adapter *padapter)
static void sd_intf_stop(struct adapter *padapter)
{
- if (padapter == NULL) {
- DBG_8192C(KERN_ERR "%s: padapter is NULL!\n", __func__);
+ if (!padapter)
return;
- }
/* hal dep */
rtw_hal_disable_interrupt(padapter);
@@ -318,9 +250,8 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv *dvobj, const struct
struct sdio_data *psdio = &dvobj->intf_data;
padapter = vzalloc(sizeof(*padapter));
- if (padapter == NULL) {
+ if (!padapter)
goto exit;
- }
padapter->dvobj = dvobj;
dvobj->if1 = padapter;
@@ -354,11 +285,8 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv *dvobj, const struct
padapter->intf_alloc_irq = &sdio_alloc_irq;
padapter->intf_free_irq = &sdio_free_irq;
- if (rtw_init_io_priv(padapter, sdio_set_intf_ops) == _FAIL) {
- RT_TRACE(_module_hci_intfs_c_, _drv_err_,
- ("rtw_drv_init: Can't init io_priv\n"));
+ if (rtw_init_io_priv(padapter, sdio_set_intf_ops) == _FAIL)
goto free_hal_data;
- }
rtw_hal_read_chip_version(padapter);
@@ -370,11 +298,8 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv *dvobj, const struct
rtw_hal_read_chip_info(padapter);
/* 3 7. init driver common data */
- if (rtw_init_drv_sw(padapter) == _FAIL) {
- RT_TRACE(_module_hci_intfs_c_, _drv_err_,
- ("rtw_drv_init: Initialize driver software resource Failed!\n"));
+ if (rtw_init_drv_sw(padapter) == _FAIL)
goto free_hal_data;
- }
rtw_wdev_alloc(padapter, dvobj_to_dev(dvobj));
@@ -384,13 +309,6 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv *dvobj, const struct
rtw_hal_disable_interrupt(padapter);
- DBG_871X("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n"
- , padapter->bDriverStopped
- , padapter->bSurpriseRemoved
- , padapter->bup
- , padapter->hw_init_completed
- );
-
status = _SUCCESS;
free_hal_data:
@@ -424,23 +342,12 @@ static void rtw_sdio_if1_deinit(struct adapter *if1)
free_mlme_ap_info(if1);
-#ifdef CONFIG_GPIO_WAKEUP
- gpio_hostwakeup_free_irq(if1);
-#endif
-
rtw_cancel_all_timer(if1);
-#ifdef CONFIG_WOWLAN
- adapter_to_pwrctl(if1)->wowlan_mode = false;
- DBG_871X_LEVEL(_drv_always_, "%s wowlan_mode:%d\n", __func__, adapter_to_pwrctl(if1)->wowlan_mode);
-#endif /* CONFIG_WOWLAN */
-
rtw_dev_unload(if1);
- DBG_871X("+r871xu_dev_remove, hw_init_completed =%d\n", if1->hw_init_completed);
- if (if1->rtw_wdev) {
+ if (if1->rtw_wdev)
rtw_wdev_free(if1->rtw_wdev);
- }
rtw_free_drv_sw(if1);
@@ -459,44 +366,32 @@ static int rtw_drv_init(
const struct sdio_device_id *id)
{
int status = _FAIL;
- struct adapter *if1 = NULL, *if2 = NULL;
+ struct adapter *if1 = NULL;
struct dvobj_priv *dvobj;
dvobj = sdio_dvobj_init(func);
- if (dvobj == NULL) {
- RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("initialize device object priv Failed!\n"));
+ if (!dvobj)
goto exit;
- }
if1 = rtw_sdio_if1_init(dvobj, id);
- if (if1 == NULL) {
- DBG_871X("rtw_init_primarystruct adapter Failed!\n");
+ if (!if1)
goto free_dvobj;
- }
/* dev_alloc_name && register_netdev */
status = rtw_drv_register_netdev(if1);
if (status != _SUCCESS)
- goto free_if2;
+ goto free_if1;
if (sdio_alloc_irq(dvobj) != _SUCCESS)
- goto free_if2;
-
-#ifdef CONFIG_GPIO_WAKEUP
- gpio_hostwakeup_alloc_irq(if1);
-#endif
-
- RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-871x_drv - drv_init, success!\n"));
+ goto free_if1;
rtw_ndev_notifier_register();
status = _SUCCESS;
-free_if2:
- if (status != _SUCCESS && if2) {
- }
- if (status != _SUCCESS && if1) {
+free_if1:
+ if (status != _SUCCESS && if1)
rtw_sdio_if1_deinit(if1);
- }
+
free_dvobj:
if (status != _SUCCESS)
sdio_dvobj_deinit(func);
@@ -509,8 +404,6 @@ static void rtw_dev_remove(struct sdio_func *func)
struct dvobj_priv *dvobj = sdio_get_drvdata(func);
struct adapter *padapter = dvobj->if1;
- RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("+rtw_dev_remove\n"));
-
dvobj->processing_dev_remove = true;
rtw_unregister_netdevs(dvobj);
@@ -522,10 +415,8 @@ static void rtw_dev_remove(struct sdio_func *func)
sdio_claim_host(func);
sdio_readb(func, 0, &err);
sdio_release_host(func);
- if (err == -ENOMEDIUM) {
+ if (err == -ENOMEDIUM)
padapter->bSurpriseRemoved = true;
- DBG_871X(KERN_NOTICE "%s: device had been removed!\n", __func__);
- }
}
rtw_ps_deny(padapter, PS_DENY_DRV_REMOVE);
@@ -540,13 +431,8 @@ static void rtw_dev_remove(struct sdio_func *func)
rtw_sdio_if1_deinit(padapter);
sdio_dvobj_deinit(func);
-
- RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("-rtw_dev_remove\n"));
}
-extern int pm_netdev_open(struct net_device *pnetdev, u8 bnormal);
-extern int pm_netdev_close(struct net_device *pnetdev, u8 bnormal);
-
static int rtw_sdio_suspend(struct device *dev)
{
struct sdio_func *func = dev_to_sdio_func(dev);
@@ -555,13 +441,10 @@ static int rtw_sdio_suspend(struct device *dev)
struct adapter *padapter = psdpriv->if1;
struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
- if (padapter->bDriverStopped) {
- DBG_871X("%s bDriverStopped = %d\n", __func__, padapter->bDriverStopped);
+ if (padapter->bDriverStopped)
return 0;
- }
if (pwrpriv->bInSuspend) {
- DBG_871X("%s bInSuspend = %d\n", __func__, pwrpriv->bInSuspend);
pdbgpriv->dbg_suspend_error_cnt++;
return 0;
}
@@ -577,7 +460,6 @@ static int rtw_resume_process(struct adapter *padapter)
if (!pwrpriv->bInSuspend) {
pdbgpriv->dbg_resume_error_cnt++;
- DBG_871X("%s bInSuspend = %d\n", __func__, pwrpriv->bInSuspend);
return -1;
}
@@ -593,57 +475,30 @@ static int rtw_sdio_resume(struct device *dev)
int ret = 0;
struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;
- DBG_871X("==> %s (%s:%d)\n", __func__, current->comm, current->pid);
-
pdbgpriv->dbg_resume_cnt++;
ret = rtw_resume_process(padapter);
pmlmeext->last_scan_time = jiffies;
- DBG_871X("<======== %s return %d\n", __func__, ret);
return ret;
}
static int __init rtw_drv_entry(void)
{
- int ret = 0;
-
- DBG_871X_LEVEL(_drv_always_, "module init start\n");
- dump_drv_version(RTW_DBGDUMP);
-#ifdef BTCOEXVERSION
- DBG_871X_LEVEL(_drv_always_, "rtl8723bs BT-Coex version = %s\n", BTCOEXVERSION);
-#endif /* BTCOEXVERSION */
-
- sdio_drvpriv.drv_registered = true;
+ int ret;
- ret = sdio_register_driver(&sdio_drvpriv.r871xs_drv);
- if (ret != 0) {
- sdio_drvpriv.drv_registered = false;
+ ret = sdio_register_driver(&rtl8723bs_sdio_driver);
+ if (ret != 0)
rtw_ndev_notifier_unregister();
- DBG_871X("%s: register driver failed!!(%d)\n", __func__, ret);
- goto exit;
- }
- goto exit;
-
-exit:
- DBG_871X_LEVEL(_drv_always_, "module init ret =%d\n", ret);
return ret;
}
static void __exit rtw_drv_halt(void)
{
- DBG_871X_LEVEL(_drv_always_, "module exit start\n");
-
- sdio_drvpriv.drv_registered = false;
-
- sdio_unregister_driver(&sdio_drvpriv.r871xs_drv);
+ sdio_unregister_driver(&rtl8723bs_sdio_driver);
rtw_ndev_notifier_unregister();
-
- DBG_871X_LEVEL(_drv_always_, "module exit success\n");
-
- rtw_mstat_dump(RTW_DBGDUMP);
}
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
index 079da433d811..5cedf775b6ef 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
@@ -40,10 +40,8 @@ u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return v;
- }
func = psdio->func;
claim_needed = rtw_sdio_claim_host_needed(func);
@@ -53,8 +51,6 @@ u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
v = sdio_f0_readb(func, addr, err);
if (claim_needed)
sdio_release_host(func);
- if (err && *err)
- DBG_871X(KERN_ERR "%s: FAIL!(%d) addr = 0x%05x\n", __func__, *err, addr);
return v;
}
@@ -76,19 +72,15 @@ s32 _sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return err;
- }
func = psdio->func;
for (i = 0; i < cnt; i++) {
pdata[i] = sdio_readb(func, addr + i, &err);
- if (err) {
- DBG_871X(KERN_ERR "%s: FAIL!(%d) addr = 0x%05x\n", __func__, err, addr + i);
+ if (err)
break;
- }
}
return err;
}
@@ -112,10 +104,8 @@ s32 sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return err;
- }
func = psdio->func;
claim_needed = rtw_sdio_claim_host_needed(func);
@@ -146,20 +136,15 @@ s32 _sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return err;
- }
func = psdio->func;
for (i = 0; i < cnt; i++) {
sdio_writeb(func, pdata[i], addr + i, &err);
- if (err) {
- DBG_871X(KERN_ERR "%s: FAIL!(%d) addr = 0x%05x val = 0x%02x\n", __func__,
- err, addr + i, pdata[i]);
+ if (err)
break;
- }
}
return err;
}
@@ -183,10 +168,8 @@ s32 sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return err;
- }
func = psdio->func;
claim_needed = rtw_sdio_claim_host_needed(func);
@@ -213,10 +196,8 @@ u8 sd_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return v;
- }
func = psdio->func;
claim_needed = rtw_sdio_claim_host_needed(func);
@@ -226,8 +207,6 @@ u8 sd_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
v = sdio_readb(func, addr, err);
if (claim_needed)
sdio_release_host(func);
- if (err && *err)
- DBG_871X(KERN_ERR "%s: FAIL!(%d) addr = 0x%05x\n", __func__, *err, addr);
return v;
}
@@ -244,10 +223,8 @@ u32 sd_read32(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return v;
- }
func = psdio->func;
claim_needed = rtw_sdio_claim_host_needed(func);
@@ -261,8 +238,6 @@ u32 sd_read32(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
if (err && *err) {
int i;
- DBG_871X(KERN_ERR "%s: (%d) addr = 0x%05x, val = 0x%x\n", __func__, *err, addr, v);
-
*err = 0;
for (i = 0; i < SD_IO_TRY_CNT; i++) {
if (claim_needed)
@@ -275,7 +250,6 @@ u32 sd_read32(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
rtw_reset_continual_io_error(psdiodev);
break;
} else {
- DBG_871X(KERN_ERR "%s: (%d) addr = 0x%05x, val = 0x%x, try_cnt =%d\n", __func__, *err, addr, v, i);
if ((-ESHUTDOWN == *err) || (-ENODEV == *err))
padapter->bSurpriseRemoved = true;
@@ -285,12 +259,6 @@ u32 sd_read32(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
}
}
}
-
- if (i == SD_IO_TRY_CNT)
- DBG_871X(KERN_ERR "%s: FAIL!(%d) addr = 0x%05x, val = 0x%x, try_cnt =%d\n", __func__, *err, addr, v, i);
- else
- DBG_871X(KERN_ERR "%s: (%d) addr = 0x%05x, val = 0x%x, try_cnt =%d\n", __func__, *err, addr, v, i);
-
}
return v;
}
@@ -307,10 +275,8 @@ void sd_write8(struct intf_hdl *pintfhdl, u32 addr, u8 v, s32 *err)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return;
- }
func = psdio->func;
claim_needed = rtw_sdio_claim_host_needed(func);
@@ -320,8 +286,6 @@ void sd_write8(struct intf_hdl *pintfhdl, u32 addr, u8 v, s32 *err)
sdio_writeb(func, v, addr, err);
if (claim_needed)
sdio_release_host(func);
- if (err && *err)
- DBG_871X(KERN_ERR "%s: FAIL!(%d) addr = 0x%05x val = 0x%02x\n", __func__, *err, addr, v);
}
void sd_write32(struct intf_hdl *pintfhdl, u32 addr, u32 v, s32 *err)
@@ -336,10 +300,8 @@ void sd_write32(struct intf_hdl *pintfhdl, u32 addr, u32 v, s32 *err)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return;
- }
func = psdio->func;
claim_needed = rtw_sdio_claim_host_needed(func);
@@ -353,8 +315,6 @@ void sd_write32(struct intf_hdl *pintfhdl, u32 addr, u32 v, s32 *err)
if (err && *err) {
int i;
- DBG_871X(KERN_ERR "%s: (%d) addr = 0x%05x val = 0x%08x\n", __func__, *err, addr, v);
-
*err = 0;
for (i = 0; i < SD_IO_TRY_CNT; i++) {
if (claim_needed)
@@ -366,7 +326,6 @@ void sd_write32(struct intf_hdl *pintfhdl, u32 addr, u32 v, s32 *err)
rtw_reset_continual_io_error(psdiodev);
break;
} else {
- DBG_871X(KERN_ERR "%s: (%d) addr = 0x%05x, val = 0x%x, try_cnt =%d\n", __func__, *err, addr, v, i);
if ((-ESHUTDOWN == *err) || (-ENODEV == *err))
padapter->bSurpriseRemoved = true;
@@ -377,10 +336,6 @@ void sd_write32(struct intf_hdl *pintfhdl, u32 addr, u32 v, s32 *err)
}
}
- if (i == SD_IO_TRY_CNT)
- DBG_871X(KERN_ERR "%s: FAIL!(%d) addr = 0x%05x val = 0x%08x, try_cnt =%d\n", __func__, *err, addr, v, i);
- else
- DBG_871X(KERN_ERR "%s: (%d) addr = 0x%05x val = 0x%08x, try_cnt =%d\n", __func__, *err, addr, v, i);
}
}
@@ -412,10 +367,8 @@ s32 _sd_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return err;
- }
func = psdio->func;
@@ -426,17 +379,13 @@ s32 _sd_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata)
for (i = 0; i < cnt; i++) {
*(pbuf + i) = sdio_readb(func, addr + i, &err);
- if (err) {
- DBG_871X(KERN_ERR "%s: FAIL!(%d) addr = 0x%05x\n", __func__, err, addr);
+ if (err)
break;
- }
}
return err;
}
err = sdio_memcpy_fromio(func, pdata, addr, cnt);
- if (err)
- DBG_871X(KERN_ERR "%s: FAIL(%d)! ADDR =%#x Size =%d\n", __func__, err, addr, cnt);
return err;
}
@@ -468,10 +417,9 @@ s32 sd_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return err;
- }
+
func = psdio->func;
claim_needed = rtw_sdio_claim_host_needed(func);
@@ -512,10 +460,8 @@ s32 _sd_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return err;
- }
func = psdio->func;
/* size = sdio_align_size(func, cnt); */
@@ -526,11 +472,8 @@ s32 _sd_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata)
for (i = 0; i < cnt; i++) {
sdio_writeb(func, *(pbuf + i), addr + i, &err);
- if (err) {
- DBG_871X(KERN_ERR "%s: FAIL!(%d) addr = 0x%05x val = 0x%02x\n",
- __func__, err, addr, *(pbuf + i));
+ if (err)
break;
- }
}
return err;
@@ -538,8 +481,6 @@ s32 _sd_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata)
size = cnt;
err = sdio_memcpy_toio(func, addr, pdata, size);
- if (err)
- DBG_871X(KERN_ERR "%s: FAIL(%d)! ADDR =%#x Size =%d(%d)\n", __func__, err, addr, cnt, size);
return err;
}
@@ -570,10 +511,8 @@ s32 sd_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata)
psdiodev = pintfhdl->pintf_dev;
psdio = &psdiodev->intf_data;
- if (padapter->bSurpriseRemoved) {
- /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */
+ if (padapter->bSurpriseRemoved)
return err;
- }
func = psdio->func;
claim_needed = rtw_sdio_claim_host_needed(func);
diff --git a/drivers/staging/rtl8723bs/os_dep/wifi_regd.c b/drivers/staging/rtl8723bs/os_dep/wifi_regd.c
index 3f04b7a954ba..0084589499b9 100644
--- a/drivers/staging/rtl8723bs/os_dep/wifi_regd.c
+++ b/drivers/staging/rtl8723bs/os_dep/wifi_regd.c
@@ -61,7 +61,7 @@ static void _rtw_reg_apply_flags(struct wiphy *wiphy)
{
struct adapter *padapter = wiphy_to_adapter(wiphy);
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
- RT_CHANNEL_INFO *channel_set = pmlmeext->channel_set;
+ struct rt_channel_info *channel_set = pmlmeext->channel_set;
u8 max_chan_nums = pmlmeext->max_chan_nums;
struct ieee80211_supported_band *sband;
@@ -150,7 +150,5 @@ void rtw_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
{
struct rtw_regulatory *reg = NULL;
- DBG_8192C("%s\n", __func__);
-
_rtw_reg_notifier_apply(wiphy, request, reg);
}
diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
index b060a6a2df34..639408eaf4df 100644
--- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
@@ -15,7 +15,7 @@ uint rtw_remainder_len(struct pkt_file *pfile)
return (pfile->buf_len - ((SIZE_PTR)(pfile->cur_addr) - (SIZE_PTR)(pfile->buf_start)));
}
-void _rtw_open_pktfile(_pkt *pktptr, struct pkt_file *pfile)
+void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile)
{
pfile->pkt = pktptr;
pfile->cur_addr = pfile->buf_start = pktptr->data;
@@ -39,7 +39,7 @@ uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen)
return len;
}
-sint rtw_endofpktfile(struct pkt_file *pfile)
+signed int rtw_endofpktfile(struct pkt_file *pfile)
{
if (pfile->pkt_len == 0)
return true;
@@ -67,7 +67,7 @@ void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitb
#define WMM_XMIT_THRESHOLD (NR_XMITFRAME * 2 / 5)
-void rtw_os_pkt_complete(struct adapter *padapter, _pkt *pkt)
+void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt)
{
u16 queue;
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
@@ -104,7 +104,7 @@ void rtw_os_xmit_schedule(struct adapter *padapter)
complete(&pri_adapter->xmitpriv.xmit_comp);
}
-static void rtw_check_xmit_resource(struct adapter *padapter, _pkt *pkt)
+static void rtw_check_xmit_resource(struct adapter *padapter, struct sk_buff *pkt)
{
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
u16 queue;
@@ -112,10 +112,8 @@ static void rtw_check_xmit_resource(struct adapter *padapter, _pkt *pkt)
queue = skb_get_queue_mapping(pkt);
if (padapter->registrypriv.wifi_spec) {
/* No free space for Tx, tx_worker is too slow */
- if (pxmitpriv->hwxmits[queue].accnt > WMM_XMIT_THRESHOLD) {
- /* DBG_871X("%s(): stop netif_subqueue[%d]\n", __func__, queue); */
+ if (pxmitpriv->hwxmits[queue].accnt > WMM_XMIT_THRESHOLD)
netif_stop_subqueue(padapter->pnetdev, queue);
- }
} else {
if (pxmitpriv->free_xmitframe_cnt <= 4) {
if (!netif_tx_queue_stopped(netdev_get_tx_queue(padapter->pnetdev, queue)))
@@ -139,8 +137,6 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
int i;
s32 res;
- DBG_COUNTER(padapter->tx_logs.os_tx_m2u);
-
spin_lock_bh(&pstapriv->asoc_list_lock);
phead = &pstapriv->asoc_list;
plist = get_next(phead);
@@ -160,20 +156,14 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
for (i = 0; i < chk_alive_num; i++) {
psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]);
- if (!(psta->state & _FW_LINKED)) {
- DBG_COUNTER(padapter->tx_logs.os_tx_m2u_ignore_fw_linked);
+ if (!(psta->state & _FW_LINKED))
continue;
- }
/* avoid come from STA1 and send back STA1 */
if (!memcmp(psta->hwaddr, &skb->data[6], 6) ||
!memcmp(psta->hwaddr, null_addr, 6) ||
- !memcmp(psta->hwaddr, bc_addr, 6)) {
- DBG_COUNTER(padapter->tx_logs.os_tx_m2u_ignore_self);
+ !memcmp(psta->hwaddr, bc_addr, 6))
continue;
- }
-
- DBG_COUNTER(padapter->tx_logs.os_tx_m2u_entry);
newskb = rtw_skb_copy(skb);
@@ -181,14 +171,10 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
memcpy(newskb->data, psta->hwaddr, 6);
res = rtw_xmit(padapter, &newskb);
if (res < 0) {
- DBG_COUNTER(padapter->tx_logs.os_tx_m2u_entry_err_xmit);
- DBG_871X("%s()-%d: rtw_xmit() return error!\n", __func__, __LINE__);
pxmitpriv->tx_drop++;
dev_kfree_skb_any(newskb);
}
} else {
- DBG_COUNTER(padapter->tx_logs.os_tx_m2u_entry_err_skb);
- DBG_871X("%s-%d: rtw_skb_copy() failed!\n", __func__, __LINE__);
pxmitpriv->tx_drop++;
/* dev_kfree_skb_any(skb); */
return false; /* Caller shall tx this multicast frame via normal way. */
@@ -199,24 +185,15 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
return true;
}
-int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev)
+int _rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev)
{
struct adapter *padapter = rtw_netdev_priv(pnetdev);
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
s32 res = 0;
- DBG_COUNTER(padapter->tx_logs.os_tx);
- RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("+xmit_enry\n"));
-
- if (rtw_if_up(padapter) == false) {
- DBG_COUNTER(padapter->tx_logs.os_tx_err_up);
- RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit_entry: rtw_if_up fail\n"));
- #ifdef DBG_TX_DROP_FRAME
- DBG_871X("DBG_TX_DROP_FRAME %s if_up fail\n", __func__);
- #endif
+ if (rtw_if_up(padapter) == false)
goto drop_packet;
- }
rtw_check_xmit_resource(padapter, pkt);
@@ -224,50 +201,35 @@ int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev)
&& check_fwstate(pmlmepriv, WIFI_AP_STATE) == true
&& (IP_MCAST_MAC(pkt->data)
|| ICMPV6_MCAST_MAC(pkt->data)
- #ifdef CONFIG_TX_BCAST2UNI
- || is_broadcast_mac_addr(pkt->data)
- #endif
)
&& padapter->registrypriv.wifi_spec == 0) {
if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME / 4)) {
res = rtw_mlcst2unicst(padapter, pkt);
if (res)
goto exit;
- } else {
- /* DBG_871X("Stop M2U(%d, %d)! ", pxmitpriv->free_xmitframe_cnt, pxmitpriv->free_xmitbuf_cnt); */
- /* DBG_871X("!m2u); */
- DBG_COUNTER(padapter->tx_logs.os_tx_m2u_stop);
}
}
res = rtw_xmit(padapter, &pkt);
- if (res < 0) {
- #ifdef DBG_TX_DROP_FRAME
- DBG_871X("DBG_TX_DROP_FRAME %s rtw_xmit fail\n", __func__);
- #endif
+ if (res < 0)
goto drop_packet;
- }
- RT_TRACE(_module_xmit_osdep_c_, _drv_info_, ("rtw_xmit_entry: tx_pkts =%d\n", (u32)pxmitpriv->tx_pkts));
goto exit;
drop_packet:
pxmitpriv->tx_drop++;
dev_kfree_skb_any(pkt);
- RT_TRACE(_module_xmit_osdep_c_, _drv_notice_, ("rtw_xmit_entry: drop, tx_drop =%d\n", (u32)pxmitpriv->tx_drop));
exit:
return 0;
}
-int rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev)
+int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev)
{
int ret = 0;
- if (pkt) {
- rtw_mstat_update(MSTAT_TYPE_SKB, MSTAT_ALLOC_SUCCESS, pkt->truesize);
+ if (pkt)
ret = _rtw_xmit_entry(pkt, pnetdev);
- }
return ret;
}
diff --git a/drivers/staging/rts5208/xd.c b/drivers/staging/rts5208/xd.c
index 0f369935fb6c..a305e15dfb9c 100644
--- a/drivers/staging/rts5208/xd.c
+++ b/drivers/staging/rts5208/xd.c
@@ -1628,7 +1628,6 @@ static int xd_finish_write(struct rtsx_chip *chip,
int retval, zone_no;
u16 log_off;
- dev_dbg(rtsx_dev(chip), "%s ", __func__);
dev_dbg(rtsx_dev(chip), "old_blk = 0x%x, ", old_blk);
dev_dbg(rtsx_dev(chip), "new_blk = 0x%x, ", new_blk);
dev_dbg(rtsx_dev(chip), "log_blk = 0x%x\n", log_blk);
@@ -1806,7 +1805,6 @@ int xd_delay_write(struct rtsx_chip *chip)
int retval;
if (delay_write->delay_write_flag) {
- dev_dbg(rtsx_dev(chip), "%s\n", __func__);
retval = xd_switch_clock(chip);
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h
index 19823c7277a4..23eefd019ec9 100644
--- a/drivers/staging/sm750fb/sm750.h
+++ b/drivers/staging/sm750fb/sm750.h
@@ -55,23 +55,27 @@ struct lynx_accel {
volatile unsigned char __iomem *dpPortBase;
/* function pointers */
- void (*de_init)(struct lynx_accel *);
+ void (*de_init)(struct lynx_accel *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);
+ int (*de_fillrect)(struct lynx_accel *accel,
+ u32 base, u32 pitch, u32 bpp,
+ u32 x, u32 y, u32 width, u32 height,
+ u32 color, u32 rop);
+
+ int (*de_copyarea)(struct lynx_accel *accel,
+ u32 s_base, u32 s_pitch,
+ u32 sx, u32 sy,
+ u32 d_base, u32 d_pitch,
+ u32 bpp, u32 dx, u32 dy,
+ u32 width, u32 height,
+ u32 rop2);
+
+ int (*de_imageblit)(struct lynx_accel *accel, const char *p_srcbuf,
+ u32 src_delta, u32 start_bit, u32 d_base, u32 d_pitch,
+ u32 byte_per_pixel, u32 dx, u32 dy, u32 width,
+ u32 height, u32 f_color, u32 b_color, u32 rop2);
};
diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c
index 0433536930a9..a3bc568c660d 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -122,7 +122,6 @@ struct chanstat {
* @n_rcv_packets_not_accepted: # bogs rcv packets.
* @queuefullmsg_logged:
* @struct chstat:
- * @struct irq_poll_timer:
* @struct napi:
* @struct cmdrsp:
*/
@@ -183,7 +182,6 @@ struct visornic_devdata {
int queuefullmsg_logged;
struct chanstat chstat;
- struct timer_list irq_poll_timer;
struct napi_struct napi;
struct uiscmdrsp cmdrsp[SIZEOF_CMDRSP];
};
@@ -341,7 +339,7 @@ static void visornic_serverdown_complete(struct visornic_devdata *devdata)
struct net_device *netdev = devdata->netdev;
/* Stop polling for interrupts */
- del_timer_sync(&devdata->irq_poll_timer);
+ visorbus_disable_channel_interrupts(devdata->dev);
rtnl_lock();
dev_close(netdev);
@@ -534,7 +532,7 @@ static int visornic_disable_with_timeout(struct net_device *netdev,
return err;
/* wait for ack to arrive before we try to free rcv buffers
- * NOTE: the other end automatically unposts the rcv buffers when
+ * NOTE: the other end automatically unposts the rcv buffers
* when it gets a disable.
*/
spin_lock_irqsave(&devdata->priv_lock, flags);
@@ -1749,17 +1747,17 @@ static int visornic_poll(struct napi_struct *napi, int budget)
return rx_count;
}
-/* poll_for_irq - checks the status of the response queue
- * @t: pointer to the 'struct timer_list' from which we can retrieve the
- * the visornic devdata struct.
+/* visornic_channel_interrupt - checks the status of the response queue
*
* Main function of the vnic_incoming thread. Periodically check the response
* queue and drain it if needed.
*/
-static void poll_for_irq(struct timer_list *t)
+static void visornic_channel_interrupt(struct visor_device *dev)
{
- struct visornic_devdata *devdata = from_timer(devdata, t,
- irq_poll_timer);
+ struct visornic_devdata *devdata = dev_get_drvdata(&dev->device);
+
+ if (!devdata)
+ return;
if (!visorchannel_signalempty(
devdata->dev->visorchannel,
@@ -1768,7 +1766,6 @@ static void poll_for_irq(struct timer_list *t)
atomic_set(&devdata->interrupt_rcvd, 0);
- mod_timer(&devdata->irq_poll_timer, msecs_to_jiffies(2));
}
/* visornic_probe - probe function for visornic devices
@@ -1890,13 +1887,6 @@ static int visornic_probe(struct visor_device *dev)
/* Let's start our threads to get responses */
netif_napi_add(netdev, &devdata->napi, visornic_poll, NAPI_WEIGHT);
- timer_setup(&devdata->irq_poll_timer, poll_for_irq, 0);
- /* Note: This time has to start running before the while
- * loop below because the napi routine is responsible for
- * setting enab_dis_acked
- */
- mod_timer(&devdata->irq_poll_timer, msecs_to_jiffies(2));
-
channel_offset = offsetof(struct visor_io_channel,
channel_header.features);
err = visorbus_read_channel(dev, channel_offset, &features, 8);
@@ -1949,7 +1939,7 @@ cleanup_register_netdev:
unregister_netdev(netdev);
cleanup_napi_add:
- del_timer_sync(&devdata->irq_poll_timer);
+ visorbus_disable_channel_interrupts(dev);
netif_napi_del(&devdata->napi);
cleanup_xmit_cmdrsp:
@@ -2017,7 +2007,7 @@ static void visornic_remove(struct visor_device *dev)
/* this will call visornic_close() */
unregister_netdev(netdev);
- del_timer_sync(&devdata->irq_poll_timer);
+ visorbus_disable_channel_interrupts(devdata->dev);
netif_napi_del(&devdata->napi);
dev_set_drvdata(&dev->device, NULL);
@@ -2091,7 +2081,7 @@ static int visornic_resume(struct visor_device *dev,
* we can start using the device again.
* TODO: State transitions
*/
- mod_timer(&devdata->irq_poll_timer, msecs_to_jiffies(2));
+ visorbus_enable_channel_interrupts(dev);
rtnl_lock();
dev_open(netdev, NULL);
@@ -2113,7 +2103,7 @@ static struct visor_driver visornic_driver = {
.remove = visornic_remove,
.pause = visornic_pause,
.resume = visornic_resume,
- .channel_interrupt = NULL,
+ .channel_interrupt = visornic_channel_interrupt,
};
/* visornic_init - init function
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
index 542aff131d06..f2ef1d641e70 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
@@ -14,14 +14,14 @@ static const struct snd_pcm_hardware snd_bcm2835_playback_hw = {
SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_SYNC_APPLPTR | SNDRV_PCM_INFO_BATCH),
.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE,
- .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
+ .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_192000,
.rate_min = 8000,
- .rate_max = 48000,
+ .rate_max = 192000,
.channels_min = 1,
- .channels_max = 2,
- .buffer_bytes_max = 128 * 1024,
+ .channels_max = 8,
+ .buffer_bytes_max = 512 * 1024,
.period_bytes_min = 1 * 1024,
- .period_bytes_max = 128 * 1024,
+ .period_bytes_max = 512 * 1024,
.periods_min = 1,
.periods_max = 128,
};
diff --git a/drivers/staging/vc04_services/interface/TODO b/drivers/staging/vc04_services/interface/TODO
index 0bcb8f158afc..39810ce017cd 100644
--- a/drivers/staging/vc04_services/interface/TODO
+++ b/drivers/staging/vc04_services/interface/TODO
@@ -27,8 +27,8 @@ unused.
3) Make driver more portable
Building this driver with arm/multi_v7_defconfig or arm64/defconfig
-leads to data corruption during the following command:
-
+leads to data corruption during the following command:
+
vchiq_test -f 1
This should be fixed.
@@ -37,7 +37,7 @@ This should be fixed.
Even the VPU firmware doesn't support a VCHI re-connect, the driver
should properly handle a module unload. This also includes that all
-resouces must be freed (kthreads, debugfs entries, ...) and global
+resources must be freed (kthreads, debugfs entries, ...) and global
variables avoided.
5) Cleanup logging mechanism
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 59e45dc03a97..8b2b4771f420 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -2332,8 +2332,10 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service,
int *entity_uc;
int local_uc;
- if (!arm_state)
+ if (!arm_state) {
+ ret = VCHIQ_ERROR;
goto out;
+ }
vchiq_log_trace(vchiq_susp_log_level, "%s", __func__);
@@ -2389,8 +2391,10 @@ vchiq_release_internal(struct vchiq_state *state, struct vchiq_service *service)
char entity[16];
int *entity_uc;
- if (!arm_state)
+ if (!arm_state) {
+ ret = VCHIQ_ERROR;
goto out;
+ }
vchiq_log_trace(vchiq_susp_log_level, "%s", __func__);
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 0b0a97bfd01c..517a8c9b41ed 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -28,6 +28,8 @@
((unsigned int)(info - state->slot_info))
#define SLOT_QUEUE_INDEX_FROM_POS(pos) \
((int)((unsigned int)(pos) / VCHIQ_SLOT_SIZE))
+#define SLOT_QUEUE_INDEX_FROM_POS_MASKED(pos) \
+ (SLOT_QUEUE_INDEX_FROM_POS(pos) & VCHIQ_SLOT_QUEUE_MASK)
#define BULK_INDEX(x) (x & (VCHIQ_NUM_SERVICE_BULKS - 1))
@@ -338,7 +340,7 @@ static void
mark_service_closing_internal(struct vchiq_service *service, int sh_thread)
{
struct vchiq_state *state = service->state;
- struct vchiq_service_quota *service_quota;
+ struct vchiq_service_quota *quota;
service->closing = 1;
@@ -357,8 +359,8 @@ mark_service_closing_internal(struct vchiq_service *service, int sh_thread)
}
/* Unblock any sending thread. */
- service_quota = &state->service_quotas[service->localport];
- complete(&service_quota->quota_event);
+ quota = &state->service_quotas[service->localport];
+ complete(&quota->quota_event);
}
static void
@@ -537,22 +539,23 @@ request_poll(struct vchiq_state *state, struct vchiq_service *service,
int poll_type)
{
u32 value;
+ int index;
- if (service) {
- do {
- value = atomic_read(&service->poll_flags);
- } while (atomic_cmpxchg(&service->poll_flags, value,
- value | BIT(poll_type)) != value);
+ if (!service)
+ goto skip_service;
- do {
- value = atomic_read(&state->poll_services[
- service->localport>>5]);
- } while (atomic_cmpxchg(
- &state->poll_services[service->localport>>5],
- value, value | BIT(service->localport & 0x1f))
- != value);
- }
+ do {
+ value = atomic_read(&service->poll_flags);
+ } while (atomic_cmpxchg(&service->poll_flags, value,
+ value | BIT(poll_type)) != value);
+
+ index = BITSET_WORD(service->localport);
+ do {
+ value = atomic_read(&state->poll_services[index]);
+ } while (atomic_cmpxchg(&state->poll_services[index],
+ value, value | BIT(service->localport & 0x1f)) != value);
+skip_service:
state->poll_needed = 1;
wmb();
@@ -612,8 +615,7 @@ reserve_space(struct vchiq_state *state, size_t space, int is_blocking)
}
slot_index = local->slot_queue[
- SLOT_QUEUE_INDEX_FROM_POS(tx_pos) &
- VCHIQ_SLOT_QUEUE_MASK];
+ SLOT_QUEUE_INDEX_FROM_POS_MASKED(tx_pos)];
state->tx_data =
(char *)SLOT_DATA_FROM_INDEX(state, slot_index);
}
@@ -674,28 +676,28 @@ process_free_queue(struct vchiq_state *state, BITSET_T *service_found,
if (VCHIQ_MSG_TYPE(msgid) == VCHIQ_MSG_DATA) {
int port = VCHIQ_MSG_SRCPORT(msgid);
- struct vchiq_service_quota *service_quota =
+ struct vchiq_service_quota *quota =
&state->service_quotas[port];
int count;
spin_lock(&quota_spinlock);
- count = service_quota->message_use_count;
+ count = quota->message_use_count;
if (count > 0)
- service_quota->message_use_count =
+ quota->message_use_count =
count - 1;
spin_unlock(&quota_spinlock);
- if (count == service_quota->message_quota)
+ if (count == quota->message_quota)
/*
* Signal the service that it
* has dropped below its quota
*/
- complete(&service_quota->quota_event);
+ complete(&quota->quota_event);
else if (count == 0) {
vchiq_log_error(vchiq_core_log_level,
"service %d message_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)",
port,
- service_quota->message_use_count,
+ quota->message_use_count,
header, msgid, header->msgid,
header->size);
WARN(1, "invalid message use count\n");
@@ -705,9 +707,9 @@ process_free_queue(struct vchiq_state *state, BITSET_T *service_found,
BITSET_SET(service_found, port);
spin_lock(&quota_spinlock);
- count = service_quota->slot_use_count;
+ count = quota->slot_use_count;
if (count > 0)
- service_quota->slot_use_count =
+ quota->slot_use_count =
count - 1;
spin_unlock(&quota_spinlock);
@@ -716,7 +718,7 @@ process_free_queue(struct vchiq_state *state, BITSET_T *service_found,
* Signal the service in case
* it has dropped below its quota
*/
- complete(&service_quota->quota_event);
+ complete(&quota->quota_event);
vchiq_log_trace(
vchiq_core_log_level,
"%d: pfq:%d %x@%pK - slot_use->%d",
@@ -822,7 +824,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
void *context, size_t size, int flags)
{
struct vchiq_shared_state *local;
- struct vchiq_service_quota *service_quota = NULL;
+ struct vchiq_service_quota *quota = NULL;
struct vchiq_header *header;
int type = VCHIQ_MSG_TYPE(msgid);
@@ -856,7 +858,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
return VCHIQ_ERROR;
}
- service_quota = &state->service_quotas[service->localport];
+ quota = &state->service_quotas[service->localport];
spin_lock(&quota_spinlock);
@@ -893,22 +895,21 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
}
}
- while ((service_quota->message_use_count ==
- service_quota->message_quota) ||
- ((tx_end_index != service_quota->previous_tx_index) &&
- (service_quota->slot_use_count ==
- service_quota->slot_quota))) {
+ while ((quota->message_use_count == quota->message_quota) ||
+ ((tx_end_index != quota->previous_tx_index) &&
+ (quota->slot_use_count ==
+ quota->slot_quota))) {
spin_unlock(&quota_spinlock);
vchiq_log_trace(vchiq_core_log_level,
"%d: qm:%d %s,%zx - quota stall (msg %d, slot %d)",
state->id, service->localport,
msg_type_str(type), size,
- service_quota->message_use_count,
- service_quota->slot_use_count);
+ quota->message_use_count,
+ quota->slot_use_count);
VCHIQ_SERVICE_STATS_INC(service, quota_stalls);
mutex_unlock(&state->slot_mutex);
if (wait_for_completion_interruptible(
- &service_quota->quota_event))
+ &quota->quota_event))
return VCHIQ_RETRY;
if (service->closing)
return VCHIQ_ERROR;
@@ -974,7 +975,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
(size_t)callback_result));
spin_lock(&quota_spinlock);
- service_quota->message_use_count++;
+ quota->message_use_count++;
tx_end_index =
SLOT_QUEUE_INDEX_FROM_POS(state->local_tx_pos - 1);
@@ -992,9 +993,9 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
* If this isn't the same slot last used by this service,
* the service's slot_use_count must be increased.
*/
- if (tx_end_index != service_quota->previous_tx_index) {
- service_quota->previous_tx_index = tx_end_index;
- slot_use_count = ++service_quota->slot_use_count;
+ if (tx_end_index != quota->previous_tx_index) {
+ quota->previous_tx_index = tx_end_index;
+ slot_use_count = ++quota->slot_use_count;
} else {
slot_use_count = 0;
}
@@ -1567,8 +1568,7 @@ parse_rx_slots(struct vchiq_state *state)
WARN_ON(!((state->rx_pos & VCHIQ_SLOT_MASK) == 0));
rx_index = remote->slot_queue[
- SLOT_QUEUE_INDEX_FROM_POS(state->rx_pos) &
- VCHIQ_SLOT_QUEUE_MASK];
+ SLOT_QUEUE_INDEX_FROM_POS_MASKED(state->rx_pos)];
state->rx_data = (char *)SLOT_DATA_FROM_INDEX(state,
rx_index);
state->rx_info = SLOT_INFO_FROM_INDEX(state, rx_index);
@@ -1681,8 +1681,7 @@ parse_rx_slots(struct vchiq_state *state)
"%d: prs OPENACK@%pK,%x (%d->%d) v:%d",
state->id, header, size, remoteport, localport,
service->peer_version);
- if (service->srvstate ==
- VCHIQ_SRVSTATE_OPENING) {
+ if (service->srvstate == VCHIQ_SRVSTATE_OPENING) {
service->remoteport = remoteport;
vchiq_set_service_state(service,
VCHIQ_SRVSTATE_OPEN);
@@ -1716,9 +1715,8 @@ parse_rx_slots(struct vchiq_state *state)
"%d: prs DATA@%pK,%x (%d->%d)",
state->id, header, size, remoteport, localport);
- if ((service->remoteport == remoteport)
- && (service->srvstate ==
- VCHIQ_SRVSTATE_OPEN)) {
+ if ((service->remoteport == remoteport) &&
+ (service->srvstate == VCHIQ_SRVSTATE_OPEN)) {
header->msgid = msgid | VCHIQ_MSGID_CLAIMED;
claim_slot(state->rx_info);
DEBUG_TRACE(PARSE_LINE);
@@ -1753,9 +1751,8 @@ parse_rx_slots(struct vchiq_state *state)
break;
case VCHIQ_MSG_BULK_RX_DONE:
case VCHIQ_MSG_BULK_TX_DONE:
- if ((service->remoteport == remoteport)
- && (service->srvstate !=
- VCHIQ_SRVSTATE_FREE)) {
+ if ((service->remoteport == remoteport) &&
+ (service->srvstate != VCHIQ_SRVSTATE_FREE)) {
struct vchiq_bulk_queue *queue;
struct vchiq_bulk *bulk;
@@ -2209,9 +2206,9 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero)
state->slot_queue_available = 0;
for (i = 0; i < VCHIQ_MAX_SERVICES; i++) {
- struct vchiq_service_quota *service_quota =
+ struct vchiq_service_quota *quota =
&state->service_quotas[i];
- init_completion(&service_quota->quota_event);
+ init_completion(&quota->quota_event);
}
for (i = local->slot_first; i <= local->slot_last; i++) {
@@ -2366,7 +2363,7 @@ vchiq_add_service_internal(struct vchiq_state *state,
{
struct vchiq_service *service;
struct vchiq_service __rcu **pservice = NULL;
- struct vchiq_service_quota *service_quota;
+ struct vchiq_service_quota *quota;
int ret;
int i;
@@ -2445,10 +2442,9 @@ vchiq_add_service_internal(struct vchiq_state *state,
srv = rcu_dereference(state->services[i]);
if (!srv)
pservice = &state->services[i];
- else if ((srv->public_fourcc == params->fourcc)
- && ((srv->instance != instance) ||
- (srv->base.callback !=
- params->callback))) {
+ else if ((srv->public_fourcc == params->fourcc) &&
+ ((srv->instance != instance) ||
+ (srv->base.callback != params->callback))) {
/*
* There is another server using this
* fourcc which doesn't match.
@@ -2481,11 +2477,11 @@ vchiq_add_service_internal(struct vchiq_state *state,
return NULL;
}
- service_quota = &state->service_quotas[service->localport];
- service_quota->slot_quota = state->default_slot_quota;
- service_quota->message_quota = state->default_message_quota;
- if (service_quota->slot_use_count == 0)
- service_quota->previous_tx_index =
+ quota = &state->service_quotas[service->localport];
+ quota->slot_quota = state->default_slot_quota;
+ quota->message_quota = state->default_message_quota;
+ if (quota->slot_use_count == 0)
+ quota->previous_tx_index =
SLOT_QUEUE_INDEX_FROM_POS(state->local_tx_pos)
- 1;
@@ -2526,24 +2522,27 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id)
&payload,
sizeof(payload),
QMFLAGS_IS_BLOCKING);
- if (status == VCHIQ_SUCCESS) {
- /* Wait for the ACK/NAK */
- if (wait_for_completion_interruptible(&service->remove_event)) {
- status = VCHIQ_RETRY;
- vchiq_release_service_internal(service);
- } else if ((service->srvstate != VCHIQ_SRVSTATE_OPEN) &&
- (service->srvstate != VCHIQ_SRVSTATE_OPENSYNC)) {
- if (service->srvstate != VCHIQ_SRVSTATE_CLOSEWAIT)
- vchiq_log_error(vchiq_core_log_level,
- "%d: osi - srvstate = %s (ref %u)",
- service->state->id,
- srvstate_names[service->srvstate],
- kref_read(&service->ref_count));
- status = VCHIQ_ERROR;
- VCHIQ_SERVICE_STATS_INC(service, error_count);
- vchiq_release_service_internal(service);
- }
+
+ if (status != VCHIQ_SUCCESS)
+ return status;
+
+ /* Wait for the ACK/NAK */
+ if (wait_for_completion_interruptible(&service->remove_event)) {
+ status = VCHIQ_RETRY;
+ vchiq_release_service_internal(service);
+ } else if ((service->srvstate != VCHIQ_SRVSTATE_OPEN) &&
+ (service->srvstate != VCHIQ_SRVSTATE_OPENSYNC)) {
+ if (service->srvstate != VCHIQ_SRVSTATE_CLOSEWAIT)
+ vchiq_log_error(vchiq_core_log_level,
+ "%d: osi - srvstate = %s (ref %u)",
+ service->state->id,
+ srvstate_names[service->srvstate],
+ kref_read(&service->ref_count));
+ status = VCHIQ_ERROR;
+ VCHIQ_SERVICE_STATS_INC(service, error_count);
+ vchiq_release_service_internal(service);
}
+
return status;
}
@@ -2939,8 +2938,8 @@ vchiq_close_service(unsigned int handle)
service->state->id, service->localport);
if ((service->srvstate == VCHIQ_SRVSTATE_FREE) ||
- (service->srvstate == VCHIQ_SRVSTATE_LISTENING) ||
- (service->srvstate == VCHIQ_SRVSTATE_HIDDEN)) {
+ (service->srvstate == VCHIQ_SRVSTATE_LISTENING) ||
+ (service->srvstate == VCHIQ_SRVSTATE_HIDDEN)) {
unlock_service(service);
return VCHIQ_ERROR;
}
@@ -2963,8 +2962,8 @@ vchiq_close_service(unsigned int handle)
}
if ((service->srvstate == VCHIQ_SRVSTATE_FREE) ||
- (service->srvstate == VCHIQ_SRVSTATE_LISTENING) ||
- (service->srvstate == VCHIQ_SRVSTATE_OPEN))
+ (service->srvstate == VCHIQ_SRVSTATE_LISTENING) ||
+ (service->srvstate == VCHIQ_SRVSTATE_OPEN))
break;
vchiq_log_warning(vchiq_core_log_level,
@@ -2974,8 +2973,8 @@ vchiq_close_service(unsigned int handle)
}
if ((status == VCHIQ_SUCCESS) &&
- (service->srvstate != VCHIQ_SRVSTATE_FREE) &&
- (service->srvstate != VCHIQ_SRVSTATE_LISTENING))
+ (service->srvstate != VCHIQ_SRVSTATE_FREE) &&
+ (service->srvstate != VCHIQ_SRVSTATE_LISTENING))
status = VCHIQ_ERROR;
unlock_service(service);
@@ -3006,7 +3005,7 @@ vchiq_remove_service(unsigned int handle)
mark_service_closing(service);
if ((service->srvstate == VCHIQ_SRVSTATE_HIDDEN) ||
- (current == service->state->slot_handler_thread)) {
+ (current == service->state->slot_handler_thread)) {
/*
* Make it look like a client, because it must be removed and
* not left in the LISTENING state.
@@ -3027,7 +3026,7 @@ vchiq_remove_service(unsigned int handle)
}
if ((service->srvstate == VCHIQ_SRVSTATE_FREE) ||
- (service->srvstate == VCHIQ_SRVSTATE_OPEN))
+ (service->srvstate == VCHIQ_SRVSTATE_OPEN))
break;
vchiq_log_warning(vchiq_core_log_level,
@@ -3037,7 +3036,7 @@ vchiq_remove_service(unsigned int handle)
}
if ((status == VCHIQ_SUCCESS) &&
- (service->srvstate != VCHIQ_SRVSTATE_FREE))
+ (service->srvstate != VCHIQ_SRVSTATE_FREE))
status = VCHIQ_ERROR;
unlock_service(service);
@@ -3070,9 +3069,16 @@ enum vchiq_status vchiq_bulk_transfer(unsigned int handle,
enum vchiq_status status = VCHIQ_ERROR;
int payload[2];
- if (!service || service->srvstate != VCHIQ_SRVSTATE_OPEN ||
- (!offset && !uoffset) ||
- vchiq_check_service(service) != VCHIQ_SUCCESS)
+ if (!service)
+ goto error_exit;
+
+ if (service->srvstate != VCHIQ_SRVSTATE_OPEN)
+ goto error_exit;
+
+ if (!offset && !uoffset)
+ goto error_exit;
+
+ if (vchiq_check_service(service) != VCHIQ_SUCCESS)
goto error_exit;
switch (mode) {
@@ -3216,8 +3222,10 @@ vchiq_queue_message(unsigned int handle,
struct vchiq_service *service = find_service_by_handle(handle);
enum vchiq_status status = VCHIQ_ERROR;
- if (!service ||
- (vchiq_check_service(service) != VCHIQ_SUCCESS))
+ if (!service)
+ goto error_exit;
+
+ if (vchiq_check_service(service) != VCHIQ_SUCCESS)
goto error_exit;
if (!size) {
@@ -3299,7 +3307,7 @@ vchiq_release_message(unsigned int handle,
slot_index = SLOT_INDEX_FROM_DATA(state, (void *)header);
if ((slot_index >= remote->slot_first) &&
- (slot_index <= remote->slot_last)) {
+ (slot_index <= remote->slot_last)) {
int msgid = header->msgid;
if (msgid & VCHIQ_MSGID_CLAIMED) {
@@ -3328,10 +3336,15 @@ vchiq_get_peer_version(unsigned int handle, short *peer_version)
enum vchiq_status status = VCHIQ_ERROR;
struct vchiq_service *service = find_service_by_handle(handle);
- if (!service ||
- (vchiq_check_service(service) != VCHIQ_SUCCESS) ||
- !peer_version)
+ if (!service)
+ goto exit;
+
+ if (vchiq_check_service(service) != VCHIQ_SUCCESS)
goto exit;
+
+ if (!peer_version)
+ goto exit;
+
*peer_version = service->peer_version;
status = VCHIQ_SUCCESS;
@@ -3358,77 +3371,70 @@ vchiq_set_service_option(unsigned int handle,
{
struct vchiq_service *service = find_service_by_handle(handle);
enum vchiq_status status = VCHIQ_ERROR;
+ struct vchiq_service_quota *quota;
- if (service) {
- switch (option) {
- case VCHIQ_SERVICE_OPTION_AUTOCLOSE:
- service->auto_close = value;
- status = VCHIQ_SUCCESS;
- break;
+ if (!service)
+ return VCHIQ_ERROR;
- case VCHIQ_SERVICE_OPTION_SLOT_QUOTA: {
- struct vchiq_service_quota *service_quota =
- &service->state->service_quotas[
- service->localport];
- if (value == 0)
- value = service->state->default_slot_quota;
- if ((value >= service_quota->slot_use_count) &&
- (value < (unsigned short)~0)) {
- service_quota->slot_quota = value;
- if ((value >= service_quota->slot_use_count) &&
- (service_quota->message_quota >=
- service_quota->message_use_count)) {
- /*
- * Signal the service that it may have
- * dropped below its quota
- */
- complete(&service_quota->quota_event);
- }
- status = VCHIQ_SUCCESS;
- }
- } break;
-
- case VCHIQ_SERVICE_OPTION_MESSAGE_QUOTA: {
- struct vchiq_service_quota *service_quota =
- &service->state->service_quotas[
- service->localport];
- if (value == 0)
- value = service->state->default_message_quota;
- if ((value >= service_quota->message_use_count) &&
- (value < (unsigned short)~0)) {
- service_quota->message_quota = value;
- if ((value >=
- service_quota->message_use_count) &&
- (service_quota->slot_quota >=
- service_quota->slot_use_count))
- /*
- * Signal the service that it may have
- * dropped below its quota
- */
- complete(&service_quota->quota_event);
- status = VCHIQ_SUCCESS;
- }
- } break;
+ switch (option) {
+ case VCHIQ_SERVICE_OPTION_AUTOCLOSE:
+ service->auto_close = value;
+ status = VCHIQ_SUCCESS;
+ break;
- case VCHIQ_SERVICE_OPTION_SYNCHRONOUS:
- if ((service->srvstate == VCHIQ_SRVSTATE_HIDDEN) ||
- (service->srvstate ==
- VCHIQ_SRVSTATE_LISTENING)) {
- service->sync = value;
- status = VCHIQ_SUCCESS;
- }
- break;
+ case VCHIQ_SERVICE_OPTION_SLOT_QUOTA:
+ quota = &service->state->service_quotas[service->localport];
+ if (value == 0)
+ value = service->state->default_slot_quota;
+ if ((value >= quota->slot_use_count) &&
+ (value < (unsigned short)~0)) {
+ quota->slot_quota = value;
+ if ((value >= quota->slot_use_count) &&
+ (quota->message_quota >= quota->message_use_count))
+ /*
+ * Signal the service that it may have
+ * dropped below its quota
+ */
+ complete(&quota->quota_event);
+ status = VCHIQ_SUCCESS;
+ }
+ break;
- case VCHIQ_SERVICE_OPTION_TRACE:
- service->trace = value;
+ case VCHIQ_SERVICE_OPTION_MESSAGE_QUOTA:
+ quota = &service->state->service_quotas[service->localport];
+ if (value == 0)
+ value = service->state->default_message_quota;
+ if ((value >= quota->message_use_count) &&
+ (value < (unsigned short)~0)) {
+ quota->message_quota = value;
+ if ((value >= quota->message_use_count) &&
+ (quota->slot_quota >= quota->slot_use_count))
+ /*
+ * Signal the service that it may have
+ * dropped below its quota
+ */
+ complete(&quota->quota_event);
status = VCHIQ_SUCCESS;
- break;
+ }
+ break;
- default:
- break;
+ case VCHIQ_SERVICE_OPTION_SYNCHRONOUS:
+ if ((service->srvstate == VCHIQ_SRVSTATE_HIDDEN) ||
+ (service->srvstate == VCHIQ_SRVSTATE_LISTENING)) {
+ service->sync = value;
+ status = VCHIQ_SUCCESS;
}
- unlock_service(service);
+ break;
+
+ case VCHIQ_SERVICE_OPTION_TRACE:
+ service->trace = value;
+ status = VCHIQ_SUCCESS;
+ break;
+
+ default:
+ break;
}
+ unlock_service(service);
return status;
}
@@ -3592,7 +3598,7 @@ int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service)
if (service->srvstate != VCHIQ_SRVSTATE_FREE) {
char remoteport[30];
- struct vchiq_service_quota *service_quota =
+ struct vchiq_service_quota *quota =
&service->state->service_quotas[service->localport];
int fourcc = service->base.fourcc;
int tx_pending, rx_pending;
@@ -3612,10 +3618,10 @@ int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service)
" '%c%c%c%c' remote %s (msg use %d/%d, slot use %d/%d)",
VCHIQ_FOURCC_AS_4CHARS(fourcc),
remoteport,
- service_quota->message_use_count,
- service_quota->message_quota,
- service_quota->slot_use_count,
- service_quota->slot_quota);
+ quota->message_use_count,
+ quota->message_quota,
+ quota->slot_use_count,
+ quota->slot_quota);
err = vchiq_dump(dump_context, buf, len + 1);
if (err)
@@ -3702,24 +3708,22 @@ vchiq_loud_error_footer(void)
enum vchiq_status vchiq_send_remote_use(struct vchiq_state *state)
{
- enum vchiq_status status = VCHIQ_RETRY;
+ if (state->conn_state == VCHIQ_CONNSTATE_DISCONNECTED)
+ return VCHIQ_RETRY;
- if (state->conn_state != VCHIQ_CONNSTATE_DISCONNECTED)
- status = queue_message(state, NULL,
- VCHIQ_MAKE_MSG(VCHIQ_MSG_REMOTE_USE, 0, 0),
- NULL, NULL, 0, 0);
- return status;
+ return queue_message(state, NULL,
+ VCHIQ_MAKE_MSG(VCHIQ_MSG_REMOTE_USE, 0, 0),
+ NULL, NULL, 0, 0);
}
enum vchiq_status vchiq_send_remote_use_active(struct vchiq_state *state)
{
- enum vchiq_status status = VCHIQ_RETRY;
+ if (state->conn_state == VCHIQ_CONNSTATE_DISCONNECTED)
+ return VCHIQ_RETRY;
- if (state->conn_state != VCHIQ_CONNSTATE_DISCONNECTED)
- status = queue_message(state, NULL,
- VCHIQ_MAKE_MSG(VCHIQ_MSG_REMOTE_USE_ACTIVE, 0, 0),
- NULL, NULL, 0, 0);
- return status;
+ return queue_message(state, NULL,
+ VCHIQ_MAKE_MSG(VCHIQ_MSG_REMOTE_USE_ACTIVE, 0, 0),
+ NULL, NULL, 0, 0);
}
void vchiq_log_dump_mem(const char *label, u32 addr, const void *void_mem,
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h
index ec2f033cdf32..e9bf055a4ca9 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h
@@ -7,7 +7,7 @@
#include "vchiq_core.h"
struct vchiq_debugfs_node {
- struct dentry *dentry;
+ struct dentry *dentry;
};
void vchiq_debugfs_init(void);
diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
index 9097bcbd67d8..06bca7be5203 100644
--- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
@@ -432,7 +432,7 @@ buffer_from_host(struct vchiq_mmal_instance *instance,
m.u.buffer_from_host.buffer_header.pts = MMAL_TIME_UNKNOWN;
m.u.buffer_from_host.buffer_header.dts = MMAL_TIME_UNKNOWN;
- /* clear buffer type sepecific data */
+ /* clear buffer type specific data */
memset(&m.u.buffer_from_host.buffer_header_type_specific, 0,
sizeof(m.u.buffer_from_host.buffer_header_type_specific));
@@ -927,7 +927,7 @@ release_msg:
return ret;
}
-/* create comonent on vc */
+/* create component on vc */
static int create_component(struct vchiq_mmal_instance *instance,
struct vchiq_mmal_component *component,
const char *name)
diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c
index 1aa675241599..d89163299172 100644
--- a/drivers/staging/vt6655/baseband.c
+++ b/drivers/staging/vt6655/baseband.c
@@ -52,7 +52,7 @@
/*--------------------- Static Variables --------------------------*/
#define CB_VT3253_INIT_FOR_RFMD 446
-static const unsigned char byVT3253InitTab_RFMD[CB_VT3253_INIT_FOR_RFMD][2] = {
+static const unsigned char by_vt3253_init_tab_rfmd[CB_VT3253_INIT_FOR_RFMD][2] = {
{0x00, 0x30},
{0x01, 0x00},
{0x02, 0x00},
@@ -2002,8 +2002,8 @@ bool bb_vt3253_init(struct vnt_private *priv)
if (by_local_id <= REV_ID_VT3253_A1) {
for (ii = 0; ii < CB_VT3253_INIT_FOR_RFMD; ii++)
result &= bb_write_embedded(priv,
- byVT3253InitTab_RFMD[ii][0],
- byVT3253InitTab_RFMD[ii][1]);
+ by_vt3253_init_tab_rfmd[ii][0],
+ by_vt3253_init_tab_rfmd[ii][1]);
} else {
for (ii = 0; ii < CB_VT3253B0_INIT_FOR_RFMD; ii++)
diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c
index 889fc22f19bd..cf46ee63681a 100644
--- a/drivers/staging/vt6655/channel.c
+++ b/drivers/staging/vt6655/channel.c
@@ -114,40 +114,38 @@ static struct ieee80211_supported_band vnt_supported_5ghz_band = {
.n_bitrates = ARRAY_SIZE(vnt_rates_a),
};
-void vnt_init_bands(struct vnt_private *priv)
+static void vnt_init_band(struct vnt_private *priv,
+ struct ieee80211_supported_band *supported_band,
+ enum nl80211_band band)
{
- struct ieee80211_channel *ch;
int i;
+ for (i = 0; i < supported_band->n_channels; i++) {
+ supported_band->channels[i].max_power = 0x3f;
+ supported_band->channels[i].flags =
+ IEEE80211_CHAN_NO_HT40;
+ }
+
+ priv->hw->wiphy->bands[band] = supported_band;
+}
+
+void vnt_init_bands(struct vnt_private *priv)
+{
switch (priv->byRFType) {
case RF_AIROHA7230:
case RF_UW2452:
case RF_NOTHING:
default:
- ch = vnt_channels_5ghz;
-
- for (i = 0; i < ARRAY_SIZE(vnt_channels_5ghz); i++) {
- ch[i].max_power = 0x3f;
- ch[i].flags = IEEE80211_CHAN_NO_HT40;
- }
-
- priv->hw->wiphy->bands[NL80211_BAND_5GHZ] =
- &vnt_supported_5ghz_band;
+ vnt_init_band(priv, &vnt_supported_5ghz_band,
+ NL80211_BAND_5GHZ);
fallthrough;
case RF_RFMD2959:
case RF_AIROHA:
case RF_AL2230S:
case RF_UW2451:
case RF_VT3226:
- ch = vnt_channels_2ghz;
-
- for (i = 0; i < ARRAY_SIZE(vnt_channels_2ghz); i++) {
- ch[i].max_power = 0x3f;
- ch[i].flags = IEEE80211_CHAN_NO_HT40;
- }
-
- priv->hw->wiphy->bands[NL80211_BAND_2GHZ] =
- &vnt_supported_2ghz_band;
+ vnt_init_band(priv, &vnt_supported_2ghz_band,
+ NL80211_BAND_2GHZ);
break;
}
}
@@ -155,8 +153,8 @@ void vnt_init_bands(struct vnt_private *priv)
/**
* set_channel() - Set NIC media channel
*
- * @pDeviceHandler: The adapter to be set
- * @uConnectionChannel: Channel to be set
+ * @priv: The adapter to be set
+ * @ch: Channel to be set
*
* Return Value: true if succeeded; false if failed.
*
diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 10f3dfda83b5..396736eee690 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -375,7 +375,8 @@ int vnt_radio_power_off(struct vnt_private *priv)
case RF_VT3226D0:
case RF_VT3342A0:
ret = vnt_mac_reg_bits_off(priv, MAC_REG_SOFTPWRCTL,
- (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
+ (SOFTPWRCTL_SWPE2 |
+ SOFTPWRCTL_SWPE3));
break;
}
diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c
index 56a5f891447b..9fca7f26372a 100644
--- a/drivers/staging/wfx/hif_rx.c
+++ b/drivers/staging/wfx/hif_rx.c
@@ -391,9 +391,9 @@ void wfx_handle_rx(struct wfx_dev *wdev, struct sk_buff *skb)
}
// Note: mutex_is_lock cause an implicit memory barrier that protect
// buf_send
- if (mutex_is_locked(&wdev->hif_cmd.lock)
- && wdev->hif_cmd.buf_send
- && wdev->hif_cmd.buf_send->id == hif_id) {
+ if (mutex_is_locked(&wdev->hif_cmd.lock) &&
+ wdev->hif_cmd.buf_send &&
+ wdev->hif_cmd.buf_send->id == hif_id) {
hif_generic_confirm(wdev, hif, hif->body);
goto free;
}
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 196779a1b89a..cb7e8abdf43c 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -199,7 +199,7 @@ int wfx_update_pm(struct wfx_vif *wvif)
}
int wfx_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
- u16 queue, const struct ieee80211_tx_queue_params *params)
+ u16 queue, const struct ieee80211_tx_queue_params *params)
{
struct wfx_dev *wdev = hw->priv;
struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
diff --git a/drivers/staging/wimax/Documentation/i2400m.rst b/drivers/staging/wimax/Documentation/i2400m.rst
deleted file mode 100644
index 194388c0c351..000000000000
--- a/drivers/staging/wimax/Documentation/i2400m.rst
+++ /dev/null
@@ -1,283 +0,0 @@
-.. include:: <isonum.txt>
-
-====================================================
-Driver for the Intel Wireless Wimax Connection 2400m
-====================================================
-
-:Copyright: |copy| 2008 Intel Corporation < linux-wimax@intel.com >
-
- This provides a driver for the Intel Wireless WiMAX Connection 2400m
- and a basic Linux kernel WiMAX stack.
-
-1. Requirements
-===============
-
- * Linux installation with Linux kernel 2.6.22 or newer (if building
- from a separate tree)
- * Intel i2400m Echo Peak or Baxter Peak; this includes the Intel
- Wireless WiMAX/WiFi Link 5x50 series.
- * build tools:
-
- + Linux kernel development package for the target kernel; to
- build against your currently running kernel, you need to have
- the kernel development package corresponding to the running
- image installed (usually if your kernel is named
- linux-VERSION, the development package is called
- linux-dev-VERSION or linux-headers-VERSION).
- + GNU C Compiler, make
-
-2. Compilation and installation
-===============================
-
-2.1. Compilation of the drivers included in the kernel
-------------------------------------------------------
-
- Configure the kernel; to enable the WiMAX drivers select Drivers >
- Networking Drivers > WiMAX device support. Enable all of them as
- modules (easier).
-
- If USB or SDIO are not enabled in the kernel configuration, the options
- to build the i2400m USB or SDIO drivers will not show. Enable said
- subsystems and go back to the WiMAX menu to enable the drivers.
-
- Compile and install your kernel as usual.
-
-2.2. Compilation of the drivers distributed as an standalone module
--------------------------------------------------------------------
-
- To compile::
-
- $ cd source/directory
- $ make
-
- Once built you can load and unload using the provided load.sh script;
- load.sh will load the modules, load.sh u will unload them.
-
- To install in the default kernel directories (and enable auto loading
- when the device is plugged)::
-
- $ make install
- $ depmod -a
-
- If your kernel development files are located in a non standard
- directory or if you want to build for a kernel that is not the
- currently running one, set KDIR to the right location::
-
- $ make KDIR=/path/to/kernel/dev/tree
-
- For more information, please contact linux-wimax@intel.com.
-
-3. Installing the firmware
---------------------------
-
- The firmware can be obtained from http://linuxwimax.org or might have
- been supplied with your hardware.
-
- It has to be installed in the target system::
-
- $ cp FIRMWAREFILE.sbcf /lib/firmware/i2400m-fw-BUSTYPE-1.3.sbcf
-
- * NOTE: if your firmware came in an .rpm or .deb file, just install
- it as normal, with the rpm (rpm -i FIRMWARE.rpm) or dpkg
- (dpkg -i FIRMWARE.deb) commands. No further action is needed.
- * BUSTYPE will be usb or sdio, depending on the hardware you have.
- Each hardware type comes with its own firmware and will not work
- with other types.
-
-4. Design
-=========
-
- This package contains two major parts: a WiMAX kernel stack and a
- driver for the Intel i2400m.
-
- The WiMAX stack is designed to provide for common WiMAX control
- services to current and future WiMAX devices from any vendor; please
- see README.wimax for details.
-
- The i2400m kernel driver is broken up in two main parts: the bus
- generic driver and the bus-specific drivers. The bus generic driver
- forms the drivercore and contain no knowledge of the actual method we
- use to connect to the device. The bus specific drivers are just the
- glue to connect the bus-generic driver and the device. Currently only
- USB and SDIO are supported. See drivers/net/wimax/i2400m/i2400m.h for
- more information.
-
- The bus generic driver is logically broken up in two parts: OS-glue and
- hardware-glue. The OS-glue interfaces with Linux. The hardware-glue
- interfaces with the device on using an interface provided by the
- bus-specific driver. The reason for this breakup is to be able to
- easily reuse the hardware-glue to write drivers for other OSes; note
- the hardware glue part is written as a native Linux driver; no
- abstraction layers are used, so to port to another OS, the Linux kernel
- API calls should be replaced with the target OS's.
-
-5. Usage
-========
-
- To load the driver, follow the instructions in the install section;
- once the driver is loaded, plug in the device (unless it is permanently
- plugged in). The driver will enumerate the device, upload the firmware
- and output messages in the kernel log (dmesg, /var/log/messages or
- /var/log/kern.log) such as::
-
- ...
- i2400m_usb 5-4:1.0: firmware interface version 8.0.0
- i2400m_usb 5-4:1.0: WiMAX interface wmx0 (00:1d:e1:01:94:2c) ready
-
- At this point the device is ready to work.
-
- Current versions require the Intel WiMAX Network Service in userspace
- to make things work. See the network service's README for instructions
- on how to scan, connect and disconnect.
-
-5.1. Module parameters
-----------------------
-
- Module parameters can be set at kernel or module load time or by
- echoing values::
-
- $ echo VALUE > /sys/module/MODULENAME/parameters/PARAMETERNAME
-
- To make changes permanent, for example, for the i2400m module, you can
- also create a file named /etc/modprobe.d/i2400m containing::
-
- options i2400m idle_mode_disabled=1
-
- To find which parameters are supported by a module, run::
-
- $ modinfo path/to/module.ko
-
- During kernel bootup (if the driver is linked in the kernel), specify
- the following to the kernel command line::
-
- i2400m.PARAMETER=VALUE
-
-5.1.1. i2400m: idle_mode_disabled
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
- The i2400m module supports a parameter to disable idle mode. This
- parameter, once set, will take effect only when the device is
- reinitialized by the driver (eg: following a reset or a reconnect).
-
-5.2. Debug operations: debugfs entries
---------------------------------------
-
- The driver will register debugfs entries that allow the user to tweak
- debug settings. There are three main container directories where
- entries are placed, which correspond to the three blocks a i2400m WiMAX
- driver has:
-
- * /sys/kernel/debug/wimax:DEVNAME/ for the generic WiMAX stack
- controls
- * /sys/kernel/debug/wimax:DEVNAME/i2400m for the i2400m generic
- driver controls
- * /sys/kernel/debug/wimax:DEVNAME/i2400m-usb (or -sdio) for the
- bus-specific i2400m-usb or i2400m-sdio controls).
-
- Of course, if debugfs is mounted in a directory other than
- /sys/kernel/debug, those paths will change.
-
-5.2.1. Increasing debug output
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
- The files named *dl_* indicate knobs for controlling the debug output
- of different submodules::
-
- # find /sys/kernel/debug/wimax\:wmx0 -name \*dl_\*
- /sys/kernel/debug/wimax:wmx0/i2400m-usb/dl_tx
- /sys/kernel/debug/wimax:wmx0/i2400m-usb/dl_rx
- /sys/kernel/debug/wimax:wmx0/i2400m-usb/dl_notif
- /sys/kernel/debug/wimax:wmx0/i2400m-usb/dl_fw
- /sys/kernel/debug/wimax:wmx0/i2400m-usb/dl_usb
- /sys/kernel/debug/wimax:wmx0/i2400m/dl_tx
- /sys/kernel/debug/wimax:wmx0/i2400m/dl_rx
- /sys/kernel/debug/wimax:wmx0/i2400m/dl_rfkill
- /sys/kernel/debug/wimax:wmx0/i2400m/dl_netdev
- /sys/kernel/debug/wimax:wmx0/i2400m/dl_fw
- /sys/kernel/debug/wimax:wmx0/i2400m/dl_debugfs
- /sys/kernel/debug/wimax:wmx0/i2400m/dl_driver
- /sys/kernel/debug/wimax:wmx0/i2400m/dl_control
- /sys/kernel/debug/wimax:wmx0/wimax_dl_stack
- /sys/kernel/debug/wimax:wmx0/wimax_dl_op_rfkill
- /sys/kernel/debug/wimax:wmx0/wimax_dl_op_reset
- /sys/kernel/debug/wimax:wmx0/wimax_dl_op_msg
- /sys/kernel/debug/wimax:wmx0/wimax_dl_id_table
- /sys/kernel/debug/wimax:wmx0/wimax_dl_debugfs
-
- By reading the file you can obtain the current value of said debug
- level; by writing to it, you can set it.
-
- To increase the debug level of, for example, the i2400m's generic TX
- engine, just write::
-
- $ echo 3 > /sys/kernel/debug/wimax:wmx0/i2400m/dl_tx
-
- Increasing numbers yield increasing debug information; for details of
- what is printed and the available levels, check the source. The code
- uses 0 for disabled and increasing values until 8.
-
-5.2.2. RX and TX statistics
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
- The i2400m/rx_stats and i2400m/tx_stats provide statistics about the
- data reception/delivery from the device::
-
- $ cat /sys/kernel/debug/wimax:wmx0/i2400m/rx_stats
- 45 1 3 34 3104 48 480
-
- The numbers reported are:
-
- * packets/RX-buffer: total, min, max
- * RX-buffers: total RX buffers received, accumulated RX buffer size
- in bytes, min size received, max size received
-
- Thus, to find the average buffer size received, divide accumulated
- RX-buffer / total RX-buffers.
-
- To clear the statistics back to 0, write anything to the rx_stats file::
-
- $ echo 1 > /sys/kernel/debug/wimax:wmx0/i2400m_rx_stats
-
- Likewise for TX.
-
- Note the packets this debug file refers to are not network packet, but
- packets in the sense of the device-specific protocol for communication
- to the host. See drivers/net/wimax/i2400m/tx.c.
-
-5.2.3. Tracing messages received from user space
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
- To echo messages received from user space into the trace pipe that the
- i2400m driver creates, set the debug file i2400m/trace_msg_from_user to
- 1::
-
- $ echo 1 > /sys/kernel/debug/wimax:wmx0/i2400m/trace_msg_from_user
-
-5.2.4. Performing a device reset
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
- By writing a 0, a 1 or a 2 to the file
- /sys/kernel/debug/wimax:wmx0/reset, the driver performs a warm (without
- disconnecting from the bus), cold (disconnecting from the bus) or bus
- (bus specific) reset on the device.
-
-5.2.5. Asking the device to enter power saving mode
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
- By writing any value to the /sys/kernel/debug/wimax:wmx0 file, the
- device will attempt to enter power saving mode.
-
-6. Troubleshooting
-==================
-
-6.1. Driver complains about ``i2400m-fw-usb-1.2.sbcf: request failed``
-----------------------------------------------------------------------
-
- If upon connecting the device, the following is output in the kernel
- log::
-
- i2400m_usb 5-4:1.0: fw i2400m-fw-usb-1.3.sbcf: request failed: -2
-
- This means that the driver cannot locate the firmware file named
- /lib/firmware/i2400m-fw-usb-1.2.sbcf. Check that the file is present in
- the right location.
diff --git a/drivers/staging/wimax/Documentation/index.rst b/drivers/staging/wimax/Documentation/index.rst
deleted file mode 100644
index fdf7c1f99ff5..000000000000
--- a/drivers/staging/wimax/Documentation/index.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0
-
-===============
-WiMAX subsystem
-===============
-
-.. toctree::
- :maxdepth: 2
-
- wimax
-
- i2400m
-
-.. only:: subproject and html
-
- Indices
- =======
-
- * :ref:`genindex`
diff --git a/drivers/staging/wimax/Documentation/wimax.rst b/drivers/staging/wimax/Documentation/wimax.rst
deleted file mode 100644
index 817ee8ba2732..000000000000
--- a/drivers/staging/wimax/Documentation/wimax.rst
+++ /dev/null
@@ -1,89 +0,0 @@
-.. include:: <isonum.txt>
-
-========================
-Linux kernel WiMAX stack
-========================
-
-:Copyright: |copy| 2008 Intel Corporation < linux-wimax@intel.com >
-
- This provides a basic Linux kernel WiMAX stack to provide a common
- control API for WiMAX devices, usable from kernel and user space.
-
-1. Design
-=========
-
- The WiMAX stack is designed to provide for common WiMAX control
- services to current and future WiMAX devices from any vendor.
-
- Because currently there is only one and we don't know what would be the
- common services, the APIs it currently provides are very minimal.
- However, it is done in such a way that it is easily extensible to
- accommodate future requirements.
-
- The stack works by embedding a struct wimax_dev in your device's
- control structures. This provides a set of callbacks that the WiMAX
- stack will call in order to implement control operations requested by
- the user. As well, the stack provides API functions that the driver
- calls to notify about changes of state in the device.
-
- The stack exports the API calls needed to control the device to user
- space using generic netlink as a marshalling mechanism. You can access
- them using your own code or use the wrappers provided for your
- convenience in libwimax (in the wimax-tools package).
-
- For detailed information on the stack, please see
- include/linux/wimax.h.
-
-2. Usage
-========
-
- For usage in a driver (registration, API, etc) please refer to the
- instructions in the header file include/linux/wimax.h.
-
- When a device is registered with the WiMAX stack, a set of debugfs
- files will appear in /sys/kernel/debug/wimax:wmxX can tweak for
- control.
-
-2.1. Obtaining debug information: debugfs entries
--------------------------------------------------
-
- The WiMAX stack is compiled, by default, with debug messages that can
- be used to diagnose issues. By default, said messages are disabled.
-
- The drivers will register debugfs entries that allow the user to tweak
- debug settings.
-
- Each driver, when registering with the stack, will cause a debugfs
- directory named wimax:DEVICENAME to be created; optionally, it might
- create more subentries below it.
-
-2.1.1. Increasing debug output
-------------------------------
-
- The files named *dl_* indicate knobs for controlling the debug output
- of different submodules of the WiMAX stack::
-
- # find /sys/kernel/debug/wimax\:wmx0 -name \*dl_\*
- /sys/kernel/debug/wimax:wmx0/wimax_dl_stack
- /sys/kernel/debug/wimax:wmx0/wimax_dl_op_rfkill
- /sys/kernel/debug/wimax:wmx0/wimax_dl_op_reset
- /sys/kernel/debug/wimax:wmx0/wimax_dl_op_msg
- /sys/kernel/debug/wimax:wmx0/wimax_dl_id_table
- /sys/kernel/debug/wimax:wmx0/wimax_dl_debugfs
- /sys/kernel/debug/wimax:wmx0/.... # other driver specific files
-
- NOTE:
- Of course, if debugfs is mounted in a directory other than
- /sys/kernel/debug, those paths will change.
-
- By reading the file you can obtain the current value of said debug
- level; by writing to it, you can set it.
-
- To increase the debug level of, for example, the id-table submodule,
- just write:
-
- $ echo 3 > /sys/kernel/debug/wimax:wmx0/wimax_dl_id_table
-
- Increasing numbers yield increasing debug information; for details of
- what is printed and the available levels, check the source. The code
- uses 0 for disabled and increasing values until 8.
diff --git a/drivers/staging/wimax/Kconfig b/drivers/staging/wimax/Kconfig
deleted file mode 100644
index 113c35072e2c..000000000000
--- a/drivers/staging/wimax/Kconfig
+++ /dev/null
@@ -1,47 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-#
-# WiMAX LAN device configuration
-#
-
-menuconfig WIMAX
- tristate "WiMAX Wireless Broadband support"
- depends on NET
- depends on RFKILL || !RFKILL
- help
-
- Select to configure support for devices that provide
- wireless broadband connectivity using the WiMAX protocol
- (IEEE 802.16).
-
- Please note that most of these devices require signing up
- for a service plan with a provider.
-
- The different WiMAX drivers can be enabled in the menu entry
-
- Device Drivers > Network device support > WiMAX Wireless
- Broadband devices
-
- If unsure, it is safe to select M (module).
-
-if WIMAX
-
-config WIMAX_DEBUG_LEVEL
- int "WiMAX debug level"
- depends on WIMAX
- default 8
- help
-
- Select the maximum debug verbosity level to be compiled into
- the WiMAX stack code.
-
- By default, debug messages are disabled at runtime and can
- be selectively enabled for different parts of the code using
- the sysfs debug-levels file.
-
- If set at zero, this will compile out all the debug code.
-
- It is recommended that it is left at 8.
-
-source "drivers/staging/wimax/i2400m/Kconfig"
-
-endif
diff --git a/drivers/staging/wimax/Makefile b/drivers/staging/wimax/Makefile
deleted file mode 100644
index 0e3f988656aa..000000000000
--- a/drivers/staging/wimax/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-obj-$(CONFIG_WIMAX) += wimax.o
-
-wimax-y := \
- id-table.o \
- op-msg.o \
- op-reset.o \
- op-rfkill.o \
- op-state-get.o \
- stack.o
-
-wimax-$(CONFIG_DEBUG_FS) += debugfs.o
-
-obj-$(CONFIG_WIMAX_I2400M) += i2400m/
diff --git a/drivers/staging/wimax/TODO b/drivers/staging/wimax/TODO
deleted file mode 100644
index 26e4cb9e9599..000000000000
--- a/drivers/staging/wimax/TODO
+++ /dev/null
@@ -1,18 +0,0 @@
-There are no known users of this driver as of October 2020, and it will
-be removed unless someone turns out to still need it in future releases.
-
-According to https://en.wikipedia.org/wiki/List_of_WiMAX_networks, there
-have been many public wimax networks, but it appears that many of these
-have migrated to LTE or discontinued their service altogether. As most
-PCs and phones lack WiMAX hardware support, the remaining networks tend
-to use standalone routers. These almost certainly run Linux, but not a
-modern kernel or the mainline wimax driver stack.
-
-NetworkManager appears to have dropped userspace support in 2015
-https://bugzilla.gnome.org/show_bug.cgi?id=747846, the www.linuxwimax.org
-site had already shut down earlier.
-
-WiMax is apparently still being deployed on airport campus networks
-("AeroMACS"), but in a frequency band that was not supported by the old
-Intel 2400m (used in Sandy Bridge laptops and earlier), which is the
-only driver using the kernel's wimax stack.
diff --git a/drivers/staging/wimax/debug-levels.h b/drivers/staging/wimax/debug-levels.h
deleted file mode 100644
index b854802d1d00..000000000000
--- a/drivers/staging/wimax/debug-levels.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Linux WiMAX Stack
- * Debug levels control file for the wimax module
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-#ifndef __debug_levels__h__
-#define __debug_levels__h__
-
-/* Maximum compile and run time debug level for all submodules */
-#define D_MODULENAME wimax
-#define D_MASTER CONFIG_WIMAX_DEBUG_LEVEL
-
-#include "linux-wimax-debug.h"
-
-/* List of all the enabled modules */
-enum d_module {
- D_SUBMODULE_DECLARE(debugfs),
- D_SUBMODULE_DECLARE(id_table),
- D_SUBMODULE_DECLARE(op_msg),
- D_SUBMODULE_DECLARE(op_reset),
- D_SUBMODULE_DECLARE(op_rfkill),
- D_SUBMODULE_DECLARE(op_state_get),
- D_SUBMODULE_DECLARE(stack),
-};
-
-#endif /* #ifndef __debug_levels__h__ */
diff --git a/drivers/staging/wimax/debugfs.c b/drivers/staging/wimax/debugfs.c
deleted file mode 100644
index e11bff61ffcf..000000000000
--- a/drivers/staging/wimax/debugfs.c
+++ /dev/null
@@ -1,38 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * Debugfs support
- *
- * Copyright (C) 2005-2006 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-#include <linux/debugfs.h>
-#include "linux-wimax.h"
-#include "wimax-internal.h"
-
-#define D_SUBMODULE debugfs
-#include "debug-levels.h"
-
-void wimax_debugfs_add(struct wimax_dev *wimax_dev)
-{
- struct net_device *net_dev = wimax_dev->net_dev;
- struct dentry *dentry;
- char buf[128];
-
- snprintf(buf, sizeof(buf), "wimax:%s", net_dev->name);
- dentry = debugfs_create_dir(buf, NULL);
- wimax_dev->debugfs_dentry = dentry;
-
- d_level_register_debugfs("wimax_dl_", debugfs, dentry);
- d_level_register_debugfs("wimax_dl_", id_table, dentry);
- d_level_register_debugfs("wimax_dl_", op_msg, dentry);
- d_level_register_debugfs("wimax_dl_", op_reset, dentry);
- d_level_register_debugfs("wimax_dl_", op_rfkill, dentry);
- d_level_register_debugfs("wimax_dl_", op_state_get, dentry);
- d_level_register_debugfs("wimax_dl_", stack, dentry);
-}
-
-void wimax_debugfs_rm(struct wimax_dev *wimax_dev)
-{
- debugfs_remove_recursive(wimax_dev->debugfs_dentry);
-}
diff --git a/drivers/staging/wimax/i2400m/Kconfig b/drivers/staging/wimax/i2400m/Kconfig
deleted file mode 100644
index 843b905a26a3..000000000000
--- a/drivers/staging/wimax/i2400m/Kconfig
+++ /dev/null
@@ -1,37 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-
-config WIMAX_I2400M
- tristate
- depends on WIMAX
- select FW_LOADER
-
-comment "Enable USB support to see WiMAX USB drivers"
- depends on USB = n
-
-config WIMAX_I2400M_USB
- tristate "Intel Wireless WiMAX Connection 2400 over USB (including 5x50)"
- depends on WIMAX && USB
- select WIMAX_I2400M
- help
- Select if you have a device based on the Intel WiMAX
- Connection 2400 over USB (like any of the Intel Wireless
- WiMAX/WiFi Link 5x50 series).
-
- If unsure, it is safe to select M (module).
-
-config WIMAX_I2400M_DEBUG_LEVEL
- int "WiMAX i2400m debug level"
- depends on WIMAX_I2400M
- default 8
- help
-
- Select the maximum debug verbosity level to be compiled into
- the WiMAX i2400m driver code.
-
- By default, this is disabled at runtime and can be
- selectively enabled at runtime for different parts of the
- code using the sysfs debug-levels file.
-
- If set at zero, this will compile out all the debug code.
-
- It is recommended that it is left at 8.
diff --git a/drivers/staging/wimax/i2400m/Makefile b/drivers/staging/wimax/i2400m/Makefile
deleted file mode 100644
index b1db1eff0648..000000000000
--- a/drivers/staging/wimax/i2400m/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-
-obj-$(CONFIG_WIMAX_I2400M) += i2400m.o
-obj-$(CONFIG_WIMAX_I2400M_USB) += i2400m-usb.o
-
-i2400m-y := \
- control.o \
- driver.o \
- fw.o \
- op-rfkill.o \
- sysfs.o \
- netdev.o \
- tx.o \
- rx.o
-
-i2400m-$(CONFIG_DEBUG_FS) += debugfs.o
-
-i2400m-usb-y := \
- usb-fw.o \
- usb-notif.o \
- usb-tx.o \
- usb-rx.o \
- usb.o
diff --git a/drivers/staging/wimax/i2400m/control.c b/drivers/staging/wimax/i2400m/control.c
deleted file mode 100644
index 1e270b2101e8..000000000000
--- a/drivers/staging/wimax/i2400m/control.c
+++ /dev/null
@@ -1,1434 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Miscellaneous control functions for managing the device
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * 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 Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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
- * OWNER 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.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * - Initial implementation
- *
- * This is a collection of functions used to control the device (plus
- * a few helpers).
- *
- * There are utilities for handling TLV buffers, hooks on the device's
- * reports to act on device changes of state [i2400m_report_hook()],
- * on acks to commands [i2400m_msg_ack_hook()], a helper for sending
- * commands to the device and blocking until a reply arrives
- * [i2400m_msg_to_dev()], a few high level commands for manipulating
- * the device state, powersving mode and configuration plus the
- * routines to setup the device once communication is stablished with
- * it [i2400m_dev_initialize()].
- *
- * ROADMAP
- *
- * i2400m_dev_initialize() Called by i2400m_dev_start()
- * i2400m_set_init_config()
- * i2400m_cmd_get_state()
- * i2400m_dev_shutdown() Called by i2400m_dev_stop()
- * i2400m_reset()
- *
- * i2400m_{cmd,get,set}_*()
- * i2400m_msg_to_dev()
- * i2400m_msg_check_status()
- *
- * i2400m_report_hook() Called on reception of an event
- * i2400m_report_state_hook()
- * i2400m_tlv_buffer_walk()
- * i2400m_tlv_match()
- * i2400m_report_tlv_system_state()
- * i2400m_report_tlv_rf_switches_status()
- * i2400m_report_tlv_media_status()
- * i2400m_cmd_enter_powersave()
- *
- * i2400m_msg_ack_hook() Called on reception of a reply to a
- * command, get or set
- */
-
-#include <stdarg.h>
-#include "i2400m.h"
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include "linux-wimax-i2400m.h"
-#include <linux/export.h>
-#include <linux/moduleparam.h>
-
-
-#define D_SUBMODULE control
-#include "debug-levels.h"
-
-static int i2400m_idle_mode_disabled;/* 0 (idle mode enabled) by default */
-module_param_named(idle_mode_disabled, i2400m_idle_mode_disabled, int, 0644);
-MODULE_PARM_DESC(idle_mode_disabled,
- "If true, the device will not enable idle mode negotiation "
- "with the base station (when connected) to save power.");
-
-/* 0 (power saving enabled) by default */
-static int i2400m_power_save_disabled;
-module_param_named(power_save_disabled, i2400m_power_save_disabled, int, 0644);
-MODULE_PARM_DESC(power_save_disabled,
- "If true, the driver will not tell the device to enter "
- "power saving mode when it reports it is ready for it. "
- "False by default (so the device is told to do power "
- "saving).");
-
-static int i2400m_passive_mode; /* 0 (passive mode disabled) by default */
-module_param_named(passive_mode, i2400m_passive_mode, int, 0644);
-MODULE_PARM_DESC(passive_mode,
- "If true, the driver will not do any device setup "
- "and leave it up to user space, who must be properly "
- "setup.");
-
-
-/*
- * Return if a TLV is of a give type and size
- *
- * @tlv_hdr: pointer to the TLV
- * @tlv_type: type of the TLV we are looking for
- * @tlv_size: expected size of the TLV we are looking for (if -1,
- * don't check the size). This includes the header
- * Returns: 0 if the TLV matches
- * < 0 if it doesn't match at all
- * > 0 total TLV + payload size, if the type matches, but not
- * the size
- */
-static
-ssize_t i2400m_tlv_match(const struct i2400m_tlv_hdr *tlv,
- enum i2400m_tlv tlv_type, ssize_t tlv_size)
-{
- if (le16_to_cpu(tlv->type) != tlv_type) /* Not our type? skip */
- return -1;
- if (tlv_size != -1
- && le16_to_cpu(tlv->length) + sizeof(*tlv) != tlv_size) {
- size_t size = le16_to_cpu(tlv->length) + sizeof(*tlv);
- printk(KERN_WARNING "W: tlv type 0x%x mismatched because of "
- "size (got %zu vs %zd expected)\n",
- tlv_type, size, tlv_size);
- return size;
- }
- return 0;
-}
-
-
-/*
- * Given a buffer of TLVs, iterate over them
- *
- * @i2400m: device instance
- * @tlv_buf: pointer to the beginning of the TLV buffer
- * @buf_size: buffer size in bytes
- * @tlv_pos: seek position; this is assumed to be a pointer returned
- * by i2400m_tlv_buffer_walk() [and thus, validated]. The
- * TLV returned will be the one following this one.
- *
- * Usage:
- *
- * tlv_itr = NULL;
- * while (tlv_itr = i2400m_tlv_buffer_walk(i2400m, buf, size, tlv_itr)) {
- * ...
- * // Do stuff with tlv_itr, DON'T MODIFY IT
- * ...
- * }
- */
-static
-const struct i2400m_tlv_hdr *i2400m_tlv_buffer_walk(
- struct i2400m *i2400m,
- const void *tlv_buf, size_t buf_size,
- const struct i2400m_tlv_hdr *tlv_pos)
-{
- struct device *dev = i2400m_dev(i2400m);
- const struct i2400m_tlv_hdr *tlv_top = tlv_buf + buf_size;
- size_t offset, length, avail_size;
- unsigned type;
-
- if (tlv_pos == NULL) /* Take the first one? */
- tlv_pos = tlv_buf;
- else /* Nope, the next one */
- tlv_pos = (void *) tlv_pos
- + le16_to_cpu(tlv_pos->length) + sizeof(*tlv_pos);
- if (tlv_pos == tlv_top) { /* buffer done */
- tlv_pos = NULL;
- goto error_beyond_end;
- }
- if (tlv_pos > tlv_top) {
- tlv_pos = NULL;
- WARN_ON(1);
- goto error_beyond_end;
- }
- offset = (void *) tlv_pos - (void *) tlv_buf;
- avail_size = buf_size - offset;
- if (avail_size < sizeof(*tlv_pos)) {
- dev_err(dev, "HW BUG? tlv_buf %p [%zu bytes], tlv @%zu: "
- "short header\n", tlv_buf, buf_size, offset);
- goto error_short_header;
- }
- type = le16_to_cpu(tlv_pos->type);
- length = le16_to_cpu(tlv_pos->length);
- if (avail_size < sizeof(*tlv_pos) + length) {
- dev_err(dev, "HW BUG? tlv_buf %p [%zu bytes], "
- "tlv type 0x%04x @%zu: "
- "short data (%zu bytes vs %zu needed)\n",
- tlv_buf, buf_size, type, offset, avail_size,
- sizeof(*tlv_pos) + length);
- goto error_short_header;
- }
-error_short_header:
-error_beyond_end:
- return tlv_pos;
-}
-
-
-/*
- * Find a TLV in a buffer of sequential TLVs
- *
- * @i2400m: device descriptor
- * @tlv_hdr: pointer to the first TLV in the sequence
- * @size: size of the buffer in bytes; all TLVs are assumed to fit
- * fully in the buffer (otherwise we'll complain).
- * @tlv_type: type of the TLV we are looking for
- * @tlv_size: expected size of the TLV we are looking for (if -1,
- * don't check the size). This includes the header
- *
- * Returns: NULL if the TLV is not found, otherwise a pointer to
- * it. If the sizes don't match, an error is printed and NULL
- * returned.
- */
-static
-const struct i2400m_tlv_hdr *i2400m_tlv_find(
- struct i2400m *i2400m,
- const struct i2400m_tlv_hdr *tlv_hdr, size_t size,
- enum i2400m_tlv tlv_type, ssize_t tlv_size)
-{
- ssize_t match;
- struct device *dev = i2400m_dev(i2400m);
- const struct i2400m_tlv_hdr *tlv = NULL;
- while ((tlv = i2400m_tlv_buffer_walk(i2400m, tlv_hdr, size, tlv))) {
- match = i2400m_tlv_match(tlv, tlv_type, tlv_size);
- if (match == 0) /* found it :) */
- break;
- if (match > 0)
- dev_warn(dev, "TLV type 0x%04x found with size "
- "mismatch (%zu vs %zd needed)\n",
- tlv_type, match, tlv_size);
- }
- return tlv;
-}
-
-
-static const struct
-{
- char *msg;
- int errno;
-} ms_to_errno[I2400M_MS_MAX] = {
- [I2400M_MS_DONE_OK] = { "", 0 },
- [I2400M_MS_DONE_IN_PROGRESS] = { "", 0 },
- [I2400M_MS_INVALID_OP] = { "invalid opcode", -ENOSYS },
- [I2400M_MS_BAD_STATE] = { "invalid state", -EILSEQ },
- [I2400M_MS_ILLEGAL_VALUE] = { "illegal value", -EINVAL },
- [I2400M_MS_MISSING_PARAMS] = { "missing parameters", -ENOMSG },
- [I2400M_MS_VERSION_ERROR] = { "bad version", -EIO },
- [I2400M_MS_ACCESSIBILITY_ERROR] = { "accesibility error", -EIO },
- [I2400M_MS_BUSY] = { "busy", -EBUSY },
- [I2400M_MS_CORRUPTED_TLV] = { "corrupted TLV", -EILSEQ },
- [I2400M_MS_UNINITIALIZED] = { "uninitialized", -EILSEQ },
- [I2400M_MS_UNKNOWN_ERROR] = { "unknown error", -EIO },
- [I2400M_MS_PRODUCTION_ERROR] = { "production error", -EIO },
- [I2400M_MS_NO_RF] = { "no RF", -EIO },
- [I2400M_MS_NOT_READY_FOR_POWERSAVE] =
- { "not ready for powersave", -EACCES },
- [I2400M_MS_THERMAL_CRITICAL] = { "thermal critical", -EL3HLT },
-};
-
-
-/*
- * i2400m_msg_check_status - translate a message's status code
- *
- * @i2400m: device descriptor
- * @l3l4_hdr: message header
- * @strbuf: buffer to place a formatted error message (unless NULL).
- * @strbuf_size: max amount of available space; larger messages will
- * be truncated.
- *
- * Returns: errno code corresponding to the status code in @l3l4_hdr
- * and a message in @strbuf describing the error.
- */
-int i2400m_msg_check_status(const struct i2400m_l3l4_hdr *l3l4_hdr,
- char *strbuf, size_t strbuf_size)
-{
- int result;
- enum i2400m_ms status = le16_to_cpu(l3l4_hdr->status);
- const char *str;
-
- if (status == 0)
- return 0;
- if (status >= ARRAY_SIZE(ms_to_errno)) {
- str = "unknown status code";
- result = -EBADR;
- } else {
- str = ms_to_errno[status].msg;
- result = ms_to_errno[status].errno;
- }
- if (strbuf)
- snprintf(strbuf, strbuf_size, "%s (%d)", str, status);
- return result;
-}
-
-
-/*
- * Act on a TLV System State reported by the device
- *
- * @i2400m: device descriptor
- * @ss: validated System State TLV
- */
-static
-void i2400m_report_tlv_system_state(struct i2400m *i2400m,
- const struct i2400m_tlv_system_state *ss)
-{
- struct device *dev = i2400m_dev(i2400m);
- struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
- enum i2400m_system_state i2400m_state = le32_to_cpu(ss->state);
-
- d_fnstart(3, dev, "(i2400m %p ss %p [%u])\n", i2400m, ss, i2400m_state);
-
- if (i2400m->state != i2400m_state) {
- i2400m->state = i2400m_state;
- wake_up_all(&i2400m->state_wq);
- }
- switch (i2400m_state) {
- case I2400M_SS_UNINITIALIZED:
- case I2400M_SS_INIT:
- case I2400M_SS_CONFIG:
- case I2400M_SS_PRODUCTION:
- wimax_state_change(wimax_dev, WIMAX_ST_UNINITIALIZED);
- break;
-
- case I2400M_SS_RF_OFF:
- case I2400M_SS_RF_SHUTDOWN:
- wimax_state_change(wimax_dev, WIMAX_ST_RADIO_OFF);
- break;
-
- case I2400M_SS_READY:
- case I2400M_SS_STANDBY:
- case I2400M_SS_SLEEPACTIVE:
- wimax_state_change(wimax_dev, WIMAX_ST_READY);
- break;
-
- case I2400M_SS_CONNECTING:
- case I2400M_SS_WIMAX_CONNECTED:
- wimax_state_change(wimax_dev, WIMAX_ST_READY);
- break;
-
- case I2400M_SS_SCAN:
- case I2400M_SS_OUT_OF_ZONE:
- wimax_state_change(wimax_dev, WIMAX_ST_SCANNING);
- break;
-
- case I2400M_SS_IDLE:
- d_printf(1, dev, "entering BS-negotiated idle mode\n");
- fallthrough;
- case I2400M_SS_DISCONNECTING:
- case I2400M_SS_DATA_PATH_CONNECTED:
- wimax_state_change(wimax_dev, WIMAX_ST_CONNECTED);
- break;
-
- default:
- /* Huh? just in case, shut it down */
- dev_err(dev, "HW BUG? unknown state %u: shutting down\n",
- i2400m_state);
- i2400m_reset(i2400m, I2400M_RT_WARM);
- break;
- }
- d_fnend(3, dev, "(i2400m %p ss %p [%u]) = void\n",
- i2400m, ss, i2400m_state);
-}
-
-
-/*
- * Parse and act on a TLV Media Status sent by the device
- *
- * @i2400m: device descriptor
- * @ms: validated Media Status TLV
- *
- * This will set the carrier up on down based on the device's link
- * report. This is done asides of what the WiMAX stack does based on
- * the device's state as sometimes we need to do a link-renew (the BS
- * wants us to renew a DHCP lease, for example).
- *
- * In fact, doc says that every time we get a link-up, we should do a
- * DHCP negotiation...
- */
-static
-void i2400m_report_tlv_media_status(struct i2400m *i2400m,
- const struct i2400m_tlv_media_status *ms)
-{
- struct device *dev = i2400m_dev(i2400m);
- struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
- struct net_device *net_dev = wimax_dev->net_dev;
- enum i2400m_media_status status = le32_to_cpu(ms->media_status);
-
- d_fnstart(3, dev, "(i2400m %p ms %p [%u])\n", i2400m, ms, status);
-
- switch (status) {
- case I2400M_MEDIA_STATUS_LINK_UP:
- netif_carrier_on(net_dev);
- break;
- case I2400M_MEDIA_STATUS_LINK_DOWN:
- netif_carrier_off(net_dev);
- break;
- /*
- * This is the network telling us we need to retrain the DHCP
- * lease -- so far, we are trusting the WiMAX Network Service
- * in user space to pick this up and poke the DHCP client.
- */
- case I2400M_MEDIA_STATUS_LINK_RENEW:
- netif_carrier_on(net_dev);
- break;
- default:
- dev_err(dev, "HW BUG? unknown media status %u\n",
- status);
- }
- d_fnend(3, dev, "(i2400m %p ms %p [%u]) = void\n",
- i2400m, ms, status);
-}
-
-
-/*
- * Process a TLV from a 'state report'
- *
- * @i2400m: device descriptor
- * @tlv: pointer to the TLV header; it has been already validated for
- * consistent size.
- * @tag: for error messages
- *
- * Act on the TLVs from a 'state report'.
- */
-static
-void i2400m_report_state_parse_tlv(struct i2400m *i2400m,
- const struct i2400m_tlv_hdr *tlv,
- const char *tag)
-{
- struct device *dev = i2400m_dev(i2400m);
- const struct i2400m_tlv_media_status *ms;
- const struct i2400m_tlv_system_state *ss;
- const struct i2400m_tlv_rf_switches_status *rfss;
-
- if (0 == i2400m_tlv_match(tlv, I2400M_TLV_SYSTEM_STATE, sizeof(*ss))) {
- ss = container_of(tlv, typeof(*ss), hdr);
- d_printf(2, dev, "%s: system state TLV "
- "found (0x%04x), state 0x%08x\n",
- tag, I2400M_TLV_SYSTEM_STATE,
- le32_to_cpu(ss->state));
- i2400m_report_tlv_system_state(i2400m, ss);
- }
- if (0 == i2400m_tlv_match(tlv, I2400M_TLV_RF_STATUS, sizeof(*rfss))) {
- rfss = container_of(tlv, typeof(*rfss), hdr);
- d_printf(2, dev, "%s: RF status TLV "
- "found (0x%04x), sw 0x%02x hw 0x%02x\n",
- tag, I2400M_TLV_RF_STATUS,
- le32_to_cpu(rfss->sw_rf_switch),
- le32_to_cpu(rfss->hw_rf_switch));
- i2400m_report_tlv_rf_switches_status(i2400m, rfss);
- }
- if (0 == i2400m_tlv_match(tlv, I2400M_TLV_MEDIA_STATUS, sizeof(*ms))) {
- ms = container_of(tlv, typeof(*ms), hdr);
- d_printf(2, dev, "%s: Media Status TLV: %u\n",
- tag, le32_to_cpu(ms->media_status));
- i2400m_report_tlv_media_status(i2400m, ms);
- }
-}
-
-
-/*
- * Parse a 'state report' and extract information
- *
- * @i2400m: device descriptor
- * @l3l4_hdr: pointer to message; it has been already validated for
- * consistent size.
- * @size: size of the message (header + payload). The header length
- * declaration is assumed to be congruent with @size (as in
- * sizeof(*l3l4_hdr) + l3l4_hdr->length == size)
- *
- * Walk over the TLVs in a report state and act on them.
- */
-static
-void i2400m_report_state_hook(struct i2400m *i2400m,
- const struct i2400m_l3l4_hdr *l3l4_hdr,
- size_t size, const char *tag)
-{
- struct device *dev = i2400m_dev(i2400m);
- const struct i2400m_tlv_hdr *tlv;
- size_t tlv_size = le16_to_cpu(l3l4_hdr->length);
-
- d_fnstart(4, dev, "(i2400m %p, l3l4_hdr %p, size %zu, %s)\n",
- i2400m, l3l4_hdr, size, tag);
- tlv = NULL;
-
- while ((tlv = i2400m_tlv_buffer_walk(i2400m, &l3l4_hdr->pl,
- tlv_size, tlv)))
- i2400m_report_state_parse_tlv(i2400m, tlv, tag);
- d_fnend(4, dev, "(i2400m %p, l3l4_hdr %p, size %zu, %s) = void\n",
- i2400m, l3l4_hdr, size, tag);
-}
-
-
-/*
- * i2400m_report_hook - (maybe) act on a report
- *
- * @i2400m: device descriptor
- * @l3l4_hdr: pointer to message; it has been already validated for
- * consistent size.
- * @size: size of the message (header + payload). The header length
- * declaration is assumed to be congruent with @size (as in
- * sizeof(*l3l4_hdr) + l3l4_hdr->length == size)
- *
- * Extract information we might need (like carrien on/off) from a
- * device report.
- */
-void i2400m_report_hook(struct i2400m *i2400m,
- const struct i2400m_l3l4_hdr *l3l4_hdr, size_t size)
-{
- struct device *dev = i2400m_dev(i2400m);
- unsigned msg_type;
-
- d_fnstart(3, dev, "(i2400m %p l3l4_hdr %p size %zu)\n",
- i2400m, l3l4_hdr, size);
- /* Chew on the message, we might need some information from
- * here */
- msg_type = le16_to_cpu(l3l4_hdr->type);
- switch (msg_type) {
- case I2400M_MT_REPORT_STATE: /* carrier detection... */
- i2400m_report_state_hook(i2400m,
- l3l4_hdr, size, "REPORT STATE");
- break;
- /* If the device is ready for power save, then ask it to do
- * it. */
- case I2400M_MT_REPORT_POWERSAVE_READY: /* zzzzz */
- if (l3l4_hdr->status == cpu_to_le16(I2400M_MS_DONE_OK)) {
- if (i2400m_power_save_disabled)
- d_printf(1, dev, "ready for powersave, "
- "not requesting (disabled by module "
- "parameter)\n");
- else {
- d_printf(1, dev, "ready for powersave, "
- "requesting\n");
- i2400m_cmd_enter_powersave(i2400m);
- }
- }
- break;
- }
- d_fnend(3, dev, "(i2400m %p l3l4_hdr %p size %zu) = void\n",
- i2400m, l3l4_hdr, size);
-}
-
-
-/*
- * i2400m_msg_ack_hook - process cmd/set/get ack for internal status
- *
- * @i2400m: device descriptor
- * @l3l4_hdr: pointer to message; it has been already validated for
- * consistent size.
- * @size: size of the message
- *
- * Extract information we might need from acks to commands and act on
- * it. This is akin to i2400m_report_hook(). Note most of this
- * processing should be done in the function that calls the
- * command. This is here for some cases where it can't happen...
- */
-static void i2400m_msg_ack_hook(struct i2400m *i2400m,
- const struct i2400m_l3l4_hdr *l3l4_hdr,
- size_t size)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- unsigned int ack_type;
- char strerr[32];
-
- /* Chew on the message, we might need some information from
- * here */
- ack_type = le16_to_cpu(l3l4_hdr->type);
- switch (ack_type) {
- case I2400M_MT_CMD_ENTER_POWERSAVE:
- /* This is just left here for the sake of example, as
- * the processing is done somewhere else. */
- if (0) {
- result = i2400m_msg_check_status(
- l3l4_hdr, strerr, sizeof(strerr));
- if (result >= 0)
- d_printf(1, dev, "ready for power save: %zd\n",
- size);
- }
- break;
- }
-}
-
-
-/*
- * i2400m_msg_size_check() - verify message size and header are congruent
- *
- * It is ok if the total message size is larger than the expected
- * size, as there can be padding.
- */
-int i2400m_msg_size_check(struct i2400m *i2400m,
- const struct i2400m_l3l4_hdr *l3l4_hdr,
- size_t msg_size)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- size_t expected_size;
- d_fnstart(4, dev, "(i2400m %p l3l4_hdr %p msg_size %zu)\n",
- i2400m, l3l4_hdr, msg_size);
- if (msg_size < sizeof(*l3l4_hdr)) {
- dev_err(dev, "bad size for message header "
- "(expected at least %zu, got %zu)\n",
- (size_t) sizeof(*l3l4_hdr), msg_size);
- result = -EIO;
- goto error_hdr_size;
- }
- expected_size = le16_to_cpu(l3l4_hdr->length) + sizeof(*l3l4_hdr);
- if (msg_size < expected_size) {
- dev_err(dev, "bad size for message code 0x%04x (expected %zu, "
- "got %zu)\n", le16_to_cpu(l3l4_hdr->type),
- expected_size, msg_size);
- result = -EIO;
- } else
- result = 0;
-error_hdr_size:
- d_fnend(4, dev,
- "(i2400m %p l3l4_hdr %p msg_size %zu) = %d\n",
- i2400m, l3l4_hdr, msg_size, result);
- return result;
-}
-
-
-
-/*
- * Cancel a wait for a command ACK
- *
- * @i2400m: device descriptor
- * @code: [negative] errno code to cancel with (don't use
- * -EINPROGRESS)
- *
- * If there is an ack already filled out, free it.
- */
-void i2400m_msg_to_dev_cancel_wait(struct i2400m *i2400m, int code)
-{
- struct sk_buff *ack_skb;
- unsigned long flags;
-
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- ack_skb = i2400m->ack_skb;
- if (ack_skb && !IS_ERR(ack_skb))
- kfree_skb(ack_skb);
- i2400m->ack_skb = ERR_PTR(code);
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-}
-
-
-/**
- * i2400m_msg_to_dev - Send a control message to the device and get a response
- *
- * @i2400m: device descriptor
- *
- * @buf: pointer to the buffer containing the message to be sent; it
- * has to start with a &struct i2400M_l3l4_hdr and then
- * followed by the payload. Once this function returns, the
- * buffer can be reused.
- *
- * @buf_len: buffer size
- *
- * Returns:
- *
- * Pointer to skb containing the ack message. You need to check the
- * pointer with IS_ERR(), as it might be an error code. Error codes
- * could happen because:
- *
- * - the message wasn't formatted correctly
- * - couldn't send the message
- * - failed waiting for a response
- * - the ack message wasn't formatted correctly
- *
- * The returned skb has been allocated with wimax_msg_to_user_alloc(),
- * it contains the response in a netlink attribute and is ready to be
- * passed up to user space with wimax_msg_to_user_send(). To access
- * the payload and its length, use wimax_msg_{data,len}() on the skb.
- *
- * The skb has to be freed with kfree_skb() once done.
- *
- * Description:
- *
- * This function delivers a message/command to the device and waits
- * for an ack to be received. The format is described in
- * linux/wimax/i2400m.h. In summary, a command/get/set is followed by an
- * ack.
- *
- * This function will not check the ack status, that's left up to the
- * caller. Once done with the ack skb, it has to be kfree_skb()ed.
- *
- * The i2400m handles only one message at the same time, thus we need
- * the mutex to exclude other players.
- *
- * We write the message and then wait for an answer to come back. The
- * RX path intercepts control messages and handles them in
- * i2400m_rx_ctl(). Reports (notifications) are (maybe) processed
- * locally and then forwarded (as needed) to user space on the WiMAX
- * stack message pipe. Acks are saved and passed back to us through an
- * skb in i2400m->ack_skb which is ready to be given to generic
- * netlink if need be.
- */
-struct sk_buff *i2400m_msg_to_dev(struct i2400m *i2400m,
- const void *buf, size_t buf_len)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- const struct i2400m_l3l4_hdr *msg_l3l4_hdr;
- struct sk_buff *ack_skb;
- const struct i2400m_l3l4_hdr *ack_l3l4_hdr;
- size_t ack_len;
- int ack_timeout;
- unsigned msg_type;
- unsigned long flags;
-
- d_fnstart(3, dev, "(i2400m %p buf %p len %zu)\n",
- i2400m, buf, buf_len);
-
- rmb(); /* Make sure we see what i2400m_dev_reset_handle() */
- if (i2400m->boot_mode)
- return ERR_PTR(-EL3RST);
-
- msg_l3l4_hdr = buf;
- /* Check msg & payload consistency */
- result = i2400m_msg_size_check(i2400m, msg_l3l4_hdr, buf_len);
- if (result < 0)
- goto error_bad_msg;
- msg_type = le16_to_cpu(msg_l3l4_hdr->type);
- d_printf(1, dev, "CMD/GET/SET 0x%04x %zu bytes\n",
- msg_type, buf_len);
- d_dump(2, dev, buf, buf_len);
-
- /* Setup the completion, ack_skb ("we are waiting") and send
- * the message to the device */
- mutex_lock(&i2400m->msg_mutex);
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- i2400m->ack_skb = ERR_PTR(-EINPROGRESS);
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- init_completion(&i2400m->msg_completion);
- result = i2400m_tx(i2400m, buf, buf_len, I2400M_PT_CTRL);
- if (result < 0) {
- dev_err(dev, "can't send message 0x%04x: %d\n",
- le16_to_cpu(msg_l3l4_hdr->type), result);
- goto error_tx;
- }
-
- /* Some commands take longer to execute because of crypto ops,
- * so we give them some more leeway on timeout */
- switch (msg_type) {
- case I2400M_MT_GET_TLS_OPERATION_RESULT:
- case I2400M_MT_CMD_SEND_EAP_RESPONSE:
- ack_timeout = 5 * HZ;
- break;
- default:
- ack_timeout = HZ;
- }
-
- if (unlikely(i2400m->trace_msg_from_user))
- wimax_msg(&i2400m->wimax_dev, "echo", buf, buf_len, GFP_KERNEL);
- /* The RX path in rx.c will put any response for this message
- * in i2400m->ack_skb and wake us up. If we cancel the wait,
- * we need to change the value of i2400m->ack_skb to something
- * not -EINPROGRESS so RX knows there is no one waiting. */
- result = wait_for_completion_interruptible_timeout(
- &i2400m->msg_completion, ack_timeout);
- if (result == 0) {
- dev_err(dev, "timeout waiting for reply to message 0x%04x\n",
- msg_type);
- result = -ETIMEDOUT;
- i2400m_msg_to_dev_cancel_wait(i2400m, result);
- goto error_wait_for_completion;
- } else if (result < 0) {
- dev_err(dev, "error waiting for reply to message 0x%04x: %d\n",
- msg_type, result);
- i2400m_msg_to_dev_cancel_wait(i2400m, result);
- goto error_wait_for_completion;
- }
-
- /* Pull out the ack data from i2400m->ack_skb -- see if it is
- * an error and act accordingly */
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- ack_skb = i2400m->ack_skb;
- if (IS_ERR(ack_skb))
- result = PTR_ERR(ack_skb);
- else
- result = 0;
- i2400m->ack_skb = NULL;
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- if (result < 0)
- goto error_ack_status;
- ack_l3l4_hdr = wimax_msg_data_len(ack_skb, &ack_len);
-
- /* Check the ack and deliver it if it is ok */
- if (unlikely(i2400m->trace_msg_from_user))
- wimax_msg(&i2400m->wimax_dev, "echo",
- ack_l3l4_hdr, ack_len, GFP_KERNEL);
- result = i2400m_msg_size_check(i2400m, ack_l3l4_hdr, ack_len);
- if (result < 0) {
- dev_err(dev, "HW BUG? reply to message 0x%04x: %d\n",
- msg_type, result);
- goto error_bad_ack_len;
- }
- if (msg_type != le16_to_cpu(ack_l3l4_hdr->type)) {
- dev_err(dev, "HW BUG? bad reply 0x%04x to message 0x%04x\n",
- le16_to_cpu(ack_l3l4_hdr->type), msg_type);
- result = -EIO;
- goto error_bad_ack_type;
- }
- i2400m_msg_ack_hook(i2400m, ack_l3l4_hdr, ack_len);
- mutex_unlock(&i2400m->msg_mutex);
- d_fnend(3, dev, "(i2400m %p buf %p len %zu) = %p\n",
- i2400m, buf, buf_len, ack_skb);
- return ack_skb;
-
-error_bad_ack_type:
-error_bad_ack_len:
- kfree_skb(ack_skb);
-error_ack_status:
-error_wait_for_completion:
-error_tx:
- mutex_unlock(&i2400m->msg_mutex);
-error_bad_msg:
- d_fnend(3, dev, "(i2400m %p buf %p len %zu) = %d\n",
- i2400m, buf, buf_len, result);
- return ERR_PTR(result);
-}
-
-
-/*
- * Definitions for the Enter Power Save command
- *
- * The Enter Power Save command requests the device to go into power
- * saving mode. The device will ack or nak the command depending on it
- * being ready for it. If it acks, we tell the USB subsystem to
- *
- * As well, the device might request to go into power saving mode by
- * sending a report (REPORT_POWERSAVE_READY), in which case, we issue
- * this command. The hookups in the RX coder allow
- */
-enum {
- I2400M_WAKEUP_ENABLED = 0x01,
- I2400M_WAKEUP_DISABLED = 0x02,
- I2400M_TLV_TYPE_WAKEUP_MODE = 144,
-};
-
-struct i2400m_cmd_enter_power_save {
- struct i2400m_l3l4_hdr hdr;
- struct i2400m_tlv_hdr tlv;
- __le32 val;
-} __packed;
-
-
-/*
- * Request entering power save
- *
- * This command is (mainly) executed when the device indicates that it
- * is ready to go into powersave mode via a REPORT_POWERSAVE_READY.
- */
-int i2400m_cmd_enter_powersave(struct i2400m *i2400m)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *ack_skb;
- struct i2400m_cmd_enter_power_save *cmd;
- char strerr[32];
-
- result = -ENOMEM;
- cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
- if (cmd == NULL)
- goto error_alloc;
- cmd->hdr.type = cpu_to_le16(I2400M_MT_CMD_ENTER_POWERSAVE);
- cmd->hdr.length = cpu_to_le16(sizeof(*cmd) - sizeof(cmd->hdr));
- cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
- cmd->tlv.type = cpu_to_le16(I2400M_TLV_TYPE_WAKEUP_MODE);
- cmd->tlv.length = cpu_to_le16(sizeof(cmd->val));
- cmd->val = cpu_to_le32(I2400M_WAKEUP_ENABLED);
-
- ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
- result = PTR_ERR(ack_skb);
- if (IS_ERR(ack_skb)) {
- dev_err(dev, "Failed to issue 'Enter power save' command: %d\n",
- result);
- goto error_msg_to_dev;
- }
- result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
- strerr, sizeof(strerr));
- if (result == -EACCES)
- d_printf(1, dev, "Cannot enter power save mode\n");
- else if (result < 0)
- dev_err(dev, "'Enter power save' (0x%04x) command failed: "
- "%d - %s\n", I2400M_MT_CMD_ENTER_POWERSAVE,
- result, strerr);
- else
- d_printf(1, dev, "device ready to power save\n");
- kfree_skb(ack_skb);
-error_msg_to_dev:
- kfree(cmd);
-error_alloc:
- return result;
-}
-EXPORT_SYMBOL_GPL(i2400m_cmd_enter_powersave);
-
-
-/*
- * Definitions for getting device information
- */
-enum {
- I2400M_TLV_DETAILED_DEVICE_INFO = 140
-};
-
-/**
- * i2400m_get_device_info - Query the device for detailed device information
- *
- * @i2400m: device descriptor
- *
- * Returns: an skb whose skb->data points to a 'struct
- * i2400m_tlv_detailed_device_info'. When done, kfree_skb() it. The
- * skb is *guaranteed* to contain the whole TLV data structure.
- *
- * On error, IS_ERR(skb) is true and ERR_PTR(skb) is the error
- * code.
- */
-struct sk_buff *i2400m_get_device_info(struct i2400m *i2400m)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *ack_skb;
- struct i2400m_l3l4_hdr *cmd;
- const struct i2400m_l3l4_hdr *ack;
- size_t ack_len;
- const struct i2400m_tlv_hdr *tlv;
- const struct i2400m_tlv_detailed_device_info *ddi;
- char strerr[32];
-
- ack_skb = ERR_PTR(-ENOMEM);
- cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
- if (cmd == NULL)
- goto error_alloc;
- cmd->type = cpu_to_le16(I2400M_MT_GET_DEVICE_INFO);
- cmd->length = 0;
- cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
-
- ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
- if (IS_ERR(ack_skb)) {
- dev_err(dev, "Failed to issue 'get device info' command: %ld\n",
- PTR_ERR(ack_skb));
- goto error_msg_to_dev;
- }
- ack = wimax_msg_data_len(ack_skb, &ack_len);
- result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
- if (result < 0) {
- dev_err(dev, "'get device info' (0x%04x) command failed: "
- "%d - %s\n", I2400M_MT_GET_DEVICE_INFO, result,
- strerr);
- goto error_cmd_failed;
- }
- tlv = i2400m_tlv_find(i2400m, ack->pl, ack_len - sizeof(*ack),
- I2400M_TLV_DETAILED_DEVICE_INFO, sizeof(*ddi));
- if (tlv == NULL) {
- dev_err(dev, "GET DEVICE INFO: "
- "detailed device info TLV not found (0x%04x)\n",
- I2400M_TLV_DETAILED_DEVICE_INFO);
- result = -EIO;
- goto error_no_tlv;
- }
- skb_pull(ack_skb, (void *) tlv - (void *) ack_skb->data);
-error_msg_to_dev:
- kfree(cmd);
-error_alloc:
- return ack_skb;
-
-error_no_tlv:
-error_cmd_failed:
- kfree_skb(ack_skb);
- kfree(cmd);
- return ERR_PTR(result);
-}
-
-
-/* Firmware interface versions we support */
-enum {
- I2400M_HDIv_MAJOR = 9,
- I2400M_HDIv_MINOR = 1,
- I2400M_HDIv_MINOR_2 = 2,
-};
-
-
-/**
- * i2400m_firmware_check - check firmware versions are compatible with
- * the driver
- *
- * @i2400m: device descriptor
- *
- * Returns: 0 if ok, < 0 errno code an error and a message in the
- * kernel log.
- *
- * Long function, but quite simple; first chunk launches the command
- * and double checks the reply for the right TLV. Then we process the
- * TLV (where the meat is).
- *
- * Once we process the TLV that gives us the firmware's interface
- * version, we encode it and save it in i2400m->fw_version for future
- * reference.
- */
-int i2400m_firmware_check(struct i2400m *i2400m)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *ack_skb;
- struct i2400m_l3l4_hdr *cmd;
- const struct i2400m_l3l4_hdr *ack;
- size_t ack_len;
- const struct i2400m_tlv_hdr *tlv;
- const struct i2400m_tlv_l4_message_versions *l4mv;
- char strerr[32];
- unsigned major, minor, branch;
-
- result = -ENOMEM;
- cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
- if (cmd == NULL)
- goto error_alloc;
- cmd->type = cpu_to_le16(I2400M_MT_GET_LM_VERSION);
- cmd->length = 0;
- cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
-
- ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
- if (IS_ERR(ack_skb)) {
- result = PTR_ERR(ack_skb);
- dev_err(dev, "Failed to issue 'get lm version' command: %-d\n",
- result);
- goto error_msg_to_dev;
- }
- ack = wimax_msg_data_len(ack_skb, &ack_len);
- result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
- if (result < 0) {
- dev_err(dev, "'get lm version' (0x%04x) command failed: "
- "%d - %s\n", I2400M_MT_GET_LM_VERSION, result,
- strerr);
- goto error_cmd_failed;
- }
- tlv = i2400m_tlv_find(i2400m, ack->pl, ack_len - sizeof(*ack),
- I2400M_TLV_L4_MESSAGE_VERSIONS, sizeof(*l4mv));
- if (tlv == NULL) {
- dev_err(dev, "get lm version: TLV not found (0x%04x)\n",
- I2400M_TLV_L4_MESSAGE_VERSIONS);
- result = -EIO;
- goto error_no_tlv;
- }
- l4mv = container_of(tlv, typeof(*l4mv), hdr);
- major = le16_to_cpu(l4mv->major);
- minor = le16_to_cpu(l4mv->minor);
- branch = le16_to_cpu(l4mv->branch);
- result = -EINVAL;
- if (major != I2400M_HDIv_MAJOR) {
- dev_err(dev, "unsupported major fw version "
- "%u.%u.%u\n", major, minor, branch);
- goto error_bad_major;
- }
- result = 0;
- if (minor > I2400M_HDIv_MINOR_2 || minor < I2400M_HDIv_MINOR)
- dev_warn(dev, "untested minor fw version %u.%u.%u\n",
- major, minor, branch);
- /* Yes, we ignore the branch -- we don't have to track it */
- i2400m->fw_version = major << 16 | minor;
- dev_info(dev, "firmware interface version %u.%u.%u\n",
- major, minor, branch);
-error_bad_major:
-error_no_tlv:
-error_cmd_failed:
- kfree_skb(ack_skb);
-error_msg_to_dev:
- kfree(cmd);
-error_alloc:
- return result;
-}
-
-
-/*
- * Send an DoExitIdle command to the device to ask it to go out of
- * basestation-idle mode.
- *
- * @i2400m: device descriptor
- *
- * This starts a renegotiation with the basestation that might involve
- * another crypto handshake with user space.
- *
- * Returns: 0 if ok, < 0 errno code on error.
- */
-int i2400m_cmd_exit_idle(struct i2400m *i2400m)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *ack_skb;
- struct i2400m_l3l4_hdr *cmd;
- char strerr[32];
-
- result = -ENOMEM;
- cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
- if (cmd == NULL)
- goto error_alloc;
- cmd->type = cpu_to_le16(I2400M_MT_CMD_EXIT_IDLE);
- cmd->length = 0;
- cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
-
- ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
- result = PTR_ERR(ack_skb);
- if (IS_ERR(ack_skb)) {
- dev_err(dev, "Failed to issue 'exit idle' command: %d\n",
- result);
- goto error_msg_to_dev;
- }
- result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
- strerr, sizeof(strerr));
- kfree_skb(ack_skb);
-error_msg_to_dev:
- kfree(cmd);
-error_alloc:
- return result;
-
-}
-
-
-/*
- * Query the device for its state, update the WiMAX stack's idea of it
- *
- * @i2400m: device descriptor
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * Executes a 'Get State' command and parses the returned
- * TLVs.
- *
- * Because this is almost identical to a 'Report State', we use
- * i2400m_report_state_hook() to parse the answer. This will set the
- * carrier state, as well as the RF Kill switches state.
- */
-static int i2400m_cmd_get_state(struct i2400m *i2400m)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *ack_skb;
- struct i2400m_l3l4_hdr *cmd;
- const struct i2400m_l3l4_hdr *ack;
- size_t ack_len;
- char strerr[32];
-
- result = -ENOMEM;
- cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
- if (cmd == NULL)
- goto error_alloc;
- cmd->type = cpu_to_le16(I2400M_MT_GET_STATE);
- cmd->length = 0;
- cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
-
- ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
- if (IS_ERR(ack_skb)) {
- dev_err(dev, "Failed to issue 'get state' command: %ld\n",
- PTR_ERR(ack_skb));
- result = PTR_ERR(ack_skb);
- goto error_msg_to_dev;
- }
- ack = wimax_msg_data_len(ack_skb, &ack_len);
- result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
- if (result < 0) {
- dev_err(dev, "'get state' (0x%04x) command failed: "
- "%d - %s\n", I2400M_MT_GET_STATE, result, strerr);
- goto error_cmd_failed;
- }
- i2400m_report_state_hook(i2400m, ack, ack_len - sizeof(*ack),
- "GET STATE");
- result = 0;
- kfree_skb(ack_skb);
-error_cmd_failed:
-error_msg_to_dev:
- kfree(cmd);
-error_alloc:
- return result;
-}
-
-/**
- * Set basic configuration settings
- *
- * @i2400m: device descriptor
- * @arg: array of pointers to the TLV headers to send for
- * configuration (each followed by its payload).
- * TLV headers and payloads must be properly initialized, with the
- * right endianess (LE).
- * @args: number of pointers in the @arg array
- */
-static int i2400m_set_init_config(struct i2400m *i2400m,
- const struct i2400m_tlv_hdr **arg,
- size_t args)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *ack_skb;
- struct i2400m_l3l4_hdr *cmd;
- char strerr[32];
- unsigned argc, argsize, tlv_size;
- const struct i2400m_tlv_hdr *tlv_hdr;
- void *buf, *itr;
-
- d_fnstart(3, dev, "(i2400m %p arg %p args %zu)\n", i2400m, arg, args);
- result = 0;
- if (args == 0)
- goto none;
- /* Compute the size of all the TLVs, so we can alloc a
- * contiguous command block to copy them. */
- argsize = 0;
- for (argc = 0; argc < args; argc++) {
- tlv_hdr = arg[argc];
- argsize += sizeof(*tlv_hdr) + le16_to_cpu(tlv_hdr->length);
- }
- WARN_ON(argc >= 9); /* As per hw spec */
-
- /* Alloc the space for the command and TLVs*/
- result = -ENOMEM;
- buf = kzalloc(sizeof(*cmd) + argsize, GFP_KERNEL);
- if (buf == NULL)
- goto error_alloc;
- cmd = buf;
- cmd->type = cpu_to_le16(I2400M_MT_SET_INIT_CONFIG);
- cmd->length = cpu_to_le16(argsize);
- cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
-
- /* Copy the TLVs */
- itr = buf + sizeof(*cmd);
- for (argc = 0; argc < args; argc++) {
- tlv_hdr = arg[argc];
- tlv_size = sizeof(*tlv_hdr) + le16_to_cpu(tlv_hdr->length);
- memcpy(itr, tlv_hdr, tlv_size);
- itr += tlv_size;
- }
-
- /* Send the message! */
- ack_skb = i2400m_msg_to_dev(i2400m, buf, sizeof(*cmd) + argsize);
- result = PTR_ERR(ack_skb);
- if (IS_ERR(ack_skb)) {
- dev_err(dev, "Failed to issue 'init config' command: %d\n",
- result);
-
- goto error_msg_to_dev;
- }
- result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
- strerr, sizeof(strerr));
- if (result < 0)
- dev_err(dev, "'init config' (0x%04x) command failed: %d - %s\n",
- I2400M_MT_SET_INIT_CONFIG, result, strerr);
- kfree_skb(ack_skb);
-error_msg_to_dev:
- kfree(buf);
-error_alloc:
-none:
- d_fnend(3, dev, "(i2400m %p arg %p args %zu) = %d\n",
- i2400m, arg, args, result);
- return result;
-
-}
-
-/**
- * i2400m_set_idle_timeout - Set the device's idle mode timeout
- *
- * @i2400m: i2400m device descriptor
- *
- * @msecs: milliseconds for the timeout to enter idle mode. Between
- * 100 to 300000 (5m); 0 to disable. In increments of 100.
- *
- * After this @msecs of the link being idle (no data being sent or
- * received), the device will negotiate with the basestation entering
- * idle mode for saving power. The connection is maintained, but
- * getting out of it (done in tx.c) will require some negotiation,
- * possible crypto re-handshake and a possible DHCP re-lease.
- *
- * Only available if fw_version >= 0x00090002.
- *
- * Returns: 0 if ok, < 0 errno code on error.
- */
-int i2400m_set_idle_timeout(struct i2400m *i2400m, unsigned msecs)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *ack_skb;
- struct {
- struct i2400m_l3l4_hdr hdr;
- struct i2400m_tlv_config_idle_timeout cit;
- } *cmd;
- const struct i2400m_l3l4_hdr *ack;
- size_t ack_len;
- char strerr[32];
-
- result = -ENOSYS;
- if (i2400m_le_v1_3(i2400m))
- goto error_alloc;
- result = -ENOMEM;
- cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
- if (cmd == NULL)
- goto error_alloc;
- cmd->hdr.type = cpu_to_le16(I2400M_MT_GET_STATE);
- cmd->hdr.length = cpu_to_le16(sizeof(*cmd) - sizeof(cmd->hdr));
- cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
-
- cmd->cit.hdr.type =
- cpu_to_le16(I2400M_TLV_CONFIG_IDLE_TIMEOUT);
- cmd->cit.hdr.length = cpu_to_le16(sizeof(cmd->cit.timeout));
- cmd->cit.timeout = cpu_to_le32(msecs);
-
- ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
- if (IS_ERR(ack_skb)) {
- dev_err(dev, "Failed to issue 'set idle timeout' command: "
- "%ld\n", PTR_ERR(ack_skb));
- result = PTR_ERR(ack_skb);
- goto error_msg_to_dev;
- }
- ack = wimax_msg_data_len(ack_skb, &ack_len);
- result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
- if (result < 0) {
- dev_err(dev, "'set idle timeout' (0x%04x) command failed: "
- "%d - %s\n", I2400M_MT_GET_STATE, result, strerr);
- goto error_cmd_failed;
- }
- result = 0;
- kfree_skb(ack_skb);
-error_cmd_failed:
-error_msg_to_dev:
- kfree(cmd);
-error_alloc:
- return result;
-}
-
-
-/**
- * i2400m_dev_initialize - Initialize the device once communications are ready
- *
- * @i2400m: device descriptor
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * Configures the device to work the way we like it.
- *
- * At the point of this call, the device is registered with the WiMAX
- * and netdev stacks, firmware is uploaded and we can talk to the
- * device normally.
- */
-int i2400m_dev_initialize(struct i2400m *i2400m)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct i2400m_tlv_config_idle_parameters idle_params;
- struct i2400m_tlv_config_idle_timeout idle_timeout;
- struct i2400m_tlv_config_d2h_data_format df;
- struct i2400m_tlv_config_dl_host_reorder dlhr;
- const struct i2400m_tlv_hdr *args[9];
- unsigned argc = 0;
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
- if (i2400m_passive_mode)
- goto out_passive;
- /* Disable idle mode? (enabled by default) */
- if (i2400m_idle_mode_disabled) {
- if (i2400m_le_v1_3(i2400m)) {
- idle_params.hdr.type =
- cpu_to_le16(I2400M_TLV_CONFIG_IDLE_PARAMETERS);
- idle_params.hdr.length = cpu_to_le16(
- sizeof(idle_params) - sizeof(idle_params.hdr));
- idle_params.idle_timeout = 0;
- idle_params.idle_paging_interval = 0;
- args[argc++] = &idle_params.hdr;
- } else {
- idle_timeout.hdr.type =
- cpu_to_le16(I2400M_TLV_CONFIG_IDLE_TIMEOUT);
- idle_timeout.hdr.length = cpu_to_le16(
- sizeof(idle_timeout) - sizeof(idle_timeout.hdr));
- idle_timeout.timeout = 0;
- args[argc++] = &idle_timeout.hdr;
- }
- }
- if (i2400m_ge_v1_4(i2400m)) {
- /* Enable extended RX data format? */
- df.hdr.type =
- cpu_to_le16(I2400M_TLV_CONFIG_D2H_DATA_FORMAT);
- df.hdr.length = cpu_to_le16(
- sizeof(df) - sizeof(df.hdr));
- df.format = 1;
- args[argc++] = &df.hdr;
-
- /* Enable RX data reordering?
- * (switch flipped in rx.c:i2400m_rx_setup() after fw upload) */
- if (i2400m->rx_reorder) {
- dlhr.hdr.type =
- cpu_to_le16(I2400M_TLV_CONFIG_DL_HOST_REORDER);
- dlhr.hdr.length = cpu_to_le16(
- sizeof(dlhr) - sizeof(dlhr.hdr));
- dlhr.reorder = 1;
- args[argc++] = &dlhr.hdr;
- }
- }
- result = i2400m_set_init_config(i2400m, args, argc);
- if (result < 0)
- goto error;
-out_passive:
- /*
- * Update state: Here it just calls a get state; parsing the
- * result (System State TLV and RF Status TLV [done in the rx
- * path hooks]) will set the hardware and software RF-Kill
- * status.
- */
- result = i2400m_cmd_get_state(i2400m);
-error:
- if (result < 0)
- dev_err(dev, "failed to initialize the device: %d\n", result);
- d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
- return result;
-}
-
-
-/**
- * i2400m_dev_shutdown - Shutdown a running device
- *
- * @i2400m: device descriptor
- *
- * Release resources acquired during the running of the device; in
- * theory, should also tell the device to go to sleep, switch off the
- * radio, all that, but at this point, in most cases (driver
- * disconnection, reset handling) we can't even talk to the device.
- */
-void i2400m_dev_shutdown(struct i2400m *i2400m)
-{
- struct device *dev = i2400m_dev(i2400m);
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
- d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
diff --git a/drivers/staging/wimax/i2400m/debug-levels.h b/drivers/staging/wimax/i2400m/debug-levels.h
deleted file mode 100644
index a317e9fbb734..000000000000
--- a/drivers/staging/wimax/i2400m/debug-levels.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Debug levels control file for the i2400m module
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-#ifndef __debug_levels__h__
-#define __debug_levels__h__
-
-/* Maximum compile and run time debug level for all submodules */
-#define D_MODULENAME i2400m
-#define D_MASTER CONFIG_WIMAX_I2400M_DEBUG_LEVEL
-
-#include "../linux-wimax-debug.h"
-
-/* List of all the enabled modules */
-enum d_module {
- D_SUBMODULE_DECLARE(control),
- D_SUBMODULE_DECLARE(driver),
- D_SUBMODULE_DECLARE(debugfs),
- D_SUBMODULE_DECLARE(fw),
- D_SUBMODULE_DECLARE(netdev),
- D_SUBMODULE_DECLARE(rfkill),
- D_SUBMODULE_DECLARE(rx),
- D_SUBMODULE_DECLARE(sysfs),
- D_SUBMODULE_DECLARE(tx),
-};
-
-
-#endif /* #ifndef __debug_levels__h__ */
diff --git a/drivers/staging/wimax/i2400m/debugfs.c b/drivers/staging/wimax/i2400m/debugfs.c
deleted file mode 100644
index 1c640b41ea4c..000000000000
--- a/drivers/staging/wimax/i2400m/debugfs.c
+++ /dev/null
@@ -1,253 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Debugfs interfaces to manipulate driver and device information
- *
- * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-
-#include <linux/debugfs.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/spinlock.h>
-#include <linux/device.h>
-#include <linux/export.h>
-#include "i2400m.h"
-
-
-#define D_SUBMODULE debugfs
-#include "debug-levels.h"
-
-static
-int debugfs_netdev_queue_stopped_get(void *data, u64 *val)
-{
- struct i2400m *i2400m = data;
- *val = netif_queue_stopped(i2400m->wimax_dev.net_dev);
- return 0;
-}
-DEFINE_DEBUGFS_ATTRIBUTE(fops_netdev_queue_stopped,
- debugfs_netdev_queue_stopped_get,
- NULL, "%llu\n");
-
-/*
- * We don't allow partial reads of this file, as then the reader would
- * get weirdly confused data as it is updated.
- *
- * So or you read it all or nothing; if you try to read with an offset
- * != 0, we consider you are done reading.
- */
-static
-ssize_t i2400m_rx_stats_read(struct file *filp, char __user *buffer,
- size_t count, loff_t *ppos)
-{
- struct i2400m *i2400m = filp->private_data;
- char buf[128];
- unsigned long flags;
-
- if (*ppos != 0)
- return 0;
- if (count < sizeof(buf))
- return -ENOSPC;
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- snprintf(buf, sizeof(buf), "%u %u %u %u %u %u %u\n",
- i2400m->rx_pl_num, i2400m->rx_pl_min,
- i2400m->rx_pl_max, i2400m->rx_num,
- i2400m->rx_size_acc,
- i2400m->rx_size_min, i2400m->rx_size_max);
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
-}
-
-
-/* Any write clears the stats */
-static
-ssize_t i2400m_rx_stats_write(struct file *filp, const char __user *buffer,
- size_t count, loff_t *ppos)
-{
- struct i2400m *i2400m = filp->private_data;
- unsigned long flags;
-
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- i2400m->rx_pl_num = 0;
- i2400m->rx_pl_max = 0;
- i2400m->rx_pl_min = UINT_MAX;
- i2400m->rx_num = 0;
- i2400m->rx_size_acc = 0;
- i2400m->rx_size_min = UINT_MAX;
- i2400m->rx_size_max = 0;
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- return count;
-}
-
-static
-const struct file_operations i2400m_rx_stats_fops = {
- .owner = THIS_MODULE,
- .open = simple_open,
- .read = i2400m_rx_stats_read,
- .write = i2400m_rx_stats_write,
- .llseek = default_llseek,
-};
-
-
-/* See i2400m_rx_stats_read() */
-static
-ssize_t i2400m_tx_stats_read(struct file *filp, char __user *buffer,
- size_t count, loff_t *ppos)
-{
- struct i2400m *i2400m = filp->private_data;
- char buf[128];
- unsigned long flags;
-
- if (*ppos != 0)
- return 0;
- if (count < sizeof(buf))
- return -ENOSPC;
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- snprintf(buf, sizeof(buf), "%u %u %u %u %u %u %u\n",
- i2400m->tx_pl_num, i2400m->tx_pl_min,
- i2400m->tx_pl_max, i2400m->tx_num,
- i2400m->tx_size_acc,
- i2400m->tx_size_min, i2400m->tx_size_max);
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
- return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
-}
-
-/* Any write clears the stats */
-static
-ssize_t i2400m_tx_stats_write(struct file *filp, const char __user *buffer,
- size_t count, loff_t *ppos)
-{
- struct i2400m *i2400m = filp->private_data;
- unsigned long flags;
-
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- i2400m->tx_pl_num = 0;
- i2400m->tx_pl_max = 0;
- i2400m->tx_pl_min = UINT_MAX;
- i2400m->tx_num = 0;
- i2400m->tx_size_acc = 0;
- i2400m->tx_size_min = UINT_MAX;
- i2400m->tx_size_max = 0;
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
- return count;
-}
-
-static
-const struct file_operations i2400m_tx_stats_fops = {
- .owner = THIS_MODULE,
- .open = simple_open,
- .read = i2400m_tx_stats_read,
- .write = i2400m_tx_stats_write,
- .llseek = default_llseek,
-};
-
-
-/* Write 1 to ask the device to go into suspend */
-static
-int debugfs_i2400m_suspend_set(void *data, u64 val)
-{
- int result;
- struct i2400m *i2400m = data;
- result = i2400m_cmd_enter_powersave(i2400m);
- if (result >= 0)
- result = 0;
- return result;
-}
-DEFINE_DEBUGFS_ATTRIBUTE(fops_i2400m_suspend,
- NULL, debugfs_i2400m_suspend_set,
- "%llu\n");
-
-/*
- * Reset the device
- *
- * Write 0 to ask the device to soft reset, 1 to cold reset, 2 to bus
- * reset (as defined by enum i2400m_reset_type).
- */
-static
-int debugfs_i2400m_reset_set(void *data, u64 val)
-{
- int result;
- struct i2400m *i2400m = data;
- enum i2400m_reset_type rt = val;
- switch(rt) {
- case I2400M_RT_WARM:
- case I2400M_RT_COLD:
- case I2400M_RT_BUS:
- result = i2400m_reset(i2400m, rt);
- if (result >= 0)
- result = 0;
- break;
- default:
- result = -EINVAL;
- }
- return result;
-}
-DEFINE_DEBUGFS_ATTRIBUTE(fops_i2400m_reset,
- NULL, debugfs_i2400m_reset_set,
- "%llu\n");
-
-void i2400m_debugfs_add(struct i2400m *i2400m)
-{
- struct dentry *dentry = i2400m->wimax_dev.debugfs_dentry;
-
- dentry = debugfs_create_dir("i2400m", dentry);
- i2400m->debugfs_dentry = dentry;
-
- d_level_register_debugfs("dl_", control, dentry);
- d_level_register_debugfs("dl_", driver, dentry);
- d_level_register_debugfs("dl_", debugfs, dentry);
- d_level_register_debugfs("dl_", fw, dentry);
- d_level_register_debugfs("dl_", netdev, dentry);
- d_level_register_debugfs("dl_", rfkill, dentry);
- d_level_register_debugfs("dl_", rx, dentry);
- d_level_register_debugfs("dl_", tx, dentry);
-
- debugfs_create_size_t("tx_in", 0400, dentry, &i2400m->tx_in);
- debugfs_create_size_t("tx_out", 0400, dentry, &i2400m->tx_out);
- debugfs_create_u32("state", 0600, dentry, &i2400m->state);
-
- /*
- * Trace received messages from user space
- *
- * In order to tap the bidirectional message stream in the
- * 'msg' pipe, user space can read from the 'msg' pipe;
- * however, due to limitations in libnl, we can't know what
- * the different applications are sending down to the kernel.
- *
- * So we have this hack where the driver will echo any message
- * received on the msg pipe from user space [through a call to
- * wimax_dev->op_msg_from_user() into
- * i2400m_op_msg_from_user()] into the 'trace' pipe that this
- * driver creates.
- *
- * So then, reading from both the 'trace' and 'msg' pipes in
- * user space will provide a full dump of the traffic.
- *
- * Write 1 to activate, 0 to clear.
- *
- * It is not really very atomic, but it is also not too
- * critical.
- */
- debugfs_create_u8("trace_msg_from_user", 0600, dentry,
- &i2400m->trace_msg_from_user);
-
- debugfs_create_file("netdev_queue_stopped", 0400, dentry, i2400m,
- &fops_netdev_queue_stopped);
-
- debugfs_create_file("rx_stats", 0600, dentry, i2400m,
- &i2400m_rx_stats_fops);
-
- debugfs_create_file("tx_stats", 0600, dentry, i2400m,
- &i2400m_tx_stats_fops);
-
- debugfs_create_file("suspend", 0200, dentry, i2400m,
- &fops_i2400m_suspend);
-
- debugfs_create_file("reset", 0200, dentry, i2400m, &fops_i2400m_reset);
-}
-
-void i2400m_debugfs_rm(struct i2400m *i2400m)
-{
- debugfs_remove_recursive(i2400m->debugfs_dentry);
-}
diff --git a/drivers/staging/wimax/i2400m/driver.c b/drivers/staging/wimax/i2400m/driver.c
deleted file mode 100644
index f5186458bb3d..000000000000
--- a/drivers/staging/wimax/i2400m/driver.c
+++ /dev/null
@@ -1,1003 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Generic probe/disconnect, reset and message passing
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * See i2400m.h for driver documentation. This contains helpers for
- * the driver model glue [_setup()/_release()], handling device resets
- * [_dev_reset_handle()], and the backends for the WiMAX stack ops
- * reset [_op_reset()] and message from user [_op_msg_from_user()].
- *
- * ROADMAP:
- *
- * i2400m_op_msg_from_user()
- * i2400m_msg_to_dev()
- * wimax_msg_to_user_send()
- *
- * i2400m_op_reset()
- * i240m->bus_reset()
- *
- * i2400m_dev_reset_handle()
- * __i2400m_dev_reset_handle()
- * __i2400m_dev_stop()
- * __i2400m_dev_start()
- *
- * i2400m_setup()
- * i2400m->bus_setup()
- * i2400m_bootrom_init()
- * register_netdev()
- * wimax_dev_add()
- * i2400m_dev_start()
- * __i2400m_dev_start()
- * i2400m_dev_bootstrap()
- * i2400m_tx_setup()
- * i2400m->bus_dev_start()
- * i2400m_firmware_check()
- * i2400m_check_mac_addr()
- *
- * i2400m_release()
- * i2400m_dev_stop()
- * __i2400m_dev_stop()
- * i2400m_dev_shutdown()
- * i2400m->bus_dev_stop()
- * i2400m_tx_release()
- * i2400m->bus_release()
- * wimax_dev_rm()
- * unregister_netdev()
- */
-#include "i2400m.h"
-#include <linux/etherdevice.h>
-#include "linux-wimax-i2400m.h"
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/suspend.h>
-#include <linux/slab.h>
-
-#define D_SUBMODULE driver
-#include "debug-levels.h"
-
-
-static char i2400m_debug_params[128];
-module_param_string(debug, i2400m_debug_params, sizeof(i2400m_debug_params),
- 0644);
-MODULE_PARM_DESC(debug,
- "String of space-separated NAME:VALUE pairs, where NAMEs "
- "are the different debug submodules and VALUE are the "
- "initial debug value to set.");
-
-static char i2400m_barkers_params[128];
-module_param_string(barkers, i2400m_barkers_params,
- sizeof(i2400m_barkers_params), 0644);
-MODULE_PARM_DESC(barkers,
- "String of comma-separated 32-bit values; each is "
- "recognized as the value the device sends as a reboot "
- "signal; values are appended to a list--setting one value "
- "as zero cleans the existing list and starts a new one.");
-
-/*
- * WiMAX stack operation: relay a message from user space
- *
- * @wimax_dev: device descriptor
- * @pipe_name: named pipe the message is for
- * @msg_buf: pointer to the message bytes
- * @msg_len: length of the buffer
- * @genl_info: passed by the generic netlink layer
- *
- * The WiMAX stack will call this function when a message was received
- * from user space.
- *
- * For the i2400m, this is an L3L4 message, as specified in
- * include/linux/wimax/i2400m.h, and thus prefixed with a 'struct
- * i2400m_l3l4_hdr'. Driver (and device) expect the messages to be
- * coded in Little Endian.
- *
- * This function just verifies that the header declaration and the
- * payload are consistent and then deals with it, either forwarding it
- * to the device or procesing it locally.
- *
- * In the i2400m, messages are basically commands that will carry an
- * ack, so we use i2400m_msg_to_dev() and then deliver the ack back to
- * user space. The rx.c code might intercept the response and use it
- * to update the driver's state, but then it will pass it on so it can
- * be relayed back to user space.
- *
- * Note that asynchronous events from the device are processed and
- * sent to user space in rx.c.
- */
-static
-int i2400m_op_msg_from_user(struct wimax_dev *wimax_dev,
- const char *pipe_name,
- const void *msg_buf, size_t msg_len,
- const struct genl_info *genl_info)
-{
- int result;
- struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *ack_skb;
-
- d_fnstart(4, dev, "(wimax_dev %p [i2400m %p] msg_buf %p "
- "msg_len %zu genl_info %p)\n", wimax_dev, i2400m,
- msg_buf, msg_len, genl_info);
- ack_skb = i2400m_msg_to_dev(i2400m, msg_buf, msg_len);
- result = PTR_ERR(ack_skb);
- if (IS_ERR(ack_skb))
- goto error_msg_to_dev;
- result = wimax_msg_send(&i2400m->wimax_dev, ack_skb);
-error_msg_to_dev:
- d_fnend(4, dev, "(wimax_dev %p [i2400m %p] msg_buf %p msg_len %zu "
- "genl_info %p) = %d\n", wimax_dev, i2400m, msg_buf, msg_len,
- genl_info, result);
- return result;
-}
-
-
-/*
- * Context to wait for a reset to finalize
- */
-struct i2400m_reset_ctx {
- struct completion completion;
- int result;
-};
-
-
-/*
- * WiMAX stack operation: reset a device
- *
- * @wimax_dev: device descriptor
- *
- * See the documentation for wimax_reset() and wimax_dev->op_reset for
- * the requirements of this function. The WiMAX stack guarantees
- * serialization on calls to this function.
- *
- * Do a warm reset on the device; if it fails, resort to a cold reset
- * and return -ENODEV. On successful warm reset, we need to block
- * until it is complete.
- *
- * The bus-driver implementation of reset takes care of falling back
- * to cold reset if warm fails.
- */
-static
-int i2400m_op_reset(struct wimax_dev *wimax_dev)
-{
- int result;
- struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
- struct device *dev = i2400m_dev(i2400m);
- struct i2400m_reset_ctx ctx = {
- .completion = COMPLETION_INITIALIZER_ONSTACK(ctx.completion),
- .result = 0,
- };
-
- d_fnstart(4, dev, "(wimax_dev %p)\n", wimax_dev);
- mutex_lock(&i2400m->init_mutex);
- i2400m->reset_ctx = &ctx;
- mutex_unlock(&i2400m->init_mutex);
- result = i2400m_reset(i2400m, I2400M_RT_WARM);
- if (result < 0)
- goto out;
- result = wait_for_completion_timeout(&ctx.completion, 4*HZ);
- if (result == 0)
- result = -ETIMEDOUT;
- else if (result > 0)
- result = ctx.result;
- /* if result < 0, pass it on */
- mutex_lock(&i2400m->init_mutex);
- i2400m->reset_ctx = NULL;
- mutex_unlock(&i2400m->init_mutex);
-out:
- d_fnend(4, dev, "(wimax_dev %p) = %d\n", wimax_dev, result);
- return result;
-}
-
-
-/*
- * Check the MAC address we got from boot mode is ok
- *
- * @i2400m: device descriptor
- *
- * Returns: 0 if ok, < 0 errno code on error.
- */
-static
-int i2400m_check_mac_addr(struct i2400m *i2400m)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *skb;
- const struct i2400m_tlv_detailed_device_info *ddi;
- struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
- skb = i2400m_get_device_info(i2400m);
- if (IS_ERR(skb)) {
- result = PTR_ERR(skb);
- dev_err(dev, "Cannot verify MAC address, error reading: %d\n",
- result);
- goto error;
- }
- /* Extract MAC address */
- ddi = (void *) skb->data;
- BUILD_BUG_ON(ETH_ALEN != sizeof(ddi->mac_address));
- d_printf(2, dev, "GET DEVICE INFO: mac addr %pM\n",
- ddi->mac_address);
- if (!memcmp(net_dev->perm_addr, ddi->mac_address,
- sizeof(ddi->mac_address)))
- goto ok;
- dev_warn(dev, "warning: device reports a different MAC address "
- "to that of boot mode's\n");
- dev_warn(dev, "device reports %pM\n", ddi->mac_address);
- dev_warn(dev, "boot mode reported %pM\n", net_dev->perm_addr);
- if (is_zero_ether_addr(ddi->mac_address))
- dev_err(dev, "device reports an invalid MAC address, "
- "not updating\n");
- else {
- dev_warn(dev, "updating MAC address\n");
- net_dev->addr_len = ETH_ALEN;
- memcpy(net_dev->perm_addr, ddi->mac_address, ETH_ALEN);
- memcpy(net_dev->dev_addr, ddi->mac_address, ETH_ALEN);
- }
-ok:
- result = 0;
- kfree_skb(skb);
-error:
- d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
- return result;
-}
-
-
-/**
- * __i2400m_dev_start - Bring up driver communication with the device
- *
- * @i2400m: device descriptor
- * @flags: boot mode flags
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * Uploads firmware and brings up all the resources needed to be able
- * to communicate with the device.
- *
- * The workqueue has to be setup early, at least before RX handling
- * (it's only real user for now) so it can process reports as they
- * arrive. We also want to destroy it if we retry, to make sure it is
- * flushed...easier like this.
- *
- * TX needs to be setup before the bus-specific code (otherwise on
- * shutdown, the bus-tx code could try to access it).
- */
-static
-int __i2400m_dev_start(struct i2400m *i2400m, enum i2400m_bri flags)
-{
- int result;
- struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
- struct net_device *net_dev = wimax_dev->net_dev;
- struct device *dev = i2400m_dev(i2400m);
- int times = i2400m->bus_bm_retries;
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-retry:
- result = i2400m_dev_bootstrap(i2400m, flags);
- if (result < 0) {
- dev_err(dev, "cannot bootstrap device: %d\n", result);
- goto error_bootstrap;
- }
- result = i2400m_tx_setup(i2400m);
- if (result < 0)
- goto error_tx_setup;
- result = i2400m_rx_setup(i2400m);
- if (result < 0)
- goto error_rx_setup;
- i2400m->work_queue = create_singlethread_workqueue(wimax_dev->name);
- if (i2400m->work_queue == NULL) {
- result = -ENOMEM;
- dev_err(dev, "cannot create workqueue\n");
- goto error_create_workqueue;
- }
- if (i2400m->bus_dev_start) {
- result = i2400m->bus_dev_start(i2400m);
- if (result < 0)
- goto error_bus_dev_start;
- }
- i2400m->ready = 1;
- wmb(); /* see i2400m->ready's documentation */
- /* process pending reports from the device */
- queue_work(i2400m->work_queue, &i2400m->rx_report_ws);
- result = i2400m_firmware_check(i2400m); /* fw versions ok? */
- if (result < 0)
- goto error_fw_check;
- /* At this point is ok to send commands to the device */
- result = i2400m_check_mac_addr(i2400m);
- if (result < 0)
- goto error_check_mac_addr;
- result = i2400m_dev_initialize(i2400m);
- if (result < 0)
- goto error_dev_initialize;
-
- /* We don't want any additional unwanted error recovery triggered
- * from any other context so if anything went wrong before we come
- * here, let's keep i2400m->error_recovery untouched and leave it to
- * dev_reset_handle(). See dev_reset_handle(). */
-
- atomic_dec(&i2400m->error_recovery);
- /* Every thing works so far, ok, now we are ready to
- * take error recovery if it's required. */
-
- /* At this point, reports will come for the device and set it
- * to the right state if it is different than UNINITIALIZED */
- d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
- net_dev, i2400m, result);
- return result;
-
-error_dev_initialize:
-error_check_mac_addr:
-error_fw_check:
- i2400m->ready = 0;
- wmb(); /* see i2400m->ready's documentation */
- flush_workqueue(i2400m->work_queue);
- if (i2400m->bus_dev_stop)
- i2400m->bus_dev_stop(i2400m);
-error_bus_dev_start:
- destroy_workqueue(i2400m->work_queue);
-error_create_workqueue:
- i2400m_rx_release(i2400m);
-error_rx_setup:
- i2400m_tx_release(i2400m);
-error_tx_setup:
-error_bootstrap:
- if (result == -EL3RST && times-- > 0) {
- flags = I2400M_BRI_SOFT|I2400M_BRI_MAC_REINIT;
- goto retry;
- }
- d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
- net_dev, i2400m, result);
- return result;
-}
-
-
-static
-int i2400m_dev_start(struct i2400m *i2400m, enum i2400m_bri bm_flags)
-{
- int result = 0;
- mutex_lock(&i2400m->init_mutex); /* Well, start the device */
- if (i2400m->updown == 0) {
- result = __i2400m_dev_start(i2400m, bm_flags);
- if (result >= 0) {
- i2400m->updown = 1;
- i2400m->alive = 1;
- wmb();/* see i2400m->updown and i2400m->alive's doc */
- }
- }
- mutex_unlock(&i2400m->init_mutex);
- return result;
-}
-
-
-/**
- * i2400m_dev_stop - Tear down driver communication with the device
- *
- * @i2400m: device descriptor
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * Releases all the resources allocated to communicate with the
- * device. Note we cannot destroy the workqueue earlier as until RX is
- * fully destroyed, it could still try to schedule jobs.
- */
-static
-void __i2400m_dev_stop(struct i2400m *i2400m)
-{
- struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
- struct device *dev = i2400m_dev(i2400m);
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
- wimax_state_change(wimax_dev, __WIMAX_ST_QUIESCING);
- i2400m_msg_to_dev_cancel_wait(i2400m, -EL3RST);
- complete(&i2400m->msg_completion);
- i2400m_net_wake_stop(i2400m);
- i2400m_dev_shutdown(i2400m);
- /*
- * Make sure no report hooks are running *before* we stop the
- * communication infrastructure with the device.
- */
- i2400m->ready = 0; /* nobody can queue work anymore */
- wmb(); /* see i2400m->ready's documentation */
- flush_workqueue(i2400m->work_queue);
-
- if (i2400m->bus_dev_stop)
- i2400m->bus_dev_stop(i2400m);
- destroy_workqueue(i2400m->work_queue);
- i2400m_rx_release(i2400m);
- i2400m_tx_release(i2400m);
- wimax_state_change(wimax_dev, WIMAX_ST_DOWN);
- d_fnend(3, dev, "(i2400m %p) = 0\n", i2400m);
-}
-
-
-/*
- * Watch out -- we only need to stop if there is a need for it. The
- * device could have reset itself and failed to come up again (see
- * _i2400m_dev_reset_handle()).
- */
-static
-void i2400m_dev_stop(struct i2400m *i2400m)
-{
- mutex_lock(&i2400m->init_mutex);
- if (i2400m->updown) {
- __i2400m_dev_stop(i2400m);
- i2400m->updown = 0;
- i2400m->alive = 0;
- wmb(); /* see i2400m->updown and i2400m->alive's doc */
- }
- mutex_unlock(&i2400m->init_mutex);
-}
-
-
-/*
- * Listen to PM events to cache the firmware before suspend/hibernation
- *
- * When the device comes out of suspend, it might go into reset and
- * firmware has to be uploaded again. At resume, most of the times, we
- * can't load firmware images from disk, so we need to cache it.
- *
- * i2400m_fw_cache() will allocate a kobject and attach the firmware
- * to it; that way we don't have to worry too much about the fw loader
- * hitting a race condition.
- *
- * Note: modus operandi stolen from the Orinoco driver; thx.
- */
-static
-int i2400m_pm_notifier(struct notifier_block *notifier,
- unsigned long pm_event,
- void *unused)
-{
- struct i2400m *i2400m =
- container_of(notifier, struct i2400m, pm_notifier);
- struct device *dev = i2400m_dev(i2400m);
-
- d_fnstart(3, dev, "(i2400m %p pm_event %lx)\n", i2400m, pm_event);
- switch (pm_event) {
- case PM_HIBERNATION_PREPARE:
- case PM_SUSPEND_PREPARE:
- i2400m_fw_cache(i2400m);
- break;
- case PM_POST_RESTORE:
- /* Restore from hibernation failed. We need to clean
- * up in exactly the same way, so fall through. */
- case PM_POST_HIBERNATION:
- case PM_POST_SUSPEND:
- i2400m_fw_uncache(i2400m);
- break;
-
- case PM_RESTORE_PREPARE:
- default:
- break;
- }
- d_fnend(3, dev, "(i2400m %p pm_event %lx) = void\n", i2400m, pm_event);
- return NOTIFY_DONE;
-}
-
-
-/*
- * pre-reset is called before a device is going on reset
- *
- * This has to be followed by a call to i2400m_post_reset(), otherwise
- * bad things might happen.
- */
-int i2400m_pre_reset(struct i2400m *i2400m)
-{
- struct device *dev = i2400m_dev(i2400m);
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
- d_printf(1, dev, "pre-reset shut down\n");
-
- mutex_lock(&i2400m->init_mutex);
- if (i2400m->updown) {
- netif_tx_disable(i2400m->wimax_dev.net_dev);
- __i2400m_dev_stop(i2400m);
- /* down't set updown to zero -- this way
- * post_reset can restore properly */
- }
- mutex_unlock(&i2400m->init_mutex);
- if (i2400m->bus_release)
- i2400m->bus_release(i2400m);
- d_fnend(3, dev, "(i2400m %p) = 0\n", i2400m);
- return 0;
-}
-EXPORT_SYMBOL_GPL(i2400m_pre_reset);
-
-
-/*
- * Restore device state after a reset
- *
- * Do the work needed after a device reset to bring it up to the same
- * state as it was before the reset.
- *
- * NOTE: this requires i2400m->init_mutex taken
- */
-int i2400m_post_reset(struct i2400m *i2400m)
-{
- int result = 0;
- struct device *dev = i2400m_dev(i2400m);
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
- d_printf(1, dev, "post-reset start\n");
- if (i2400m->bus_setup) {
- result = i2400m->bus_setup(i2400m);
- if (result < 0) {
- dev_err(dev, "bus-specific setup failed: %d\n",
- result);
- goto error_bus_setup;
- }
- }
- mutex_lock(&i2400m->init_mutex);
- if (i2400m->updown) {
- result = __i2400m_dev_start(
- i2400m, I2400M_BRI_SOFT | I2400M_BRI_MAC_REINIT);
- if (result < 0)
- goto error_dev_start;
- }
- mutex_unlock(&i2400m->init_mutex);
- d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
- return result;
-
-error_dev_start:
- if (i2400m->bus_release)
- i2400m->bus_release(i2400m);
- /* even if the device was up, it could not be recovered, so we
- * mark it as down. */
- i2400m->updown = 0;
- wmb(); /* see i2400m->updown's documentation */
- mutex_unlock(&i2400m->init_mutex);
-error_bus_setup:
- d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
- return result;
-}
-EXPORT_SYMBOL_GPL(i2400m_post_reset);
-
-
-/*
- * The device has rebooted; fix up the device and the driver
- *
- * Tear down the driver communication with the device, reload the
- * firmware and reinitialize the communication with the device.
- *
- * If someone calls a reset when the device's firmware is down, in
- * theory we won't see it because we are not listening. However, just
- * in case, leave the code to handle it.
- *
- * If there is a reset context, use it; this means someone is waiting
- * for us to tell him when the reset operation is complete and the
- * device is ready to rock again.
- *
- * NOTE: if we are in the process of bringing up or down the
- * communication with the device [running i2400m_dev_start() or
- * _stop()], don't do anything, let it fail and handle it.
- *
- * This function is ran always in a thread context
- *
- * This function gets passed, as payload to i2400m_work() a 'const
- * char *' ptr with a "reason" why the reset happened (for messages).
- */
-static
-void __i2400m_dev_reset_handle(struct work_struct *ws)
-{
- struct i2400m *i2400m = container_of(ws, struct i2400m, reset_ws);
- const char *reason = i2400m->reset_reason;
- struct device *dev = i2400m_dev(i2400m);
- struct i2400m_reset_ctx *ctx = i2400m->reset_ctx;
- int result;
-
- d_fnstart(3, dev, "(ws %p i2400m %p reason %s)\n", ws, i2400m, reason);
-
- i2400m->boot_mode = 1;
- wmb(); /* Make sure i2400m_msg_to_dev() sees boot_mode */
-
- result = 0;
- if (mutex_trylock(&i2400m->init_mutex) == 0) {
- /* We are still in i2400m_dev_start() [let it fail] or
- * i2400m_dev_stop() [we are shutting down anyway, so
- * ignore it] or we are resetting somewhere else. */
- dev_err(dev, "device rebooted somewhere else?\n");
- i2400m_msg_to_dev_cancel_wait(i2400m, -EL3RST);
- complete(&i2400m->msg_completion);
- goto out;
- }
-
- dev_err(dev, "%s: reinitializing driver\n", reason);
- rmb();
- if (i2400m->updown) {
- __i2400m_dev_stop(i2400m);
- i2400m->updown = 0;
- wmb(); /* see i2400m->updown's documentation */
- }
-
- if (i2400m->alive) {
- result = __i2400m_dev_start(i2400m,
- I2400M_BRI_SOFT | I2400M_BRI_MAC_REINIT);
- if (result < 0) {
- dev_err(dev, "%s: cannot start the device: %d\n",
- reason, result);
- result = -EUCLEAN;
- if (atomic_read(&i2400m->bus_reset_retries)
- >= I2400M_BUS_RESET_RETRIES) {
- result = -ENODEV;
- dev_err(dev, "tried too many times to "
- "reset the device, giving up\n");
- }
- }
- }
-
- if (i2400m->reset_ctx) {
- ctx->result = result;
- complete(&ctx->completion);
- }
- mutex_unlock(&i2400m->init_mutex);
- if (result == -EUCLEAN) {
- /*
- * We come here because the reset during operational mode
- * wasn't successfully done and need to proceed to a bus
- * reset. For the dev_reset_handle() to be able to handle
- * the reset event later properly, we restore boot_mode back
- * to the state before previous reset. ie: just like we are
- * issuing the bus reset for the first time
- */
- i2400m->boot_mode = 0;
- wmb();
-
- atomic_inc(&i2400m->bus_reset_retries);
- /* ops, need to clean up [w/ init_mutex not held] */
- result = i2400m_reset(i2400m, I2400M_RT_BUS);
- if (result >= 0)
- result = -ENODEV;
- } else {
- rmb();
- if (i2400m->alive) {
- /* great, we expect the device state up and
- * dev_start() actually brings the device state up */
- i2400m->updown = 1;
- wmb();
- atomic_set(&i2400m->bus_reset_retries, 0);
- }
- }
-out:
- d_fnend(3, dev, "(ws %p i2400m %p reason %s) = void\n",
- ws, i2400m, reason);
-}
-
-
-/*
- * i2400m_dev_reset_handle - Handle a device's reset in a thread context
- *
- * Schedule a device reset handling out on a thread context, so it
- * is safe to call from atomic context. We can't use the i2400m's
- * queue as we are going to destroy it and reinitialize it as part of
- * the driver bringup/bringup process.
- *
- * See __i2400m_dev_reset_handle() for details; that takes care of
- * reinitializing the driver to handle the reset, calling into the
- * bus-specific functions ops as needed.
- */
-int i2400m_dev_reset_handle(struct i2400m *i2400m, const char *reason)
-{
- i2400m->reset_reason = reason;
- return schedule_work(&i2400m->reset_ws);
-}
-EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle);
-
-
-/*
- * The actual work of error recovery.
- *
- * The current implementation of error recovery is to trigger a bus reset.
- */
-static
-void __i2400m_error_recovery(struct work_struct *ws)
-{
- struct i2400m *i2400m = container_of(ws, struct i2400m, recovery_ws);
-
- i2400m_reset(i2400m, I2400M_RT_BUS);
-}
-
-/*
- * Schedule a work struct for error recovery.
- *
- * The intention of error recovery is to bring back the device to some
- * known state whenever TX sees -110 (-ETIMEOUT) on copying the data to
- * the device. The TX failure could mean a device bus stuck, so the current
- * error recovery implementation is to trigger a bus reset to the device
- * and hopefully it can bring back the device.
- *
- * The actual work of error recovery has to be in a thread context because
- * it is kicked off in the TX thread (i2400ms->tx_workqueue) which is to be
- * destroyed by the error recovery mechanism (currently a bus reset).
- *
- * Also, there may be already a queue of TX works that all hit
- * the -ETIMEOUT error condition because the device is stuck already.
- * Since bus reset is used as the error recovery mechanism and we don't
- * want consecutive bus resets simply because the multiple TX works
- * in the queue all hit the same device erratum, the flag "error_recovery"
- * is introduced for preventing unwanted consecutive bus resets.
- *
- * Error recovery shall only be invoked again if previous one was completed.
- * The flag error_recovery is set when error recovery mechanism is scheduled,
- * and is checked when we need to schedule another error recovery. If it is
- * in place already, then we shouldn't schedule another one.
- */
-void i2400m_error_recovery(struct i2400m *i2400m)
-{
- if (atomic_add_return(1, &i2400m->error_recovery) == 1)
- schedule_work(&i2400m->recovery_ws);
- else
- atomic_dec(&i2400m->error_recovery);
-}
-EXPORT_SYMBOL_GPL(i2400m_error_recovery);
-
-/*
- * Alloc the command and ack buffers for boot mode
- *
- * Get the buffers needed to deal with boot mode messages.
- */
-static
-int i2400m_bm_buf_alloc(struct i2400m *i2400m)
-{
- i2400m->bm_cmd_buf = kzalloc(I2400M_BM_CMD_BUF_SIZE, GFP_KERNEL);
- if (i2400m->bm_cmd_buf == NULL)
- goto error_bm_cmd_kzalloc;
- i2400m->bm_ack_buf = kzalloc(I2400M_BM_ACK_BUF_SIZE, GFP_KERNEL);
- if (i2400m->bm_ack_buf == NULL)
- goto error_bm_ack_buf_kzalloc;
- return 0;
-
-error_bm_ack_buf_kzalloc:
- kfree(i2400m->bm_cmd_buf);
-error_bm_cmd_kzalloc:
- return -ENOMEM;
-}
-
-
-/*
- * Free boot mode command and ack buffers.
- */
-static
-void i2400m_bm_buf_free(struct i2400m *i2400m)
-{
- kfree(i2400m->bm_ack_buf);
- kfree(i2400m->bm_cmd_buf);
-}
-
-
-/*
- * i2400m_init - Initialize a 'struct i2400m' from all zeroes
- *
- * This is a bus-generic API call.
- */
-void i2400m_init(struct i2400m *i2400m)
-{
- wimax_dev_init(&i2400m->wimax_dev);
-
- i2400m->boot_mode = 1;
- i2400m->rx_reorder = 1;
- init_waitqueue_head(&i2400m->state_wq);
-
- spin_lock_init(&i2400m->tx_lock);
- i2400m->tx_pl_min = UINT_MAX;
- i2400m->tx_size_min = UINT_MAX;
-
- spin_lock_init(&i2400m->rx_lock);
- i2400m->rx_pl_min = UINT_MAX;
- i2400m->rx_size_min = UINT_MAX;
- INIT_LIST_HEAD(&i2400m->rx_reports);
- INIT_WORK(&i2400m->rx_report_ws, i2400m_report_hook_work);
-
- mutex_init(&i2400m->msg_mutex);
- init_completion(&i2400m->msg_completion);
-
- mutex_init(&i2400m->init_mutex);
- /* wake_tx_ws is initialized in i2400m_tx_setup() */
-
- INIT_WORK(&i2400m->reset_ws, __i2400m_dev_reset_handle);
- INIT_WORK(&i2400m->recovery_ws, __i2400m_error_recovery);
-
- atomic_set(&i2400m->bus_reset_retries, 0);
-
- i2400m->alive = 0;
-
- /* initialize error_recovery to 1 for denoting we
- * are not yet ready to take any error recovery */
- atomic_set(&i2400m->error_recovery, 1);
-}
-EXPORT_SYMBOL_GPL(i2400m_init);
-
-
-int i2400m_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
-{
- struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-
- /*
- * Make sure we stop TXs and down the carrier before
- * resetting; this is needed to avoid things like
- * i2400m_wake_tx() scheduling stuff in parallel.
- */
- if (net_dev->reg_state == NETREG_REGISTERED) {
- netif_tx_disable(net_dev);
- netif_carrier_off(net_dev);
- }
- return i2400m->bus_reset(i2400m, rt);
-}
-EXPORT_SYMBOL_GPL(i2400m_reset);
-
-
-/**
- * i2400m_setup - bus-generic setup function for the i2400m device
- *
- * @i2400m: device descriptor (bus-specific parts have been initialized)
- * @bm_flags: boot mode flags
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * Sets up basic device comunication infrastructure, boots the ROM to
- * read the MAC address, registers with the WiMAX and network stacks
- * and then brings up the device.
- */
-int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
- struct net_device *net_dev = i2400m->wimax_dev.net_dev;
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
-
- snprintf(wimax_dev->name, sizeof(wimax_dev->name),
- "i2400m-%s:%s", dev->bus->name, dev_name(dev));
-
- result = i2400m_bm_buf_alloc(i2400m);
- if (result < 0) {
- dev_err(dev, "cannot allocate bootmode scratch buffers\n");
- goto error_bm_buf_alloc;
- }
-
- if (i2400m->bus_setup) {
- result = i2400m->bus_setup(i2400m);
- if (result < 0) {
- dev_err(dev, "bus-specific setup failed: %d\n",
- result);
- goto error_bus_setup;
- }
- }
-
- result = i2400m_bootrom_init(i2400m, bm_flags);
- if (result < 0) {
- dev_err(dev, "read mac addr: bootrom init "
- "failed: %d\n", result);
- goto error_bootrom_init;
- }
- result = i2400m_read_mac_addr(i2400m);
- if (result < 0)
- goto error_read_mac_addr;
- eth_random_addr(i2400m->src_mac_addr);
-
- i2400m->pm_notifier.notifier_call = i2400m_pm_notifier;
- register_pm_notifier(&i2400m->pm_notifier);
-
- result = register_netdev(net_dev); /* Okey dokey, bring it up */
- if (result < 0) {
- dev_err(dev, "cannot register i2400m network device: %d\n",
- result);
- goto error_register_netdev;
- }
- netif_carrier_off(net_dev);
-
- i2400m->wimax_dev.op_msg_from_user = i2400m_op_msg_from_user;
- i2400m->wimax_dev.op_rfkill_sw_toggle = i2400m_op_rfkill_sw_toggle;
- i2400m->wimax_dev.op_reset = i2400m_op_reset;
-
- result = wimax_dev_add(&i2400m->wimax_dev, net_dev);
- if (result < 0)
- goto error_wimax_dev_add;
-
- /* Now setup all that requires a registered net and wimax device. */
- result = sysfs_create_group(&net_dev->dev.kobj, &i2400m_dev_attr_group);
- if (result < 0) {
- dev_err(dev, "cannot setup i2400m's sysfs: %d\n", result);
- goto error_sysfs_setup;
- }
-
- i2400m_debugfs_add(i2400m);
-
- result = i2400m_dev_start(i2400m, bm_flags);
- if (result < 0)
- goto error_dev_start;
- d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
- return result;
-
-error_dev_start:
- i2400m_debugfs_rm(i2400m);
- sysfs_remove_group(&i2400m->wimax_dev.net_dev->dev.kobj,
- &i2400m_dev_attr_group);
-error_sysfs_setup:
- wimax_dev_rm(&i2400m->wimax_dev);
-error_wimax_dev_add:
- unregister_netdev(net_dev);
-error_register_netdev:
- unregister_pm_notifier(&i2400m->pm_notifier);
-error_read_mac_addr:
-error_bootrom_init:
- if (i2400m->bus_release)
- i2400m->bus_release(i2400m);
-error_bus_setup:
- i2400m_bm_buf_free(i2400m);
-error_bm_buf_alloc:
- d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
- return result;
-}
-EXPORT_SYMBOL_GPL(i2400m_setup);
-
-
-/*
- * i2400m_release - release the bus-generic driver resources
- *
- * Sends a disconnect message and undoes any setup done by i2400m_setup()
- */
-void i2400m_release(struct i2400m *i2400m)
-{
- struct device *dev = i2400m_dev(i2400m);
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
- netif_stop_queue(i2400m->wimax_dev.net_dev);
-
- i2400m_dev_stop(i2400m);
-
- cancel_work_sync(&i2400m->reset_ws);
- cancel_work_sync(&i2400m->recovery_ws);
-
- i2400m_debugfs_rm(i2400m);
- sysfs_remove_group(&i2400m->wimax_dev.net_dev->dev.kobj,
- &i2400m_dev_attr_group);
- wimax_dev_rm(&i2400m->wimax_dev);
- unregister_netdev(i2400m->wimax_dev.net_dev);
- unregister_pm_notifier(&i2400m->pm_notifier);
- if (i2400m->bus_release)
- i2400m->bus_release(i2400m);
- i2400m_bm_buf_free(i2400m);
- d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
-EXPORT_SYMBOL_GPL(i2400m_release);
-
-
-/*
- * Debug levels control; see debug.h
- */
-struct d_level D_LEVEL[] = {
- D_SUBMODULE_DEFINE(control),
- D_SUBMODULE_DEFINE(driver),
- D_SUBMODULE_DEFINE(debugfs),
- D_SUBMODULE_DEFINE(fw),
- D_SUBMODULE_DEFINE(netdev),
- D_SUBMODULE_DEFINE(rfkill),
- D_SUBMODULE_DEFINE(rx),
- D_SUBMODULE_DEFINE(sysfs),
- D_SUBMODULE_DEFINE(tx),
-};
-size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
-
-
-static
-int __init i2400m_driver_init(void)
-{
- d_parse_params(D_LEVEL, D_LEVEL_SIZE, i2400m_debug_params,
- "i2400m.debug");
- return i2400m_barker_db_init(i2400m_barkers_params);
-}
-module_init(i2400m_driver_init);
-
-static
-void __exit i2400m_driver_exit(void)
-{
- i2400m_barker_db_exit();
-}
-module_exit(i2400m_driver_exit);
-
-MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
-MODULE_DESCRIPTION("Intel 2400M WiMAX networking bus-generic driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/wimax/i2400m/fw.c b/drivers/staging/wimax/i2400m/fw.c
deleted file mode 100644
index 92ea5c101e76..000000000000
--- a/drivers/staging/wimax/i2400m/fw.c
+++ /dev/null
@@ -1,1666 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Firmware uploader
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * 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 Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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
- * OWNER 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.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * - Initial implementation
- *
- *
- * THE PROCEDURE
- *
- * The 2400m and derived devices work in two modes: boot-mode or
- * normal mode. In boot mode we can execute only a handful of commands
- * targeted at uploading the firmware and launching it.
- *
- * The 2400m enters boot mode when it is first connected to the
- * system, when it crashes and when you ask it to reboot. There are
- * two submodes of the boot mode: signed and non-signed. Signed takes
- * firmwares signed with a certain private key, non-signed takes any
- * firmware. Normal hardware takes only signed firmware.
- *
- * On boot mode, in USB, we write to the device using the bulk out
- * endpoint and read from it in the notification endpoint.
- *
- * Upon entrance to boot mode, the device sends (preceded with a few
- * zero length packets (ZLPs) on the notification endpoint in USB) a
- * reboot barker (4 le32 words with the same value). We ack it by
- * sending the same barker to the device. The device acks with a
- * reboot ack barker (4 le32 words with value I2400M_ACK_BARKER) and
- * then is fully booted. At this point we can upload the firmware.
- *
- * Note that different iterations of the device and EEPROM
- * configurations will send different [re]boot barkers; these are
- * collected in i2400m_barker_db along with the firmware
- * characteristics they require.
- *
- * This process is accomplished by the i2400m_bootrom_init()
- * function. All the device interaction happens through the
- * i2400m_bm_cmd() [boot mode command]. Special return values will
- * indicate if the device did reset during the process.
- *
- * After this, we read the MAC address and then (if needed)
- * reinitialize the device. We need to read it ahead of time because
- * in the future, we might not upload the firmware until userspace
- * 'ifconfig up's the device.
- *
- * We can then upload the firmware file. The file is composed of a BCF
- * header (basic data, keys and signatures) and a list of write
- * commands and payloads. Optionally more BCF headers might follow the
- * main payload. We first upload the header [i2400m_dnload_init()] and
- * then pass the commands and payloads verbatim to the i2400m_bm_cmd()
- * function [i2400m_dnload_bcf()]. Then we tell the device to jump to
- * the new firmware [i2400m_dnload_finalize()].
- *
- * Once firmware is uploaded, we are good to go :)
- *
- * When we don't know in which mode we are, we first try by sending a
- * warm reset request that will take us to boot-mode. If we time out
- * waiting for a reboot barker, that means maybe we are already in
- * boot mode, so we send a reboot barker.
- *
- * COMMAND EXECUTION
- *
- * This code (and process) is single threaded; for executing commands,
- * we post a URB to the notification endpoint, post the command, wait
- * for data on the notification buffer. We don't need to worry about
- * others as we know we are the only ones in there.
- *
- * BACKEND IMPLEMENTATION
- *
- * This code is bus-generic; the bus-specific driver provides back end
- * implementations to send a boot mode command to the device and to
- * read an acknolwedgement from it (or an asynchronous notification)
- * from it.
- *
- * FIRMWARE LOADING
- *
- * Note that in some cases, we can't just load a firmware file (for
- * example, when resuming). For that, we might cache the firmware
- * file. Thus, when doing the bootstrap, if there is a cache firmware
- * file, it is used; if not, loading from disk is attempted.
- *
- * ROADMAP
- *
- * i2400m_barker_db_init Called by i2400m_driver_init()
- * i2400m_barker_db_add
- *
- * i2400m_barker_db_exit Called by i2400m_driver_exit()
- *
- * i2400m_dev_bootstrap Called by __i2400m_dev_start()
- * request_firmware
- * i2400m_fw_bootstrap
- * i2400m_fw_check
- * i2400m_fw_hdr_check
- * i2400m_fw_dnload
- * release_firmware
- *
- * i2400m_fw_dnload
- * i2400m_bootrom_init
- * i2400m_bm_cmd
- * i2400m_reset
- * i2400m_dnload_init
- * i2400m_dnload_init_signed
- * i2400m_dnload_init_nonsigned
- * i2400m_download_chunk
- * i2400m_bm_cmd
- * i2400m_dnload_bcf
- * i2400m_bm_cmd
- * i2400m_dnload_finalize
- * i2400m_bm_cmd
- *
- * i2400m_bm_cmd
- * i2400m->bus_bm_cmd_send()
- * i2400m->bus_bm_wait_for_ack
- * __i2400m_bm_ack_verify
- * i2400m_is_boot_barker
- *
- * i2400m_bm_cmd_prepare Used by bus-drivers to prep
- * commands before sending
- *
- * i2400m_pm_notifier Called on Power Management events
- * i2400m_fw_cache
- * i2400m_fw_uncache
- */
-#include <linux/firmware.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/usb.h>
-#include <linux/export.h>
-#include "i2400m.h"
-
-
-#define D_SUBMODULE fw
-#include "debug-levels.h"
-
-
-static const __le32 i2400m_ACK_BARKER[4] = {
- cpu_to_le32(I2400M_ACK_BARKER),
- cpu_to_le32(I2400M_ACK_BARKER),
- cpu_to_le32(I2400M_ACK_BARKER),
- cpu_to_le32(I2400M_ACK_BARKER)
-};
-
-
-/**
- * Prepare a boot-mode command for delivery
- *
- * @cmd: pointer to bootrom header to prepare
- *
- * Computes checksum if so needed. After calling this function, DO NOT
- * modify the command or header as the checksum won't work anymore.
- *
- * We do it from here because some times we cannot do it in the
- * original context the command was sent (it is a const), so when we
- * copy it to our staging buffer, we add the checksum there.
- */
-void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd)
-{
- if (i2400m_brh_get_use_checksum(cmd)) {
- int i;
- __le32 checksum = 0;
- const u32 *checksum_ptr = (void *) cmd->payload;
-
- for (i = 0; i < le32_to_cpu(cmd->data_size) / 4; i++)
- le32_add_cpu(&checksum, *checksum_ptr++);
-
- le32_add_cpu(&checksum, le32_to_cpu(cmd->command));
- le32_add_cpu(&checksum, le32_to_cpu(cmd->target_addr));
- le32_add_cpu(&checksum, le32_to_cpu(cmd->data_size));
-
- cmd->block_checksum = checksum;
- }
-}
-EXPORT_SYMBOL_GPL(i2400m_bm_cmd_prepare);
-
-
-/*
- * Database of known barkers.
- *
- * A barker is what the device sends indicating he is ready to be
- * bootloaded. Different versions of the device will send different
- * barkers. Depending on the barker, it might mean the device wants
- * some kind of firmware or the other.
- */
-static struct i2400m_barker_db {
- __le32 data[4];
-} *i2400m_barker_db;
-static size_t i2400m_barker_db_used, i2400m_barker_db_size;
-
-
-static
-int i2400m_zrealloc_2x(void **ptr, size_t *_count, size_t el_size,
- gfp_t gfp_flags)
-{
- size_t old_count = *_count,
- new_count = old_count ? 2 * old_count : 2,
- old_size = el_size * old_count,
- new_size = el_size * new_count;
- void *nptr = krealloc(*ptr, new_size, gfp_flags);
- if (nptr) {
- /* zero the other half or the whole thing if old_count
- * was zero */
- if (old_size == 0)
- memset(nptr, 0, new_size);
- else
- memset(nptr + old_size, 0, old_size);
- *_count = new_count;
- *ptr = nptr;
- return 0;
- } else
- return -ENOMEM;
-}
-
-
-/*
- * Add a barker to the database
- *
- * This cannot used outside of this module and only at at module_init
- * time. This is to avoid the need to do locking.
- */
-static
-int i2400m_barker_db_add(u32 barker_id)
-{
- int result;
-
- struct i2400m_barker_db *barker;
- if (i2400m_barker_db_used >= i2400m_barker_db_size) {
- result = i2400m_zrealloc_2x(
- (void **) &i2400m_barker_db, &i2400m_barker_db_size,
- sizeof(i2400m_barker_db[0]), GFP_KERNEL);
- if (result < 0)
- return result;
- }
- barker = i2400m_barker_db + i2400m_barker_db_used++;
- barker->data[0] = le32_to_cpu(barker_id);
- barker->data[1] = le32_to_cpu(barker_id);
- barker->data[2] = le32_to_cpu(barker_id);
- barker->data[3] = le32_to_cpu(barker_id);
- return 0;
-}
-
-
-void i2400m_barker_db_exit(void)
-{
- kfree(i2400m_barker_db);
- i2400m_barker_db = NULL;
- i2400m_barker_db_size = 0;
- i2400m_barker_db_used = 0;
-}
-
-
-/*
- * Helper function to add all the known stable barkers to the barker
- * database.
- */
-static
-int i2400m_barker_db_known_barkers(void)
-{
- int result;
-
- result = i2400m_barker_db_add(I2400M_NBOOT_BARKER);
- if (result < 0)
- goto error_add;
- result = i2400m_barker_db_add(I2400M_SBOOT_BARKER);
- if (result < 0)
- goto error_add;
- result = i2400m_barker_db_add(I2400M_SBOOT_BARKER_6050);
- if (result < 0)
- goto error_add;
-error_add:
- return result;
-}
-
-
-/*
- * Initialize the barker database
- *
- * This can only be used from the module_init function for this
- * module; this is to avoid the need to do locking.
- *
- * @options: command line argument with extra barkers to
- * recognize. This is a comma-separated list of 32-bit hex
- * numbers. They are appended to the existing list. Setting 0
- * cleans the existing list and starts a new one.
- */
-int i2400m_barker_db_init(const char *_options)
-{
- int result;
- char *options = NULL, *options_orig, *token;
-
- i2400m_barker_db = NULL;
- i2400m_barker_db_size = 0;
- i2400m_barker_db_used = 0;
-
- result = i2400m_barker_db_known_barkers();
- if (result < 0)
- goto error_add;
- /* parse command line options from i2400m.barkers */
- if (_options != NULL) {
- unsigned barker;
-
- options_orig = kstrdup(_options, GFP_KERNEL);
- if (options_orig == NULL) {
- result = -ENOMEM;
- goto error_parse;
- }
- options = options_orig;
-
- while ((token = strsep(&options, ",")) != NULL) {
- if (*token == '\0') /* eat joint commas */
- continue;
- if (sscanf(token, "%x", &barker) != 1
- || barker > 0xffffffff) {
- printk(KERN_ERR "%s: can't recognize "
- "i2400m.barkers value '%s' as "
- "a 32-bit number\n",
- __func__, token);
- result = -EINVAL;
- goto error_parse;
- }
- if (barker == 0) {
- /* clean list and start new */
- i2400m_barker_db_exit();
- continue;
- }
- result = i2400m_barker_db_add(barker);
- if (result < 0)
- goto error_parse_add;
- }
- kfree(options_orig);
- }
- return 0;
-
-error_parse_add:
-error_parse:
- kfree(options_orig);
-error_add:
- kfree(i2400m_barker_db);
- return result;
-}
-
-
-/*
- * Recognize a boot barker
- *
- * @buf: buffer where the boot barker.
- * @buf_size: size of the buffer (has to be 16 bytes). It is passed
- * here so the function can check it for the caller.
- *
- * Note that as a side effect, upon identifying the obtained boot
- * barker, this function will set i2400m->barker to point to the right
- * barker database entry. Subsequent calls to the function will result
- * in verifying that the same type of boot barker is returned when the
- * device [re]boots (as long as the same device instance is used).
- *
- * Return: 0 if @buf matches a known boot barker. -ENOENT if the
- * buffer in @buf doesn't match any boot barker in the database or
- * -EILSEQ if the buffer doesn't have the right size.
- */
-int i2400m_is_boot_barker(struct i2400m *i2400m,
- const void *buf, size_t buf_size)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct i2400m_barker_db *barker;
- int i;
-
- result = -ENOENT;
- if (buf_size != sizeof(i2400m_barker_db[i].data))
- return result;
-
- /* Short circuit if we have already discovered the barker
- * associated with the device. */
- if (i2400m->barker &&
- !memcmp(buf, i2400m->barker, sizeof(i2400m->barker->data)))
- return 0;
-
- for (i = 0; i < i2400m_barker_db_used; i++) {
- barker = &i2400m_barker_db[i];
- BUILD_BUG_ON(sizeof(barker->data) != 16);
- if (memcmp(buf, barker->data, sizeof(barker->data)))
- continue;
-
- if (i2400m->barker == NULL) {
- i2400m->barker = barker;
- d_printf(1, dev, "boot barker set to #%u/%08x\n",
- i, le32_to_cpu(barker->data[0]));
- if (barker->data[0] == le32_to_cpu(I2400M_NBOOT_BARKER))
- i2400m->sboot = 0;
- else
- i2400m->sboot = 1;
- } else if (i2400m->barker != barker) {
- dev_err(dev, "HW inconsistency: device "
- "reports a different boot barker "
- "than set (from %08x to %08x)\n",
- le32_to_cpu(i2400m->barker->data[0]),
- le32_to_cpu(barker->data[0]));
- result = -EIO;
- } else
- d_printf(2, dev, "boot barker confirmed #%u/%08x\n",
- i, le32_to_cpu(barker->data[0]));
- result = 0;
- break;
- }
- return result;
-}
-EXPORT_SYMBOL_GPL(i2400m_is_boot_barker);
-
-
-/*
- * Verify the ack data received
- *
- * Given a reply to a boot mode command, chew it and verify everything
- * is ok.
- *
- * @opcode: opcode which generated this ack. For error messages.
- * @ack: pointer to ack data we received
- * @ack_size: size of that data buffer
- * @flags: I2400M_BM_CMD_* flags we called the command with.
- *
- * Way too long function -- maybe it should be further split
- */
-static
-ssize_t __i2400m_bm_ack_verify(struct i2400m *i2400m, int opcode,
- struct i2400m_bootrom_header *ack,
- size_t ack_size, int flags)
-{
- ssize_t result = -ENOMEM;
- struct device *dev = i2400m_dev(i2400m);
-
- d_fnstart(8, dev, "(i2400m %p opcode %d ack %p size %zu)\n",
- i2400m, opcode, ack, ack_size);
- if (ack_size < sizeof(*ack)) {
- result = -EIO;
- dev_err(dev, "boot-mode cmd %d: HW BUG? notification didn't "
- "return enough data (%zu bytes vs %zu expected)\n",
- opcode, ack_size, sizeof(*ack));
- goto error_ack_short;
- }
- result = i2400m_is_boot_barker(i2400m, ack, ack_size);
- if (result >= 0) {
- result = -ERESTARTSYS;
- d_printf(6, dev, "boot-mode cmd %d: HW boot barker\n", opcode);
- goto error_reboot;
- }
- if (ack_size == sizeof(i2400m_ACK_BARKER)
- && memcmp(ack, i2400m_ACK_BARKER, sizeof(*ack)) == 0) {
- result = -EISCONN;
- d_printf(3, dev, "boot-mode cmd %d: HW reboot ack barker\n",
- opcode);
- goto error_reboot_ack;
- }
- result = 0;
- if (flags & I2400M_BM_CMD_RAW)
- goto out_raw;
- ack->data_size = le32_to_cpu(ack->data_size);
- ack->target_addr = le32_to_cpu(ack->target_addr);
- ack->block_checksum = le32_to_cpu(ack->block_checksum);
- d_printf(5, dev, "boot-mode cmd %d: notification for opcode %u "
- "response %u csum %u rr %u da %u\n",
- opcode, i2400m_brh_get_opcode(ack),
- i2400m_brh_get_response(ack),
- i2400m_brh_get_use_checksum(ack),
- i2400m_brh_get_response_required(ack),
- i2400m_brh_get_direct_access(ack));
- result = -EIO;
- if (i2400m_brh_get_signature(ack) != 0xcbbc) {
- dev_err(dev, "boot-mode cmd %d: HW BUG? wrong signature "
- "0x%04x\n", opcode, i2400m_brh_get_signature(ack));
- goto error_ack_signature;
- }
- if (opcode != -1 && opcode != i2400m_brh_get_opcode(ack)) {
- dev_err(dev, "boot-mode cmd %d: HW BUG? "
- "received response for opcode %u, expected %u\n",
- opcode, i2400m_brh_get_opcode(ack), opcode);
- goto error_ack_opcode;
- }
- if (i2400m_brh_get_response(ack) != 0) { /* failed? */
- dev_err(dev, "boot-mode cmd %d: error; hw response %u\n",
- opcode, i2400m_brh_get_response(ack));
- goto error_ack_failed;
- }
- if (ack_size < ack->data_size + sizeof(*ack)) {
- dev_err(dev, "boot-mode cmd %d: SW BUG "
- "driver provided only %zu bytes for %zu bytes "
- "of data\n", opcode, ack_size,
- (size_t) le32_to_cpu(ack->data_size) + sizeof(*ack));
- goto error_ack_short_buffer;
- }
- result = ack_size;
- /* Don't you love this stack of empty targets? Well, I don't
- * either, but it helps track exactly who comes in here and
- * why :) */
-error_ack_short_buffer:
-error_ack_failed:
-error_ack_opcode:
-error_ack_signature:
-out_raw:
-error_reboot_ack:
-error_reboot:
-error_ack_short:
- d_fnend(8, dev, "(i2400m %p opcode %d ack %p size %zu) = %d\n",
- i2400m, opcode, ack, ack_size, (int) result);
- return result;
-}
-
-
-/**
- * i2400m_bm_cmd - Execute a boot mode command
- *
- * @i2400m: device descriptor
- * @cmd: buffer containing the command data (pointing at the header).
- * This data can be ANYWHERE (for USB, we will copy it to an
- * specific buffer). Make sure everything is in proper little
- * endian.
- *
- * A raw buffer can be also sent, just cast it and set flags to
- * I2400M_BM_CMD_RAW.
- *
- * This function will generate a checksum for you if the
- * checksum bit in the command is set (unless I2400M_BM_CMD_RAW
- * is set).
- *
- * You can use the i2400m->bm_cmd_buf to stage your commands and
- * send them.
- *
- * If NULL, no command is sent (we just wait for an ack).
- *
- * @cmd_size: size of the command. Will be auto padded to the
- * bus-specific drivers padding requirements.
- *
- * @ack: buffer where to place the acknowledgement. If it is a regular
- * command response, all fields will be returned with the right,
- * native endianess.
- *
- * You *cannot* use i2400m->bm_ack_buf for this buffer.
- *
- * @ack_size: size of @ack, 16 aligned; you need to provide at least
- * sizeof(*ack) bytes and then enough to contain the return data
- * from the command
- *
- * @flags: see I2400M_BM_CMD_* above.
- *
- * Returns: bytes received by the notification; if < 0, an errno code
- * denoting an error or:
- *
- * -ERESTARTSYS The device has rebooted
- *
- * Executes a boot-mode command and waits for a response, doing basic
- * validation on it; if a zero length response is received, it retries
- * waiting for a response until a non-zero one is received (timing out
- * after %I2400M_BOOT_RETRIES retries).
- */
-static
-ssize_t i2400m_bm_cmd(struct i2400m *i2400m,
- const struct i2400m_bootrom_header *cmd, size_t cmd_size,
- struct i2400m_bootrom_header *ack, size_t ack_size,
- int flags)
-{
- ssize_t result, rx_bytes;
- struct device *dev = i2400m_dev(i2400m);
- int opcode = cmd == NULL ? -1 : i2400m_brh_get_opcode(cmd);
-
- d_fnstart(6, dev, "(i2400m %p cmd %p size %zu ack %p size %zu)\n",
- i2400m, cmd, cmd_size, ack, ack_size);
- BUG_ON(ack_size < sizeof(*ack));
- BUG_ON(i2400m->boot_mode == 0);
-
- if (cmd != NULL) { /* send the command */
- result = i2400m->bus_bm_cmd_send(i2400m, cmd, cmd_size, flags);
- if (result < 0)
- goto error_cmd_send;
- if ((flags & I2400M_BM_CMD_RAW) == 0)
- d_printf(5, dev,
- "boot-mode cmd %d csum %u rr %u da %u: "
- "addr 0x%04x size %u block csum 0x%04x\n",
- opcode, i2400m_brh_get_use_checksum(cmd),
- i2400m_brh_get_response_required(cmd),
- i2400m_brh_get_direct_access(cmd),
- cmd->target_addr, cmd->data_size,
- cmd->block_checksum);
- }
- result = i2400m->bus_bm_wait_for_ack(i2400m, ack, ack_size);
- if (result < 0) {
- dev_err(dev, "boot-mode cmd %d: error waiting for an ack: %d\n",
- opcode, (int) result); /* bah, %zd doesn't work */
- goto error_wait_for_ack;
- }
- rx_bytes = result;
- /* verify the ack and read more if necessary [result is the
- * final amount of bytes we get in the ack] */
- result = __i2400m_bm_ack_verify(i2400m, opcode, ack, ack_size, flags);
- if (result < 0)
- goto error_bad_ack;
- /* Don't you love this stack of empty targets? Well, I don't
- * either, but it helps track exactly who comes in here and
- * why :) */
- result = rx_bytes;
-error_bad_ack:
-error_wait_for_ack:
-error_cmd_send:
- d_fnend(6, dev, "(i2400m %p cmd %p size %zu ack %p size %zu) = %d\n",
- i2400m, cmd, cmd_size, ack, ack_size, (int) result);
- return result;
-}
-
-
-/**
- * i2400m_download_chunk - write a single chunk of data to the device's memory
- *
- * @i2400m: device descriptor
- * @chunk: the buffer to write
- * @__chunk_len: length of the buffer to write
- * @addr: address in the device memory space
- * @direct: bootrom write mode
- * @do_csum: should a checksum validation be performed
- */
-static int i2400m_download_chunk(struct i2400m *i2400m, const void *chunk,
- size_t __chunk_len, unsigned long addr,
- unsigned int direct, unsigned int do_csum)
-{
- int ret;
- size_t chunk_len = ALIGN(__chunk_len, I2400M_PL_ALIGN);
- struct device *dev = i2400m_dev(i2400m);
- struct {
- struct i2400m_bootrom_header cmd;
- u8 cmd_payload[];
- } __packed *buf;
- struct i2400m_bootrom_header ack;
-
- d_fnstart(5, dev, "(i2400m %p chunk %p __chunk_len %zu addr 0x%08lx "
- "direct %u do_csum %u)\n", i2400m, chunk, __chunk_len,
- addr, direct, do_csum);
- buf = i2400m->bm_cmd_buf;
- memcpy(buf->cmd_payload, chunk, __chunk_len);
- memset(buf->cmd_payload + __chunk_len, 0xad, chunk_len - __chunk_len);
-
- buf->cmd.command = i2400m_brh_command(I2400M_BRH_WRITE,
- __chunk_len & 0x3 ? 0 : do_csum,
- __chunk_len & 0xf ? 0 : direct);
- buf->cmd.target_addr = cpu_to_le32(addr);
- buf->cmd.data_size = cpu_to_le32(__chunk_len);
- ret = i2400m_bm_cmd(i2400m, &buf->cmd, sizeof(buf->cmd) + chunk_len,
- &ack, sizeof(ack), 0);
- if (ret >= 0)
- ret = 0;
- d_fnend(5, dev, "(i2400m %p chunk %p __chunk_len %zu addr 0x%08lx "
- "direct %u do_csum %u) = %d\n", i2400m, chunk, __chunk_len,
- addr, direct, do_csum, ret);
- return ret;
-}
-
-
-/*
- * Download a BCF file's sections to the device
- *
- * @i2400m: device descriptor
- * @bcf: pointer to firmware data (first header followed by the
- * payloads). Assumed verified and consistent.
- * @bcf_len: length (in bytes) of the @bcf buffer.
- *
- * Returns: < 0 errno code on error or the offset to the jump instruction.
- *
- * Given a BCF file, downloads each section (a command and a payload)
- * to the device's address space. Actually, it just executes each
- * command i the BCF file.
- *
- * The section size has to be aligned to 4 bytes AND the padding has
- * to be taken from the firmware file, as the signature takes it into
- * account.
- */
-static
-ssize_t i2400m_dnload_bcf(struct i2400m *i2400m,
- const struct i2400m_bcf_hdr *bcf, size_t bcf_len)
-{
- ssize_t ret;
- struct device *dev = i2400m_dev(i2400m);
- size_t offset, /* iterator offset */
- data_size, /* Size of the data payload */
- section_size, /* Size of the whole section (cmd + payload) */
- section = 1;
- const struct i2400m_bootrom_header *bh;
- struct i2400m_bootrom_header ack;
-
- d_fnstart(3, dev, "(i2400m %p bcf %p bcf_len %zu)\n",
- i2400m, bcf, bcf_len);
- /* Iterate over the command blocks in the BCF file that start
- * after the header */
- offset = le32_to_cpu(bcf->header_len) * sizeof(u32);
- while (1) { /* start sending the file */
- bh = (void *) bcf + offset;
- data_size = le32_to_cpu(bh->data_size);
- section_size = ALIGN(sizeof(*bh) + data_size, 4);
- d_printf(7, dev,
- "downloading section #%zu (@%zu %zu B) to 0x%08x\n",
- section, offset, sizeof(*bh) + data_size,
- le32_to_cpu(bh->target_addr));
- /*
- * We look for JUMP cmd from the bootmode header,
- * either I2400M_BRH_SIGNED_JUMP for secure boot
- * or I2400M_BRH_JUMP for unsecure boot, the last chunk
- * should be the bootmode header with JUMP cmd.
- */
- if (i2400m_brh_get_opcode(bh) == I2400M_BRH_SIGNED_JUMP ||
- i2400m_brh_get_opcode(bh) == I2400M_BRH_JUMP) {
- d_printf(5, dev, "jump found @%zu\n", offset);
- break;
- }
- if (offset + section_size > bcf_len) {
- dev_err(dev, "fw %s: bad section #%zu, "
- "end (@%zu) beyond EOF (@%zu)\n",
- i2400m->fw_name, section,
- offset + section_size, bcf_len);
- ret = -EINVAL;
- goto error_section_beyond_eof;
- }
- __i2400m_msleep(20);
- ret = i2400m_bm_cmd(i2400m, bh, section_size,
- &ack, sizeof(ack), I2400M_BM_CMD_RAW);
- if (ret < 0) {
- dev_err(dev, "fw %s: section #%zu (@%zu %zu B) "
- "failed %d\n", i2400m->fw_name, section,
- offset, sizeof(*bh) + data_size, (int) ret);
- goto error_send;
- }
- offset += section_size;
- section++;
- }
- ret = offset;
-error_section_beyond_eof:
-error_send:
- d_fnend(3, dev, "(i2400m %p bcf %p bcf_len %zu) = %d\n",
- i2400m, bcf, bcf_len, (int) ret);
- return ret;
-}
-
-
-/*
- * Indicate if the device emitted a reboot barker that indicates
- * "signed boot"
- */
-static
-unsigned i2400m_boot_is_signed(struct i2400m *i2400m)
-{
- return likely(i2400m->sboot);
-}
-
-
-/*
- * Do the final steps of uploading firmware
- *
- * @bcf_hdr: BCF header we are actually using
- * @bcf: pointer to the firmware image (which matches the first header
- * that is followed by the actual payloads).
- * @offset: [byte] offset into @bcf for the command we need to send.
- *
- * Depending on the boot mode (signed vs non-signed), different
- * actions need to be taken.
- */
-static
-int i2400m_dnload_finalize(struct i2400m *i2400m,
- const struct i2400m_bcf_hdr *bcf_hdr,
- const struct i2400m_bcf_hdr *bcf, size_t offset)
-{
- int ret = 0;
- struct device *dev = i2400m_dev(i2400m);
- struct i2400m_bootrom_header *cmd, ack;
- struct {
- struct i2400m_bootrom_header cmd;
- u8 cmd_pl[0];
- } __packed *cmd_buf;
- size_t signature_block_offset, signature_block_size;
-
- d_fnstart(3, dev, "offset %zu\n", offset);
- cmd = (void *) bcf + offset;
- if (i2400m_boot_is_signed(i2400m) == 0) {
- struct i2400m_bootrom_header jump_ack;
- d_printf(1, dev, "unsecure boot, jumping to 0x%08x\n",
- le32_to_cpu(cmd->target_addr));
- cmd_buf = i2400m->bm_cmd_buf;
- memcpy(&cmd_buf->cmd, cmd, sizeof(*cmd));
- cmd = &cmd_buf->cmd;
- /* now cmd points to the actual bootrom_header in cmd_buf */
- i2400m_brh_set_opcode(cmd, I2400M_BRH_JUMP);
- cmd->data_size = 0;
- ret = i2400m_bm_cmd(i2400m, cmd, sizeof(*cmd),
- &jump_ack, sizeof(jump_ack), 0);
- } else {
- d_printf(1, dev, "secure boot, jumping to 0x%08x\n",
- le32_to_cpu(cmd->target_addr));
- cmd_buf = i2400m->bm_cmd_buf;
- memcpy(&cmd_buf->cmd, cmd, sizeof(*cmd));
- signature_block_offset =
- sizeof(*bcf_hdr)
- + le32_to_cpu(bcf_hdr->key_size) * sizeof(u32)
- + le32_to_cpu(bcf_hdr->exponent_size) * sizeof(u32);
- signature_block_size =
- le32_to_cpu(bcf_hdr->modulus_size) * sizeof(u32);
- memcpy(cmd_buf->cmd_pl,
- (void *) bcf_hdr + signature_block_offset,
- signature_block_size);
- ret = i2400m_bm_cmd(i2400m, &cmd_buf->cmd,
- sizeof(cmd_buf->cmd) + signature_block_size,
- &ack, sizeof(ack), I2400M_BM_CMD_RAW);
- }
- d_fnend(3, dev, "returning %d\n", ret);
- return ret;
-}
-
-
-/**
- * i2400m_bootrom_init - Reboots a powered device into boot mode
- *
- * @i2400m: device descriptor
- * @flags:
- * I2400M_BRI_SOFT: a reboot barker has been seen
- * already, so don't wait for it.
- *
- * I2400M_BRI_NO_REBOOT: Don't send a reboot command, but wait
- * for a reboot barker notification. This is a one shot; if
- * the state machine needs to send a reboot command it will.
- *
- * Returns:
- *
- * < 0 errno code on error, 0 if ok.
- *
- * Description:
- *
- * Tries hard enough to put the device in boot-mode. There are two
- * main phases to this:
- *
- * a. (1) send a reboot command and (2) get a reboot barker
- *
- * b. (1) echo/ack the reboot sending the reboot barker back and (2)
- * getting an ack barker in return
- *
- * We want to skip (a) in some cases [soft]. The state machine is
- * horrible, but it is basically: on each phase, send what has to be
- * sent (if any), wait for the answer and act on the answer. We might
- * have to backtrack and retry, so we keep a max tries counter for
- * that.
- *
- * It sucks because we don't know ahead of time which is going to be
- * the reboot barker (the device might send different ones depending
- * on its EEPROM config) and once the device reboots and waits for the
- * echo/ack reboot barker being sent back, it doesn't understand
- * anything else. So we can be left at the point where we don't know
- * what to send to it -- cold reset and bus reset seem to have little
- * effect. So the function iterates (in this case) through all the
- * known barkers and tries them all until an ACK is
- * received. Otherwise, it gives up.
- *
- * If we get a timeout after sending a warm reset, we do it again.
- */
-int i2400m_bootrom_init(struct i2400m *i2400m, enum i2400m_bri flags)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct i2400m_bootrom_header *cmd;
- struct i2400m_bootrom_header ack;
- int count = i2400m->bus_bm_retries;
- int ack_timeout_cnt = 1;
- unsigned i;
-
- BUILD_BUG_ON(sizeof(*cmd) != sizeof(i2400m_barker_db[0].data));
- BUILD_BUG_ON(sizeof(ack) != sizeof(i2400m_ACK_BARKER));
-
- d_fnstart(4, dev, "(i2400m %p flags 0x%08x)\n", i2400m, flags);
- result = -ENOMEM;
- cmd = i2400m->bm_cmd_buf;
- if (flags & I2400M_BRI_SOFT)
- goto do_reboot_ack;
-do_reboot:
- ack_timeout_cnt = 1;
- if (--count < 0)
- goto error_timeout;
- d_printf(4, dev, "device reboot: reboot command [%d # left]\n",
- count);
- if ((flags & I2400M_BRI_NO_REBOOT) == 0)
- i2400m_reset(i2400m, I2400M_RT_WARM);
- result = i2400m_bm_cmd(i2400m, NULL, 0, &ack, sizeof(ack),
- I2400M_BM_CMD_RAW);
- flags &= ~I2400M_BRI_NO_REBOOT;
- switch (result) {
- case -ERESTARTSYS:
- /*
- * at this point, i2400m_bm_cmd(), through
- * __i2400m_bm_ack_process(), has updated
- * i2400m->barker and we are good to go.
- */
- d_printf(4, dev, "device reboot: got reboot barker\n");
- break;
- case -EISCONN: /* we don't know how it got here...but we follow it */
- d_printf(4, dev, "device reboot: got ack barker - whatever\n");
- goto do_reboot;
- case -ETIMEDOUT:
- /*
- * Device has timed out, we might be in boot mode
- * already and expecting an ack; if we don't know what
- * the barker is, we just send them all. Cold reset
- * and bus reset don't work. Beats me.
- */
- if (i2400m->barker != NULL) {
- dev_err(dev, "device boot: reboot barker timed out, "
- "trying (set) %08x echo/ack\n",
- le32_to_cpu(i2400m->barker->data[0]));
- goto do_reboot_ack;
- }
- for (i = 0; i < i2400m_barker_db_used; i++) {
- struct i2400m_barker_db *barker = &i2400m_barker_db[i];
- memcpy(cmd, barker->data, sizeof(barker->data));
- result = i2400m_bm_cmd(i2400m, cmd, sizeof(*cmd),
- &ack, sizeof(ack),
- I2400M_BM_CMD_RAW);
- if (result == -EISCONN) {
- dev_warn(dev, "device boot: got ack barker "
- "after sending echo/ack barker "
- "#%d/%08x; rebooting j.i.c.\n",
- i, le32_to_cpu(barker->data[0]));
- flags &= ~I2400M_BRI_NO_REBOOT;
- goto do_reboot;
- }
- }
- dev_err(dev, "device boot: tried all the echo/acks, could "
- "not get device to respond; giving up");
- result = -ESHUTDOWN;
- case -EPROTO:
- case -ESHUTDOWN: /* dev is gone */
- case -EINTR: /* user cancelled */
- goto error_dev_gone;
- default:
- dev_err(dev, "device reboot: error %d while waiting "
- "for reboot barker - rebooting\n", result);
- d_dump(1, dev, &ack, result);
- goto do_reboot;
- }
- /* At this point we ack back with 4 REBOOT barkers and expect
- * 4 ACK barkers. This is ugly, as we send a raw command --
- * hence the cast. _bm_cmd() will catch the reboot ack
- * notification and report it as -EISCONN. */
-do_reboot_ack:
- d_printf(4, dev, "device reboot ack: sending ack [%d # left]\n", count);
- memcpy(cmd, i2400m->barker->data, sizeof(i2400m->barker->data));
- result = i2400m_bm_cmd(i2400m, cmd, sizeof(*cmd),
- &ack, sizeof(ack), I2400M_BM_CMD_RAW);
- switch (result) {
- case -ERESTARTSYS:
- d_printf(4, dev, "reboot ack: got reboot barker - retrying\n");
- if (--count < 0)
- goto error_timeout;
- goto do_reboot_ack;
- case -EISCONN:
- d_printf(4, dev, "reboot ack: got ack barker - good\n");
- break;
- case -ETIMEDOUT: /* no response, maybe it is the other type? */
- if (ack_timeout_cnt-- < 0) {
- d_printf(4, dev, "reboot ack timedout: retrying\n");
- goto do_reboot_ack;
- } else {
- dev_err(dev, "reboot ack timedout too long: "
- "trying reboot\n");
- goto do_reboot;
- }
- break;
- case -EPROTO:
- case -ESHUTDOWN: /* dev is gone */
- goto error_dev_gone;
- default:
- dev_err(dev, "device reboot ack: error %d while waiting for "
- "reboot ack barker - rebooting\n", result);
- goto do_reboot;
- }
- d_printf(2, dev, "device reboot ack: got ack barker - boot done\n");
- result = 0;
-exit_timeout:
-error_dev_gone:
- d_fnend(4, dev, "(i2400m %p flags 0x%08x) = %d\n",
- i2400m, flags, result);
- return result;
-
-error_timeout:
- dev_err(dev, "Timed out waiting for reboot ack\n");
- result = -ETIMEDOUT;
- goto exit_timeout;
-}
-
-
-/*
- * Read the MAC addr
- *
- * The position this function reads is fixed in device memory and
- * always available, even without firmware.
- *
- * Note we specify we want to read only six bytes, but provide space
- * for 16, as we always get it rounded up.
- */
-int i2400m_read_mac_addr(struct i2400m *i2400m)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct net_device *net_dev = i2400m->wimax_dev.net_dev;
- struct i2400m_bootrom_header *cmd;
- struct {
- struct i2400m_bootrom_header ack;
- u8 ack_pl[16];
- } __packed ack_buf;
-
- d_fnstart(5, dev, "(i2400m %p)\n", i2400m);
- cmd = i2400m->bm_cmd_buf;
- cmd->command = i2400m_brh_command(I2400M_BRH_READ, 0, 1);
- cmd->target_addr = cpu_to_le32(0x00203fe8);
- cmd->data_size = cpu_to_le32(6);
- result = i2400m_bm_cmd(i2400m, cmd, sizeof(*cmd),
- &ack_buf.ack, sizeof(ack_buf), 0);
- if (result < 0) {
- dev_err(dev, "BM: read mac addr failed: %d\n", result);
- goto error_read_mac;
- }
- d_printf(2, dev, "mac addr is %pM\n", ack_buf.ack_pl);
- if (i2400m->bus_bm_mac_addr_impaired == 1) {
- ack_buf.ack_pl[0] = 0x00;
- ack_buf.ack_pl[1] = 0x16;
- ack_buf.ack_pl[2] = 0xd3;
- get_random_bytes(&ack_buf.ack_pl[3], 3);
- dev_err(dev, "BM is MAC addr impaired, faking MAC addr to "
- "mac addr is %pM\n", ack_buf.ack_pl);
- result = 0;
- }
- net_dev->addr_len = ETH_ALEN;
- memcpy(net_dev->dev_addr, ack_buf.ack_pl, ETH_ALEN);
-error_read_mac:
- d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, result);
- return result;
-}
-
-
-/*
- * Initialize a non signed boot
- *
- * This implies sending some magic values to the device's memory. Note
- * we convert the values to little endian in the same array
- * declaration.
- */
-static
-int i2400m_dnload_init_nonsigned(struct i2400m *i2400m)
-{
- unsigned i = 0;
- int ret = 0;
- struct device *dev = i2400m_dev(i2400m);
- d_fnstart(5, dev, "(i2400m %p)\n", i2400m);
- if (i2400m->bus_bm_pokes_table) {
- while (i2400m->bus_bm_pokes_table[i].address) {
- ret = i2400m_download_chunk(
- i2400m,
- &i2400m->bus_bm_pokes_table[i].data,
- sizeof(i2400m->bus_bm_pokes_table[i].data),
- i2400m->bus_bm_pokes_table[i].address, 1, 1);
- if (ret < 0)
- break;
- i++;
- }
- }
- d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, ret);
- return ret;
-}
-
-
-/*
- * Initialize the signed boot process
- *
- * @i2400m: device descriptor
- *
- * @bcf_hdr: pointer to the firmware header; assumes it is fully in
- * memory (it has gone through basic validation).
- *
- * Returns: 0 if ok, < 0 errno code on error, -ERESTARTSYS if the hw
- * rebooted.
- *
- * This writes the firmware BCF header to the device using the
- * HASH_PAYLOAD_ONLY command.
- */
-static
-int i2400m_dnload_init_signed(struct i2400m *i2400m,
- const struct i2400m_bcf_hdr *bcf_hdr)
-{
- int ret;
- struct device *dev = i2400m_dev(i2400m);
- struct {
- struct i2400m_bootrom_header cmd;
- struct i2400m_bcf_hdr cmd_pl;
- } __packed *cmd_buf;
- struct i2400m_bootrom_header ack;
-
- d_fnstart(5, dev, "(i2400m %p bcf_hdr %p)\n", i2400m, bcf_hdr);
- cmd_buf = i2400m->bm_cmd_buf;
- cmd_buf->cmd.command =
- i2400m_brh_command(I2400M_BRH_HASH_PAYLOAD_ONLY, 0, 0);
- cmd_buf->cmd.target_addr = 0;
- cmd_buf->cmd.data_size = cpu_to_le32(sizeof(cmd_buf->cmd_pl));
- memcpy(&cmd_buf->cmd_pl, bcf_hdr, sizeof(*bcf_hdr));
- ret = i2400m_bm_cmd(i2400m, &cmd_buf->cmd, sizeof(*cmd_buf),
- &ack, sizeof(ack), 0);
- if (ret >= 0)
- ret = 0;
- d_fnend(5, dev, "(i2400m %p bcf_hdr %p) = %d\n", i2400m, bcf_hdr, ret);
- return ret;
-}
-
-
-/*
- * Initialize the firmware download at the device size
- *
- * Multiplex to the one that matters based on the device's mode
- * (signed or non-signed).
- */
-static
-int i2400m_dnload_init(struct i2400m *i2400m,
- const struct i2400m_bcf_hdr *bcf_hdr)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
-
- if (i2400m_boot_is_signed(i2400m)) {
- d_printf(1, dev, "signed boot\n");
- result = i2400m_dnload_init_signed(i2400m, bcf_hdr);
- if (result == -ERESTARTSYS)
- return result;
- if (result < 0)
- dev_err(dev, "firmware %s: signed boot download "
- "initialization failed: %d\n",
- i2400m->fw_name, result);
- } else {
- /* non-signed boot process without pokes */
- d_printf(1, dev, "non-signed boot\n");
- result = i2400m_dnload_init_nonsigned(i2400m);
- if (result == -ERESTARTSYS)
- return result;
- if (result < 0)
- dev_err(dev, "firmware %s: non-signed download "
- "initialization failed: %d\n",
- i2400m->fw_name, result);
- }
- return result;
-}
-
-
-/*
- * Run consistency tests on the firmware file and load up headers
- *
- * Check for the firmware being made for the i2400m device,
- * etc...These checks are mostly informative, as the device will make
- * them too; but the driver's response is more informative on what
- * went wrong.
- *
- * This will also look at all the headers present on the firmware
- * file, and update i2400m->fw_bcf_hdr to point to them.
- */
-static
-int i2400m_fw_hdr_check(struct i2400m *i2400m,
- const struct i2400m_bcf_hdr *bcf_hdr,
- size_t index, size_t offset)
-{
- struct device *dev = i2400m_dev(i2400m);
-
- unsigned module_type, header_len, major_version, minor_version,
- module_id, module_vendor, date, size;
-
- module_type = le32_to_cpu(bcf_hdr->module_type);
- header_len = sizeof(u32) * le32_to_cpu(bcf_hdr->header_len);
- major_version = (le32_to_cpu(bcf_hdr->header_version) & 0xffff0000)
- >> 16;
- minor_version = le32_to_cpu(bcf_hdr->header_version) & 0x0000ffff;
- module_id = le32_to_cpu(bcf_hdr->module_id);
- module_vendor = le32_to_cpu(bcf_hdr->module_vendor);
- date = le32_to_cpu(bcf_hdr->date);
- size = sizeof(u32) * le32_to_cpu(bcf_hdr->size);
-
- d_printf(1, dev, "firmware %s #%zd@%08zx: BCF header "
- "type:vendor:id 0x%x:%x:%x v%u.%u (%u/%u B) built %08x\n",
- i2400m->fw_name, index, offset,
- module_type, module_vendor, module_id,
- major_version, minor_version, header_len, size, date);
-
- /* Hard errors */
- if (major_version != 1) {
- dev_err(dev, "firmware %s #%zd@%08zx: major header version "
- "v%u.%u not supported\n",
- i2400m->fw_name, index, offset,
- major_version, minor_version);
- return -EBADF;
- }
-
- if (module_type != 6) { /* built for the right hardware? */
- dev_err(dev, "firmware %s #%zd@%08zx: unexpected module "
- "type 0x%x; aborting\n",
- i2400m->fw_name, index, offset,
- module_type);
- return -EBADF;
- }
-
- if (module_vendor != 0x8086) {
- dev_err(dev, "firmware %s #%zd@%08zx: unexpected module "
- "vendor 0x%x; aborting\n",
- i2400m->fw_name, index, offset, module_vendor);
- return -EBADF;
- }
-
- if (date < 0x20080300)
- dev_warn(dev, "firmware %s #%zd@%08zx: build date %08x "
- "too old; unsupported\n",
- i2400m->fw_name, index, offset, date);
- return 0;
-}
-
-
-/*
- * Run consistency tests on the firmware file and load up headers
- *
- * Check for the firmware being made for the i2400m device,
- * etc...These checks are mostly informative, as the device will make
- * them too; but the driver's response is more informative on what
- * went wrong.
- *
- * This will also look at all the headers present on the firmware
- * file, and update i2400m->fw_hdrs to point to them.
- */
-static
-int i2400m_fw_check(struct i2400m *i2400m, const void *bcf, size_t bcf_size)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- size_t headers = 0;
- const struct i2400m_bcf_hdr *bcf_hdr;
- const void *itr, *next, *top;
- size_t slots = 0, used_slots = 0;
-
- for (itr = bcf, top = itr + bcf_size;
- itr < top;
- headers++, itr = next) {
- size_t leftover, offset, header_len, size;
-
- leftover = top - itr;
- offset = itr - bcf;
- if (leftover <= sizeof(*bcf_hdr)) {
- dev_err(dev, "firmware %s: %zu B left at @%zx, "
- "not enough for BCF header\n",
- i2400m->fw_name, leftover, offset);
- break;
- }
- bcf_hdr = itr;
- /* Only the first header is supposed to be followed by
- * payload */
- header_len = sizeof(u32) * le32_to_cpu(bcf_hdr->header_len);
- size = sizeof(u32) * le32_to_cpu(bcf_hdr->size);
- if (headers == 0)
- next = itr + size;
- else
- next = itr + header_len;
-
- result = i2400m_fw_hdr_check(i2400m, bcf_hdr, headers, offset);
- if (result < 0)
- continue;
- if (used_slots + 1 >= slots) {
- /* +1 -> we need to account for the one we'll
- * occupy and at least an extra one for
- * always being NULL */
- result = i2400m_zrealloc_2x(
- (void **) &i2400m->fw_hdrs, &slots,
- sizeof(i2400m->fw_hdrs[0]),
- GFP_KERNEL);
- if (result < 0)
- goto error_zrealloc;
- }
- i2400m->fw_hdrs[used_slots] = bcf_hdr;
- used_slots++;
- }
- if (headers == 0) {
- dev_err(dev, "firmware %s: no usable headers found\n",
- i2400m->fw_name);
- result = -EBADF;
- } else
- result = 0;
-error_zrealloc:
- return result;
-}
-
-
-/*
- * Match a barker to a BCF header module ID
- *
- * The device sends a barker which tells the firmware loader which
- * header in the BCF file has to be used. This does the matching.
- */
-static
-unsigned i2400m_bcf_hdr_match(struct i2400m *i2400m,
- const struct i2400m_bcf_hdr *bcf_hdr)
-{
- u32 barker = le32_to_cpu(i2400m->barker->data[0])
- & 0x7fffffff;
- u32 module_id = le32_to_cpu(bcf_hdr->module_id)
- & 0x7fffffff; /* high bit used for something else */
-
- /* special case for 5x50 */
- if (barker == I2400M_SBOOT_BARKER && module_id == 0)
- return 1;
- if (module_id == barker)
- return 1;
- return 0;
-}
-
-static
-const struct i2400m_bcf_hdr *i2400m_bcf_hdr_find(struct i2400m *i2400m)
-{
- struct device *dev = i2400m_dev(i2400m);
- const struct i2400m_bcf_hdr **bcf_itr, *bcf_hdr;
- unsigned i = 0;
- u32 barker = le32_to_cpu(i2400m->barker->data[0]);
-
- d_printf(2, dev, "finding BCF header for barker %08x\n", barker);
- if (barker == I2400M_NBOOT_BARKER) {
- bcf_hdr = i2400m->fw_hdrs[0];
- d_printf(1, dev, "using BCF header #%u/%08x for non-signed "
- "barker\n", 0, le32_to_cpu(bcf_hdr->module_id));
- return bcf_hdr;
- }
- for (bcf_itr = i2400m->fw_hdrs; *bcf_itr != NULL; bcf_itr++, i++) {
- bcf_hdr = *bcf_itr;
- if (i2400m_bcf_hdr_match(i2400m, bcf_hdr)) {
- d_printf(1, dev, "hit on BCF hdr #%u/%08x\n",
- i, le32_to_cpu(bcf_hdr->module_id));
- return bcf_hdr;
- } else
- d_printf(1, dev, "miss on BCF hdr #%u/%08x\n",
- i, le32_to_cpu(bcf_hdr->module_id));
- }
- dev_err(dev, "cannot find a matching BCF header for barker %08x\n",
- barker);
- return NULL;
-}
-
-
-/*
- * Download the firmware to the device
- *
- * @i2400m: device descriptor
- * @bcf: pointer to loaded (and minimally verified for consistency)
- * firmware
- * @bcf_size: size of the @bcf buffer (header plus payloads)
- *
- * The process for doing this is described in this file's header.
- *
- * Note we only reinitialize boot-mode if the flags say so. Some hw
- * iterations need it, some don't. In any case, if we loop, we always
- * need to reinitialize the boot room, hence the flags modification.
- */
-static
-int i2400m_fw_dnload(struct i2400m *i2400m, const struct i2400m_bcf_hdr *bcf,
- size_t fw_size, enum i2400m_bri flags)
-{
- int ret = 0;
- struct device *dev = i2400m_dev(i2400m);
- int count = i2400m->bus_bm_retries;
- const struct i2400m_bcf_hdr *bcf_hdr;
- size_t bcf_size;
-
- d_fnstart(5, dev, "(i2400m %p bcf %p fw size %zu)\n",
- i2400m, bcf, fw_size);
- i2400m->boot_mode = 1;
- wmb(); /* Make sure other readers see it */
-hw_reboot:
- if (count-- == 0) {
- ret = -ERESTARTSYS;
- dev_err(dev, "device rebooted too many times, aborting\n");
- goto error_too_many_reboots;
- }
- if (flags & I2400M_BRI_MAC_REINIT) {
- ret = i2400m_bootrom_init(i2400m, flags);
- if (ret < 0) {
- dev_err(dev, "bootrom init failed: %d\n", ret);
- goto error_bootrom_init;
- }
- }
- flags |= I2400M_BRI_MAC_REINIT;
-
- /*
- * Initialize the download, push the bytes to the device and
- * then jump to the new firmware. Note @ret is passed with the
- * offset of the jump instruction to _dnload_finalize()
- *
- * Note we need to use the BCF header in the firmware image
- * that matches the barker that the device sent when it
- * rebooted, so it has to be passed along.
- */
- ret = -EBADF;
- bcf_hdr = i2400m_bcf_hdr_find(i2400m);
- if (bcf_hdr == NULL)
- goto error_bcf_hdr_find;
-
- ret = i2400m_dnload_init(i2400m, bcf_hdr);
- if (ret == -ERESTARTSYS)
- goto error_dev_rebooted;
- if (ret < 0)
- goto error_dnload_init;
-
- /*
- * bcf_size refers to one header size plus the fw sections size
- * indicated by the header,ie. if there are other extended headers
- * at the tail, they are not counted
- */
- bcf_size = sizeof(u32) * le32_to_cpu(bcf_hdr->size);
- ret = i2400m_dnload_bcf(i2400m, bcf, bcf_size);
- if (ret == -ERESTARTSYS)
- goto error_dev_rebooted;
- if (ret < 0) {
- dev_err(dev, "fw %s: download failed: %d\n",
- i2400m->fw_name, ret);
- goto error_dnload_bcf;
- }
-
- ret = i2400m_dnload_finalize(i2400m, bcf_hdr, bcf, ret);
- if (ret == -ERESTARTSYS)
- goto error_dev_rebooted;
- if (ret < 0) {
- dev_err(dev, "fw %s: "
- "download finalization failed: %d\n",
- i2400m->fw_name, ret);
- goto error_dnload_finalize;
- }
-
- d_printf(2, dev, "fw %s successfully uploaded\n",
- i2400m->fw_name);
- i2400m->boot_mode = 0;
- wmb(); /* Make sure i2400m_msg_to_dev() sees boot_mode */
-error_dnload_finalize:
-error_dnload_bcf:
-error_dnload_init:
-error_bcf_hdr_find:
-error_bootrom_init:
-error_too_many_reboots:
- d_fnend(5, dev, "(i2400m %p bcf %p size %zu) = %d\n",
- i2400m, bcf, fw_size, ret);
- return ret;
-
-error_dev_rebooted:
- dev_err(dev, "device rebooted, %d tries left\n", count);
- /* we got the notification already, no need to wait for it again */
- flags |= I2400M_BRI_SOFT;
- goto hw_reboot;
-}
-
-static
-int i2400m_fw_bootstrap(struct i2400m *i2400m, const struct firmware *fw,
- enum i2400m_bri flags)
-{
- int ret;
- struct device *dev = i2400m_dev(i2400m);
- const struct i2400m_bcf_hdr *bcf; /* Firmware data */
-
- d_fnstart(5, dev, "(i2400m %p)\n", i2400m);
- bcf = (void *) fw->data;
- ret = i2400m_fw_check(i2400m, bcf, fw->size);
- if (ret >= 0)
- ret = i2400m_fw_dnload(i2400m, bcf, fw->size, flags);
- if (ret < 0)
- dev_err(dev, "%s: cannot use: %d, skipping\n",
- i2400m->fw_name, ret);
- kfree(i2400m->fw_hdrs);
- i2400m->fw_hdrs = NULL;
- d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, ret);
- return ret;
-}
-
-
-/* Refcounted container for firmware data */
-struct i2400m_fw {
- struct kref kref;
- const struct firmware *fw;
-};
-
-
-static
-void i2400m_fw_destroy(struct kref *kref)
-{
- struct i2400m_fw *i2400m_fw =
- container_of(kref, struct i2400m_fw, kref);
- release_firmware(i2400m_fw->fw);
- kfree(i2400m_fw);
-}
-
-
-static
-struct i2400m_fw *i2400m_fw_get(struct i2400m_fw *i2400m_fw)
-{
- if (i2400m_fw != NULL && i2400m_fw != (void *) ~0)
- kref_get(&i2400m_fw->kref);
- return i2400m_fw;
-}
-
-
-static
-void i2400m_fw_put(struct i2400m_fw *i2400m_fw)
-{
- kref_put(&i2400m_fw->kref, i2400m_fw_destroy);
-}
-
-
-/**
- * i2400m_dev_bootstrap - Bring the device to a known state and upload firmware
- *
- * @i2400m: device descriptor
- * @flags:
- * I2400M_BRI_SOFT: a reboot barker has been seen
- * already, so don't wait for it.
- *
- * I2400M_BRI_NO_REBOOT: Don't send a reboot command, but wait
- * for a reboot barker notification. This is a one shot; if
- * the state machine needs to send a reboot command it will.
- *
- * Returns: >= 0 if ok, < 0 errno code on error.
- *
- * This sets up the firmware upload environment, loads the firmware
- * file from disk, verifies and then calls the firmware upload process
- * per se.
- *
- * Can be called either from probe, or after a warm reset. Can not be
- * called from within an interrupt. All the flow in this code is
- * single-threade; all I/Os are synchronous.
- */
-int i2400m_dev_bootstrap(struct i2400m *i2400m, enum i2400m_bri flags)
-{
- int ret, itr;
- struct device *dev = i2400m_dev(i2400m);
- struct i2400m_fw *i2400m_fw;
- const struct firmware *fw;
- const char *fw_name;
-
- d_fnstart(5, dev, "(i2400m %p)\n", i2400m);
-
- ret = -ENODEV;
- spin_lock(&i2400m->rx_lock);
- i2400m_fw = i2400m_fw_get(i2400m->fw_cached);
- spin_unlock(&i2400m->rx_lock);
- if (i2400m_fw == (void *) ~0) {
- dev_err(dev, "can't load firmware now!");
- goto out;
- } else if (i2400m_fw != NULL) {
- dev_info(dev, "firmware %s: loading from cache\n",
- i2400m->fw_name);
- ret = i2400m_fw_bootstrap(i2400m, i2400m_fw->fw, flags);
- i2400m_fw_put(i2400m_fw);
- goto out;
- }
-
- /* Load firmware files to memory. */
- for (itr = 0, ret = -ENOENT; ; itr++) {
- fw_name = i2400m->bus_fw_names[itr];
- if (fw_name == NULL) {
- dev_err(dev, "Could not find a usable firmware image\n");
- break;
- }
- d_printf(1, dev, "trying firmware %s (%d)\n", fw_name, itr);
- ret = request_firmware(&fw, fw_name, dev);
- if (ret < 0) {
- dev_err(dev, "fw %s: cannot load file: %d\n",
- fw_name, ret);
- continue;
- }
- i2400m->fw_name = fw_name;
- ret = i2400m_fw_bootstrap(i2400m, fw, flags);
- release_firmware(fw);
- if (ret >= 0) /* firmware loaded successfully */
- break;
- i2400m->fw_name = NULL;
- }
-out:
- d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, ret);
- return ret;
-}
-EXPORT_SYMBOL_GPL(i2400m_dev_bootstrap);
-
-
-void i2400m_fw_cache(struct i2400m *i2400m)
-{
- int result;
- struct i2400m_fw *i2400m_fw;
- struct device *dev = i2400m_dev(i2400m);
-
- /* if there is anything there, free it -- now, this'd be weird */
- spin_lock(&i2400m->rx_lock);
- i2400m_fw = i2400m->fw_cached;
- spin_unlock(&i2400m->rx_lock);
- if (i2400m_fw != NULL && i2400m_fw != (void *) ~0) {
- i2400m_fw_put(i2400m_fw);
- WARN(1, "%s:%u: still cached fw still present?\n",
- __func__, __LINE__);
- }
-
- if (i2400m->fw_name == NULL) {
- dev_err(dev, "firmware n/a: can't cache\n");
- i2400m_fw = (void *) ~0;
- goto out;
- }
-
- i2400m_fw = kzalloc(sizeof(*i2400m_fw), GFP_ATOMIC);
- if (i2400m_fw == NULL)
- goto out;
- kref_init(&i2400m_fw->kref);
- result = request_firmware(&i2400m_fw->fw, i2400m->fw_name, dev);
- if (result < 0) {
- dev_err(dev, "firmware %s: failed to cache: %d\n",
- i2400m->fw_name, result);
- kfree(i2400m_fw);
- i2400m_fw = (void *) ~0;
- } else
- dev_info(dev, "firmware %s: cached\n", i2400m->fw_name);
-out:
- spin_lock(&i2400m->rx_lock);
- i2400m->fw_cached = i2400m_fw;
- spin_unlock(&i2400m->rx_lock);
-}
-
-
-void i2400m_fw_uncache(struct i2400m *i2400m)
-{
- struct i2400m_fw *i2400m_fw;
-
- spin_lock(&i2400m->rx_lock);
- i2400m_fw = i2400m->fw_cached;
- i2400m->fw_cached = NULL;
- spin_unlock(&i2400m->rx_lock);
-
- if (i2400m_fw != NULL && i2400m_fw != (void *) ~0)
- i2400m_fw_put(i2400m_fw);
-}
-
diff --git a/drivers/staging/wimax/i2400m/i2400m-usb.h b/drivers/staging/wimax/i2400m/i2400m-usb.h
deleted file mode 100644
index eff4f464a23e..000000000000
--- a/drivers/staging/wimax/i2400m/i2400m-usb.h
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * USB-specific i2400m driver definitions
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * 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 Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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
- * OWNER 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.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * - Initial implementation
- *
- *
- * This driver implements the bus-specific part of the i2400m for
- * USB. Check i2400m.h for a generic driver description.
- *
- * ARCHITECTURE
- *
- * This driver listens to notifications sent from the notification
- * endpoint (in usb-notif.c); when data is ready to read, the code in
- * there schedules a read from the device (usb-rx.c) and then passes
- * the data to the generic RX code (rx.c).
- *
- * When the generic driver needs to send data (network or control), it
- * queues up in the TX FIFO (tx.c) and that will notify the driver
- * through the i2400m->bus_tx_kick() callback
- * (usb-tx.c:i2400mu_bus_tx_kick) which will send the items in the
- * FIFO queue.
- *
- * This driver, as well, implements the USB-specific ops for the generic
- * driver to be able to setup/teardown communication with the device
- * [i2400m_bus_dev_start() and i2400m_bus_dev_stop()], reseting the
- * device [i2400m_bus_reset()] and performing firmware upload
- * [i2400m_bus_bm_cmd() and i2400_bus_bm_wait_for_ack()].
- */
-
-#ifndef __I2400M_USB_H__
-#define __I2400M_USB_H__
-
-#include "i2400m.h"
-#include <linux/kthread.h>
-
-
-/*
- * Error Density Count: cheapo error density (over time) counter
- *
- * Originally by Reinette Chatre <reinette.chatre@intel.com>
- *
- * Embed an 'struct edc' somewhere. Each time there is a soft or
- * retryable error, call edc_inc() and check if the error top
- * watermark has been reached.
- */
-enum {
- EDC_MAX_ERRORS = 10,
- EDC_ERROR_TIMEFRAME = HZ,
-};
-
-/* error density counter */
-struct edc {
- unsigned long timestart;
- u16 errorcount;
-};
-
-struct i2400m_endpoint_cfg {
- unsigned char bulk_out;
- unsigned char notification;
- unsigned char reset_cold;
- unsigned char bulk_in;
-};
-
-static inline void edc_init(struct edc *edc)
-{
- edc->timestart = jiffies;
-}
-
-/**
- * edc_inc - report a soft error and check if we are over the watermark
- *
- * @edc: pointer to error density counter.
- * @max_err: maximum number of errors we can accept over the timeframe
- * @timeframe: length of the timeframe (in jiffies).
- *
- * Returns: !0 1 if maximum acceptable errors per timeframe has been
- * exceeded. 0 otherwise.
- *
- * This is way to determine if the number of acceptable errors per time
- * period has been exceeded. It is not accurate as there are cases in which
- * this scheme will not work, for example if there are periodic occurrences
- * of errors that straddle updates to the start time. This scheme is
- * sufficient for our usage.
- *
- * To use, embed a 'struct edc' somewhere, initialize it with
- * edc_init() and when an error hits:
- *
- * if (do_something_fails_with_a_soft_error) {
- * if (edc_inc(&my->edc, MAX_ERRORS, MAX_TIMEFRAME))
- * Ops, hard error, do something about it
- * else
- * Retry or ignore, depending on whatever
- * }
- */
-static inline int edc_inc(struct edc *edc, u16 max_err, u16 timeframe)
-{
- unsigned long now;
-
- now = jiffies;
- if (time_after(now, edc->timestart + timeframe)) {
- edc->errorcount = 1;
- edc->timestart = now;
- } else if (++edc->errorcount > max_err) {
- edc->errorcount = 0;
- edc->timestart = now;
- return 1;
- }
- return 0;
-}
-
-/* Host-Device interface for USB */
-enum {
- I2400M_USB_BOOT_RETRIES = 3,
- I2400MU_MAX_NOTIFICATION_LEN = 256,
- I2400MU_BLK_SIZE = 16,
- I2400MU_PL_SIZE_MAX = 0x3EFF,
-
- /* Device IDs */
- USB_DEVICE_ID_I6050 = 0x0186,
- USB_DEVICE_ID_I6050_2 = 0x0188,
- USB_DEVICE_ID_I6150 = 0x07d6,
- USB_DEVICE_ID_I6150_2 = 0x07d7,
- USB_DEVICE_ID_I6150_3 = 0x07d9,
- USB_DEVICE_ID_I6250 = 0x0187,
-};
-
-
-/**
- * struct i2400mu - descriptor for a USB connected i2400m
- *
- * @i2400m: bus-generic i2400m implementation; has to be first (see
- * it's documentation in i2400m.h).
- *
- * @usb_dev: pointer to our USB device
- *
- * @usb_iface: pointer to our USB interface
- *
- * @urb_edc: error density counter; used to keep a density-on-time tab
- * on how many soft (retryable or ignorable) errors we get. If we
- * go over the threshold, we consider the bus transport is failing
- * too much and reset.
- *
- * @notif_urb: URB for receiving notifications from the device.
- *
- * @tx_kthread: thread we use for data TX. We use a thread because in
- * order to do deep power saving and put the device to sleep, we
- * need to call usb_autopm_*() [blocking functions].
- *
- * @tx_wq: waitqueue for the TX kthread to sleep when there is no data
- * to be sent; when more data is available, it is woken up by
- * i2400mu_bus_tx_kick().
- *
- * @rx_kthread: thread we use for data RX. We use a thread because in
- * order to do deep power saving and put the device to sleep, we
- * need to call usb_autopm_*() [blocking functions].
- *
- * @rx_wq: waitqueue for the RX kthread to sleep when there is no data
- * to receive. When data is available, it is woken up by
- * usb-notif.c:i2400mu_notification_grok().
- *
- * @rx_pending_count: number of rx-data-ready notifications that were
- * still not handled by the RX kthread.
- *
- * @rx_size: current RX buffer size that is being used.
- *
- * @rx_size_acc: accumulator of the sizes of the previous read
- * transactions.
- *
- * @rx_size_cnt: number of read transactions accumulated in
- * @rx_size_acc.
- *
- * @do_autopm: disable(0)/enable(>0) calling the
- * usb_autopm_get/put_interface() barriers when executing
- * commands. See doc in i2400mu_suspend() for more information.
- *
- * @rx_size_auto_shrink: if true, the rx_size is shrunk
- * automatically based on the average size of the received
- * transactions. This allows the receive code to allocate smaller
- * chunks of memory and thus reduce pressure on the memory
- * allocator by not wasting so much space. By default it is
- * enabled.
- *
- * @debugfs_dentry: hookup for debugfs files.
- * These have to be in a separate directory, a child of
- * (wimax_dev->debugfs_dentry) so they can be removed when the
- * module unloads, as we don't keep each dentry.
- */
-struct i2400mu {
- struct i2400m i2400m; /* FIRST! See doc */
-
- struct usb_device *usb_dev;
- struct usb_interface *usb_iface;
- struct edc urb_edc; /* Error density counter */
- struct i2400m_endpoint_cfg endpoint_cfg;
-
- struct urb *notif_urb;
- struct task_struct *tx_kthread;
- wait_queue_head_t tx_wq;
-
- struct task_struct *rx_kthread;
- wait_queue_head_t rx_wq;
- atomic_t rx_pending_count;
- size_t rx_size, rx_size_acc, rx_size_cnt;
- atomic_t do_autopm;
- u8 rx_size_auto_shrink;
-
- struct dentry *debugfs_dentry;
- unsigned i6050:1; /* 1 if this is a 6050 based SKU */
-};
-
-
-static inline
-void i2400mu_init(struct i2400mu *i2400mu)
-{
- i2400m_init(&i2400mu->i2400m);
- edc_init(&i2400mu->urb_edc);
- init_waitqueue_head(&i2400mu->tx_wq);
- atomic_set(&i2400mu->rx_pending_count, 0);
- init_waitqueue_head(&i2400mu->rx_wq);
- i2400mu->rx_size = PAGE_SIZE - sizeof(struct skb_shared_info);
- atomic_set(&i2400mu->do_autopm, 1);
- i2400mu->rx_size_auto_shrink = 1;
-}
-
-int i2400mu_notification_setup(struct i2400mu *);
-void i2400mu_notification_release(struct i2400mu *);
-
-int i2400mu_rx_setup(struct i2400mu *);
-void i2400mu_rx_release(struct i2400mu *);
-void i2400mu_rx_kick(struct i2400mu *);
-
-int i2400mu_tx_setup(struct i2400mu *);
-void i2400mu_tx_release(struct i2400mu *);
-void i2400mu_bus_tx_kick(struct i2400m *);
-
-ssize_t i2400mu_bus_bm_cmd_send(struct i2400m *,
- const struct i2400m_bootrom_header *, size_t,
- int);
-ssize_t i2400mu_bus_bm_wait_for_ack(struct i2400m *,
- struct i2400m_bootrom_header *, size_t);
-#endif /* #ifndef __I2400M_USB_H__ */
diff --git a/drivers/staging/wimax/i2400m/i2400m.h b/drivers/staging/wimax/i2400m/i2400m.h
deleted file mode 100644
index de22cc6f2c5c..000000000000
--- a/drivers/staging/wimax/i2400m/i2400m.h
+++ /dev/null
@@ -1,970 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Declarations for bus-generic internal APIs
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * 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 Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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
- * OWNER 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.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * - Initial implementation
- *
- *
- * GENERAL DRIVER ARCHITECTURE
- *
- * The i2400m driver is split in the following two major parts:
- *
- * - bus specific driver
- * - bus generic driver (this part)
- *
- * The bus specific driver sets up stuff specific to the bus the
- * device is connected to (USB, PCI, tam-tam...non-authoritative
- * nor binding list) which is basically the device-model management
- * (probe/disconnect, etc), moving data from device to kernel and
- * back, doing the power saving details and reseting the device.
- *
- * For details on each bus-specific driver, see it's include file,
- * i2400m-BUSNAME.h
- *
- * The bus-generic functionality break up is:
- *
- * - Firmware upload: fw.c - takes care of uploading firmware to the
- * device. bus-specific driver just needs to provides a way to
- * execute boot-mode commands and to reset the device.
- *
- * - RX handling: rx.c - receives data from the bus-specific code and
- * feeds it to the network or WiMAX stack or uses it to modify
- * the driver state. bus-specific driver only has to receive
- * frames and pass them to this module.
- *
- * - TX handling: tx.c - manages the TX FIFO queue and provides means
- * for the bus-specific TX code to pull data from the FIFO
- * queue. bus-specific code just pulls frames from this module
- * to sends them to the device.
- *
- * - netdev glue: netdev.c - interface with Linux networking
- * stack. Pass around data frames, and configure when the
- * device is up and running or shutdown (through ifconfig up /
- * down). Bus-generic only.
- *
- * - control ops: control.c - implements various commands for
- * controlling the device. bus-generic only.
- *
- * - device model glue: driver.c - implements helpers for the
- * device-model glue done by the bus-specific layer
- * (setup/release the driver resources), turning the device on
- * and off, handling the device reboots/resets and a few simple
- * WiMAX stack ops.
- *
- * Code is also broken up in linux-glue / device-glue.
- *
- * Linux glue contains functions that deal mostly with gluing with the
- * rest of the Linux kernel.
- *
- * Device-glue are functions that deal mostly with the way the device
- * does things and talk the device's language.
- *
- * device-glue code is licensed BSD so other open source OSes can take
- * it to implement their drivers.
- *
- *
- * APIs AND HEADER FILES
- *
- * This bus generic code exports three APIs:
- *
- * - HDI (host-device interface) definitions common to all busses
- * (include/linux/wimax/i2400m.h); these can be also used by user
- * space code.
- * - internal API for the bus-generic code
- * - external API for the bus-specific drivers
- *
- *
- * LIFE CYCLE:
- *
- * When the bus-specific driver probes, it allocates a network device
- * with enough space for it's data structue, that must contain a
- * &struct i2400m at the top.
- *
- * On probe, it needs to fill the i2400m members marked as [fill], as
- * well as i2400m->wimax_dev.net_dev and call i2400m_setup(). The
- * i2400m driver will only register with the WiMAX and network stacks;
- * the only access done to the device is to read the MAC address so we
- * can register a network device.
- *
- * The high-level call flow is:
- *
- * bus_probe()
- * i2400m_setup()
- * i2400m->bus_setup()
- * boot rom initialization / read mac addr
- * network / WiMAX stacks registration
- * i2400m_dev_start()
- * i2400m->bus_dev_start()
- * i2400m_dev_initialize()
- *
- * The reverse applies for a disconnect() call:
- *
- * bus_disconnect()
- * i2400m_release()
- * i2400m_dev_stop()
- * i2400m_dev_shutdown()
- * i2400m->bus_dev_stop()
- * network / WiMAX stack unregistration
- * i2400m->bus_release()
- *
- * At this point, control and data communications are possible.
- *
- * While the device is up, it might reset. The bus-specific driver has
- * to catch that situation and call i2400m_dev_reset_handle() to deal
- * with it (reset the internal driver structures and go back to square
- * one).
- */
-
-#ifndef __I2400M_H__
-#define __I2400M_H__
-
-#include <linux/usb.h>
-#include <linux/netdevice.h>
-#include <linux/completion.h>
-#include <linux/rwsem.h>
-#include <linux/atomic.h>
-#include "../net-wimax.h"
-#include "linux-wimax-i2400m.h"
-#include <asm/byteorder.h>
-
-enum {
-/* netdev interface */
- /*
- * Out of NWG spec (R1_v1.2.2), 3.3.3 ASN Bearer Plane MTU Size
- *
- * The MTU is 1400 or less
- */
- I2400M_MAX_MTU = 1400,
-};
-
-/* Misc constants */
-enum {
- /* Size of the Boot Mode Command buffer */
- I2400M_BM_CMD_BUF_SIZE = 16 * 1024,
- I2400M_BM_ACK_BUF_SIZE = 256,
-};
-
-enum {
- /* Maximum number of bus reset can be retried */
- I2400M_BUS_RESET_RETRIES = 3,
-};
-
-/**
- * struct i2400m_poke_table - Hardware poke table for the Intel 2400m
- *
- * This structure will be used to create a device specific poke table
- * to put the device in a consistent state at boot time.
- *
- * @address: The device address to poke
- *
- * @data: The data value to poke to the device address
- *
- */
-struct i2400m_poke_table{
- __le32 address;
- __le32 data;
-};
-
-#define I2400M_FW_POKE(a, d) { \
- .address = cpu_to_le32(a), \
- .data = cpu_to_le32(d) \
-}
-
-
-/**
- * i2400m_reset_type - methods to reset a device
- *
- * @I2400M_RT_WARM: Reset without device disconnection, device handles
- * are kept valid but state is back to power on, with firmware
- * re-uploaded.
- * @I2400M_RT_COLD: Tell the device to disconnect itself from the bus
- * and reconnect. Renders all device handles invalid.
- * @I2400M_RT_BUS: Tells the bus to reset the device; last measure
- * used when both types above don't work.
- */
-enum i2400m_reset_type {
- I2400M_RT_WARM, /* first measure */
- I2400M_RT_COLD, /* second measure */
- I2400M_RT_BUS, /* call in artillery */
-};
-
-struct i2400m_reset_ctx;
-struct i2400m_roq;
-struct i2400m_barker_db;
-
-/**
- * struct i2400m - descriptor for an Intel 2400m
- *
- * Members marked with [fill] must be filled out/initialized before
- * calling i2400m_setup().
- *
- * Note the @bus_setup/@bus_release, @bus_dev_start/@bus_dev_release
- * call pairs are very much doing almost the same, and depending on
- * the underlying bus, some stuff has to be put in one or the
- * other. The idea of setup/release is that they setup the minimal
- * amount needed for loading firmware, where us dev_start/stop setup
- * the rest needed to do full data/control traffic.
- *
- * @bus_tx_block_size: [fill] USB imposes a 16 block size, but other
- * busses will differ. So we have a tx_blk_size variable that the
- * bus layer sets to tell the engine how much of that we need.
- *
- * @bus_tx_room_min: [fill] Minimum room required while allocating
- * TX queue's buffer space for message header. USB requires
- * 16 bytes. Refer to bus specific driver code for details.
- *
- * @bus_pl_size_max: [fill] Maximum payload size.
- *
- * @bus_setup: [optional fill] Function called by the bus-generic code
- * [i2400m_setup()] to setup the basic bus-specific communications
- * to the the device needed to load firmware. See LIFE CYCLE above.
- *
- * NOTE: Doesn't need to upload the firmware, as that is taken
- * care of by the bus-generic code.
- *
- * @bus_release: [optional fill] Function called by the bus-generic
- * code [i2400m_release()] to shutdown the basic bus-specific
- * communications to the the device needed to load firmware. See
- * LIFE CYCLE above.
- *
- * This function does not need to reset the device, just tear down
- * all the host resources created to handle communication with
- * the device.
- *
- * @bus_dev_start: [optional fill] Function called by the bus-generic
- * code [i2400m_dev_start()] to do things needed to start the
- * device. See LIFE CYCLE above.
- *
- * NOTE: Doesn't need to upload the firmware, as that is taken
- * care of by the bus-generic code.
- *
- * @bus_dev_stop: [optional fill] Function called by the bus-generic
- * code [i2400m_dev_stop()] to do things needed for stopping the
- * device. See LIFE CYCLE above.
- *
- * This function does not need to reset the device, just tear down
- * all the host resources created to handle communication with
- * the device.
- *
- * @bus_tx_kick: [fill] Function called by the bus-generic code to let
- * the bus-specific code know that there is data available in the
- * TX FIFO for transmission to the device.
- *
- * This function cannot sleep.
- *
- * @bus_reset: [fill] Function called by the bus-generic code to reset
- * the device in in various ways. Doesn't need to wait for the
- * reset to finish.
- *
- * If warm or cold reset fail, this function is expected to do a
- * bus-specific reset (eg: USB reset) to get the device to a
- * working state (even if it implies device disconecction).
- *
- * Note the warm reset is used by the firmware uploader to
- * reinitialize the device.
- *
- * IMPORTANT: this is called very early in the device setup
- * process, so it cannot rely on common infrastructure being laid
- * out.
- *
- * IMPORTANT: don't call reset on RT_BUS with i2400m->init_mutex
- * held, as the .pre/.post reset handlers will deadlock.
- *
- * @bus_bm_retries: [fill] How many times shall a firmware upload /
- * device initialization be retried? Different models of the same
- * device might need different values, hence it is set by the
- * bus-specific driver. Note this value is used in two places,
- * i2400m_fw_dnload() and __i2400m_dev_start(); they won't become
- * multiplicative (__i2400m_dev_start() calling N times
- * i2400m_fw_dnload() and this trying N times to download the
- * firmware), as if __i2400m_dev_start() only retries if the
- * firmware crashed while initializing the device (not in a
- * general case).
- *
- * @bus_bm_cmd_send: [fill] Function called to send a boot-mode
- * command. Flags are defined in 'enum i2400m_bm_cmd_flags'. This
- * is synchronous and has to return 0 if ok or < 0 errno code in
- * any error condition.
- *
- * @bus_bm_wait_for_ack: [fill] Function called to wait for a
- * boot-mode notification (that can be a response to a previously
- * issued command or an asynchronous one). Will read until all the
- * indicated size is read or timeout. Reading more or less data
- * than asked for is an error condition. Return 0 if ok, < 0 errno
- * code on error.
- *
- * The caller to this function will check if the response is a
- * barker that indicates the device going into reset mode.
- *
- * @bus_fw_names: [fill] a NULL-terminated array with the names of the
- * firmware images to try loading. This is made a list so we can
- * support backward compatibility of firmware releases (eg: if we
- * can't find the default v1.4, we try v1.3). In general, the name
- * should be i2400m-fw-X-VERSION.sbcf, where X is the bus name.
- * The list is tried in order and the first one that loads is
- * used. The fw loader will set i2400m->fw_name to point to the
- * active firmware image.
- *
- * @bus_bm_mac_addr_impaired: [fill] Set to true if the device's MAC
- * address provided in boot mode is kind of broken and needs to
- * be re-read later on.
- *
- * @bus_bm_pokes_table: [fill/optional] A table of device addresses
- * and values that will be poked at device init time to move the
- * device to the correct state for the type of boot/firmware being
- * used. This table MUST be terminated with (0x000000,
- * 0x00000000) or bad things will happen.
- *
- *
- * @wimax_dev: WiMAX generic device for linkage into the kernel WiMAX
- * stack. Due to the way a net_device is allocated, we need to
- * force this to be the first field so that we can get from
- * netdev_priv() the right pointer.
- *
- * @updown: the device is up and ready for transmitting control and
- * data packets. This implies @ready (communication infrastructure
- * with the device is ready) and the device's firmware has been
- * loaded and the device initialized.
- *
- * Write to it only inside a i2400m->init_mutex protected area
- * followed with a wmb(); rmb() before accesing (unless locked
- * inside i2400m->init_mutex). Read access can be loose like that
- * [just using rmb()] because the paths that use this also do
- * other error checks later on.
- *
- * @ready: Communication infrastructure with the device is ready, data
- * frames can start to be passed around (this is lighter than
- * using the WiMAX state for certain hot paths).
- *
- * Write to it only inside a i2400m->init_mutex protected area
- * followed with a wmb(); rmb() before accesing (unless locked
- * inside i2400m->init_mutex). Read access can be loose like that
- * [just using rmb()] because the paths that use this also do
- * other error checks later on.
- *
- * @rx_reorder: 1 if RX reordering is enabled; this can only be
- * set at probe time.
- *
- * @state: device's state (as reported by it)
- *
- * @state_wq: waitqueue that is woken up whenever the state changes
- *
- * @tx_lock: spinlock to protect TX members
- *
- * @tx_buf: FIFO buffer for TX; we queue data here
- *
- * @tx_in: FIFO index for incoming data. Note this doesn't wrap around
- * and it is always greater than @tx_out.
- *
- * @tx_out: FIFO index for outgoing data
- *
- * @tx_msg: current TX message that is active in the FIFO for
- * appending payloads.
- *
- * @tx_sequence: current sequence number for TX messages from the
- * device to the host.
- *
- * @tx_msg_size: size of the current message being transmitted by the
- * bus-specific code.
- *
- * @tx_pl_num: total number of payloads sent
- *
- * @tx_pl_max: maximum number of payloads sent in a TX message
- *
- * @tx_pl_min: minimum number of payloads sent in a TX message
- *
- * @tx_num: number of TX messages sent
- *
- * @tx_size_acc: number of bytes in all TX messages sent
- * (this is different to net_dev's statistics as it also counts
- * control messages).
- *
- * @tx_size_min: smallest TX message sent.
- *
- * @tx_size_max: biggest TX message sent.
- *
- * @rx_lock: spinlock to protect RX members and rx_roq_refcount.
- *
- * @rx_pl_num: total number of payloads received
- *
- * @rx_pl_max: maximum number of payloads received in a RX message
- *
- * @rx_pl_min: minimum number of payloads received in a RX message
- *
- * @rx_num: number of RX messages received
- *
- * @rx_size_acc: number of bytes in all RX messages received
- * (this is different to net_dev's statistics as it also counts
- * control messages).
- *
- * @rx_size_min: smallest RX message received.
- *
- * @rx_size_max: buggest RX message received.
- *
- * @rx_roq: RX ReOrder queues. (fw >= v1.4) When packets are received
- * out of order, the device will ask the driver to hold certain
- * packets until the ones that are received out of order can be
- * delivered. Then the driver can release them to the host. See
- * drivers/net/i2400m/rx.c for details.
- *
- * @rx_roq_refcount: refcount rx_roq. This refcounts any access to
- * rx_roq thus preventing rx_roq being destroyed when rx_roq
- * is being accessed. rx_roq_refcount is protected by rx_lock.
- *
- * @rx_reports: reports received from the device that couldn't be
- * processed because the driver wasn't still ready; when ready,
- * they are pulled from here and chewed.
- *
- * @rx_reports_ws: Work struct used to kick a scan of the RX reports
- * list and to process each.
- *
- * @src_mac_addr: MAC address used to make ethernet packets be coming
- * from. This is generated at i2400m_setup() time and used during
- * the life cycle of the instance. See i2400m_fake_eth_header().
- *
- * @init_mutex: Mutex used for serializing the device bringup
- * sequence; this way if the device reboots in the middle, we
- * don't try to do a bringup again while we are tearing down the
- * one that failed.
- *
- * Can't reuse @msg_mutex because from within the bringup sequence
- * we need to send messages to the device and thus use @msg_mutex.
- *
- * @msg_mutex: mutex used to send control commands to the device (we
- * only allow one at a time, per host-device interface design).
- *
- * @msg_completion: used to wait for an ack to a control command sent
- * to the device.
- *
- * @ack_skb: used to store the actual ack to a control command if the
- * reception of the command was successful. Otherwise, a ERR_PTR()
- * errno code that indicates what failed with the ack reception.
- *
- * Only valid after @msg_completion is woken up. Only updateable
- * if @msg_completion is armed. Only touched by
- * i2400m_msg_to_dev().
- *
- * Protected by @rx_lock. In theory the command execution flow is
- * sequential, but in case the device sends an out-of-phase or
- * very delayed response, we need to avoid it trampling current
- * execution.
- *
- * @bm_cmd_buf: boot mode command buffer for composing firmware upload
- * commands.
- *
- * USB can't r/w to stack, vmalloc, etc...as well, we end up
- * having to alloc/free a lot to compose commands, so we use these
- * for stagging and not having to realloc all the time.
- *
- * This assumes the code always runs serialized. Only one thread
- * can call i2400m_bm_cmd() at the same time.
- *
- * @bm_ack_buf: boot mode acknoledge buffer for staging reception of
- * responses to commands.
- *
- * See @bm_cmd_buf.
- *
- * @work_queue: work queue for processing device reports. This
- * workqueue cannot be used for processing TX or RX to the device,
- * as from it we'll process device reports, which might require
- * further communication with the device.
- *
- * @debugfs_dentry: hookup for debugfs files.
- * These have to be in a separate directory, a child of
- * (wimax_dev->debugfs_dentry) so they can be removed when the
- * module unloads, as we don't keep each dentry.
- *
- * @fw_name: name of the firmware image that is currently being used.
- *
- * @fw_version: version of the firmware interface, Major.minor,
- * encoded in the high word and low word (major << 16 | minor).
- *
- * @fw_hdrs: NULL terminated array of pointers to the firmware
- * headers. This is only available during firmware load time.
- *
- * @fw_cached: Used to cache firmware when the system goes to
- * suspend/standby/hibernation (as on resume we can't read it). If
- * NULL, no firmware was cached, read it. If ~0, you can't read
- * any firmware files (the system still didn't come out of suspend
- * and failed to cache one), so abort; otherwise, a valid cached
- * firmware to be used. Access to this variable is protected by
- * the spinlock i2400m->rx_lock.
- *
- * @barker: barker type that the device uses; this is initialized by
- * i2400m_is_boot_barker() the first time it is called. Then it
- * won't change during the life cycle of the device and every time
- * a boot barker is received, it is just verified for it being the
- * same.
- *
- * @pm_notifier: used to register for PM events
- *
- * @bus_reset_retries: counter for the number of bus resets attempted for
- * this boot. It's not for tracking the number of bus resets during
- * the whole driver life cycle (from insmod to rmmod) but for the
- * number of dev_start() executed until dev_start() returns a success
- * (ie: a good boot means a dev_stop() followed by a successful
- * dev_start()). dev_reset_handler() increments this counter whenever
- * it is triggering a bus reset. It checks this counter to decide if a
- * subsequent bus reset should be retried. dev_reset_handler() retries
- * the bus reset until dev_start() succeeds or the counter reaches
- * I2400M_BUS_RESET_RETRIES. The counter is cleared to 0 in
- * dev_reset_handle() when dev_start() returns a success,
- * ie: a successul boot is completed.
- *
- * @alive: flag to denote if the device *should* be alive. This flag is
- * everything like @updown (see doc for @updown) except reflecting
- * the device state *we expect* rather than the actual state as denoted
- * by @updown. It is set 1 whenever @updown is set 1 in dev_start().
- * Then the device is expected to be alive all the time
- * (i2400m->alive remains 1) until the driver is removed. Therefore
- * all the device reboot events detected can be still handled properly
- * by either dev_reset_handle() or .pre_reset/.post_reset as long as
- * the driver presents. It is set 0 along with @updown in dev_stop().
- *
- * @error_recovery: flag to denote if we are ready to take an error recovery.
- * 0 for ready to take an error recovery; 1 for not ready. It is
- * initialized to 1 while probe() since we don't tend to take any error
- * recovery during probe(). It is decremented by 1 whenever dev_start()
- * succeeds to indicate we are ready to take error recovery from now on.
- * It is checked every time we wanna schedule an error recovery. If an
- * error recovery is already in place (error_recovery was set 1), we
- * should not schedule another one until the last one is done.
- */
-struct i2400m {
- struct wimax_dev wimax_dev; /* FIRST! See doc */
-
- unsigned updown:1; /* Network device is up or down */
- unsigned boot_mode:1; /* is the device in boot mode? */
- unsigned sboot:1; /* signed or unsigned fw boot */
- unsigned ready:1; /* Device comm infrastructure ready */
- unsigned rx_reorder:1; /* RX reorder is enabled */
- u8 trace_msg_from_user; /* echo rx msgs to 'trace' pipe */
- /* typed u8 so /sys/kernel/debug/u8 can tweak */
- enum i2400m_system_state state;
- wait_queue_head_t state_wq; /* Woken up when on state updates */
-
- size_t bus_tx_block_size;
- size_t bus_tx_room_min;
- size_t bus_pl_size_max;
- unsigned bus_bm_retries;
-
- int (*bus_setup)(struct i2400m *);
- int (*bus_dev_start)(struct i2400m *);
- void (*bus_dev_stop)(struct i2400m *);
- void (*bus_release)(struct i2400m *);
- void (*bus_tx_kick)(struct i2400m *);
- int (*bus_reset)(struct i2400m *, enum i2400m_reset_type);
- ssize_t (*bus_bm_cmd_send)(struct i2400m *,
- const struct i2400m_bootrom_header *,
- size_t, int flags);
- ssize_t (*bus_bm_wait_for_ack)(struct i2400m *,
- struct i2400m_bootrom_header *, size_t);
- const char **bus_fw_names;
- unsigned bus_bm_mac_addr_impaired:1;
- const struct i2400m_poke_table *bus_bm_pokes_table;
-
- spinlock_t tx_lock; /* protect TX state */
- void *tx_buf;
- size_t tx_in, tx_out;
- struct i2400m_msg_hdr *tx_msg;
- size_t tx_sequence, tx_msg_size;
- /* TX stats */
- unsigned tx_pl_num, tx_pl_max, tx_pl_min,
- tx_num, tx_size_acc, tx_size_min, tx_size_max;
-
- /* RX stuff */
- /* protect RX state and rx_roq_refcount */
- spinlock_t rx_lock;
- unsigned rx_pl_num, rx_pl_max, rx_pl_min,
- rx_num, rx_size_acc, rx_size_min, rx_size_max;
- struct i2400m_roq *rx_roq; /* access is refcounted */
- struct kref rx_roq_refcount; /* refcount access to rx_roq */
- u8 src_mac_addr[ETH_HLEN];
- struct list_head rx_reports; /* under rx_lock! */
- struct work_struct rx_report_ws;
-
- struct mutex msg_mutex; /* serialize command execution */
- struct completion msg_completion;
- struct sk_buff *ack_skb; /* protected by rx_lock */
-
- void *bm_ack_buf; /* for receiving acks over USB */
- void *bm_cmd_buf; /* for issuing commands over USB */
-
- struct workqueue_struct *work_queue;
-
- struct mutex init_mutex; /* protect bringup seq */
- struct i2400m_reset_ctx *reset_ctx; /* protected by init_mutex */
-
- struct work_struct wake_tx_ws;
- struct sk_buff *wake_tx_skb;
-
- struct work_struct reset_ws;
- const char *reset_reason;
-
- struct work_struct recovery_ws;
-
- struct dentry *debugfs_dentry;
- const char *fw_name; /* name of the current firmware image */
- unsigned long fw_version; /* version of the firmware interface */
- const struct i2400m_bcf_hdr **fw_hdrs;
- struct i2400m_fw *fw_cached; /* protected by rx_lock */
- struct i2400m_barker_db *barker;
-
- struct notifier_block pm_notifier;
-
- /* counting bus reset retries in this boot */
- atomic_t bus_reset_retries;
-
- /* if the device is expected to be alive */
- unsigned alive;
-
- /* 0 if we are ready for error recovery; 1 if not ready */
- atomic_t error_recovery;
-
-};
-
-
-/*
- * Bus-generic internal APIs
- * -------------------------
- */
-
-static inline
-struct i2400m *wimax_dev_to_i2400m(struct wimax_dev *wimax_dev)
-{
- return container_of(wimax_dev, struct i2400m, wimax_dev);
-}
-
-static inline
-struct i2400m *net_dev_to_i2400m(struct net_device *net_dev)
-{
- return wimax_dev_to_i2400m(netdev_priv(net_dev));
-}
-
-/*
- * Boot mode support
- */
-
-/**
- * i2400m_bm_cmd_flags - flags to i2400m_bm_cmd()
- *
- * @I2400M_BM_CMD_RAW: send the command block as-is, without doing any
- * extra processing for adding CRC.
- */
-enum i2400m_bm_cmd_flags {
- I2400M_BM_CMD_RAW = 1 << 2,
-};
-
-/**
- * i2400m_bri - Boot-ROM indicators
- *
- * Flags for i2400m_bootrom_init() and i2400m_dev_bootstrap() [which
- * are passed from things like i2400m_setup()]. Can be combined with
- * |.
- *
- * @I2400M_BRI_SOFT: The device rebooted already and a reboot
- * barker received, proceed directly to ack the boot sequence.
- * @I2400M_BRI_NO_REBOOT: Do not reboot the device and proceed
- * directly to wait for a reboot barker from the device.
- * @I2400M_BRI_MAC_REINIT: We need to reinitialize the boot
- * rom after reading the MAC address. This is quite a dirty hack,
- * if you ask me -- the device requires the bootrom to be
- * initialized after reading the MAC address.
- */
-enum i2400m_bri {
- I2400M_BRI_SOFT = 1 << 1,
- I2400M_BRI_NO_REBOOT = 1 << 2,
- I2400M_BRI_MAC_REINIT = 1 << 3,
-};
-
-void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *);
-int i2400m_dev_bootstrap(struct i2400m *, enum i2400m_bri);
-int i2400m_read_mac_addr(struct i2400m *);
-int i2400m_bootrom_init(struct i2400m *, enum i2400m_bri);
-int i2400m_is_boot_barker(struct i2400m *, const void *, size_t);
-static inline
-int i2400m_is_d2h_barker(const void *buf)
-{
- const __le32 *barker = buf;
- return le32_to_cpu(*barker) == I2400M_D2H_MSG_BARKER;
-}
-void i2400m_unknown_barker(struct i2400m *, const void *, size_t);
-
-/* Make/grok boot-rom header commands */
-
-static inline
-__le32 i2400m_brh_command(enum i2400m_brh_opcode opcode, unsigned use_checksum,
- unsigned direct_access)
-{
- return cpu_to_le32(
- I2400M_BRH_SIGNATURE
- | (direct_access ? I2400M_BRH_DIRECT_ACCESS : 0)
- | I2400M_BRH_RESPONSE_REQUIRED /* response always required */
- | (use_checksum ? I2400M_BRH_USE_CHECKSUM : 0)
- | (opcode & I2400M_BRH_OPCODE_MASK));
-}
-
-static inline
-void i2400m_brh_set_opcode(struct i2400m_bootrom_header *hdr,
- enum i2400m_brh_opcode opcode)
-{
- hdr->command = cpu_to_le32(
- (le32_to_cpu(hdr->command) & ~I2400M_BRH_OPCODE_MASK)
- | (opcode & I2400M_BRH_OPCODE_MASK));
-}
-
-static inline
-unsigned i2400m_brh_get_opcode(const struct i2400m_bootrom_header *hdr)
-{
- return le32_to_cpu(hdr->command) & I2400M_BRH_OPCODE_MASK;
-}
-
-static inline
-unsigned i2400m_brh_get_response(const struct i2400m_bootrom_header *hdr)
-{
- return (le32_to_cpu(hdr->command) & I2400M_BRH_RESPONSE_MASK)
- >> I2400M_BRH_RESPONSE_SHIFT;
-}
-
-static inline
-unsigned i2400m_brh_get_use_checksum(const struct i2400m_bootrom_header *hdr)
-{
- return le32_to_cpu(hdr->command) & I2400M_BRH_USE_CHECKSUM;
-}
-
-static inline
-unsigned i2400m_brh_get_response_required(
- const struct i2400m_bootrom_header *hdr)
-{
- return le32_to_cpu(hdr->command) & I2400M_BRH_RESPONSE_REQUIRED;
-}
-
-static inline
-unsigned i2400m_brh_get_direct_access(const struct i2400m_bootrom_header *hdr)
-{
- return le32_to_cpu(hdr->command) & I2400M_BRH_DIRECT_ACCESS;
-}
-
-static inline
-unsigned i2400m_brh_get_signature(const struct i2400m_bootrom_header *hdr)
-{
- return (le32_to_cpu(hdr->command) & I2400M_BRH_SIGNATURE_MASK)
- >> I2400M_BRH_SIGNATURE_SHIFT;
-}
-
-
-/*
- * Driver / device setup and internal functions
- */
-void i2400m_init(struct i2400m *);
-int i2400m_reset(struct i2400m *, enum i2400m_reset_type);
-void i2400m_netdev_setup(struct net_device *net_dev);
-int i2400m_sysfs_setup(struct device_driver *);
-void i2400m_sysfs_release(struct device_driver *);
-int i2400m_tx_setup(struct i2400m *);
-void i2400m_wake_tx_work(struct work_struct *);
-void i2400m_tx_release(struct i2400m *);
-
-int i2400m_rx_setup(struct i2400m *);
-void i2400m_rx_release(struct i2400m *);
-
-void i2400m_fw_cache(struct i2400m *);
-void i2400m_fw_uncache(struct i2400m *);
-
-void i2400m_net_rx(struct i2400m *, struct sk_buff *, unsigned, const void *,
- int);
-void i2400m_net_erx(struct i2400m *, struct sk_buff *, enum i2400m_cs);
-void i2400m_net_wake_stop(struct i2400m *);
-enum i2400m_pt;
-int i2400m_tx(struct i2400m *, const void *, size_t, enum i2400m_pt);
-
-#ifdef CONFIG_DEBUG_FS
-void i2400m_debugfs_add(struct i2400m *);
-void i2400m_debugfs_rm(struct i2400m *);
-#else
-static inline void i2400m_debugfs_add(struct i2400m *i2400m) {}
-static inline void i2400m_debugfs_rm(struct i2400m *i2400m) {}
-#endif
-
-/* Initialize/shutdown the device */
-int i2400m_dev_initialize(struct i2400m *);
-void i2400m_dev_shutdown(struct i2400m *);
-
-extern struct attribute_group i2400m_dev_attr_group;
-
-
-/* HDI message's payload description handling */
-
-static inline
-size_t i2400m_pld_size(const struct i2400m_pld *pld)
-{
- return I2400M_PLD_SIZE_MASK & le32_to_cpu(pld->val);
-}
-
-static inline
-enum i2400m_pt i2400m_pld_type(const struct i2400m_pld *pld)
-{
- return (I2400M_PLD_TYPE_MASK & le32_to_cpu(pld->val))
- >> I2400M_PLD_TYPE_SHIFT;
-}
-
-static inline
-void i2400m_pld_set(struct i2400m_pld *pld, size_t size,
- enum i2400m_pt type)
-{
- pld->val = cpu_to_le32(
- ((type << I2400M_PLD_TYPE_SHIFT) & I2400M_PLD_TYPE_MASK)
- | (size & I2400M_PLD_SIZE_MASK));
-}
-
-
-/*
- * API for the bus-specific drivers
- * --------------------------------
- */
-
-static inline
-struct i2400m *i2400m_get(struct i2400m *i2400m)
-{
- dev_hold(i2400m->wimax_dev.net_dev);
- return i2400m;
-}
-
-static inline
-void i2400m_put(struct i2400m *i2400m)
-{
- dev_put(i2400m->wimax_dev.net_dev);
-}
-
-int i2400m_dev_reset_handle(struct i2400m *, const char *);
-int i2400m_pre_reset(struct i2400m *);
-int i2400m_post_reset(struct i2400m *);
-void i2400m_error_recovery(struct i2400m *);
-
-/*
- * _setup()/_release() are called by the probe/disconnect functions of
- * the bus-specific drivers.
- */
-int i2400m_setup(struct i2400m *, enum i2400m_bri bm_flags);
-void i2400m_release(struct i2400m *);
-
-int i2400m_rx(struct i2400m *, struct sk_buff *);
-struct i2400m_msg_hdr *i2400m_tx_msg_get(struct i2400m *, size_t *);
-void i2400m_tx_msg_sent(struct i2400m *);
-
-
-/*
- * Utility functions
- */
-
-static inline
-struct device *i2400m_dev(struct i2400m *i2400m)
-{
- return i2400m->wimax_dev.net_dev->dev.parent;
-}
-
-int i2400m_msg_check_status(const struct i2400m_l3l4_hdr *, char *, size_t);
-int i2400m_msg_size_check(struct i2400m *, const struct i2400m_l3l4_hdr *,
- size_t);
-struct sk_buff *i2400m_msg_to_dev(struct i2400m *, const void *, size_t);
-void i2400m_msg_to_dev_cancel_wait(struct i2400m *, int);
-void i2400m_report_hook(struct i2400m *, const struct i2400m_l3l4_hdr *,
- size_t);
-void i2400m_report_hook_work(struct work_struct *);
-int i2400m_cmd_enter_powersave(struct i2400m *);
-int i2400m_cmd_exit_idle(struct i2400m *);
-struct sk_buff *i2400m_get_device_info(struct i2400m *);
-int i2400m_firmware_check(struct i2400m *);
-int i2400m_set_idle_timeout(struct i2400m *, unsigned);
-
-static inline
-struct usb_endpoint_descriptor *usb_get_epd(struct usb_interface *iface, int ep)
-{
- return &iface->cur_altsetting->endpoint[ep].desc;
-}
-
-int i2400m_op_rfkill_sw_toggle(struct wimax_dev *, enum wimax_rf_state);
-void i2400m_report_tlv_rf_switches_status(struct i2400m *,
- const struct i2400m_tlv_rf_switches_status *);
-
-/*
- * Helpers for firmware backwards compatibility
- *
- * As we aim to support at least the firmware version that was
- * released with the previous kernel/driver release, some code will be
- * conditionally executed depending on the firmware version. On each
- * release, the code to support fw releases past the last two ones
- * will be purged.
- *
- * By making it depend on this macros, it is easier to keep it a tab
- * on what has to go and what not.
- */
-static inline
-unsigned i2400m_le_v1_3(struct i2400m *i2400m)
-{
- /* running fw is lower or v1.3 */
- return i2400m->fw_version <= 0x00090001;
-}
-
-static inline
-unsigned i2400m_ge_v1_4(struct i2400m *i2400m)
-{
- /* running fw is higher or v1.4 */
- return i2400m->fw_version >= 0x00090002;
-}
-
-
-/*
- * Do a millisecond-sleep for allowing wireshark to dump all the data
- * packets. Used only for debugging.
- */
-static inline
-void __i2400m_msleep(unsigned ms)
-{
-#if 1
-#else
- msleep(ms);
-#endif
-}
-
-
-/* module initialization helpers */
-int i2400m_barker_db_init(const char *);
-void i2400m_barker_db_exit(void);
-
-
-
-#endif /* #ifndef __I2400M_H__ */
diff --git a/drivers/staging/wimax/i2400m/linux-wimax-i2400m.h b/drivers/staging/wimax/i2400m/linux-wimax-i2400m.h
deleted file mode 100644
index fd198bc24a3c..000000000000
--- a/drivers/staging/wimax/i2400m/linux-wimax-i2400m.h
+++ /dev/null
@@ -1,572 +0,0 @@
-/*
- * Intel Wireless WiMax Connection 2400m
- * Host-Device protocol interface definitions
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * 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 Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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
- * OWNER 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.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * - Initial implementation
- *
- *
- * This header defines the data structures and constants used to
- * communicate with the device.
- *
- * BOOTMODE/BOOTROM/FIRMWARE UPLOAD PROTOCOL
- *
- * The firmware upload protocol is quite simple and only requires a
- * handful of commands. See drivers/net/wimax/i2400m/fw.c for more
- * details.
- *
- * The BCF data structure is for the firmware file header.
- *
- *
- * THE DATA / CONTROL PROTOCOL
- *
- * This is the normal protocol spoken with the device once the
- * firmware is uploaded. It transports data payloads and control
- * messages back and forth.
- *
- * It consists 'messages' that pack one or more payloads each. The
- * format is described in detail in drivers/net/wimax/i2400m/rx.c and
- * tx.c.
- *
- *
- * THE L3L4 PROTOCOL
- *
- * The term L3L4 refers to Layer 3 (the device), Layer 4 (the
- * driver/host software).
- *
- * This is the control protocol used by the host to control the i2400m
- * device (scan, connect, disconnect...). This is sent to / received
- * as control frames. These frames consist of a header and zero or
- * more TLVs with information. We call each control frame a "message".
- *
- * Each message is composed of:
- *
- * HEADER
- * [TLV0 + PAYLOAD0]
- * [TLV1 + PAYLOAD1]
- * [...]
- * [TLVN + PAYLOADN]
- *
- * The HEADER is defined by 'struct i2400m_l3l4_hdr'. The payloads are
- * defined by a TLV structure (Type Length Value) which is a 'header'
- * (struct i2400m_tlv_hdr) and then the payload.
- *
- * All integers are represented as Little Endian.
- *
- * - REQUESTS AND EVENTS
- *
- * The requests can be clasified as follows:
- *
- * COMMAND: implies a request from the host to the device requesting
- * an action being performed. The device will reply with a
- * message (with the same type as the command), status and
- * no (TLV) payload. Execution of a command might cause
- * events (of different type) to be sent later on as
- * device's state changes.
- *
- * GET/SET: similar to COMMAND, but will not cause other
- * EVENTs. The reply, in the case of GET, will contain
- * TLVs with the requested information.
- *
- * EVENT: asynchronous messages sent from the device, maybe as a
- * consequence of previous COMMANDs but disassociated from
- * them.
- *
- * Only one request might be pending at the same time (ie: don't
- * parallelize nor post another GET request before the previous
- * COMMAND has been acknowledged with it's corresponding reply by the
- * device).
- *
- * The different requests and their formats are described below:
- *
- * I2400M_MT_* Message types
- * I2400M_MS_* Message status (for replies, events)
- * i2400m_tlv_* TLVs
- *
- * data types are named 'struct i2400m_msg_OPNAME', OPNAME matching the
- * operation.
- */
-
-#ifndef __LINUX__WIMAX__I2400M_H__
-#define __LINUX__WIMAX__I2400M_H__
-
-#include <linux/types.h>
-#include <linux/if_ether.h>
-
-/*
- * Host Device Interface (HDI) common to all busses
- */
-
-/* Boot-mode (firmware upload mode) commands */
-
-/* Header for the firmware file */
-struct i2400m_bcf_hdr {
- __le32 module_type;
- __le32 header_len;
- __le32 header_version;
- __le32 module_id;
- __le32 module_vendor;
- __le32 date; /* BCD YYYMMDD */
- __le32 size; /* in dwords */
- __le32 key_size; /* in dwords */
- __le32 modulus_size; /* in dwords */
- __le32 exponent_size; /* in dwords */
- __u8 reserved[88];
-} __attribute__ ((packed));
-
-/* Boot mode opcodes */
-enum i2400m_brh_opcode {
- I2400M_BRH_READ = 1,
- I2400M_BRH_WRITE = 2,
- I2400M_BRH_JUMP = 3,
- I2400M_BRH_SIGNED_JUMP = 8,
- I2400M_BRH_HASH_PAYLOAD_ONLY = 9,
-};
-
-/* Boot mode command masks and stuff */
-enum i2400m_brh {
- I2400M_BRH_SIGNATURE = 0xcbbc0000,
- I2400M_BRH_SIGNATURE_MASK = 0xffff0000,
- I2400M_BRH_SIGNATURE_SHIFT = 16,
- I2400M_BRH_OPCODE_MASK = 0x0000000f,
- I2400M_BRH_RESPONSE_MASK = 0x000000f0,
- I2400M_BRH_RESPONSE_SHIFT = 4,
- I2400M_BRH_DIRECT_ACCESS = 0x00000400,
- I2400M_BRH_RESPONSE_REQUIRED = 0x00000200,
- I2400M_BRH_USE_CHECKSUM = 0x00000100,
-};
-
-
-/**
- * i2400m_bootrom_header - Header for a boot-mode command
- *
- * @cmd: the above command descriptor
- * @target_addr: where on the device memory should the action be performed.
- * @data_size: for read/write, amount of data to be read/written
- * @block_checksum: checksum value (if applicable)
- * @payload: the beginning of data attached to this header
- */
-struct i2400m_bootrom_header {
- __le32 command; /* Compose with enum i2400_brh */
- __le32 target_addr;
- __le32 data_size;
- __le32 block_checksum;
- char payload[0];
-} __attribute__ ((packed));
-
-
-/*
- * Data / control protocol
- */
-
-/* Packet types for the host-device interface */
-enum i2400m_pt {
- I2400M_PT_DATA = 0,
- I2400M_PT_CTRL,
- I2400M_PT_TRACE, /* For device debug */
- I2400M_PT_RESET_WARM, /* device reset */
- I2400M_PT_RESET_COLD, /* USB[transport] reset, like reconnect */
- I2400M_PT_EDATA, /* Extended RX data */
- I2400M_PT_ILLEGAL
-};
-
-
-/*
- * Payload for a data packet
- *
- * This is prefixed to each and every outgoing DATA type.
- */
-struct i2400m_pl_data_hdr {
- __le32 reserved;
-} __attribute__((packed));
-
-
-/*
- * Payload for an extended data packet
- *
- * New in fw v1.4
- *
- * @reorder: if this payload has to be reorder or not (and how)
- * @cs: the type of data in the packet, as defined per (802.16e
- * T11.13.19.1). Currently only 2 (IPv4 packet) supported.
- *
- * This is prefixed to each and every INCOMING DATA packet.
- */
-struct i2400m_pl_edata_hdr {
- __le32 reorder; /* bits defined in i2400m_ro */
- __u8 cs;
- __u8 reserved[11];
-} __attribute__((packed));
-
-enum i2400m_cs {
- I2400M_CS_IPV4_0 = 0,
- I2400M_CS_IPV4 = 2,
-};
-
-enum i2400m_ro {
- I2400M_RO_NEEDED = 0x01,
- I2400M_RO_TYPE = 0x03,
- I2400M_RO_TYPE_SHIFT = 1,
- I2400M_RO_CIN = 0x0f,
- I2400M_RO_CIN_SHIFT = 4,
- I2400M_RO_FBN = 0x07ff,
- I2400M_RO_FBN_SHIFT = 8,
- I2400M_RO_SN = 0x07ff,
- I2400M_RO_SN_SHIFT = 21,
-};
-
-enum i2400m_ro_type {
- I2400M_RO_TYPE_RESET = 0,
- I2400M_RO_TYPE_PACKET,
- I2400M_RO_TYPE_WS,
- I2400M_RO_TYPE_PACKET_WS,
-};
-
-
-/* Misc constants */
-enum {
- I2400M_PL_ALIGN = 16, /* Payload data size alignment */
- I2400M_PL_SIZE_MAX = 0x3EFF,
- I2400M_MAX_PLS_IN_MSG = 60,
- /* protocol barkers: sync sequences; for notifications they
- * are sent in groups of four. */
- I2400M_H2D_PREVIEW_BARKER = 0xcafe900d,
- I2400M_COLD_RESET_BARKER = 0xc01dc01d,
- I2400M_WARM_RESET_BARKER = 0x50f750f7,
- I2400M_NBOOT_BARKER = 0xdeadbeef,
- I2400M_SBOOT_BARKER = 0x0ff1c1a1,
- I2400M_SBOOT_BARKER_6050 = 0x80000001,
- I2400M_ACK_BARKER = 0xfeedbabe,
- I2400M_D2H_MSG_BARKER = 0xbeefbabe,
-};
-
-
-/*
- * Hardware payload descriptor
- *
- * Bitfields encoded in a struct to enforce typing semantics.
- *
- * Look in rx.c and tx.c for a full description of the format.
- */
-struct i2400m_pld {
- __le32 val;
-} __attribute__ ((packed));
-
-#define I2400M_PLD_SIZE_MASK 0x00003fff
-#define I2400M_PLD_TYPE_SHIFT 16
-#define I2400M_PLD_TYPE_MASK 0x000f0000
-
-/*
- * Header for a TX message or RX message
- *
- * @barker: preamble
- * @size: used for management of the FIFO queue buffer; before
- * sending, this is converted to be a real preamble. This
- * indicates the real size of the TX message that starts at this
- * point. If the highest bit is set, then this message is to be
- * skipped.
- * @sequence: sequence number of this message
- * @offset: offset where the message itself starts -- see the comments
- * in the file header about message header and payload descriptor
- * alignment.
- * @num_pls: number of payloads in this message
- * @padding: amount of padding bytes at the end of the message to make
- * it be of block-size aligned
- *
- * Look in rx.c and tx.c for a full description of the format.
- */
-struct i2400m_msg_hdr {
- union {
- __le32 barker;
- __u32 size; /* same size type as barker!! */
- };
- union {
- __le32 sequence;
- __u32 offset; /* same size type as barker!! */
- };
- __le16 num_pls;
- __le16 rsv1;
- __le16 padding;
- __le16 rsv2;
- struct i2400m_pld pld[0];
-} __attribute__ ((packed));
-
-
-
-/*
- * L3/L4 control protocol
- */
-
-enum {
- /* Interface version */
- I2400M_L3L4_VERSION = 0x0100,
-};
-
-/* Message types */
-enum i2400m_mt {
- I2400M_MT_RESERVED = 0x0000,
- I2400M_MT_INVALID = 0xffff,
- I2400M_MT_REPORT_MASK = 0x8000,
-
- I2400M_MT_GET_SCAN_RESULT = 0x4202,
- I2400M_MT_SET_SCAN_PARAM = 0x4402,
- I2400M_MT_CMD_RF_CONTROL = 0x4602,
- I2400M_MT_CMD_SCAN = 0x4603,
- I2400M_MT_CMD_CONNECT = 0x4604,
- I2400M_MT_CMD_DISCONNECT = 0x4605,
- I2400M_MT_CMD_EXIT_IDLE = 0x4606,
- I2400M_MT_GET_LM_VERSION = 0x5201,
- I2400M_MT_GET_DEVICE_INFO = 0x5202,
- I2400M_MT_GET_LINK_STATUS = 0x5203,
- I2400M_MT_GET_STATISTICS = 0x5204,
- I2400M_MT_GET_STATE = 0x5205,
- I2400M_MT_GET_MEDIA_STATUS = 0x5206,
- I2400M_MT_SET_INIT_CONFIG = 0x5404,
- I2400M_MT_CMD_INIT = 0x5601,
- I2400M_MT_CMD_TERMINATE = 0x5602,
- I2400M_MT_CMD_MODE_OF_OP = 0x5603,
- I2400M_MT_CMD_RESET_DEVICE = 0x5604,
- I2400M_MT_CMD_MONITOR_CONTROL = 0x5605,
- I2400M_MT_CMD_ENTER_POWERSAVE = 0x5606,
- I2400M_MT_GET_TLS_OPERATION_RESULT = 0x6201,
- I2400M_MT_SET_EAP_SUCCESS = 0x6402,
- I2400M_MT_SET_EAP_FAIL = 0x6403,
- I2400M_MT_SET_EAP_KEY = 0x6404,
- I2400M_MT_CMD_SEND_EAP_RESPONSE = 0x6602,
- I2400M_MT_REPORT_SCAN_RESULT = 0xc002,
- I2400M_MT_REPORT_STATE = 0xd002,
- I2400M_MT_REPORT_POWERSAVE_READY = 0xd005,
- I2400M_MT_REPORT_EAP_REQUEST = 0xe002,
- I2400M_MT_REPORT_EAP_RESTART = 0xe003,
- I2400M_MT_REPORT_ALT_ACCEPT = 0xe004,
- I2400M_MT_REPORT_KEY_REQUEST = 0xe005,
-};
-
-
-/*
- * Message Ack Status codes
- *
- * When a message is replied-to, this status is reported.
- */
-enum i2400m_ms {
- I2400M_MS_DONE_OK = 0,
- I2400M_MS_DONE_IN_PROGRESS = 1,
- I2400M_MS_INVALID_OP = 2,
- I2400M_MS_BAD_STATE = 3,
- I2400M_MS_ILLEGAL_VALUE = 4,
- I2400M_MS_MISSING_PARAMS = 5,
- I2400M_MS_VERSION_ERROR = 6,
- I2400M_MS_ACCESSIBILITY_ERROR = 7,
- I2400M_MS_BUSY = 8,
- I2400M_MS_CORRUPTED_TLV = 9,
- I2400M_MS_UNINITIALIZED = 10,
- I2400M_MS_UNKNOWN_ERROR = 11,
- I2400M_MS_PRODUCTION_ERROR = 12,
- I2400M_MS_NO_RF = 13,
- I2400M_MS_NOT_READY_FOR_POWERSAVE = 14,
- I2400M_MS_THERMAL_CRITICAL = 15,
- I2400M_MS_MAX
-};
-
-
-/**
- * i2400m_tlv - enumeration of the different types of TLVs
- *
- * TLVs stand for type-length-value and are the header for a payload
- * composed of almost anything. Each payload has a type assigned
- * and a length.
- */
-enum i2400m_tlv {
- I2400M_TLV_L4_MESSAGE_VERSIONS = 129,
- I2400M_TLV_SYSTEM_STATE = 141,
- I2400M_TLV_MEDIA_STATUS = 161,
- I2400M_TLV_RF_OPERATION = 162,
- I2400M_TLV_RF_STATUS = 163,
- I2400M_TLV_DEVICE_RESET_TYPE = 132,
- I2400M_TLV_CONFIG_IDLE_PARAMETERS = 601,
- I2400M_TLV_CONFIG_IDLE_TIMEOUT = 611,
- I2400M_TLV_CONFIG_D2H_DATA_FORMAT = 614,
- I2400M_TLV_CONFIG_DL_HOST_REORDER = 615,
-};
-
-
-struct i2400m_tlv_hdr {
- __le16 type;
- __le16 length; /* payload's */
- __u8 pl[0];
-} __attribute__((packed));
-
-
-struct i2400m_l3l4_hdr {
- __le16 type;
- __le16 length; /* payload's */
- __le16 version;
- __le16 resv1;
- __le16 status;
- __le16 resv2;
- struct i2400m_tlv_hdr pl[0];
-} __attribute__((packed));
-
-
-/**
- * i2400m_system_state - different states of the device
- */
-enum i2400m_system_state {
- I2400M_SS_UNINITIALIZED = 1,
- I2400M_SS_INIT,
- I2400M_SS_READY,
- I2400M_SS_SCAN,
- I2400M_SS_STANDBY,
- I2400M_SS_CONNECTING,
- I2400M_SS_WIMAX_CONNECTED,
- I2400M_SS_DATA_PATH_CONNECTED,
- I2400M_SS_IDLE,
- I2400M_SS_DISCONNECTING,
- I2400M_SS_OUT_OF_ZONE,
- I2400M_SS_SLEEPACTIVE,
- I2400M_SS_PRODUCTION,
- I2400M_SS_CONFIG,
- I2400M_SS_RF_OFF,
- I2400M_SS_RF_SHUTDOWN,
- I2400M_SS_DEVICE_DISCONNECT,
- I2400M_SS_MAX,
-};
-
-
-/**
- * i2400m_tlv_system_state - report on the state of the system
- *
- * @state: see enum i2400m_system_state
- */
-struct i2400m_tlv_system_state {
- struct i2400m_tlv_hdr hdr;
- __le32 state;
-} __attribute__((packed));
-
-
-struct i2400m_tlv_l4_message_versions {
- struct i2400m_tlv_hdr hdr;
- __le16 major;
- __le16 minor;
- __le16 branch;
- __le16 reserved;
-} __attribute__((packed));
-
-
-struct i2400m_tlv_detailed_device_info {
- struct i2400m_tlv_hdr hdr;
- __u8 reserved1[400];
- __u8 mac_address[ETH_ALEN];
- __u8 reserved2[2];
-} __attribute__((packed));
-
-
-enum i2400m_rf_switch_status {
- I2400M_RF_SWITCH_ON = 1,
- I2400M_RF_SWITCH_OFF = 2,
-};
-
-struct i2400m_tlv_rf_switches_status {
- struct i2400m_tlv_hdr hdr;
- __u8 sw_rf_switch; /* 1 ON, 2 OFF */
- __u8 hw_rf_switch; /* 1 ON, 2 OFF */
- __u8 reserved[2];
-} __attribute__((packed));
-
-
-enum {
- i2400m_rf_operation_on = 1,
- i2400m_rf_operation_off = 2
-};
-
-struct i2400m_tlv_rf_operation {
- struct i2400m_tlv_hdr hdr;
- __le32 status; /* 1 ON, 2 OFF */
-} __attribute__((packed));
-
-
-enum i2400m_tlv_reset_type {
- I2400M_RESET_TYPE_COLD = 1,
- I2400M_RESET_TYPE_WARM
-};
-
-struct i2400m_tlv_device_reset_type {
- struct i2400m_tlv_hdr hdr;
- __le32 reset_type;
-} __attribute__((packed));
-
-
-struct i2400m_tlv_config_idle_parameters {
- struct i2400m_tlv_hdr hdr;
- __le32 idle_timeout; /* 100 to 300000 ms [5min], 100 increments
- * 0 disabled */
- __le32 idle_paging_interval; /* frames */
-} __attribute__((packed));
-
-
-enum i2400m_media_status {
- I2400M_MEDIA_STATUS_LINK_UP = 1,
- I2400M_MEDIA_STATUS_LINK_DOWN,
- I2400M_MEDIA_STATUS_LINK_RENEW,
-};
-
-struct i2400m_tlv_media_status {
- struct i2400m_tlv_hdr hdr;
- __le32 media_status;
-} __attribute__((packed));
-
-
-/* New in v1.4 */
-struct i2400m_tlv_config_idle_timeout {
- struct i2400m_tlv_hdr hdr;
- __le32 timeout; /* 100 to 300000 ms [5min], 100 increments
- * 0 disabled */
-} __attribute__((packed));
-
-/* New in v1.4 -- for backward compat, will be removed */
-struct i2400m_tlv_config_d2h_data_format {
- struct i2400m_tlv_hdr hdr;
- __u8 format; /* 0 old format, 1 enhanced */
- __u8 reserved[3];
-} __attribute__((packed));
-
-/* New in v1.4 */
-struct i2400m_tlv_config_dl_host_reorder {
- struct i2400m_tlv_hdr hdr;
- __u8 reorder; /* 0 disabled, 1 enabled */
- __u8 reserved[3];
-} __attribute__((packed));
-
-
-#endif /* #ifndef __LINUX__WIMAX__I2400M_H__ */
diff --git a/drivers/staging/wimax/i2400m/netdev.c b/drivers/staging/wimax/i2400m/netdev.c
deleted file mode 100644
index cd06eaf75e8b..000000000000
--- a/drivers/staging/wimax/i2400m/netdev.c
+++ /dev/null
@@ -1,603 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Glue with the networking stack
- *
- * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * This implements an ethernet device for the i2400m.
- *
- * We fake being an ethernet device to simplify the support from user
- * space and from the other side. The world is (sadly) configured to
- * take in only Ethernet devices...
- *
- * Because of this, when using firmwares <= v1.3, there is an
- * copy-each-rxed-packet overhead on the RX path. Each IP packet has
- * to be reallocated to add an ethernet header (as there is no space
- * in what we get from the device). This is a known drawback and
- * firmwares >= 1.4 add header space that can be used to insert the
- * ethernet header without having to reallocate and copy.
- *
- * TX error handling is tricky; because we have to FIFO/queue the
- * buffers for transmission (as the hardware likes it aggregated), we
- * just give the skb to the TX subsystem and by the time it is
- * transmitted, we have long forgotten about it. So we just don't care
- * too much about it.
- *
- * Note that when the device is in idle mode with the basestation, we
- * need to negotiate coming back up online. That involves negotiation
- * and possible user space interaction. Thus, we defer to a workqueue
- * to do all that. By default, we only queue a single packet and drop
- * the rest, as potentially the time to go back from idle to normal is
- * long.
- *
- * ROADMAP
- *
- * i2400m_open Called on ifconfig up
- * i2400m_stop Called on ifconfig down
- *
- * i2400m_hard_start_xmit Called by the network stack to send a packet
- * i2400m_net_wake_tx Wake up device from basestation-IDLE & TX
- * i2400m_wake_tx_work
- * i2400m_cmd_exit_idle
- * i2400m_tx
- * i2400m_net_tx TX a data frame
- * i2400m_tx
- *
- * i2400m_change_mtu Called on ifconfig mtu XXX
- *
- * i2400m_tx_timeout Called when the device times out
- *
- * i2400m_net_rx Called by the RX code when a data frame is
- * available (firmware <= 1.3)
- * i2400m_net_erx Called by the RX code when a data frame is
- * available (firmware >= 1.4).
- * i2400m_netdev_setup Called to setup all the netdev stuff from
- * alloc_netdev.
- */
-#include <linux/if_arp.h>
-#include <linux/slab.h>
-#include <linux/netdevice.h>
-#include <linux/ethtool.h>
-#include <linux/export.h>
-#include "i2400m.h"
-
-
-#define D_SUBMODULE netdev
-#include "debug-levels.h"
-
-enum {
-/* netdev interface */
- /* 20 secs? yep, this is the maximum timeout that the device
- * might take to get out of IDLE / negotiate it with the base
- * station. We add 1sec for good measure. */
- I2400M_TX_TIMEOUT = 21 * HZ,
- /*
- * Experimentation has determined that, 20 to be a good value
- * for minimizing the jitter in the throughput.
- */
- I2400M_TX_QLEN = 20,
-};
-
-
-static
-int i2400m_open(struct net_device *net_dev)
-{
- int result;
- struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
- struct device *dev = i2400m_dev(i2400m);
-
- d_fnstart(3, dev, "(net_dev %p [i2400m %p])\n", net_dev, i2400m);
- /* Make sure we wait until init is complete... */
- mutex_lock(&i2400m->init_mutex);
- if (i2400m->updown)
- result = 0;
- else
- result = -EBUSY;
- mutex_unlock(&i2400m->init_mutex);
- d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
- net_dev, i2400m, result);
- return result;
-}
-
-
-static
-int i2400m_stop(struct net_device *net_dev)
-{
- struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
- struct device *dev = i2400m_dev(i2400m);
-
- d_fnstart(3, dev, "(net_dev %p [i2400m %p])\n", net_dev, i2400m);
- i2400m_net_wake_stop(i2400m);
- d_fnend(3, dev, "(net_dev %p [i2400m %p]) = 0\n", net_dev, i2400m);
- return 0;
-}
-
-
-/*
- * Wake up the device and transmit a held SKB, then restart the net queue
- *
- * When the device goes into basestation-idle mode, we need to tell it
- * to exit that mode; it will negotiate with the base station, user
- * space may have to intervene to rehandshake crypto and then tell us
- * when it is ready to transmit the packet we have "queued". Still we
- * need to give it sometime after it reports being ok.
- *
- * On error, there is not much we can do. If the error was on TX, we
- * still wake the queue up to see if the next packet will be luckier.
- *
- * If _cmd_exit_idle() fails...well, it could be many things; most
- * commonly it is that something else took the device out of IDLE mode
- * (for example, the base station). In that case we get an -EILSEQ and
- * we are just going to ignore that one. If the device is back to
- * connected, then fine -- if it is someother state, the packet will
- * be dropped anyway.
- */
-void i2400m_wake_tx_work(struct work_struct *ws)
-{
- int result;
- struct i2400m *i2400m = container_of(ws, struct i2400m, wake_tx_ws);
- struct net_device *net_dev = i2400m->wimax_dev.net_dev;
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *skb;
- unsigned long flags;
-
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- skb = i2400m->wake_tx_skb;
- i2400m->wake_tx_skb = NULL;
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-
- d_fnstart(3, dev, "(ws %p i2400m %p skb %p)\n", ws, i2400m, skb);
- result = -EINVAL;
- if (skb == NULL) {
- dev_err(dev, "WAKE&TX: skb disappeared!\n");
- goto out_put;
- }
- /* If we have, somehow, lost the connection after this was
- * queued, don't do anything; this might be the device got
- * reset or just disconnected. */
- if (unlikely(!netif_carrier_ok(net_dev)))
- goto out_kfree;
- result = i2400m_cmd_exit_idle(i2400m);
- if (result == -EILSEQ)
- result = 0;
- if (result < 0) {
- dev_err(dev, "WAKE&TX: device didn't get out of idle: "
- "%d - resetting\n", result);
- i2400m_reset(i2400m, I2400M_RT_BUS);
- goto error;
- }
- result = wait_event_timeout(i2400m->state_wq,
- i2400m->state != I2400M_SS_IDLE,
- net_dev->watchdog_timeo - HZ/2);
- if (result == 0)
- result = -ETIMEDOUT;
- if (result < 0) {
- dev_err(dev, "WAKE&TX: error waiting for device to exit IDLE: "
- "%d - resetting\n", result);
- i2400m_reset(i2400m, I2400M_RT_BUS);
- goto error;
- }
- msleep(20); /* device still needs some time or it drops it */
- result = i2400m_tx(i2400m, skb->data, skb->len, I2400M_PT_DATA);
-error:
- netif_wake_queue(net_dev);
-out_kfree:
- kfree_skb(skb); /* refcount transferred by _hard_start_xmit() */
-out_put:
- i2400m_put(i2400m);
- d_fnend(3, dev, "(ws %p i2400m %p skb %p) = void [%d]\n",
- ws, i2400m, skb, result);
-}
-
-
-/*
- * Prepare the data payload TX header
- *
- * The i2400m expects a 4 byte header in front of a data packet.
- *
- * Because we pretend to be an ethernet device, this packet comes with
- * an ethernet header. Pull it and push our header.
- */
-static
-void i2400m_tx_prep_header(struct sk_buff *skb)
-{
- struct i2400m_pl_data_hdr *pl_hdr;
- skb_pull(skb, ETH_HLEN);
- pl_hdr = skb_push(skb, sizeof(*pl_hdr));
- pl_hdr->reserved = 0;
-}
-
-
-
-/*
- * Cleanup resources acquired during i2400m_net_wake_tx()
- *
- * This is called by __i2400m_dev_stop and means we have to make sure
- * the workqueue is flushed from any pending work.
- */
-void i2400m_net_wake_stop(struct i2400m *i2400m)
-{
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *wake_tx_skb;
- unsigned long flags;
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
- /*
- * See i2400m_hard_start_xmit(), references are taken there and
- * here we release them if the packet was still pending.
- */
- cancel_work_sync(&i2400m->wake_tx_ws);
-
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- wake_tx_skb = i2400m->wake_tx_skb;
- i2400m->wake_tx_skb = NULL;
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-
- if (wake_tx_skb) {
- i2400m_put(i2400m);
- kfree_skb(wake_tx_skb);
- }
-
- d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
-
-
-/*
- * TX an skb to an idle device
- *
- * When the device is in basestation-idle mode, we need to wake it up
- * and then TX. So we queue a work_struct for doing so.
- *
- * We need to get an extra ref for the skb (so it is not dropped), as
- * well as be careful not to queue more than one request (won't help
- * at all). If more than one request comes or there are errors, we
- * just drop the packets (see i2400m_hard_start_xmit()).
- */
-static
-int i2400m_net_wake_tx(struct i2400m *i2400m, struct net_device *net_dev,
- struct sk_buff *skb)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- unsigned long flags;
-
- d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev);
- if (net_ratelimit()) {
- d_printf(3, dev, "WAKE&NETTX: "
- "skb %p sending %d bytes to radio\n",
- skb, skb->len);
- d_dump(4, dev, skb->data, skb->len);
- }
- /* We hold a ref count for i2400m and skb, so when
- * stopping() the device, we need to cancel that work
- * and if pending, release those resources. */
- result = 0;
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- if (!i2400m->wake_tx_skb) {
- netif_stop_queue(net_dev);
- i2400m_get(i2400m);
- i2400m->wake_tx_skb = skb_get(skb); /* transfer ref count */
- i2400m_tx_prep_header(skb);
- result = schedule_work(&i2400m->wake_tx_ws);
- WARN_ON(result == 0);
- }
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
- if (result == 0) {
- /* Yes, this happens even if we stopped the
- * queue -- blame the queue disciplines that
- * queue without looking -- I guess there is a reason
- * for that. */
- if (net_ratelimit())
- d_printf(1, dev, "NETTX: device exiting idle, "
- "dropping skb %p, queue running %d\n",
- skb, netif_queue_stopped(net_dev));
- result = -EBUSY;
- }
- d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result);
- return result;
-}
-
-
-/*
- * Transmit a packet to the base station on behalf of the network stack.
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * We need to pull the ethernet header and add the hardware header,
- * which is currently set to all zeroes and reserved.
- */
-static
-int i2400m_net_tx(struct i2400m *i2400m, struct net_device *net_dev,
- struct sk_buff *skb)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
-
- d_fnstart(3, dev, "(i2400m %p net_dev %p skb %p)\n",
- i2400m, net_dev, skb);
- /* FIXME: check eth hdr, only IPv4 is routed by the device as of now */
- netif_trans_update(net_dev);
- i2400m_tx_prep_header(skb);
- d_printf(3, dev, "NETTX: skb %p sending %d bytes to radio\n",
- skb, skb->len);
- d_dump(4, dev, skb->data, skb->len);
- result = i2400m_tx(i2400m, skb->data, skb->len, I2400M_PT_DATA);
- d_fnend(3, dev, "(i2400m %p net_dev %p skb %p) = %d\n",
- i2400m, net_dev, skb, result);
- return result;
-}
-
-
-/*
- * Transmit a packet to the base station on behalf of the network stack
- *
- *
- * Returns: NETDEV_TX_OK (always, even in case of error)
- *
- * In case of error, we just drop it. Reasons:
- *
- * - we add a hw header to each skb, and if the network stack
- * retries, we have no way to know if that skb has it or not.
- *
- * - network protocols have their own drop-recovery mechanisms
- *
- * - there is not much else we can do
- *
- * If the device is idle, we need to wake it up; that is an operation
- * that will sleep. See i2400m_net_wake_tx() for details.
- */
-static
-netdev_tx_t i2400m_hard_start_xmit(struct sk_buff *skb,
- struct net_device *net_dev)
-{
- struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
- struct device *dev = i2400m_dev(i2400m);
- int result = -1;
-
- d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev);
-
- if (skb_cow_head(skb, 0))
- goto drop;
-
- if (i2400m->state == I2400M_SS_IDLE)
- result = i2400m_net_wake_tx(i2400m, net_dev, skb);
- else
- result = i2400m_net_tx(i2400m, net_dev, skb);
- if (result < 0) {
-drop:
- net_dev->stats.tx_dropped++;
- } else {
- net_dev->stats.tx_packets++;
- net_dev->stats.tx_bytes += skb->len;
- }
- dev_kfree_skb(skb);
- d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result);
- return NETDEV_TX_OK;
-}
-
-
-static
-void i2400m_tx_timeout(struct net_device *net_dev, unsigned int txqueue)
-{
- /*
- * We might want to kick the device
- *
- * There is not much we can do though, as the device requires
- * that we send the data aggregated. By the time we receive
- * this, there might be data pending to be sent or not...
- */
- net_dev->stats.tx_errors++;
-}
-
-
-/*
- * Create a fake ethernet header
- *
- * For emulating an ethernet device, every received IP header has to
- * be prefixed with an ethernet header. Fake it with the given
- * protocol.
- */
-static
-void i2400m_rx_fake_eth_header(struct net_device *net_dev,
- void *_eth_hdr, __be16 protocol)
-{
- struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
- struct ethhdr *eth_hdr = _eth_hdr;
-
- memcpy(eth_hdr->h_dest, net_dev->dev_addr, sizeof(eth_hdr->h_dest));
- memcpy(eth_hdr->h_source, i2400m->src_mac_addr,
- sizeof(eth_hdr->h_source));
- eth_hdr->h_proto = protocol;
-}
-
-
-/*
- * i2400m_net_rx - pass a network packet to the stack
- *
- * @i2400m: device instance
- * @skb_rx: the skb where the buffer pointed to by @buf is
- * @i: 1 if payload is the only one
- * @buf: pointer to the buffer containing the data
- * @len: buffer's length
- *
- * This is only used now for the v1.3 firmware. It will be deprecated
- * in >= 2.6.31.
- *
- * Note that due to firmware limitations, we don't have space to add
- * an ethernet header, so we need to copy each packet. Firmware
- * versions >= v1.4 fix this [see i2400m_net_erx()].
- *
- * We just clone the skb and set it up so that it's skb->data pointer
- * points to "buf" and it's length.
- *
- * Note that if the payload is the last (or the only one) in a
- * multi-payload message, we don't clone the SKB but just reuse it.
- *
- * This function is normally run from a thread context. However, we
- * still use netif_rx() instead of netif_receive_skb() as was
- * recommended in the mailing list. Reason is in some stress tests
- * when sending/receiving a lot of data we seem to hit a softlock in
- * the kernel's TCP implementation [aroudn tcp_delay_timer()]. Using
- * netif_rx() took care of the issue.
- *
- * This is, of course, still open to do more research on why running
- * with netif_receive_skb() hits this softlock. FIXME.
- *
- * FIXME: currently we don't do any efforts at distinguishing if what
- * we got was an IPv4 or IPv6 header, to setup the protocol field
- * correctly.
- */
-void i2400m_net_rx(struct i2400m *i2400m, struct sk_buff *skb_rx,
- unsigned i, const void *buf, int buf_len)
-{
- struct net_device *net_dev = i2400m->wimax_dev.net_dev;
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *skb;
-
- d_fnstart(2, dev, "(i2400m %p buf %p buf_len %d)\n",
- i2400m, buf, buf_len);
- if (i) {
- skb = skb_get(skb_rx);
- d_printf(2, dev, "RX: reusing first payload skb %p\n", skb);
- skb_pull(skb, buf - (void *) skb->data);
- skb_trim(skb, (void *) skb_end_pointer(skb) - buf);
- } else {
- /* Yes, this is bad -- a lot of overhead -- see
- * comments at the top of the file */
- skb = __netdev_alloc_skb(net_dev, buf_len, GFP_KERNEL);
- if (skb == NULL) {
- dev_err(dev, "NETRX: no memory to realloc skb\n");
- net_dev->stats.rx_dropped++;
- goto error_skb_realloc;
- }
- skb_put_data(skb, buf, buf_len);
- }
- i2400m_rx_fake_eth_header(i2400m->wimax_dev.net_dev,
- skb->data - ETH_HLEN,
- cpu_to_be16(ETH_P_IP));
- skb_set_mac_header(skb, -ETH_HLEN);
- skb->dev = i2400m->wimax_dev.net_dev;
- skb->protocol = htons(ETH_P_IP);
- net_dev->stats.rx_packets++;
- net_dev->stats.rx_bytes += buf_len;
- d_printf(3, dev, "NETRX: receiving %d bytes to network stack\n",
- buf_len);
- d_dump(4, dev, buf, buf_len);
- netif_rx_ni(skb); /* see notes in function header */
-error_skb_realloc:
- d_fnend(2, dev, "(i2400m %p buf %p buf_len %d) = void\n",
- i2400m, buf, buf_len);
-}
-
-
-/*
- * i2400m_net_erx - pass a network packet to the stack (extended version)
- *
- * @i2400m: device descriptor
- * @skb: the skb where the packet is - the skb should be set to point
- * at the IP packet; this function will add ethernet headers if
- * needed.
- * @cs: packet type
- *
- * This is only used now for firmware >= v1.4. Note it is quite
- * similar to i2400m_net_rx() (used only for v1.3 firmware).
- *
- * This function is normally run from a thread context. However, we
- * still use netif_rx() instead of netif_receive_skb() as was
- * recommended in the mailing list. Reason is in some stress tests
- * when sending/receiving a lot of data we seem to hit a softlock in
- * the kernel's TCP implementation [aroudn tcp_delay_timer()]. Using
- * netif_rx() took care of the issue.
- *
- * This is, of course, still open to do more research on why running
- * with netif_receive_skb() hits this softlock. FIXME.
- */
-void i2400m_net_erx(struct i2400m *i2400m, struct sk_buff *skb,
- enum i2400m_cs cs)
-{
- struct net_device *net_dev = i2400m->wimax_dev.net_dev;
- struct device *dev = i2400m_dev(i2400m);
-
- d_fnstart(2, dev, "(i2400m %p skb %p [%u] cs %d)\n",
- i2400m, skb, skb->len, cs);
- switch(cs) {
- case I2400M_CS_IPV4_0:
- case I2400M_CS_IPV4:
- i2400m_rx_fake_eth_header(i2400m->wimax_dev.net_dev,
- skb->data - ETH_HLEN,
- cpu_to_be16(ETH_P_IP));
- skb_set_mac_header(skb, -ETH_HLEN);
- skb->dev = i2400m->wimax_dev.net_dev;
- skb->protocol = htons(ETH_P_IP);
- net_dev->stats.rx_packets++;
- net_dev->stats.rx_bytes += skb->len;
- break;
- default:
- dev_err(dev, "ERX: BUG? CS type %u unsupported\n", cs);
- goto error;
-
- }
- d_printf(3, dev, "ERX: receiving %d bytes to the network stack\n",
- skb->len);
- d_dump(4, dev, skb->data, skb->len);
- netif_rx_ni(skb); /* see notes in function header */
-error:
- d_fnend(2, dev, "(i2400m %p skb %p [%u] cs %d) = void\n",
- i2400m, skb, skb->len, cs);
-}
-
-static const struct net_device_ops i2400m_netdev_ops = {
- .ndo_open = i2400m_open,
- .ndo_stop = i2400m_stop,
- .ndo_start_xmit = i2400m_hard_start_xmit,
- .ndo_tx_timeout = i2400m_tx_timeout,
-};
-
-static void i2400m_get_drvinfo(struct net_device *net_dev,
- struct ethtool_drvinfo *info)
-{
- struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
-
- strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
- strscpy(info->fw_version, i2400m->fw_name ? : "",
- sizeof(info->fw_version));
- if (net_dev->dev.parent)
- strscpy(info->bus_info, dev_name(net_dev->dev.parent),
- sizeof(info->bus_info));
-}
-
-static const struct ethtool_ops i2400m_ethtool_ops = {
- .get_drvinfo = i2400m_get_drvinfo,
- .get_link = ethtool_op_get_link,
-};
-
-/*
- * i2400m_netdev_setup - Setup setup @net_dev's i2400m private data
- *
- * Called by alloc_netdev()
- */
-void i2400m_netdev_setup(struct net_device *net_dev)
-{
- d_fnstart(3, NULL, "(net_dev %p)\n", net_dev);
- ether_setup(net_dev);
- net_dev->mtu = I2400M_MAX_MTU;
- net_dev->min_mtu = 0;
- net_dev->max_mtu = I2400M_MAX_MTU;
- net_dev->tx_queue_len = I2400M_TX_QLEN;
- net_dev->features =
- NETIF_F_VLAN_CHALLENGED
- | NETIF_F_HIGHDMA;
- net_dev->flags =
- IFF_NOARP /* i2400m is apure IP device */
- & (~IFF_BROADCAST /* i2400m is P2P */
- & ~IFF_MULTICAST);
- net_dev->watchdog_timeo = I2400M_TX_TIMEOUT;
- net_dev->netdev_ops = &i2400m_netdev_ops;
- net_dev->ethtool_ops = &i2400m_ethtool_ops;
- d_fnend(3, NULL, "(net_dev %p) = void\n", net_dev);
-}
-EXPORT_SYMBOL_GPL(i2400m_netdev_setup);
-
diff --git a/drivers/staging/wimax/i2400m/op-rfkill.c b/drivers/staging/wimax/i2400m/op-rfkill.c
deleted file mode 100644
index fbddf2e18c14..000000000000
--- a/drivers/staging/wimax/i2400m/op-rfkill.c
+++ /dev/null
@@ -1,196 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Implement backend for the WiMAX stack rfkill support
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * The WiMAX kernel stack integrates into RF-Kill and keeps the
- * switches's status. We just need to:
- *
- * - report changes in the HW RF Kill switch [with
- * wimax_rfkill_{sw,hw}_report(), which happens when we detect those
- * indications coming through hardware reports]. We also do it on
- * initialization to let the stack know the initial HW state.
- *
- * - implement indications from the stack to change the SW RF Kill
- * switch (coming from sysfs, the wimax stack or user space).
- */
-#include "i2400m.h"
-#include "linux-wimax-i2400m.h"
-#include <linux/slab.h>
-
-
-
-#define D_SUBMODULE rfkill
-#include "debug-levels.h"
-
-/*
- * Return true if the i2400m radio is in the requested wimax_rf_state state
- *
- */
-static
-int i2400m_radio_is(struct i2400m *i2400m, enum wimax_rf_state state)
-{
- if (state == WIMAX_RF_OFF)
- return i2400m->state == I2400M_SS_RF_OFF
- || i2400m->state == I2400M_SS_RF_SHUTDOWN;
- else if (state == WIMAX_RF_ON)
- /* state == WIMAX_RF_ON */
- return i2400m->state != I2400M_SS_RF_OFF
- && i2400m->state != I2400M_SS_RF_SHUTDOWN;
- else {
- BUG();
- return -EINVAL; /* shut gcc warnings on certain arches */
- }
-}
-
-
-/*
- * WiMAX stack operation: implement SW RFKill toggling
- *
- * @wimax_dev: device descriptor
- * @skb: skb where the message has been received; skb->data is
- * expected to point to the message payload.
- * @genl_info: passed by the generic netlink layer
- *
- * Generic Netlink will call this function when a message is sent from
- * userspace to change the software RF-Kill switch status.
- *
- * This function will set the device's software RF-Kill switch state to
- * match what is requested.
- *
- * NOTE: the i2400m has a strict state machine; we can only set the
- * RF-Kill switch when it is on, the HW RF-Kill is on and the
- * device is initialized. So we ignore errors steaming from not
- * being in the right state (-EILSEQ).
- */
-int i2400m_op_rfkill_sw_toggle(struct wimax_dev *wimax_dev,
- enum wimax_rf_state state)
-{
- int result;
- struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *ack_skb;
- struct {
- struct i2400m_l3l4_hdr hdr;
- struct i2400m_tlv_rf_operation sw_rf;
- } __packed *cmd;
- char strerr[32];
-
- d_fnstart(4, dev, "(wimax_dev %p state %d)\n", wimax_dev, state);
-
- result = -ENOMEM;
- cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
- if (cmd == NULL)
- goto error_alloc;
- cmd->hdr.type = cpu_to_le16(I2400M_MT_CMD_RF_CONTROL);
- cmd->hdr.length = sizeof(cmd->sw_rf);
- cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
- cmd->sw_rf.hdr.type = cpu_to_le16(I2400M_TLV_RF_OPERATION);
- cmd->sw_rf.hdr.length = cpu_to_le16(sizeof(cmd->sw_rf.status));
- switch (state) {
- case WIMAX_RF_OFF: /* RFKILL ON, radio OFF */
- cmd->sw_rf.status = cpu_to_le32(2);
- break;
- case WIMAX_RF_ON: /* RFKILL OFF, radio ON */
- cmd->sw_rf.status = cpu_to_le32(1);
- break;
- default:
- BUG();
- }
-
- ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
- result = PTR_ERR(ack_skb);
- if (IS_ERR(ack_skb)) {
- dev_err(dev, "Failed to issue 'RF Control' command: %d\n",
- result);
- goto error_msg_to_dev;
- }
- result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
- strerr, sizeof(strerr));
- if (result < 0) {
- dev_err(dev, "'RF Control' (0x%04x) command failed: %d - %s\n",
- I2400M_MT_CMD_RF_CONTROL, result, strerr);
- goto error_cmd;
- }
-
- /* Now we wait for the state to change to RADIO_OFF or RADIO_ON */
- result = wait_event_timeout(
- i2400m->state_wq, i2400m_radio_is(i2400m, state),
- 5 * HZ);
- if (result == 0)
- result = -ETIMEDOUT;
- if (result < 0)
- dev_err(dev, "Error waiting for device to toggle RF state: "
- "%d\n", result);
- result = 0;
-error_cmd:
- kfree_skb(ack_skb);
-error_msg_to_dev:
-error_alloc:
- d_fnend(4, dev, "(wimax_dev %p state %d) = %d\n",
- wimax_dev, state, result);
- kfree(cmd);
- return result;
-}
-
-
-/*
- * Inform the WiMAX stack of changes in the RF Kill switches reported
- * by the device
- *
- * @i2400m: device descriptor
- * @rfss: TLV for RF Switches status; already validated
- *
- * NOTE: the reports on RF switch status cannot be trusted
- * or used until the device is in a state of RADIO_OFF
- * or greater.
- */
-void i2400m_report_tlv_rf_switches_status(
- struct i2400m *i2400m,
- const struct i2400m_tlv_rf_switches_status *rfss)
-{
- struct device *dev = i2400m_dev(i2400m);
- enum i2400m_rf_switch_status hw, sw;
- enum wimax_st wimax_state;
-
- sw = le32_to_cpu(rfss->sw_rf_switch);
- hw = le32_to_cpu(rfss->hw_rf_switch);
-
- d_fnstart(3, dev, "(i2400m %p rfss %p [hw %u sw %u])\n",
- i2400m, rfss, hw, sw);
- /* We only process rw switch evens when the device has been
- * fully initialized */
- wimax_state = wimax_state_get(&i2400m->wimax_dev);
- if (wimax_state < WIMAX_ST_RADIO_OFF) {
- d_printf(3, dev, "ignoring RF switches report, state %u\n",
- wimax_state);
- goto out;
- }
- switch (sw) {
- case I2400M_RF_SWITCH_ON: /* RF Kill disabled (radio on) */
- wimax_report_rfkill_sw(&i2400m->wimax_dev, WIMAX_RF_ON);
- break;
- case I2400M_RF_SWITCH_OFF: /* RF Kill enabled (radio off) */
- wimax_report_rfkill_sw(&i2400m->wimax_dev, WIMAX_RF_OFF);
- break;
- default:
- dev_err(dev, "HW BUG? Unknown RF SW state 0x%x\n", sw);
- }
-
- switch (hw) {
- case I2400M_RF_SWITCH_ON: /* RF Kill disabled (radio on) */
- wimax_report_rfkill_hw(&i2400m->wimax_dev, WIMAX_RF_ON);
- break;
- case I2400M_RF_SWITCH_OFF: /* RF Kill enabled (radio off) */
- wimax_report_rfkill_hw(&i2400m->wimax_dev, WIMAX_RF_OFF);
- break;
- default:
- dev_err(dev, "HW BUG? Unknown RF HW state 0x%x\n", hw);
- }
-out:
- d_fnend(3, dev, "(i2400m %p rfss %p [hw %u sw %u]) = void\n",
- i2400m, rfss, hw, sw);
-}
diff --git a/drivers/staging/wimax/i2400m/rx.c b/drivers/staging/wimax/i2400m/rx.c
deleted file mode 100644
index 702a1e2fabcd..000000000000
--- a/drivers/staging/wimax/i2400m/rx.c
+++ /dev/null
@@ -1,1394 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Handle incoming traffic and deliver it to the control or data planes
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * 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 Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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
- * OWNER 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.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * - Initial implementation
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * - Use skb_clone(), break up processing in chunks
- * - Split transport/device specific
- * - Make buffer size dynamic to exert less memory pressure
- * - RX reorder support
- *
- * This handles the RX path.
- *
- * We receive an RX message from the bus-specific driver, which
- * contains one or more payloads that have potentially different
- * destinataries (data or control paths).
- *
- * So we just take that payload from the transport specific code in
- * the form of an skb, break it up in chunks (a cloned skb each in the
- * case of network packets) and pass it to netdev or to the
- * command/ack handler (and from there to the WiMAX stack).
- *
- * PROTOCOL FORMAT
- *
- * The format of the buffer is:
- *
- * HEADER (struct i2400m_msg_hdr)
- * PAYLOAD DESCRIPTOR 0 (struct i2400m_pld)
- * PAYLOAD DESCRIPTOR 1
- * ...
- * PAYLOAD DESCRIPTOR N
- * PAYLOAD 0 (raw bytes)
- * PAYLOAD 1
- * ...
- * PAYLOAD N
- *
- * See tx.c for a deeper description on alignment requirements and
- * other fun facts of it.
- *
- * DATA PACKETS
- *
- * In firmwares <= v1.3, data packets have no header for RX, but they
- * do for TX (currently unused).
- *
- * In firmware >= 1.4, RX packets have an extended header (16
- * bytes). This header conveys information for management of host
- * reordering of packets (the device offloads storage of the packets
- * for reordering to the host). Read below for more information.
- *
- * The header is used as dummy space to emulate an ethernet header and
- * thus be able to act as an ethernet device without having to reallocate.
- *
- * DATA RX REORDERING
- *
- * Starting in firmware v1.4, the device can deliver packets for
- * delivery with special reordering information; this allows it to
- * more effectively do packet management when some frames were lost in
- * the radio traffic.
- *
- * Thus, for RX packets that come out of order, the device gives the
- * driver enough information to queue them properly and then at some
- * point, the signal to deliver the whole (or part) of the queued
- * packets to the networking stack. There are 16 such queues.
- *
- * This only happens when a packet comes in with the "need reorder"
- * flag set in the RX header. When such bit is set, the following
- * operations might be indicated:
- *
- * - reset queue: send all queued packets to the OS
- *
- * - queue: queue a packet
- *
- * - update ws: update the queue's window start and deliver queued
- * packets that meet the criteria
- *
- * - queue & update ws: queue a packet, update the window start and
- * deliver queued packets that meet the criteria
- *
- * (delivery criteria: the packet's [normalized] sequence number is
- * lower than the new [normalized] window start).
- *
- * See the i2400m_roq_*() functions for details.
- *
- * ROADMAP
- *
- * i2400m_rx
- * i2400m_rx_msg_hdr_check
- * i2400m_rx_pl_descr_check
- * i2400m_rx_payload
- * i2400m_net_rx
- * i2400m_rx_edata
- * i2400m_net_erx
- * i2400m_roq_reset
- * i2400m_net_erx
- * i2400m_roq_queue
- * __i2400m_roq_queue
- * i2400m_roq_update_ws
- * __i2400m_roq_update_ws
- * i2400m_net_erx
- * i2400m_roq_queue_update_ws
- * __i2400m_roq_queue
- * __i2400m_roq_update_ws
- * i2400m_net_erx
- * i2400m_rx_ctl
- * i2400m_msg_size_check
- * i2400m_report_hook_work [in a workqueue]
- * i2400m_report_hook
- * wimax_msg_to_user
- * i2400m_rx_ctl_ack
- * wimax_msg_to_user_alloc
- * i2400m_rx_trace
- * i2400m_msg_size_check
- * wimax_msg
- */
-#include <linux/slab.h>
-#include <linux/kernel.h>
-#include <linux/if_arp.h>
-#include <linux/netdevice.h>
-#include <linux/workqueue.h>
-#include <linux/export.h>
-#include <linux/moduleparam.h>
-#include "i2400m.h"
-
-
-#define D_SUBMODULE rx
-#include "debug-levels.h"
-
-static int i2400m_rx_reorder_disabled; /* 0 (rx reorder enabled) by default */
-module_param_named(rx_reorder_disabled, i2400m_rx_reorder_disabled, int, 0644);
-MODULE_PARM_DESC(rx_reorder_disabled,
- "If true, RX reordering will be disabled.");
-
-struct i2400m_report_hook_args {
- struct sk_buff *skb_rx;
- const struct i2400m_l3l4_hdr *l3l4_hdr;
- size_t size;
- struct list_head list_node;
-};
-
-
-/*
- * Execute i2400m_report_hook in a workqueue
- *
- * Goes over the list of queued reports in i2400m->rx_reports and
- * processes them.
- *
- * NOTE: refcounts on i2400m are not needed because we flush the
- * workqueue this runs on (i2400m->work_queue) before destroying
- * i2400m.
- */
-void i2400m_report_hook_work(struct work_struct *ws)
-{
- struct i2400m *i2400m = container_of(ws, struct i2400m, rx_report_ws);
- struct device *dev = i2400m_dev(i2400m);
- struct i2400m_report_hook_args *args, *args_next;
- LIST_HEAD(list);
- unsigned long flags;
-
- while (1) {
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- list_splice_init(&i2400m->rx_reports, &list);
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- if (list_empty(&list))
- break;
- else
- d_printf(1, dev, "processing queued reports\n");
- list_for_each_entry_safe(args, args_next, &list, list_node) {
- d_printf(2, dev, "processing queued report %p\n", args);
- i2400m_report_hook(i2400m, args->l3l4_hdr, args->size);
- kfree_skb(args->skb_rx);
- list_del(&args->list_node);
- kfree(args);
- }
- }
-}
-
-
-/*
- * Flush the list of queued reports
- */
-static
-void i2400m_report_hook_flush(struct i2400m *i2400m)
-{
- struct device *dev = i2400m_dev(i2400m);
- struct i2400m_report_hook_args *args, *args_next;
- LIST_HEAD(list);
- unsigned long flags;
-
- d_printf(1, dev, "flushing queued reports\n");
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- list_splice_init(&i2400m->rx_reports, &list);
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- list_for_each_entry_safe(args, args_next, &list, list_node) {
- d_printf(2, dev, "flushing queued report %p\n", args);
- kfree_skb(args->skb_rx);
- list_del(&args->list_node);
- kfree(args);
- }
-}
-
-
-/*
- * Queue a report for later processing
- *
- * @i2400m: device descriptor
- * @skb_rx: skb that contains the payload (for reference counting)
- * @l3l4_hdr: pointer to the control
- * @size: size of the message
- */
-static
-void i2400m_report_hook_queue(struct i2400m *i2400m, struct sk_buff *skb_rx,
- const void *l3l4_hdr, size_t size)
-{
- struct device *dev = i2400m_dev(i2400m);
- unsigned long flags;
- struct i2400m_report_hook_args *args;
-
- args = kzalloc(sizeof(*args), GFP_NOIO);
- if (args) {
- args->skb_rx = skb_get(skb_rx);
- args->l3l4_hdr = l3l4_hdr;
- args->size = size;
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- list_add_tail(&args->list_node, &i2400m->rx_reports);
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- d_printf(2, dev, "queued report %p\n", args);
- rmb(); /* see i2400m->ready's documentation */
- if (likely(i2400m->ready)) /* only send if up */
- queue_work(i2400m->work_queue, &i2400m->rx_report_ws);
- } else {
- if (printk_ratelimit())
- dev_err(dev, "%s:%u: Can't allocate %zu B\n",
- __func__, __LINE__, sizeof(*args));
- }
-}
-
-
-/*
- * Process an ack to a command
- *
- * @i2400m: device descriptor
- * @payload: pointer to message
- * @size: size of the message
- *
- * Pass the acknodledgment (in an skb) to the thread that is waiting
- * for it in i2400m->msg_completion.
- *
- * We need to coordinate properly with the thread waiting for the
- * ack. Check if it is waiting or if it is gone. We loose the spinlock
- * to avoid allocating on atomic contexts (yeah, could use GFP_ATOMIC,
- * but this is not so speed critical).
- */
-static
-void i2400m_rx_ctl_ack(struct i2400m *i2400m,
- const void *payload, size_t size)
-{
- struct device *dev = i2400m_dev(i2400m);
- struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
- unsigned long flags;
- struct sk_buff *ack_skb;
-
- /* Anyone waiting for an answer? */
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- if (i2400m->ack_skb != ERR_PTR(-EINPROGRESS)) {
- dev_err(dev, "Huh? reply to command with no waiters\n");
- goto error_no_waiter;
- }
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-
- ack_skb = wimax_msg_alloc(wimax_dev, NULL, payload, size, GFP_KERNEL);
-
- /* Check waiter didn't time out waiting for the answer... */
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- if (i2400m->ack_skb != ERR_PTR(-EINPROGRESS)) {
- d_printf(1, dev, "Huh? waiter for command reply cancelled\n");
- goto error_waiter_cancelled;
- }
- if (IS_ERR(ack_skb))
- dev_err(dev, "CMD/GET/SET ack: cannot allocate SKB\n");
- i2400m->ack_skb = ack_skb;
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- complete(&i2400m->msg_completion);
- return;
-
-error_waiter_cancelled:
- if (!IS_ERR(ack_skb))
- kfree_skb(ack_skb);
-error_no_waiter:
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-}
-
-
-/*
- * Receive and process a control payload
- *
- * @i2400m: device descriptor
- * @skb_rx: skb that contains the payload (for reference counting)
- * @payload: pointer to message
- * @size: size of the message
- *
- * There are two types of control RX messages: reports (asynchronous,
- * like your every day interrupts) and 'acks' (reponses to a command,
- * get or set request).
- *
- * If it is a report, we run hooks on it (to extract information for
- * things we need to do in the driver) and then pass it over to the
- * WiMAX stack to send it to user space.
- *
- * NOTE: report processing is done in a workqueue specific to the
- * generic driver, to avoid deadlocks in the system.
- *
- * If it is not a report, it is an ack to a previously executed
- * command, set or get, so wake up whoever is waiting for it from
- * i2400m_msg_to_dev(). i2400m_rx_ctl_ack() takes care of that.
- *
- * Note that the sizes we pass to other functions from here are the
- * sizes of the _l3l4_hdr + payload, not full buffer sizes, as we have
- * verified in _msg_size_check() that they are congruent.
- *
- * For reports: We can't clone the original skb where the data is
- * because we need to send this up via netlink; netlink has to add
- * headers and we can't overwrite what's preceding the payload...as
- * it is another message. So we just dup them.
- */
-static
-void i2400m_rx_ctl(struct i2400m *i2400m, struct sk_buff *skb_rx,
- const void *payload, size_t size)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- const struct i2400m_l3l4_hdr *l3l4_hdr = payload;
- unsigned msg_type;
-
- result = i2400m_msg_size_check(i2400m, l3l4_hdr, size);
- if (result < 0) {
- dev_err(dev, "HW BUG? device sent a bad message: %d\n",
- result);
- goto error_check;
- }
- msg_type = le16_to_cpu(l3l4_hdr->type);
- d_printf(1, dev, "%s 0x%04x: %zu bytes\n",
- msg_type & I2400M_MT_REPORT_MASK ? "REPORT" : "CMD/SET/GET",
- msg_type, size);
- d_dump(2, dev, l3l4_hdr, size);
- if (msg_type & I2400M_MT_REPORT_MASK) {
- /*
- * Process each report
- *
- * - has to be ran serialized as well
- *
- * - the handling might force the execution of
- * commands. That might cause reentrancy issues with
- * bus-specific subdrivers and workqueues, so the we
- * run it in a separate workqueue.
- *
- * - when the driver is not yet ready to handle them,
- * they are queued and at some point the queue is
- * restarted [NOTE: we can't queue SKBs directly, as
- * this might be a piece of a SKB, not the whole
- * thing, and this is cheaper than cloning the
- * SKB].
- *
- * Note we don't do refcounting for the device
- * structure; this is because before destroying
- * 'i2400m', we make sure to flush the
- * i2400m->work_queue, so there are no issues.
- */
- i2400m_report_hook_queue(i2400m, skb_rx, l3l4_hdr, size);
- if (unlikely(i2400m->trace_msg_from_user))
- wimax_msg(&i2400m->wimax_dev, "echo",
- l3l4_hdr, size, GFP_KERNEL);
- result = wimax_msg(&i2400m->wimax_dev, NULL, l3l4_hdr, size,
- GFP_KERNEL);
- if (result < 0)
- dev_err(dev, "error sending report to userspace: %d\n",
- result);
- } else /* an ack to a CMD, GET or SET */
- i2400m_rx_ctl_ack(i2400m, payload, size);
-error_check:
- return;
-}
-
-
-/*
- * Receive and send up a trace
- *
- * @i2400m: device descriptor
- * @skb_rx: skb that contains the trace (for reference counting)
- * @payload: pointer to trace message inside the skb
- * @size: size of the message
- *
- * THe i2400m might produce trace information (diagnostics) and we
- * send them through a different kernel-to-user pipe (to avoid
- * clogging it).
- *
- * As in i2400m_rx_ctl(), we can't clone the original skb where the
- * data is because we need to send this up via netlink; netlink has to
- * add headers and we can't overwrite what's preceding the
- * payload...as it is another message. So we just dup them.
- */
-static
-void i2400m_rx_trace(struct i2400m *i2400m,
- const void *payload, size_t size)
-{
- int result;
- struct device *dev = i2400m_dev(i2400m);
- struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
- const struct i2400m_l3l4_hdr *l3l4_hdr = payload;
- unsigned msg_type;
-
- result = i2400m_msg_size_check(i2400m, l3l4_hdr, size);
- if (result < 0) {
- dev_err(dev, "HW BUG? device sent a bad trace message: %d\n",
- result);
- goto error_check;
- }
- msg_type = le16_to_cpu(l3l4_hdr->type);
- d_printf(1, dev, "Trace %s 0x%04x: %zu bytes\n",
- msg_type & I2400M_MT_REPORT_MASK ? "REPORT" : "CMD/SET/GET",
- msg_type, size);
- d_dump(2, dev, l3l4_hdr, size);
- result = wimax_msg(wimax_dev, "trace", l3l4_hdr, size, GFP_KERNEL);
- if (result < 0)
- dev_err(dev, "error sending trace to userspace: %d\n",
- result);
-error_check:
- return;
-}
-
-
-/*
- * Reorder queue data stored on skb->cb while the skb is queued in the
- * reorder queues.
- */
-struct i2400m_roq_data {
- unsigned sn; /* Serial number for the skb */
- enum i2400m_cs cs; /* packet type for the skb */
-};
-
-
-/*
- * ReOrder Queue
- *
- * @ws: Window Start; sequence number where the current window start
- * is for this queue
- * @queue: the skb queue itself
- * @log: circular ring buffer used to log information about the
- * reorder process in this queue that can be displayed in case of
- * error to help diagnose it.
- *
- * This is the head for a list of skbs. In the skb->cb member of the
- * skb when queued here contains a 'struct i2400m_roq_data' were we
- * store the sequence number (sn) and the cs (packet type) coming from
- * the RX payload header from the device.
- */
-struct i2400m_roq {
- unsigned ws;
- struct sk_buff_head queue;
- struct i2400m_roq_log *log;
-};
-
-
-static
-void __i2400m_roq_init(struct i2400m_roq *roq)
-{
- roq->ws = 0;
- skb_queue_head_init(&roq->queue);
-}
-
-
-static
-unsigned __i2400m_roq_index(struct i2400m *i2400m, struct i2400m_roq *roq)
-{
- return ((unsigned long) roq - (unsigned long) i2400m->rx_roq)
- / sizeof(*roq);
-}
-
-
-/*
- * Normalize a sequence number based on the queue's window start
- *
- * nsn = (sn - ws) % 2048
- *
- * Note that if @sn < @roq->ws, we still need a positive number; %'s
- * sign is implementation specific, so we normalize it by adding 2048
- * to bring it to be positive.
- */
-static
-unsigned __i2400m_roq_nsn(struct i2400m_roq *roq, unsigned sn)
-{
- int r;
- r = ((int) sn - (int) roq->ws) % 2048;
- if (r < 0)
- r += 2048;
- return r;
-}
-
-
-/*
- * Circular buffer to keep the last N reorder operations
- *
- * In case something fails, dumb then to try to come up with what
- * happened.
- */
-enum {
- I2400M_ROQ_LOG_LENGTH = 32,
-};
-
-struct i2400m_roq_log {
- struct i2400m_roq_log_entry {
- enum i2400m_ro_type type;
- unsigned ws, count, sn, nsn, new_ws;
- } entry[I2400M_ROQ_LOG_LENGTH];
- unsigned in, out;
-};
-
-
-/* Print a log entry */
-static
-void i2400m_roq_log_entry_print(struct i2400m *i2400m, unsigned index,
- unsigned e_index,
- struct i2400m_roq_log_entry *e)
-{
- struct device *dev = i2400m_dev(i2400m);
-
- switch(e->type) {
- case I2400M_RO_TYPE_RESET:
- dev_err(dev, "q#%d reset ws %u cnt %u sn %u/%u"
- " - new nws %u\n",
- index, e->ws, e->count, e->sn, e->nsn, e->new_ws);
- break;
- case I2400M_RO_TYPE_PACKET:
- dev_err(dev, "q#%d queue ws %u cnt %u sn %u/%u\n",
- index, e->ws, e->count, e->sn, e->nsn);
- break;
- case I2400M_RO_TYPE_WS:
- dev_err(dev, "q#%d update_ws ws %u cnt %u sn %u/%u"
- " - new nws %u\n",
- index, e->ws, e->count, e->sn, e->nsn, e->new_ws);
- break;
- case I2400M_RO_TYPE_PACKET_WS:
- dev_err(dev, "q#%d queue_update_ws ws %u cnt %u sn %u/%u"
- " - new nws %u\n",
- index, e->ws, e->count, e->sn, e->nsn, e->new_ws);
- break;
- default:
- dev_err(dev, "q#%d BUG? entry %u - unknown type %u\n",
- index, e_index, e->type);
- break;
- }
-}
-
-
-static
-void i2400m_roq_log_add(struct i2400m *i2400m,
- struct i2400m_roq *roq, enum i2400m_ro_type type,
- unsigned ws, unsigned count, unsigned sn,
- unsigned nsn, unsigned new_ws)
-{
- struct i2400m_roq_log_entry *e;
- unsigned cnt_idx;
- int index = __i2400m_roq_index(i2400m, roq);
-
- /* if we run out of space, we eat from the end */
- if (roq->log->in - roq->log->out == I2400M_ROQ_LOG_LENGTH)
- roq->log->out++;
- cnt_idx = roq->log->in++ % I2400M_ROQ_LOG_LENGTH;
- e = &roq->log->entry[cnt_idx];
-
- e->type = type;
- e->ws = ws;
- e->count = count;
- e->sn = sn;
- e->nsn = nsn;
- e->new_ws = new_ws;
-
- if (d_test(1))
- i2400m_roq_log_entry_print(i2400m, index, cnt_idx, e);
-}
-
-
-/* Dump all the entries in the FIFO and reinitialize it */
-static
-void i2400m_roq_log_dump(struct i2400m *i2400m, struct i2400m_roq *roq)
-{
- unsigned cnt, cnt_idx;
- struct i2400m_roq_log_entry *e;
- int index = __i2400m_roq_index(i2400m, roq);
-
- BUG_ON(roq->log->out > roq->log->in);
- for (cnt = roq->log->out; cnt < roq->log->in; cnt++) {
- cnt_idx = cnt % I2400M_ROQ_LOG_LENGTH;
- e = &roq->log->entry[cnt_idx];
- i2400m_roq_log_entry_print(i2400m, index, cnt_idx, e);
- memset(e, 0, sizeof(*e));
- }
- roq->log->in = roq->log->out = 0;
-}
-
-
-/*
- * Backbone for the queuing of an skb (by normalized sequence number)
- *
- * @i2400m: device descriptor
- * @roq: reorder queue where to add
- * @skb: the skb to add
- * @sn: the sequence number of the skb
- * @nsn: the normalized sequence number of the skb (pre-computed by the
- * caller from the @sn and @roq->ws).
- *
- * We try first a couple of quick cases:
- *
- * - the queue is empty
- * - the skb would be appended to the queue
- *
- * These will be the most common operations.
- *
- * If these fail, then we have to do a sorted insertion in the queue,
- * which is the slowest path.
- *
- * We don't have to acquire a reference count as we are going to own it.
- */
-static
-void __i2400m_roq_queue(struct i2400m *i2400m, struct i2400m_roq *roq,
- struct sk_buff *skb, unsigned sn, unsigned nsn)
-{
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *skb_itr;
- struct i2400m_roq_data *roq_data_itr, *roq_data;
- unsigned nsn_itr;
-
- d_fnstart(4, dev, "(i2400m %p roq %p skb %p sn %u nsn %u)\n",
- i2400m, roq, skb, sn, nsn);
-
- roq_data = (struct i2400m_roq_data *) &skb->cb;
- BUILD_BUG_ON(sizeof(*roq_data) > sizeof(skb->cb));
- roq_data->sn = sn;
- d_printf(3, dev, "ERX: roq %p [ws %u] nsn %d sn %u\n",
- roq, roq->ws, nsn, roq_data->sn);
-
- /* Queues will be empty on not-so-bad environments, so try
- * that first */
- if (skb_queue_empty(&roq->queue)) {
- d_printf(2, dev, "ERX: roq %p - first one\n", roq);
- __skb_queue_head(&roq->queue, skb);
- goto out;
- }
- /* Now try append, as most of the operations will be that */
- skb_itr = skb_peek_tail(&roq->queue);
- roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb;
- nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn);
- /* NSN bounds assumed correct (checked when it was queued) */
- if (nsn >= nsn_itr) {
- d_printf(2, dev, "ERX: roq %p - appended after %p (nsn %d sn %u)\n",
- roq, skb_itr, nsn_itr, roq_data_itr->sn);
- __skb_queue_tail(&roq->queue, skb);
- goto out;
- }
- /* None of the fast paths option worked. Iterate to find the
- * right spot where to insert the packet; we know the queue is
- * not empty, so we are not the first ones; we also know we
- * are not going to be the last ones. The list is sorted, so
- * we have to insert before the the first guy with an nsn_itr
- * greater that our nsn. */
- skb_queue_walk(&roq->queue, skb_itr) {
- roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb;
- nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn);
- /* NSN bounds assumed correct (checked when it was queued) */
- if (nsn_itr > nsn) {
- d_printf(2, dev, "ERX: roq %p - queued before %p "
- "(nsn %d sn %u)\n", roq, skb_itr, nsn_itr,
- roq_data_itr->sn);
- __skb_queue_before(&roq->queue, skb_itr, skb);
- goto out;
- }
- }
- /* If we get here, that is VERY bad -- print info to help
- * diagnose and crash it */
- dev_err(dev, "SW BUG? failed to insert packet\n");
- dev_err(dev, "ERX: roq %p [ws %u] skb %p nsn %d sn %u\n",
- roq, roq->ws, skb, nsn, roq_data->sn);
- skb_queue_walk(&roq->queue, skb_itr) {
- roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb;
- nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn);
- /* NSN bounds assumed correct (checked when it was queued) */
- dev_err(dev, "ERX: roq %p skb_itr %p nsn %d sn %u\n",
- roq, skb_itr, nsn_itr, roq_data_itr->sn);
- }
- BUG();
-out:
- d_fnend(4, dev, "(i2400m %p roq %p skb %p sn %u nsn %d) = void\n",
- i2400m, roq, skb, sn, nsn);
-}
-
-
-/*
- * Backbone for the update window start operation
- *
- * @i2400m: device descriptor
- * @roq: Reorder queue
- * @sn: New sequence number
- *
- * Updates the window start of a queue; when doing so, it must deliver
- * to the networking stack all the queued skb's whose normalized
- * sequence number is lower than the new normalized window start.
- */
-static
-unsigned __i2400m_roq_update_ws(struct i2400m *i2400m, struct i2400m_roq *roq,
- unsigned sn)
-{
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *skb_itr, *tmp_itr;
- struct i2400m_roq_data *roq_data_itr;
- unsigned new_nws, nsn_itr;
-
- new_nws = __i2400m_roq_nsn(roq, sn);
- /*
- * For type 2(update_window_start) rx messages, there is no
- * need to check if the normalized sequence number is greater 1023.
- * Simply insert and deliver all packets to the host up to the
- * window start.
- */
- skb_queue_walk_safe(&roq->queue, skb_itr, tmp_itr) {
- roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb;
- nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn);
- /* NSN bounds assumed correct (checked when it was queued) */
- if (nsn_itr < new_nws) {
- d_printf(2, dev, "ERX: roq %p - release skb %p "
- "(nsn %u/%u new nws %u)\n",
- roq, skb_itr, nsn_itr, roq_data_itr->sn,
- new_nws);
- __skb_unlink(skb_itr, &roq->queue);
- i2400m_net_erx(i2400m, skb_itr, roq_data_itr->cs);
- }
- else
- break; /* rest of packets all nsn_itr > nws */
- }
- roq->ws = sn;
- return new_nws;
-}
-
-
-/*
- * Reset a queue
- *
- * @i2400m: device descriptor
- * @cin: Queue Index
- *
- * Deliver all the packets and reset the window-start to zero. Name is
- * kind of misleading.
- */
-static
-void i2400m_roq_reset(struct i2400m *i2400m, struct i2400m_roq *roq)
-{
- struct device *dev = i2400m_dev(i2400m);
- struct sk_buff *skb_itr, *tmp_itr;
- struct i2400m_roq_data *roq_data_itr;
-
- d_fnstart(2, dev, "(i2400m %p roq %p)\n", i2400m, roq);
- i2400m_roq_log_add(i2400m, roq, I2400M_RO_TYPE_RESET,
- roq->ws, skb_queue_len(&roq->queue),
- ~0, ~0, 0);
- skb_queue_walk_safe(&roq->queue, skb_itr, tmp_itr) {
- roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb;
- d_printf(2, dev, "ERX: roq %p - release skb %p (sn %u)\n",
- roq, skb_itr, roq_data_itr->sn);
- __skb_unlink(skb_itr, &roq->queue);
- i2400m_net_erx(i2400m, skb_itr, roq_data_itr->cs);
- }
- roq->ws = 0;
- d_fnend(2, dev, "(i2400m %p roq %p) = void\n", i2400m, roq);
-}
-
-
-/*
- * Queue a packet
- *
- * @i2400m: device descriptor
- * @cin: Queue Index
- * @skb: containing the packet data
- * @fbn: First block number of the packet in @skb
- * @lbn: Last block number of the packet in @skb
- *
- * The hardware is asking the driver to queue a packet for later
- * delivery to the networking stack.
- */
-static
-void i2400m_roq_queue(struct i2400m *i2400m, struct i2400m_roq *roq,
- struct sk_buff *skb, unsigned lbn)
-{
- struct device *dev = i2400m_dev(i2400m);
- unsigned nsn, len;
-
- d_fnstart(2, dev, "(i2400m %p roq %p skb %p lbn %u) = void\n",
- i2400m, roq, skb, lbn);
- len = skb_queue_len(&roq->queue);
- nsn = __i2400m_roq_nsn(roq, lbn);
- if (unlikely(nsn >= 1024)) {
- dev_err(dev, "SW BUG? queue nsn %d (lbn %u ws %u)\n",
- nsn, lbn, roq->ws);
- i2400m_roq_log_dump(i2400m, roq);
- i2400m_reset(i2400m, I2400M_RT_WARM);
- } else {
- __i2400m_roq_queue(i2400m, roq, skb, lbn, nsn);
- i2400m_roq_log_add(i2400m, roq, I2400M_RO_TYPE_PACKET,
- roq->ws, len, lbn, nsn, ~0);
- }
- d_fnend(2, dev, "(i2400m %p roq %p skb %p lbn %u) = void\n",
- i2400m, roq, skb, lbn);
-}
-
-
-/*
- * Update the window start in a reorder queue and deliver all skbs
- * with a lower window start
- *
- * @i2400m: device descriptor
- * @roq: Reorder queue
- * @sn: New sequence number
- */
-static
-void i2400m_roq_update_ws(struct i2400m *i2400m, struct i2400m_roq *roq,
- unsigned sn)
-{
- struct device *dev = i2400m_dev(i2400m);
- unsigned old_ws, nsn, len;
-
- d_fnstart(2, dev, "(i2400m %p roq %p sn %u)\n", i2400m, roq, sn);
- old_ws = roq->ws;
- len = skb_queue_len(&roq->queue);
- nsn = __i2400m_roq_update_ws(i2400m, roq, sn);
- i2400m_roq_log_add(i2400m, roq, I2400M_RO_TYPE_WS,
- old_ws, len, sn, nsn, roq->ws);
- d_fnstart(2, dev, "(i2400m %p roq %p sn %u) = void\n", i2400m, roq, sn);
-}
-
-
-/*
- * Queue a packet and update the window start
- *
- * @i2400m: device descriptor
- * @cin: Queue Index
- * @skb: containing the packet data
- * @fbn: First block number of the packet in @skb
- * @sn: Last block number of the packet in @skb
- *
- * Note that unlike i2400m_roq_update_ws(), which sets the new window
- * start to @sn, in here we'll set it to @sn + 1.
- */
-static
-void i2400m_roq_queue_update_ws(struct i2400m *i2400m, struct i2400m_roq *roq,
- struct sk_buff *skb, unsigned sn)
-{
- struct device *dev = i2400m_dev(i2400m);
- unsigned nsn, old_ws, len;
-
- d_fnstart(2, dev, "(i2400m %p roq %p skb %p sn %u)\n",
- i2400m, roq, skb, sn);
- len = skb_queue_len(&roq->queue);
- nsn = __i2400m_roq_nsn(roq, sn);
- /*
- * For type 3(queue_update_window_start) rx messages, there is no
- * need to check if the normalized sequence number is greater 1023.
- * Simply insert and deliver all packets to the host up to the
- * window start.
- */
- old_ws = roq->ws;
- /* If the queue is empty, don't bother as we'd queue
- * it and immediately unqueue it -- just deliver it.
- */
- if (len == 0) {
- struct i2400m_roq_data *roq_data;
- roq_data = (struct i2400m_roq_data *) &skb->cb;
- i2400m_net_erx(i2400m, skb, roq_data->cs);
- } else
- __i2400m_roq_queue(i2400m, roq, skb, sn, nsn);
-
- __i2400m_roq_update_ws(i2400m, roq, sn + 1);
- i2400m_roq_log_add(i2400m, roq, I2400M_RO_TYPE_PACKET_WS,
- old_ws, len, sn, nsn, roq->ws);
-
- d_fnend(2, dev, "(i2400m %p roq %p skb %p sn %u) = void\n",
- i2400m, roq, skb, sn);
-}
-
-
-/*
- * This routine destroys the memory allocated for rx_roq, when no
- * other thread is accessing it. Access to rx_roq is refcounted by
- * rx_roq_refcount, hence memory allocated must be destroyed when
- * rx_roq_refcount becomes zero. This routine gets executed when
- * rx_roq_refcount becomes zero.
- */
-static void i2400m_rx_roq_destroy(struct kref *ref)
-{
- unsigned itr;
- struct i2400m *i2400m
- = container_of(ref, struct i2400m, rx_roq_refcount);
- for (itr = 0; itr < I2400M_RO_CIN + 1; itr++)
- __skb_queue_purge(&i2400m->rx_roq[itr].queue);
- kfree(i2400m->rx_roq[0].log);
- kfree(i2400m->rx_roq);
- i2400m->rx_roq = NULL;
-}
-
-/*
- * Receive and send up an extended data packet
- *
- * @i2400m: device descriptor
- * @skb_rx: skb that contains the extended data packet
- * @single_last: 1 if the payload is the only one or the last one of
- * the skb.
- * @payload: pointer to the packet's data inside the skb
- * @size: size of the payload
- *
- * Starting in v1.4 of the i2400m's firmware, the device can send data
- * packets to the host in an extended format that; this incudes a 16
- * byte header (struct i2400m_pl_edata_hdr). Using this header's space
- * we can fake ethernet headers for ethernet device emulation without
- * having to copy packets around.
- *
- * This function handles said path.
- *
- *
- * Receive and send up an extended data packet that requires no reordering
- *
- * @i2400m: device descriptor
- * @skb_rx: skb that contains the extended data packet
- * @single_last: 1 if the payload is the only one or the last one of
- * the skb.
- * @payload: pointer to the packet's data (past the actual extended
- * data payload header).
- * @size: size of the payload
- *
- * Pass over to the networking stack a data packet that might have
- * reordering requirements.
- *
- * This needs to the decide if the skb in which the packet is
- * contained can be reused or if it needs to be cloned. Then it has to
- * be trimmed in the edges so that the beginning is the space for eth
- * header and then pass it to i2400m_net_erx() for the stack
- *
- * Assumes the caller has verified the sanity of the payload (size,
- * etc) already.
- */
-static
-void i2400m_rx_edata(struct i2400m *i2400m, struct sk_buff *skb_rx,
- unsigned single_last, const void *payload, size_t size)
-{
- struct device *dev = i2400m_dev(i2400m);
- const struct i2400m_pl_edata_hdr *hdr = payload;
- struct net_device *net_dev = i2400m->wimax_dev.net_dev;
- struct sk_buff *skb;
- enum i2400m_cs cs;
- u32 reorder;
- unsigned ro_needed, ro_type, ro_cin, ro_sn;
- struct i2400m_roq *roq;
- struct i2400m_roq_data *roq_data;
- unsigned long flags;
-
- BUILD_BUG_ON(ETH_HLEN > sizeof(*hdr));
-
- d_fnstart(2, dev, "(i2400m %p skb_rx %p single %u payload %p "
- "size %zu)\n", i2400m, skb_rx, single_last, payload, size);
- if (size < sizeof(*hdr)) {
- dev_err(dev, "ERX: HW BUG? message with short header (%zu "
- "vs %zu bytes expected)\n", size, sizeof(*hdr));
- goto error;
- }
-
- if (single_last) {
- skb = skb_get(skb_rx);
- d_printf(3, dev, "ERX: skb %p reusing\n", skb);
- } else {
- skb = skb_clone(skb_rx, GFP_KERNEL);
- if (skb == NULL) {
- dev_err(dev, "ERX: no memory to clone skb\n");
- net_dev->stats.rx_dropped++;
- goto error_skb_clone;
- }
- d_printf(3, dev, "ERX: skb %p cloned from %p\n", skb, skb_rx);
- }
- /* now we have to pull and trim so that the skb points to the
- * beginning of the IP packet; the netdev part will add the
- * ethernet header as needed - we know there is enough space
- * because we checked in i2400m_rx_edata(). */
- skb_pull(skb, payload + sizeof(*hdr) - (void *) skb->data);
- skb_trim(skb, (void *) skb_end_pointer(skb) - payload - sizeof(*hdr));
-
- reorder = le32_to_cpu(hdr->reorder);
- ro_needed = reorder & I2400M_RO_NEEDED;
- cs = hdr->cs;
- if (ro_needed) {
- ro_type = (reorder >> I2400M_RO_TYPE_SHIFT) & I2400M_RO_TYPE;
- ro_cin = (reorder >> I2400M_RO_CIN_SHIFT) & I2400M_RO_CIN;
- ro_sn = (reorder >> I2400M_RO_SN_SHIFT) & I2400M_RO_SN;
-
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- if (i2400m->rx_roq == NULL) {
- kfree_skb(skb); /* rx_roq is already destroyed */
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- goto error;
- }
- roq = &i2400m->rx_roq[ro_cin];
- kref_get(&i2400m->rx_roq_refcount);
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-
- roq_data = (struct i2400m_roq_data *) &skb->cb;
- roq_data->sn = ro_sn;
- roq_data->cs = cs;
- d_printf(2, dev, "ERX: reorder needed: "
- "type %u cin %u [ws %u] sn %u/%u len %zuB\n",
- ro_type, ro_cin, roq->ws, ro_sn,
- __i2400m_roq_nsn(roq, ro_sn), size);
- d_dump(2, dev, payload, size);
- switch(ro_type) {
- case I2400M_RO_TYPE_RESET:
- i2400m_roq_reset(i2400m, roq);
- kfree_skb(skb); /* no data here */
- break;
- case I2400M_RO_TYPE_PACKET:
- i2400m_roq_queue(i2400m, roq, skb, ro_sn);
- break;
- case I2400M_RO_TYPE_WS:
- i2400m_roq_update_ws(i2400m, roq, ro_sn);
- kfree_skb(skb); /* no data here */
- break;
- case I2400M_RO_TYPE_PACKET_WS:
- i2400m_roq_queue_update_ws(i2400m, roq, skb, ro_sn);
- break;
- default:
- dev_err(dev, "HW BUG? unknown reorder type %u\n", ro_type);
- }
-
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- kref_put(&i2400m->rx_roq_refcount, i2400m_rx_roq_destroy);
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- }
- else
- i2400m_net_erx(i2400m, skb, cs);
-error_skb_clone:
-error:
- d_fnend(2, dev, "(i2400m %p skb_rx %p single %u payload %p "
- "size %zu) = void\n", i2400m, skb_rx, single_last, payload, size);
-}
-
-
-/*
- * Act on a received payload
- *
- * @i2400m: device instance
- * @skb_rx: skb where the transaction was received
- * @single_last: 1 this is the only payload or the last one (so the
- * skb can be reused instead of cloned).
- * @pld: payload descriptor
- * @payload: payload data
- *
- * Upon reception of a payload, look at its guts in the payload
- * descriptor and decide what to do with it. If it is a single payload
- * skb or if the last skb is a data packet, the skb will be referenced
- * and modified (so it doesn't have to be cloned).
- */
-static
-void i2400m_rx_payload(struct i2400m *i2400m, struct sk_buff *skb_rx,
- unsigned single_last, const struct i2400m_pld *pld,
- const void *payload)
-{
- struct device *dev = i2400m_dev(i2400m);
- size_t pl_size = i2400m_pld_size(pld);
- enum i2400m_pt pl_type = i2400m_pld_type(pld);
-
- d_printf(7, dev, "RX: received payload type %u, %zu bytes\n",
- pl_type, pl_size);
- d_dump(8, dev, payload, pl_size);
-
- switch (pl_type) {
- case I2400M_PT_DATA:
- d_printf(3, dev, "RX: data payload %zu bytes\n", pl_size);
- i2400m_net_rx(i2400m, skb_rx, single_last, payload, pl_size);
- break;
- case I2400M_PT_CTRL:
- i2400m_rx_ctl(i2400m, skb_rx, payload, pl_size);
- break;
- case I2400M_PT_TRACE:
- i2400m_rx_trace(i2400m, payload, pl_size);
- break;
- case I2400M_PT_EDATA:
- d_printf(3, dev, "ERX: data payload %zu bytes\n", pl_size);
- i2400m_rx_edata(i2400m, skb_rx, single_last, payload, pl_size);
- break;
- default: /* Anything else shouldn't come to the host */
- if (printk_ratelimit())
- dev_err(dev, "RX: HW BUG? unexpected payload type %u\n",
- pl_type);
- }
-}
-
-
-/*
- * Check a received transaction's message header
- *
- * @i2400m: device descriptor
- * @msg_hdr: message header
- * @buf_size: size of the received buffer
- *
- * Check that the declarations done by a RX buffer message header are
- * sane and consistent with the amount of data that was received.
- */
-static
-int i2400m_rx_msg_hdr_check(struct i2400m *i2400m,
- const struct i2400m_msg_hdr *msg_hdr,
- size_t buf_size)
-{
- int result = -EIO;
- struct device *dev = i2400m_dev(i2400m);
- if (buf_size < sizeof(*msg_hdr)) {
- dev_err(dev, "RX: HW BUG? message with short header (%zu "
- "vs %zu bytes expected)\n", buf_size, sizeof(*msg_hdr));
- goto error;
- }
- if (msg_hdr->barker != cpu_to_le32(I2400M_D2H_MSG_BARKER)) {
- dev_err(dev, "RX: HW BUG? message received with unknown "
- "barker 0x%08x (buf_size %zu bytes)\n",
- le32_to_cpu(msg_hdr->barker), buf_size);
- goto error;
- }
- if (msg_hdr->num_pls == 0) {
- dev_err(dev, "RX: HW BUG? zero payload packets in message\n");
- goto error;
- }
- if (le16_to_cpu(msg_hdr->num_pls) > I2400M_MAX_PLS_IN_MSG) {
- dev_err(dev, "RX: HW BUG? message contains more payload "
- "than maximum; ignoring.\n");
- goto error;
- }
- result = 0;
-error:
- return result;
-}
-
-
-/*
- * Check a payload descriptor against the received data
- *
- * @i2400m: device descriptor
- * @pld: payload descriptor
- * @pl_itr: offset (in bytes) in the received buffer the payload is
- * located
- * @buf_size: size of the received buffer
- *
- * Given a payload descriptor (part of a RX buffer), check it is sane
- * and that the data it declares fits in the buffer.
- */
-static
-int i2400m_rx_pl_descr_check(struct i2400m *i2400m,
- const struct i2400m_pld *pld,
- size_t pl_itr, size_t buf_size)
-{
- int result = -EIO;
- struct device *dev = i2400m_dev(i2400m);
- size_t pl_size = i2400m_pld_size(pld);
- enum i2400m_pt pl_type = i2400m_pld_type(pld);
-
- if (pl_size > i2400m->bus_pl_size_max) {
- dev_err(dev, "RX: HW BUG? payload @%zu: size %zu is "
- "bigger than maximum %zu; ignoring message\n",
- pl_itr, pl_size, i2400m->bus_pl_size_max);
- goto error;
- }
- if (pl_itr + pl_size > buf_size) { /* enough? */
- dev_err(dev, "RX: HW BUG? payload @%zu: size %zu "
- "goes beyond the received buffer "
- "size (%zu bytes); ignoring message\n",
- pl_itr, pl_size, buf_size);
- goto error;
- }
- if (pl_type >= I2400M_PT_ILLEGAL) {
- dev_err(dev, "RX: HW BUG? illegal payload type %u; "
- "ignoring message\n", pl_type);
- goto error;
- }
- result = 0;
-error:
- return result;
-}
-
-
-/**
- * i2400m_rx - Receive a buffer of data from the device
- *
- * @i2400m: device descriptor
- * @skb: skbuff where the data has been received
- *
- * Parse in a buffer of data that contains an RX message sent from the
- * device. See the file header for the format. Run all checks on the
- * buffer header, then run over each payload's descriptors, verify
- * their consistency and act on each payload's contents. If
- * everything is successful, update the device's statistics.
- *
- * Note: You need to set the skb to contain only the length of the
- * received buffer; for that, use skb_trim(skb, RECEIVED_SIZE).
- *
- * Returns:
- *
- * 0 if ok, < 0 errno on error
- *
- * If ok, this function owns now the skb and the caller DOESN'T have
- * to run kfree_skb() on it. However, on error, the caller still owns
- * the skb and it is responsible for releasing it.
- */
-int i2400m_rx(struct i2400m *i2400m, struct sk_buff *skb)
-{
- int i, result;
- struct device *dev = i2400m_dev(i2400m);
- const struct i2400m_msg_hdr *msg_hdr;
- size_t pl_itr, pl_size;
- unsigned long flags;
- unsigned num_pls, single_last, skb_len;
-
- skb_len = skb->len;
- d_fnstart(4, dev, "(i2400m %p skb %p [size %u])\n",
- i2400m, skb, skb_len);
- msg_hdr = (void *) skb->data;
- result = i2400m_rx_msg_hdr_check(i2400m, msg_hdr, skb_len);
- if (result < 0)
- goto error_msg_hdr_check;
- result = -EIO;
- num_pls = le16_to_cpu(msg_hdr->num_pls);
- /* Check payload descriptor(s) */
- pl_itr = struct_size(msg_hdr, pld, num_pls);
- pl_itr = ALIGN(pl_itr, I2400M_PL_ALIGN);
- if (pl_itr > skb_len) { /* got all the payload descriptors? */
- dev_err(dev, "RX: HW BUG? message too short (%u bytes) for "
- "%u payload descriptors (%zu each, total %zu)\n",
- skb_len, num_pls, sizeof(msg_hdr->pld[0]), pl_itr);
- goto error_pl_descr_short;
- }
- /* Walk each payload payload--check we really got it */
- for (i = 0; i < num_pls; i++) {
- /* work around old gcc warnings */
- pl_size = i2400m_pld_size(&msg_hdr->pld[i]);
- result = i2400m_rx_pl_descr_check(i2400m, &msg_hdr->pld[i],
- pl_itr, skb_len);
- if (result < 0)
- goto error_pl_descr_check;
- single_last = num_pls == 1 || i == num_pls - 1;
- i2400m_rx_payload(i2400m, skb, single_last, &msg_hdr->pld[i],
- skb->data + pl_itr);
- pl_itr += ALIGN(pl_size, I2400M_PL_ALIGN);
- cond_resched(); /* Don't monopolize */
- }
- kfree_skb(skb);
- /* Update device statistics */
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- i2400m->rx_pl_num += i;
- if (i > i2400m->rx_pl_max)
- i2400m->rx_pl_max = i;
- if (i < i2400m->rx_pl_min)
- i2400m->rx_pl_min = i;
- i2400m->rx_num++;
- i2400m->rx_size_acc += skb_len;
- if (skb_len < i2400m->rx_size_min)
- i2400m->rx_size_min = skb_len;
- if (skb_len > i2400m->rx_size_max)
- i2400m->rx_size_max = skb_len;
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-error_pl_descr_check:
-error_pl_descr_short:
-error_msg_hdr_check:
- d_fnend(4, dev, "(i2400m %p skb %p [size %u]) = %d\n",
- i2400m, skb, skb_len, result);
- return result;
-}
-EXPORT_SYMBOL_GPL(i2400m_rx);
-
-
-void i2400m_unknown_barker(struct i2400m *i2400m,
- const void *buf, size_t size)
-{
- struct device *dev = i2400m_dev(i2400m);
- char prefix[64];
- const __le32 *barker = buf;
- dev_err(dev, "RX: HW BUG? unknown barker %08x, "
- "dropping %zu bytes\n", le32_to_cpu(*barker), size);
- snprintf(prefix, sizeof(prefix), "%s %s: ",
- dev_driver_string(dev), dev_name(dev));
- if (size > 64) {
- print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET,
- 8, 4, buf, 64, 0);
- printk(KERN_ERR "%s... (only first 64 bytes "
- "dumped)\n", prefix);
- } else
- print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET,
- 8, 4, buf, size, 0);
-}
-EXPORT_SYMBOL(i2400m_unknown_barker);
-
-
-/*
- * Initialize the RX queue and infrastructure
- *
- * This sets up all the RX reordering infrastructures, which will not
- * be used if reordering is not enabled or if the firmware does not
- * support it. The device is told to do reordering in
- * i2400m_dev_initialize(), where it also looks at the value of the
- * i2400m->rx_reorder switch before taking a decission.
- *
- * Note we allocate the roq queues in one chunk and the actual logging
- * support for it (logging) in another one and then we setup the
- * pointers from the first to the last.
- */
-int i2400m_rx_setup(struct i2400m *i2400m)
-{
- int result = 0;
-
- i2400m->rx_reorder = i2400m_rx_reorder_disabled? 0 : 1;
- if (i2400m->rx_reorder) {
- unsigned itr;
- struct i2400m_roq_log *rd;
-
- result = -ENOMEM;
-
- i2400m->rx_roq = kcalloc(I2400M_RO_CIN + 1,
- sizeof(i2400m->rx_roq[0]), GFP_KERNEL);
- if (i2400m->rx_roq == NULL)
- goto error_roq_alloc;
-
- rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
- GFP_KERNEL);
- if (rd == NULL) {
- result = -ENOMEM;
- goto error_roq_log_alloc;
- }
-
- for(itr = 0; itr < I2400M_RO_CIN + 1; itr++) {
- __i2400m_roq_init(&i2400m->rx_roq[itr]);
- i2400m->rx_roq[itr].log = &rd[itr];
- }
- kref_init(&i2400m->rx_roq_refcount);
- }
- return 0;
-
-error_roq_log_alloc:
- kfree(i2400m->rx_roq);
-error_roq_alloc:
- return result;
-}
-
-
-/* Tear down the RX queue and infrastructure */
-void i2400m_rx_release(struct i2400m *i2400m)
-{
- unsigned long flags;
-
- if (i2400m->rx_reorder) {
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- kref_put(&i2400m->rx_roq_refcount, i2400m_rx_roq_destroy);
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- }
- /* at this point, nothing can be received... */
- i2400m_report_hook_flush(i2400m);
-}
diff --git a/drivers/staging/wimax/i2400m/sysfs.c b/drivers/staging/wimax/i2400m/sysfs.c
deleted file mode 100644
index 895ee265909b..000000000000
--- a/drivers/staging/wimax/i2400m/sysfs.c
+++ /dev/null
@@ -1,65 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Sysfs interfaces to show driver and device information
- *
- * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/spinlock.h>
-#include <linux/device.h>
-#include "i2400m.h"
-
-
-#define D_SUBMODULE sysfs
-#include "debug-levels.h"
-
-
-/*
- * Set the idle timeout (msecs)
- *
- * FIXME: eventually this should be a common WiMAX stack method, but
- * would like to wait to see how other devices manage it.
- */
-static
-ssize_t i2400m_idle_timeout_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t size)
-{
- ssize_t result;
- struct i2400m *i2400m = net_dev_to_i2400m(to_net_dev(dev));
- unsigned val;
-
- result = -EINVAL;
- if (sscanf(buf, "%u\n", &val) != 1)
- goto error_no_unsigned;
- if (val != 0 && (val < 100 || val > 300000 || val % 100 != 0)) {
- dev_err(dev, "idle_timeout: %u: invalid msecs specification; "
- "valid values are 0, 100-300000 in 100 increments\n",
- val);
- goto error_bad_value;
- }
- result = i2400m_set_idle_timeout(i2400m, val);
- if (result >= 0)
- result = size;
-error_no_unsigned:
-error_bad_value:
- return result;
-}
-
-static
-DEVICE_ATTR_WO(i2400m_idle_timeout);
-
-static
-struct attribute *i2400m_dev_attrs[] = {
- &dev_attr_i2400m_idle_timeout.attr,
- NULL,
-};
-
-struct attribute_group i2400m_dev_attr_group = {
- .name = NULL, /* we want them in the same directory */
- .attrs = i2400m_dev_attrs,
-};
diff --git a/drivers/staging/wimax/i2400m/tx.c b/drivers/staging/wimax/i2400m/tx.c
deleted file mode 100644
index 8c01f42876ea..000000000000
--- a/drivers/staging/wimax/i2400m/tx.c
+++ /dev/null
@@ -1,1015 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Generic (non-bus specific) TX handling
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * 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 Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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
- * OWNER 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.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * - Initial implementation
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * - Rewritten to use a single FIFO to lower the memory allocation
- * pressure and optimize cache hits when copying to the queue, as
- * well as splitting out bus-specific code.
- *
- *
- * Implements data transmission to the device; this is done through a
- * software FIFO, as data/control frames can be coalesced (while the
- * device is reading the previous tx transaction, others accumulate).
- *
- * A FIFO is used because at the end it is resource-cheaper that trying
- * to implement scatter/gather over USB. As well, most traffic is going
- * to be download (vs upload).
- *
- * The format for sending/receiving data to/from the i2400m is
- * described in detail in rx.c:PROTOCOL FORMAT. In here we implement
- * the transmission of that. This is split between a bus-independent
- * part that just prepares everything and a bus-specific part that
- * does the actual transmission over the bus to the device (in the
- * bus-specific driver).
- *
- *
- * The general format of a device-host transaction is MSG-HDR, PLD1,
- * PLD2...PLDN, PL1, PL2,...PLN, PADDING.
- *
- * Because we need the send payload descriptors and then payloads and
- * because it is kind of expensive to do scatterlists in USB (one URB
- * per node), it becomes cheaper to append all the data to a FIFO
- * (copying to a FIFO potentially in cache is cheaper).
- *
- * Then the bus-specific code takes the parts of that FIFO that are
- * written and passes them to the device.
- *
- * So the concepts to keep in mind there are:
- *
- * We use a FIFO to queue the data in a linear buffer. We first append
- * a MSG-HDR, space for I2400M_TX_PLD_MAX payload descriptors and then
- * go appending payloads until we run out of space or of payload
- * descriptors. Then we append padding to make the whole transaction a
- * multiple of i2400m->bus_tx_block_size (as defined by the bus layer).
- *
- * - A TX message: a combination of a message header, payload
- * descriptors and payloads.
- *
- * Open: it is marked as active (i2400m->tx_msg is valid) and we
- * can keep adding payloads to it.
- *
- * Closed: we are not appending more payloads to this TX message
- * (exahusted space in the queue, too many payloads or
- * whichever). We have appended padding so the whole message
- * length is aligned to i2400m->bus_tx_block_size (as set by the
- * bus/transport layer).
- *
- * - Most of the time we keep a TX message open to which we append
- * payloads.
- *
- * - If we are going to append and there is no more space (we are at
- * the end of the FIFO), we close the message, mark the rest of the
- * FIFO space unusable (skip_tail), create a new message at the
- * beginning of the FIFO (if there is space) and append the message
- * there.
- *
- * This is because we need to give linear TX messages to the bus
- * engine. So we don't write a message to the remaining FIFO space
- * until the tail and continue at the head of it.
- *
- * - We overload one of the fields in the message header to use it as
- * 'size' of the TX message, so we can iterate over them. It also
- * contains a flag that indicates if we have to skip it or not.
- * When we send the buffer, we update that to its real on-the-wire
- * value.
- *
- * - The MSG-HDR PLD1...PLD2 stuff has to be a size multiple of 16.
- *
- * It follows that if MSG-HDR says we have N messages, the whole
- * header + descriptors is 16 + 4*N; for those to be a multiple of
- * 16, it follows that N can be 4, 8, 12, ... (32, 48, 64, 80...
- * bytes).
- *
- * So if we have only 1 payload, we have to submit a header that in
- * all truth has space for 4.
- *
- * The implication is that we reserve space for 12 (64 bytes); but
- * if we fill up only (eg) 2, our header becomes 32 bytes only. So
- * the TX engine has to shift those 32 bytes of msg header and 2
- * payloads and padding so that right after it the payloads start
- * and the TX engine has to know about that.
- *
- * It is cheaper to move the header up than the whole payloads down.
- *
- * We do this in i2400m_tx_close(). See 'i2400m_msg_hdr->offset'.
- *
- * - Each payload has to be size-padded to 16 bytes; before appending
- * it, we just do it.
- *
- * - The whole message has to be padded to i2400m->bus_tx_block_size;
- * we do this at close time. Thus, when reserving space for the
- * payload, we always make sure there is also free space for this
- * padding that sooner or later will happen.
- *
- * When we append a message, we tell the bus specific code to kick in
- * TXs. It will TX (in parallel) until the buffer is exhausted--hence
- * the lockin we do. The TX code will only send a TX message at the
- * time (which remember, might contain more than one payload). Of
- * course, when the bus-specific driver attempts to TX a message that
- * is still open, it gets closed first.
- *
- * Gee, this is messy; well a picture. In the example below we have a
- * partially full FIFO, with a closed message ready to be delivered
- * (with a moved message header to make sure it is size-aligned to
- * 16), TAIL room that was unusable (and thus is marked with a message
- * header that says 'skip this') and at the head of the buffer, an
- * incomplete message with a couple of payloads.
- *
- * N ___________________________________________________
- * | |
- * | TAIL room |
- * | |
- * | msg_hdr to skip (size |= 0x80000) |
- * |---------------------------------------------------|-------
- * | | /|\
- * | | |
- * | TX message padding | |
- * | | |
- * | | |
- * |- - - - - - - - - - - - - - - - - - - - - - - - - -| |
- * | | |
- * | payload 1 | |
- * | | N * tx_block_size
- * | | |
- * |- - - - - - - - - - - - - - - - - - - - - - - - - -| |
- * | | |
- * | payload 1 | |
- * | | |
- * | | |
- * |- - - - - - - - - - - - - - - - - - - - - - - - - -|- -|- - - -
- * | padding 3 /|\ | | /|\
- * | padding 2 | | | |
- * | pld 1 32 bytes (2 * 16) | | |
- * | pld 0 | | | |
- * | moved msg_hdr \|/ | \|/ |
- * |- - - - - - - - - - - - - - - - - - - - - - - - - -|- - - |
- * | | _PLD_SIZE
- * | unused | |
- * | | |
- * |- - - - - - - - - - - - - - - - - - - - - - - - - -| |
- * | msg_hdr (size X) [this message is closed] | \|/
- * |===================================================|========== <=== OUT
- * | |
- * | |
- * | |
- * | Free rooom |
- * | |
- * | |
- * | |
- * | |
- * | |
- * | |
- * | |
- * | |
- * | |
- * |===================================================|========== <=== IN
- * | |
- * | |
- * | |
- * | |
- * | payload 1 |
- * | |
- * | |
- * |- - - - - - - - - - - - - - - - - - - - - - - - - -|
- * | |
- * | payload 0 |
- * | |
- * | |
- * |- - - - - - - - - - - - - - - - - - - - - - - - - -|
- * | pld 11 /|\ |
- * | ... | |
- * | pld 1 64 bytes (2 * 16) |
- * | pld 0 | |
- * | msg_hdr (size X) \|/ [message is open] |
- * 0 ---------------------------------------------------
- *
- *
- * ROADMAP
- *
- * i2400m_tx_setup() Called by i2400m_setup
- * i2400m_tx_release() Called by i2400m_release()
- *
- * i2400m_tx() Called to send data or control frames
- * i2400m_tx_fifo_push() Allocates append-space in the FIFO
- * i2400m_tx_new() Opens a new message in the FIFO
- * i2400m_tx_fits() Checks if a new payload fits in the message
- * i2400m_tx_close() Closes an open message in the FIFO
- * i2400m_tx_skip_tail() Marks unusable FIFO tail space
- * i2400m->bus_tx_kick()
- *
- * Now i2400m->bus_tx_kick() is the the bus-specific driver backend
- * implementation; that would do:
- *
- * i2400m->bus_tx_kick()
- * i2400m_tx_msg_get() Gets first message ready to go
- * ...sends it...
- * i2400m_tx_msg_sent() Ack the message is sent; repeat from
- * _tx_msg_get() until it returns NULL
- * (FIFO empty).
- */
-#include <linux/netdevice.h>
-#include <linux/slab.h>
-#include <linux/export.h>
-#include "i2400m.h"
-
-
-#define D_SUBMODULE tx
-#include "debug-levels.h"
-
-enum {
- /**
- * TX Buffer size
- *
- * Doc says maximum transaction is 16KiB. If we had 16KiB en
- * route and 16KiB being queued, it boils down to needing
- * 32KiB.
- * 32KiB is insufficient for 1400 MTU, hence increasing
- * tx buffer size to 64KiB.
- */
- I2400M_TX_BUF_SIZE = 65536,
- /**
- * Message header and payload descriptors have to be 16
- * aligned (16 + 4 * N = 16 * M). If we take that average sent
- * packets are MTU size (~1400-~1500) it follows that we could
- * fit at most 10-11 payloads in one transaction. To meet the
- * alignment requirement, that means we need to leave space
- * for 12 (64 bytes). To simplify, we leave space for that. If
- * at the end there are less, we pad up to the nearest
- * multiple of 16.
- */
- /*
- * According to Intel Wimax i3200, i5x50 and i6x50 specification
- * documents, the maximum number of payloads per message can be
- * up to 60. Increasing the number of payloads to 60 per message
- * helps to accommodate smaller payloads in a single transaction.
- */
- I2400M_TX_PLD_MAX = 60,
- I2400M_TX_PLD_SIZE = sizeof(struct i2400m_msg_hdr)
- + I2400M_TX_PLD_MAX * sizeof(struct i2400m_pld),
- I2400M_TX_SKIP = 0x80000000,
- /*
- * According to Intel Wimax i3200, i5x50 and i6x50 specification
- * documents, the maximum size of each message can be up to 16KiB.
- */
- I2400M_TX_MSG_SIZE = 16384,
-};
-
-#define TAIL_FULL ((void *)~(unsigned long)NULL)
-
-/*
- * Calculate how much tail room is available
- *
- * Note the trick here. This path is ONLY caleed for Case A (see
- * i2400m_tx_fifo_push() below), where we have:
- *
- * Case A
- * N ___________
- * | tail room |
- * | |
- * |<- IN ->|
- * | |
- * | data |
- * | |
- * |<- OUT ->|
- * | |
- * | head room |
- * 0 -----------
- *
- * When calculating the tail_room, tx_in might get to be zero if
- * i2400m->tx_in is right at the end of the buffer (really full
- * buffer) if there is no head room. In this case, tail_room would be
- * I2400M_TX_BUF_SIZE, although it is actually zero. Hence the final
- * mod (%) operation. However, when doing this kind of optimization,
- * i2400m->tx_in being zero would fail, so we treat is an a special
- * case.
- */
-static inline
-size_t __i2400m_tx_tail_room(struct i2400m *i2400m)
-{
- size_t tail_room;
- size_t tx_in;
-
- if (unlikely(i2400m->tx_in == 0))
- return I2400M_TX_BUF_SIZE;
- tx_in = i2400m->tx_in % I2400M_TX_BUF_SIZE;
- tail_room = I2400M_TX_BUF_SIZE - tx_in;
- tail_room %= I2400M_TX_BUF_SIZE;
- return tail_room;
-}
-
-
-/*
- * Allocate @size bytes in the TX fifo, return a pointer to it
- *
- * @i2400m: device descriptor
- * @size: size of the buffer we need to allocate
- * @padding: ensure that there is at least this many bytes of free
- * contiguous space in the fifo. This is needed because later on
- * we might need to add padding.
- * @try_head: specify either to allocate head room or tail room space
- * in the TX FIFO. This boolean is required to avoids a system hang
- * due to an infinite loop caused by i2400m_tx_fifo_push().
- * The caller must always try to allocate tail room space first by
- * calling this routine with try_head = 0. In case if there
- * is not enough tail room space but there is enough head room space,
- * (i2400m_tx_fifo_push() returns TAIL_FULL) try to allocate head
- * room space, by calling this routine again with try_head = 1.
- *
- * Returns:
- *
- * Pointer to the allocated space. NULL if there is no
- * space. TAIL_FULL if there is no space at the tail but there is at
- * the head (Case B below).
- *
- * These are the two basic cases we need to keep an eye for -- it is
- * much better explained in linux/kernel/kfifo.c, but this code
- * basically does the same. No rocket science here.
- *
- * Case A Case B
- * N ___________ ___________
- * | tail room | | data |
- * | | | |
- * |<- IN ->| |<- OUT ->|
- * | | | |
- * | data | | room |
- * | | | |
- * |<- OUT ->| |<- IN ->|
- * | | | |
- * | head room | | data |
- * 0 ----------- -----------
- *
- * We allocate only *contiguous* space.
- *
- * We can allocate only from 'room'. In Case B, it is simple; in case
- * A, we only try from the tail room; if it is not enough, we just
- * fail and return TAIL_FULL and let the caller figure out if we wants to
- * skip the tail room and try to allocate from the head.
- *
- * There is a corner case, wherein i2400m_tx_new() can get into
- * an infinite loop calling i2400m_tx_fifo_push().
- * In certain situations, tx_in would have reached on the top of TX FIFO
- * and i2400m_tx_tail_room() returns 0, as described below:
- *
- * N ___________ tail room is zero
- * |<- IN ->|
- * | |
- * | |
- * | |
- * | data |
- * |<- OUT ->|
- * | |
- * | |
- * | head room |
- * 0 -----------
- * During such a time, where tail room is zero in the TX FIFO and if there
- * is a request to add a payload to TX FIFO, which calls:
- * i2400m_tx()
- * ->calls i2400m_tx_close()
- * ->calls i2400m_tx_skip_tail()
- * goto try_new;
- * ->calls i2400m_tx_new()
- * |----> [try_head:]
- * infinite loop | ->calls i2400m_tx_fifo_push()
- * | if (tail_room < needed)
- * | if (head_room => needed)
- * | return TAIL_FULL;
- * |<---- goto try_head;
- *
- * i2400m_tx() calls i2400m_tx_close() to close the message, since there
- * is no tail room to accommodate the payload and calls
- * i2400m_tx_skip_tail() to skip the tail space. Now i2400m_tx() calls
- * i2400m_tx_new() to allocate space for new message header calling
- * i2400m_tx_fifo_push() that returns TAIL_FULL, since there is no tail space
- * to accommodate the message header, but there is enough head space.
- * The i2400m_tx_new() keeps re-retrying by calling i2400m_tx_fifo_push()
- * ending up in a loop causing system freeze.
- *
- * This corner case is avoided by using a try_head boolean,
- * as an argument to i2400m_tx_fifo_push().
- *
- * Note:
- *
- * Assumes i2400m->tx_lock is taken, and we use that as a barrier
- *
- * The indexes keep increasing and we reset them to zero when we
- * pop data off the queue
- */
-static
-void *i2400m_tx_fifo_push(struct i2400m *i2400m, size_t size,
- size_t padding, bool try_head)
-{
- struct device *dev = i2400m_dev(i2400m);
- size_t room, tail_room, needed_size;
- void *ptr;
-
- needed_size = size + padding;
- room = I2400M_TX_BUF_SIZE - (i2400m->tx_in - i2400m->tx_out);
- if (room < needed_size) { /* this takes care of Case B */
- d_printf(2, dev, "fifo push %zu/%zu: no space\n",
- size, padding);
- return NULL;
- }
- /* Is there space at the tail? */
- tail_room = __i2400m_tx_tail_room(i2400m);
- if (!try_head && tail_room < needed_size) {
- /*
- * If the tail room space is not enough to push the message
- * in the TX FIFO, then there are two possibilities:
- * 1. There is enough head room space to accommodate
- * this message in the TX FIFO.
- * 2. There is not enough space in the head room and
- * in tail room of the TX FIFO to accommodate the message.
- * In the case (1), return TAIL_FULL so that the caller
- * can figure out, if the caller wants to push the message
- * into the head room space.
- * In the case (2), return NULL, indicating that the TX FIFO
- * cannot accommodate the message.
- */
- if (room - tail_room >= needed_size) {
- d_printf(2, dev, "fifo push %zu/%zu: tail full\n",
- size, padding);
- return TAIL_FULL; /* There might be head space */
- } else {
- d_printf(2, dev, "fifo push %zu/%zu: no head space\n",
- size, padding);
- return NULL; /* There is no space */
- }
- }
- ptr = i2400m->tx_buf + i2400m->tx_in % I2400M_TX_BUF_SIZE;
- d_printf(2, dev, "fifo push %zu/%zu: at @%zu\n", size, padding,
- i2400m->tx_in % I2400M_TX_BUF_SIZE);
- i2400m->tx_in += size;
- return ptr;
-}
-
-
-/*
- * Mark the tail of the FIFO buffer as 'to-skip'
- *
- * We should never hit the BUG_ON() because all the sizes we push to
- * the FIFO are padded to be a multiple of 16 -- the size of *msg
- * (I2400M_PL_PAD for the payloads, I2400M_TX_PLD_SIZE for the
- * header).
- *
- * Tail room can get to be zero if a message was opened when there was
- * space only for a header. _tx_close() will mark it as to-skip (as it
- * will have no payloads) and there will be no more space to flush, so
- * nothing has to be done here. This is probably cheaper than ensuring
- * in _tx_new() that there is some space for payloads...as we could
- * always possibly hit the same problem if the payload wouldn't fit.
- *
- * Note:
- *
- * Assumes i2400m->tx_lock is taken, and we use that as a barrier
- *
- * This path is only taken for Case A FIFO situations [see
- * i2400m_tx_fifo_push()]
- */
-static
-void i2400m_tx_skip_tail(struct i2400m *i2400m)
-{
- struct device *dev = i2400m_dev(i2400m);
- size_t tx_in = i2400m->tx_in % I2400M_TX_BUF_SIZE;
- size_t tail_room = __i2400m_tx_tail_room(i2400m);
- struct i2400m_msg_hdr *msg = i2400m->tx_buf + tx_in;
- if (unlikely(tail_room == 0))
- return;
- BUG_ON(tail_room < sizeof(*msg));
- msg->size = tail_room | I2400M_TX_SKIP;
- d_printf(2, dev, "skip tail: skipping %zu bytes @%zu\n",
- tail_room, tx_in);
- i2400m->tx_in += tail_room;
-}
-
-
-/*
- * Check if a skb will fit in the TX queue's current active TX
- * message (if there are still descriptors left unused).
- *
- * Returns:
- * 0 if the message won't fit, 1 if it will.
- *
- * Note:
- *
- * Assumes a TX message is active (i2400m->tx_msg).
- *
- * Assumes i2400m->tx_lock is taken, and we use that as a barrier
- */
-static
-unsigned i2400m_tx_fits(struct i2400m *i2400m)
-{
- struct i2400m_msg_hdr *msg_hdr = i2400m->tx_msg;
- return le16_to_cpu(msg_hdr->num_pls) < I2400M_TX_PLD_MAX;
-
-}
-
-
-/*
- * Start a new TX message header in the queue.
- *
- * Reserve memory from the base FIFO engine and then just initialize
- * the message header.
- *
- * We allocate the biggest TX message header we might need (one that'd
- * fit I2400M_TX_PLD_MAX payloads) -- when it is closed it will be
- * 'ironed it out' and the unneeded parts removed.
- *
- * NOTE:
- *
- * Assumes that the previous message is CLOSED (eg: either
- * there was none or 'i2400m_tx_close()' was called on it).
- *
- * Assumes i2400m->tx_lock is taken, and we use that as a barrier
- */
-static
-void i2400m_tx_new(struct i2400m *i2400m)
-{
- struct device *dev = i2400m_dev(i2400m);
- struct i2400m_msg_hdr *tx_msg;
- bool try_head = false;
- BUG_ON(i2400m->tx_msg != NULL);
- /*
- * In certain situations, TX queue might have enough space to
- * accommodate the new message header I2400M_TX_PLD_SIZE, but
- * might not have enough space to accommodate the payloads.
- * Adding bus_tx_room_min padding while allocating a new TX message
- * increases the possibilities of including at least one payload of the
- * size <= bus_tx_room_min.
- */
-try_head:
- tx_msg = i2400m_tx_fifo_push(i2400m, I2400M_TX_PLD_SIZE,
- i2400m->bus_tx_room_min, try_head);
- if (tx_msg == NULL)
- goto out;
- else if (tx_msg == TAIL_FULL) {
- i2400m_tx_skip_tail(i2400m);
- d_printf(2, dev, "new TX message: tail full, trying head\n");
- try_head = true;
- goto try_head;
- }
- memset(tx_msg, 0, I2400M_TX_PLD_SIZE);
- tx_msg->size = I2400M_TX_PLD_SIZE;
-out:
- i2400m->tx_msg = tx_msg;
- d_printf(2, dev, "new TX message: %p @%zu\n",
- tx_msg, (void *) tx_msg - i2400m->tx_buf);
-}
-
-
-/*
- * Finalize the current TX message header
- *
- * Sets the message header to be at the proper location depending on
- * how many descriptors we have (check documentation at the file's
- * header for more info on that).
- *
- * Appends padding bytes to make sure the whole TX message (counting
- * from the 'relocated' message header) is aligned to
- * tx_block_size. We assume the _append() code has left enough space
- * in the FIFO for that. If there are no payloads, just pass, as it
- * won't be transferred.
- *
- * The amount of padding bytes depends on how many payloads are in the
- * TX message, as the "msg header and payload descriptors" will be
- * shifted up in the buffer.
- */
-static
-void i2400m_tx_close(struct i2400m *i2400m)
-{
- struct device *dev = i2400m_dev(i2400m);
- struct i2400m_msg_hdr *tx_msg = i2400m->tx_msg;
- struct i2400m_msg_hdr *tx_msg_moved;
- size_t aligned_size, padding, hdr_size;
- void *pad_buf;
- unsigned num_pls;
-
- if (tx_msg->size & I2400M_TX_SKIP) /* a skipper? nothing to do */
- goto out;
- num_pls = le16_to_cpu(tx_msg->num_pls);
- /* We can get this situation when a new message was started
- * and there was no space to add payloads before hitting the
- tail (and taking padding into consideration). */
- if (num_pls == 0) {
- tx_msg->size |= I2400M_TX_SKIP;
- goto out;
- }
- /* Relocate the message header
- *
- * Find the current header size, align it to 16 and if we need
- * to move it so the tail is next to the payloads, move it and
- * set the offset.
- *
- * If it moved, this header is good only for transmission; the
- * original one (it is kept if we moved) is still used to
- * figure out where the next TX message starts (and where the
- * offset to the moved header is).
- */
- hdr_size = struct_size(tx_msg, pld, le16_to_cpu(tx_msg->num_pls));
- hdr_size = ALIGN(hdr_size, I2400M_PL_ALIGN);
- tx_msg->offset = I2400M_TX_PLD_SIZE - hdr_size;
- tx_msg_moved = (void *) tx_msg + tx_msg->offset;
- memmove(tx_msg_moved, tx_msg, hdr_size);
- tx_msg_moved->size -= tx_msg->offset;
- /*
- * Now figure out how much we have to add to the (moved!)
- * message so the size is a multiple of i2400m->bus_tx_block_size.
- */
- aligned_size = ALIGN(tx_msg_moved->size, i2400m->bus_tx_block_size);
- padding = aligned_size - tx_msg_moved->size;
- if (padding > 0) {
- pad_buf = i2400m_tx_fifo_push(i2400m, padding, 0, 0);
- if (WARN_ON(pad_buf == NULL || pad_buf == TAIL_FULL)) {
- /* This should not happen -- append should verify
- * there is always space left at least to append
- * tx_block_size */
- dev_err(dev,
- "SW BUG! Possible data leakage from memory the "
- "device should not read for padding - "
- "size %lu aligned_size %zu tx_buf %p in "
- "%zu out %zu\n",
- (unsigned long) tx_msg_moved->size,
- aligned_size, i2400m->tx_buf, i2400m->tx_in,
- i2400m->tx_out);
- } else
- memset(pad_buf, 0xad, padding);
- }
- tx_msg_moved->padding = cpu_to_le16(padding);
- tx_msg_moved->size += padding;
- if (tx_msg != tx_msg_moved)
- tx_msg->size += padding;
-out:
- i2400m->tx_msg = NULL;
-}
-
-
-/**
- * i2400m_tx - send the data in a buffer to the device
- *
- * @i2400m: device descriptor
- *
- * @buf: pointer to the buffer to transmit
- *
- * @buf_len: buffer size
- *
- * @pl_type: type of the payload we are sending.
- *
- * Returns:
- * 0 if ok, < 0 errno code on error (-ENOSPC, if there is no more
- * room for the message in the queue).
- *
- * Appends the buffer to the TX FIFO and notifies the bus-specific
- * part of the driver that there is new data ready to transmit.
- * Once this function returns, the buffer has been copied, so it can
- * be reused.
- *
- * The steps followed to append are explained in detail in the file
- * header.
- *
- * Whenever we write to a message, we increase msg->size, so it
- * reflects exactly how big the message is. This is needed so that if
- * we concatenate two messages before they can be sent, the code that
- * sends the messages can find the boundaries (and it will replace the
- * size with the real barker before sending).
- *
- * Note:
- *
- * Cold and warm reset payloads need to be sent as a single
- * payload, so we handle that.
- */
-int i2400m_tx(struct i2400m *i2400m, const void *buf, size_t buf_len,
- enum i2400m_pt pl_type)
-{
- int result = -ENOSPC;
- struct device *dev = i2400m_dev(i2400m);
- unsigned long flags;
- size_t padded_len;
- void *ptr;
- bool try_head = false;
- unsigned is_singleton = pl_type == I2400M_PT_RESET_WARM
- || pl_type == I2400M_PT_RESET_COLD;
-
- d_fnstart(3, dev, "(i2400m %p skb %p [%zu bytes] pt %u)\n",
- i2400m, buf, buf_len, pl_type);
- padded_len = ALIGN(buf_len, I2400M_PL_ALIGN);
- d_printf(5, dev, "padded_len %zd buf_len %zd\n", padded_len, buf_len);
- /* If there is no current TX message, create one; if the
- * current one is out of payload slots or we have a singleton,
- * close it and start a new one */
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- /* If tx_buf is NULL, device is shutdown */
- if (i2400m->tx_buf == NULL) {
- result = -ESHUTDOWN;
- goto error_tx_new;
- }
-try_new:
- if (unlikely(i2400m->tx_msg == NULL))
- i2400m_tx_new(i2400m);
- else if (unlikely(!i2400m_tx_fits(i2400m)
- || (is_singleton && i2400m->tx_msg->num_pls != 0))) {
- d_printf(2, dev, "closing TX message (fits %u singleton "
- "%u num_pls %u)\n", i2400m_tx_fits(i2400m),
- is_singleton, i2400m->tx_msg->num_pls);
- i2400m_tx_close(i2400m);
- i2400m_tx_new(i2400m);
- }
- if (i2400m->tx_msg == NULL)
- goto error_tx_new;
- /*
- * Check if this skb will fit in the TX queue's current active
- * TX message. The total message size must not exceed the maximum
- * size of each message I2400M_TX_MSG_SIZE. If it exceeds,
- * close the current message and push this skb into the new message.
- */
- if (i2400m->tx_msg->size + padded_len > I2400M_TX_MSG_SIZE) {
- d_printf(2, dev, "TX: message too big, going new\n");
- i2400m_tx_close(i2400m);
- i2400m_tx_new(i2400m);
- }
- if (i2400m->tx_msg == NULL)
- goto error_tx_new;
- /* So we have a current message header; now append space for
- * the message -- if there is not enough, try the head */
- ptr = i2400m_tx_fifo_push(i2400m, padded_len,
- i2400m->bus_tx_block_size, try_head);
- if (ptr == TAIL_FULL) { /* Tail is full, try head */
- d_printf(2, dev, "pl append: tail full\n");
- i2400m_tx_close(i2400m);
- i2400m_tx_skip_tail(i2400m);
- try_head = true;
- goto try_new;
- } else if (ptr == NULL) { /* All full */
- result = -ENOSPC;
- d_printf(2, dev, "pl append: all full\n");
- } else { /* Got space, copy it, set padding */
- struct i2400m_msg_hdr *tx_msg = i2400m->tx_msg;
- unsigned num_pls = le16_to_cpu(tx_msg->num_pls);
- memcpy(ptr, buf, buf_len);
- memset(ptr + buf_len, 0xad, padded_len - buf_len);
- i2400m_pld_set(&tx_msg->pld[num_pls], buf_len, pl_type);
- d_printf(3, dev, "pld 0x%08x (type 0x%1x len 0x%04zx\n",
- le32_to_cpu(tx_msg->pld[num_pls].val),
- pl_type, buf_len);
- tx_msg->num_pls = cpu_to_le16(num_pls + 1);
- tx_msg->size += padded_len;
- d_printf(2, dev, "TX: appended %zu b (up to %u b) pl #%u\n",
- padded_len, tx_msg->size, num_pls+1);
- d_printf(2, dev,
- "TX: appended hdr @%zu %zu b pl #%u @%zu %zu/%zu b\n",
- (void *)tx_msg - i2400m->tx_buf, (size_t)tx_msg->size,
- num_pls+1, ptr - i2400m->tx_buf, buf_len, padded_len);
- result = 0;
- if (is_singleton)
- i2400m_tx_close(i2400m);
- }
-error_tx_new:
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
- /* kick in most cases, except when the TX subsys is down, as
- * it might free space */
- if (likely(result != -ESHUTDOWN))
- i2400m->bus_tx_kick(i2400m);
- d_fnend(3, dev, "(i2400m %p skb %p [%zu bytes] pt %u) = %d\n",
- i2400m, buf, buf_len, pl_type, result);
- return result;
-}
-EXPORT_SYMBOL_GPL(i2400m_tx);
-
-
-/**
- * i2400m_tx_msg_get - Get the first TX message in the FIFO to start sending it
- *
- * @i2400m: device descriptors
- * @bus_size: where to place the size of the TX message
- *
- * Called by the bus-specific driver to get the first TX message at
- * the FIF that is ready for transmission.
- *
- * It sets the state in @i2400m to indicate the bus-specific driver is
- * transferring that message (i2400m->tx_msg_size).
- *
- * Once the transfer is completed, call i2400m_tx_msg_sent().
- *
- * Notes:
- *
- * The size of the TX message to be transmitted might be smaller than
- * that of the TX message in the FIFO (in case the header was
- * shorter). Hence, we copy it in @bus_size, for the bus layer to
- * use. We keep the message's size in i2400m->tx_msg_size so that
- * when the bus later is done transferring we know how much to
- * advance the fifo.
- *
- * We collect statistics here as all the data is available and we
- * assume it is going to work [see i2400m_tx_msg_sent()].
- */
-struct i2400m_msg_hdr *i2400m_tx_msg_get(struct i2400m *i2400m,
- size_t *bus_size)
-{
- struct device *dev = i2400m_dev(i2400m);
- struct i2400m_msg_hdr *tx_msg, *tx_msg_moved;
- unsigned long flags, pls;
-
- d_fnstart(3, dev, "(i2400m %p bus_size %p)\n", i2400m, bus_size);
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- tx_msg_moved = NULL;
- if (i2400m->tx_buf == NULL)
- goto out_unlock;
-skip:
- tx_msg_moved = NULL;
- if (i2400m->tx_in == i2400m->tx_out) { /* Empty FIFO? */
- i2400m->tx_in = 0;
- i2400m->tx_out = 0;
- d_printf(2, dev, "TX: FIFO empty: resetting\n");
- goto out_unlock;
- }
- tx_msg = i2400m->tx_buf + i2400m->tx_out % I2400M_TX_BUF_SIZE;
- if (tx_msg->size & I2400M_TX_SKIP) { /* skip? */
- d_printf(2, dev, "TX: skip: msg @%zu (%zu b)\n",
- i2400m->tx_out % I2400M_TX_BUF_SIZE,
- (size_t) tx_msg->size & ~I2400M_TX_SKIP);
- i2400m->tx_out += tx_msg->size & ~I2400M_TX_SKIP;
- goto skip;
- }
-
- if (tx_msg->num_pls == 0) { /* No payloads? */
- if (tx_msg == i2400m->tx_msg) { /* open, we are done */
- d_printf(2, dev,
- "TX: FIFO empty: open msg w/o payloads @%zu\n",
- (void *) tx_msg - i2400m->tx_buf);
- tx_msg = NULL;
- goto out_unlock;
- } else { /* closed, skip it */
- d_printf(2, dev,
- "TX: skip msg w/o payloads @%zu (%zu b)\n",
- (void *) tx_msg - i2400m->tx_buf,
- (size_t) tx_msg->size);
- i2400m->tx_out += tx_msg->size & ~I2400M_TX_SKIP;
- goto skip;
- }
- }
- if (tx_msg == i2400m->tx_msg) /* open msg? */
- i2400m_tx_close(i2400m);
-
- /* Now we have a valid TX message (with payloads) to TX */
- tx_msg_moved = (void *) tx_msg + tx_msg->offset;
- i2400m->tx_msg_size = tx_msg->size;
- *bus_size = tx_msg_moved->size;
- d_printf(2, dev, "TX: pid %d msg hdr at @%zu offset +@%zu "
- "size %zu bus_size %zu\n",
- current->pid, (void *) tx_msg - i2400m->tx_buf,
- (size_t) tx_msg->offset, (size_t) tx_msg->size,
- (size_t) tx_msg_moved->size);
- tx_msg_moved->barker = cpu_to_le32(I2400M_H2D_PREVIEW_BARKER);
- tx_msg_moved->sequence = cpu_to_le32(i2400m->tx_sequence++);
-
- pls = le16_to_cpu(tx_msg_moved->num_pls);
- i2400m->tx_pl_num += pls; /* Update stats */
- if (pls > i2400m->tx_pl_max)
- i2400m->tx_pl_max = pls;
- if (pls < i2400m->tx_pl_min)
- i2400m->tx_pl_min = pls;
- i2400m->tx_num++;
- i2400m->tx_size_acc += *bus_size;
- if (*bus_size < i2400m->tx_size_min)
- i2400m->tx_size_min = *bus_size;
- if (*bus_size > i2400m->tx_size_max)
- i2400m->tx_size_max = *bus_size;
-out_unlock:
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
- d_fnstart(3, dev, "(i2400m %p bus_size %p [%zu]) = %p\n",
- i2400m, bus_size, *bus_size, tx_msg_moved);
- return tx_msg_moved;
-}
-EXPORT_SYMBOL_GPL(i2400m_tx_msg_get);
-
-
-/**
- * i2400m_tx_msg_sent - indicate the transmission of a TX message
- *
- * @i2400m: device descriptor
- *
- * Called by the bus-specific driver when a message has been sent;
- * this pops it from the FIFO; and as there is space, start the queue
- * in case it was stopped.
- *
- * Should be called even if the message send failed and we are
- * dropping this TX message.
- */
-void i2400m_tx_msg_sent(struct i2400m *i2400m)
-{
- unsigned n;
- unsigned long flags;
- struct device *dev = i2400m_dev(i2400m);
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- if (i2400m->tx_buf == NULL)
- goto out_unlock;
- i2400m->tx_out += i2400m->tx_msg_size;
- d_printf(2, dev, "TX: sent %zu b\n", (size_t) i2400m->tx_msg_size);
- i2400m->tx_msg_size = 0;
- BUG_ON(i2400m->tx_out > i2400m->tx_in);
- /* level them FIFO markers off */
- n = i2400m->tx_out / I2400M_TX_BUF_SIZE;
- i2400m->tx_out %= I2400M_TX_BUF_SIZE;
- i2400m->tx_in -= n * I2400M_TX_BUF_SIZE;
-out_unlock:
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
- d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
-EXPORT_SYMBOL_GPL(i2400m_tx_msg_sent);
-
-
-/**
- * i2400m_tx_setup - Initialize the TX queue and infrastructure
- *
- * @i2400m: device descriptor
- *
- * Make sure we reset the TX sequence to zero, as when this function
- * is called, the firmware has been just restarted. Same rational
- * for tx_in, tx_out, tx_msg_size and tx_msg. We reset them since
- * the memory for TX queue is reallocated.
- */
-int i2400m_tx_setup(struct i2400m *i2400m)
-{
- int result = 0;
- void *tx_buf;
- unsigned long flags;
-
- /* Do this here only once -- can't do on
- * i2400m_hard_start_xmit() as we'll cause race conditions if
- * the WS was scheduled on another CPU */
- INIT_WORK(&i2400m->wake_tx_ws, i2400m_wake_tx_work);
-
- tx_buf = kmalloc(I2400M_TX_BUF_SIZE, GFP_ATOMIC);
- if (tx_buf == NULL) {
- result = -ENOMEM;
- goto error_kmalloc;
- }
-
- /*
- * Fail the build if we can't fit at least two maximum size messages
- * on the TX FIFO [one being delivered while one is constructed].
- */
- BUILD_BUG_ON(2 * I2400M_TX_MSG_SIZE > I2400M_TX_BUF_SIZE);
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- i2400m->tx_sequence = 0;
- i2400m->tx_in = 0;
- i2400m->tx_out = 0;
- i2400m->tx_msg_size = 0;
- i2400m->tx_msg = NULL;
- i2400m->tx_buf = tx_buf;
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
- /* Huh? the bus layer has to define this... */
- BUG_ON(i2400m->bus_tx_block_size == 0);
-error_kmalloc:
- return result;
-
-}
-
-
-/*
- * i2400m_tx_release - Tear down the TX queue and infrastructure
- */
-void i2400m_tx_release(struct i2400m *i2400m)
-{
- unsigned long flags;
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- kfree(i2400m->tx_buf);
- i2400m->tx_buf = NULL;
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-}
diff --git a/drivers/staging/wimax/i2400m/usb-debug-levels.h b/drivers/staging/wimax/i2400m/usb-debug-levels.h
deleted file mode 100644
index 8fd0111560f6..000000000000
--- a/drivers/staging/wimax/i2400m/usb-debug-levels.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Debug levels control file for the i2400m-usb module
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-#ifndef __debug_levels__h__
-#define __debug_levels__h__
-
-/* Maximum compile and run time debug level for all submodules */
-#define D_MODULENAME i2400m_usb
-#define D_MASTER CONFIG_WIMAX_I2400M_DEBUG_LEVEL
-
-#include "../linux-wimax-debug.h"
-
-/* List of all the enabled modules */
-enum d_module {
- D_SUBMODULE_DECLARE(usb),
- D_SUBMODULE_DECLARE(fw),
- D_SUBMODULE_DECLARE(notif),
- D_SUBMODULE_DECLARE(rx),
- D_SUBMODULE_DECLARE(tx),
-};
-
-
-#endif /* #ifndef __debug_levels__h__ */
diff --git a/drivers/staging/wimax/i2400m/usb-fw.c b/drivers/staging/wimax/i2400m/usb-fw.c
deleted file mode 100644
index 27ab233650d5..000000000000
--- a/drivers/staging/wimax/i2400m/usb-fw.c
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Firmware uploader's USB specifics
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * 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 Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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
- * OWNER 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.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * - Initial implementation
- *
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * - bus generic/specific split
- *
- * THE PROCEDURE
- *
- * See fw.c for the generic description of this procedure.
- *
- * This file implements only the USB specifics. It boils down to how
- * to send a command and waiting for an acknowledgement from the
- * device.
- *
- * This code (and process) is single threaded. It assumes it is the
- * only thread poking around (guaranteed by fw.c).
- *
- * COMMAND EXECUTION
- *
- * A write URB is posted with the buffer to the bulk output endpoint.
- *
- * ACK RECEPTION
- *
- * We just post a URB to the notification endpoint and wait for
- * data. We repeat until we get all the data we expect (as indicated
- * by the call from the bus generic code).
- *
- * The data is not read from the bulk in endpoint for boot mode.
- *
- * ROADMAP
- *
- * i2400mu_bus_bm_cmd_send
- * i2400m_bm_cmd_prepare...
- * i2400mu_tx_bulk_out
- *
- * i2400mu_bus_bm_wait_for_ack
- * i2400m_notif_submit
- */
-#include <linux/usb.h>
-#include <linux/gfp.h>
-#include "i2400m-usb.h"
-
-
-#define D_SUBMODULE fw
-#include "usb-debug-levels.h"
-
-
-/*
- * Synchronous write to the device
- *
- * Takes care of updating EDC counts and thus, handle device errors.
- */
-static
-ssize_t i2400mu_tx_bulk_out(struct i2400mu *i2400mu, void *buf, size_t buf_size)
-{
- int result;
- struct device *dev = &i2400mu->usb_iface->dev;
- int len;
- struct usb_endpoint_descriptor *epd;
- int pipe, do_autopm = 1;
-
- result = usb_autopm_get_interface(i2400mu->usb_iface);
- if (result < 0) {
- dev_err(dev, "BM-CMD: can't get autopm: %d\n", result);
- do_autopm = 0;
- }
- epd = usb_get_epd(i2400mu->usb_iface, i2400mu->endpoint_cfg.bulk_out);
- pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
-retry:
- result = usb_bulk_msg(i2400mu->usb_dev, pipe, buf, buf_size, &len, 200);
- switch (result) {
- case 0:
- if (len != buf_size) {
- dev_err(dev, "BM-CMD: short write (%u B vs %zu "
- "expected)\n", len, buf_size);
- result = -EIO;
- break;
- }
- result = len;
- break;
- case -EPIPE:
- /*
- * Stall -- maybe the device is choking with our
- * requests. Clear it and give it some time. If they
- * happen to often, it might be another symptom, so we
- * reset.
- *
- * No error handling for usb_clear_halt(0; if it
- * works, the retry works; if it fails, this switch
- * does the error handling for us.
- */
- if (edc_inc(&i2400mu->urb_edc,
- 10 * EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
- dev_err(dev, "BM-CMD: too many stalls in "
- "URB; resetting device\n");
- usb_queue_reset_device(i2400mu->usb_iface);
- } else {
- usb_clear_halt(i2400mu->usb_dev, pipe);
- msleep(10); /* give the device some time */
- goto retry;
- }
- fallthrough;
- case -EINVAL: /* while removing driver */
- case -ENODEV: /* dev disconnect ... */
- case -ENOENT: /* just ignore it */
- case -ESHUTDOWN: /* and exit */
- case -ECONNRESET:
- result = -ESHUTDOWN;
- break;
- case -ETIMEDOUT: /* bah... */
- break;
- default: /* any other? */
- if (edc_inc(&i2400mu->urb_edc,
- EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
- dev_err(dev, "BM-CMD: maximum errors in "
- "URB exceeded; resetting device\n");
- usb_queue_reset_device(i2400mu->usb_iface);
- result = -ENODEV;
- break;
- }
- dev_err(dev, "BM-CMD: URB error %d, retrying\n",
- result);
- goto retry;
- }
- if (do_autopm)
- usb_autopm_put_interface(i2400mu->usb_iface);
- return result;
-}
-
-
-/*
- * Send a boot-mode command over the bulk-out pipe
- *
- * Command can be a raw command, which requires no preparation (and
- * which might not even be following the command format). Checks that
- * the right amount of data was transferred.
- *
- * To satisfy USB requirements (no onstack, vmalloc or in data segment
- * buffers), we copy the command to i2400m->bm_cmd_buf and send it from
- * there.
- *
- * @flags: pass thru from i2400m_bm_cmd()
- * @return: cmd_size if ok, < 0 errno code on error.
- */
-ssize_t i2400mu_bus_bm_cmd_send(struct i2400m *i2400m,
- const struct i2400m_bootrom_header *_cmd,
- size_t cmd_size, int flags)
-{
- ssize_t result;
- struct device *dev = i2400m_dev(i2400m);
- struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
- int opcode = _cmd == NULL ? -1 : i2400m_brh_get_opcode(_cmd);
- struct i2400m_bootrom_header *cmd;
- size_t cmd_size_a = ALIGN(cmd_size, 16); /* USB restriction */
-
- d_fnstart(8, dev, "(i2400m %p cmd %p size %zu)\n",
- i2400m, _cmd, cmd_size);
- result = -E2BIG;
- if (cmd_size > I2400M_BM_CMD_BUF_SIZE)
- goto error_too_big;
- if (_cmd != i2400m->bm_cmd_buf)
- memmove(i2400m->bm_cmd_buf, _cmd, cmd_size);
- cmd = i2400m->bm_cmd_buf;
- if (cmd_size_a > cmd_size) /* Zero pad space */
- memset(i2400m->bm_cmd_buf + cmd_size, 0, cmd_size_a - cmd_size);
- if ((flags & I2400M_BM_CMD_RAW) == 0) {
- if (WARN_ON(i2400m_brh_get_response_required(cmd) == 0))
- dev_warn(dev, "SW BUG: response_required == 0\n");
- i2400m_bm_cmd_prepare(cmd);
- }
- result = i2400mu_tx_bulk_out(i2400mu, i2400m->bm_cmd_buf, cmd_size);
- if (result < 0) {
- dev_err(dev, "boot-mode cmd %d: cannot send: %zd\n",
- opcode, result);
- goto error_cmd_send;
- }
- if (result != cmd_size) { /* all was transferred? */
- dev_err(dev, "boot-mode cmd %d: incomplete transfer "
- "(%zd vs %zu submitted)\n", opcode, result, cmd_size);
- result = -EIO;
- goto error_cmd_size;
- }
-error_cmd_size:
-error_cmd_send:
-error_too_big:
- d_fnend(8, dev, "(i2400m %p cmd %p size %zu) = %zd\n",
- i2400m, _cmd, cmd_size, result);
- return result;
-}
-
-
-static
-void __i2400mu_bm_notif_cb(struct urb *urb)
-{
- complete(urb->context);
-}
-
-
-/*
- * submit a read to the notification endpoint
- *
- * @i2400m: device descriptor
- * @urb: urb to use
- * @completion: completion variable to complete when done
- *
- * Data is always read to i2400m->bm_ack_buf
- */
-static
-int i2400mu_notif_submit(struct i2400mu *i2400mu, struct urb *urb,
- struct completion *completion)
-{
- struct i2400m *i2400m = &i2400mu->i2400m;
- struct usb_endpoint_descriptor *epd;
- int pipe;
-
- epd = usb_get_epd(i2400mu->usb_iface,
- i2400mu->endpoint_cfg.notification);
- pipe = usb_rcvintpipe(i2400mu->usb_dev, epd->bEndpointAddress);
- usb_fill_int_urb(urb, i2400mu->usb_dev, pipe,
- i2400m->bm_ack_buf, I2400M_BM_ACK_BUF_SIZE,
- __i2400mu_bm_notif_cb, completion,
- epd->bInterval);
- return usb_submit_urb(urb, GFP_KERNEL);
-}
-
-
-/*
- * Read an ack from the notification endpoint
- *
- * @i2400m:
- * @_ack: pointer to where to store the read data
- * @ack_size: how many bytes we should read
- *
- * Returns: < 0 errno code on error; otherwise, amount of received bytes.
- *
- * Submits a notification read, appends the read data to the given ack
- * buffer and then repeats (until @ack_size bytes have been
- * received).
- */
-ssize_t i2400mu_bus_bm_wait_for_ack(struct i2400m *i2400m,
- struct i2400m_bootrom_header *_ack,
- size_t ack_size)
-{
- ssize_t result = -ENOMEM;
- struct device *dev = i2400m_dev(i2400m);
- struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
- struct urb notif_urb;
- void *ack = _ack;
- size_t offset, len;
- long val;
- int do_autopm = 1;
- DECLARE_COMPLETION_ONSTACK(notif_completion);
-
- d_fnstart(8, dev, "(i2400m %p ack %p size %zu)\n",
- i2400m, ack, ack_size);
- BUG_ON(_ack == i2400m->bm_ack_buf);
- result = usb_autopm_get_interface(i2400mu->usb_iface);
- if (result < 0) {
- dev_err(dev, "BM-ACK: can't get autopm: %d\n", (int) result);
- do_autopm = 0;
- }
- usb_init_urb(&notif_urb); /* ready notifications */
- usb_get_urb(&notif_urb);
- offset = 0;
- while (offset < ack_size) {
- init_completion(&notif_completion);
- result = i2400mu_notif_submit(i2400mu, &notif_urb,
- &notif_completion);
- if (result < 0)
- goto error_notif_urb_submit;
- val = wait_for_completion_interruptible_timeout(
- &notif_completion, HZ);
- if (val == 0) {
- result = -ETIMEDOUT;
- usb_kill_urb(&notif_urb); /* Timedout */
- goto error_notif_wait;
- }
- if (val == -ERESTARTSYS) {
- result = -EINTR; /* Interrupted */
- usb_kill_urb(&notif_urb);
- goto error_notif_wait;
- }
- result = notif_urb.status; /* How was the ack? */
- switch (result) {
- case 0:
- break;
- case -EINVAL: /* while removing driver */
- case -ENODEV: /* dev disconnect ... */
- case -ENOENT: /* just ignore it */
- case -ESHUTDOWN: /* and exit */
- case -ECONNRESET:
- result = -ESHUTDOWN;
- goto error_dev_gone;
- default: /* any other? */
- usb_kill_urb(&notif_urb); /* Timedout */
- if (edc_inc(&i2400mu->urb_edc,
- EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME))
- goto error_exceeded;
- dev_err(dev, "BM-ACK: URB error %d, "
- "retrying\n", notif_urb.status);
- continue; /* retry */
- }
- if (notif_urb.actual_length == 0) {
- d_printf(6, dev, "ZLP received, retrying\n");
- continue;
- }
- /* Got data, append it to the buffer */
- len = min(ack_size - offset, (size_t) notif_urb.actual_length);
- memcpy(ack + offset, i2400m->bm_ack_buf, len);
- offset += len;
- }
- result = offset;
-error_notif_urb_submit:
-error_notif_wait:
-error_dev_gone:
-out:
- if (do_autopm)
- usb_autopm_put_interface(i2400mu->usb_iface);
- d_fnend(8, dev, "(i2400m %p ack %p size %zu) = %ld\n",
- i2400m, ack, ack_size, (long) result);
- usb_put_urb(&notif_urb);
- return result;
-
-error_exceeded:
- dev_err(dev, "bm: maximum errors in notification URB exceeded; "
- "resetting device\n");
- usb_queue_reset_device(i2400mu->usb_iface);
- goto out;
-}
diff --git a/drivers/staging/wimax/i2400m/usb-notif.c b/drivers/staging/wimax/i2400m/usb-notif.c
deleted file mode 100644
index 5d429f816125..000000000000
--- a/drivers/staging/wimax/i2400m/usb-notif.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m over USB
- * Notification handling
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * 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 Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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
- * OWNER 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.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * - Initial implementation
- *
- *
- * The notification endpoint is active when the device is not in boot
- * mode; in here we just read and get notifications; based on those,
- * we act to either reinitialize the device after a reboot or to
- * submit a RX request.
- *
- * ROADMAP
- *
- * i2400mu_usb_notification_setup()
- *
- * i2400mu_usb_notification_release()
- *
- * i2400mu_usb_notification_cb() Called when a URB is ready
- * i2400mu_notif_grok()
- * i2400m_is_boot_barker()
- * i2400m_dev_reset_handle()
- * i2400mu_rx_kick()
- */
-#include <linux/usb.h>
-#include <linux/slab.h>
-#include "i2400m-usb.h"
-
-
-#define D_SUBMODULE notif
-#include "usb-debug-levels.h"
-
-
-static const
-__le32 i2400m_ZERO_BARKER[4] = { 0, 0, 0, 0 };
-
-
-/*
- * Process a received notification
- *
- * In normal operation mode, we can only receive two types of payloads
- * on the notification endpoint:
- *
- * - a reboot barker, we do a bootstrap (the device has reseted).
- *
- * - a block of zeroes: there is pending data in the IN endpoint
- */
-static
-int i2400mu_notification_grok(struct i2400mu *i2400mu, const void *buf,
- size_t buf_len)
-{
- int ret;
- struct device *dev = &i2400mu->usb_iface->dev;
- struct i2400m *i2400m = &i2400mu->i2400m;
-
- d_fnstart(4, dev, "(i2400m %p buf %p buf_len %zu)\n",
- i2400mu, buf, buf_len);
- ret = -EIO;
- if (buf_len < sizeof(i2400m_ZERO_BARKER))
- /* Not a bug, just ignore */
- goto error_bad_size;
- ret = 0;
- if (!memcmp(i2400m_ZERO_BARKER, buf, sizeof(i2400m_ZERO_BARKER))) {
- i2400mu_rx_kick(i2400mu);
- goto out;
- }
- ret = i2400m_is_boot_barker(i2400m, buf, buf_len);
- if (unlikely(ret >= 0))
- ret = i2400m_dev_reset_handle(i2400m, "device rebooted");
- else /* Unknown or unexpected data in the notif message */
- i2400m_unknown_barker(i2400m, buf, buf_len);
-error_bad_size:
-out:
- d_fnend(4, dev, "(i2400m %p buf %p buf_len %zu) = %d\n",
- i2400mu, buf, buf_len, ret);
- return ret;
-}
-
-
-/*
- * URB callback for the notification endpoint
- *
- * @urb: the urb received from the notification endpoint
- *
- * This function will just process the USB side of the transaction,
- * checking everything is fine, pass the processing to
- * i2400m_notification_grok() and resubmit the URB.
- */
-static
-void i2400mu_notification_cb(struct urb *urb)
-{
- int ret;
- struct i2400mu *i2400mu = urb->context;
- struct device *dev = &i2400mu->usb_iface->dev;
-
- d_fnstart(4, dev, "(urb %p status %d actual_length %d)\n",
- urb, urb->status, urb->actual_length);
- ret = urb->status;
- switch (ret) {
- case 0:
- ret = i2400mu_notification_grok(i2400mu, urb->transfer_buffer,
- urb->actual_length);
- if (ret == -EIO && edc_inc(&i2400mu->urb_edc, EDC_MAX_ERRORS,
- EDC_ERROR_TIMEFRAME))
- goto error_exceeded;
- if (ret == -ENOMEM) /* uff...power cycle? shutdown? */
- goto error_exceeded;
- break;
- case -EINVAL: /* while removing driver */
- case -ENODEV: /* dev disconnect ... */
- case -ENOENT: /* ditto */
- case -ESHUTDOWN: /* URB killed */
- case -ECONNRESET: /* disconnection */
- goto out; /* Notify around */
- default: /* Some error? */
- if (edc_inc(&i2400mu->urb_edc,
- EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME))
- goto error_exceeded;
- dev_err(dev, "notification: URB error %d, retrying\n",
- urb->status);
- }
- usb_mark_last_busy(i2400mu->usb_dev);
- ret = usb_submit_urb(i2400mu->notif_urb, GFP_ATOMIC);
- switch (ret) {
- case 0:
- case -EINVAL: /* while removing driver */
- case -ENODEV: /* dev disconnect ... */
- case -ENOENT: /* ditto */
- case -ESHUTDOWN: /* URB killed */
- case -ECONNRESET: /* disconnection */
- break; /* just ignore */
- default: /* Some error? */
- dev_err(dev, "notification: cannot submit URB: %d\n", ret);
- goto error_submit;
- }
- d_fnend(4, dev, "(urb %p status %d actual_length %d) = void\n",
- urb, urb->status, urb->actual_length);
- return;
-
-error_exceeded:
- dev_err(dev, "maximum errors in notification URB exceeded; "
- "resetting device\n");
-error_submit:
- usb_queue_reset_device(i2400mu->usb_iface);
-out:
- d_fnend(4, dev, "(urb %p status %d actual_length %d) = void\n",
- urb, urb->status, urb->actual_length);
-}
-
-
-/*
- * setup the notification endpoint
- *
- * @i2400m: device descriptor
- *
- * This procedure prepares the notification urb and handler for receiving
- * unsolicited barkers from the device.
- */
-int i2400mu_notification_setup(struct i2400mu *i2400mu)
-{
- struct device *dev = &i2400mu->usb_iface->dev;
- int usb_pipe, ret = 0;
- struct usb_endpoint_descriptor *epd;
- char *buf;
-
- d_fnstart(4, dev, "(i2400m %p)\n", i2400mu);
- buf = kmalloc(I2400MU_MAX_NOTIFICATION_LEN, GFP_KERNEL | GFP_DMA);
- if (buf == NULL) {
- ret = -ENOMEM;
- goto error_buf_alloc;
- }
-
- i2400mu->notif_urb = usb_alloc_urb(0, GFP_KERNEL);
- if (!i2400mu->notif_urb) {
- ret = -ENOMEM;
- goto error_alloc_urb;
- }
- epd = usb_get_epd(i2400mu->usb_iface,
- i2400mu->endpoint_cfg.notification);
- usb_pipe = usb_rcvintpipe(i2400mu->usb_dev, epd->bEndpointAddress);
- usb_fill_int_urb(i2400mu->notif_urb, i2400mu->usb_dev, usb_pipe,
- buf, I2400MU_MAX_NOTIFICATION_LEN,
- i2400mu_notification_cb, i2400mu, epd->bInterval);
- ret = usb_submit_urb(i2400mu->notif_urb, GFP_KERNEL);
- if (ret != 0) {
- dev_err(dev, "notification: cannot submit URB: %d\n", ret);
- goto error_submit;
- }
- d_fnend(4, dev, "(i2400m %p) = %d\n", i2400mu, ret);
- return ret;
-
-error_submit:
- usb_free_urb(i2400mu->notif_urb);
-error_alloc_urb:
- kfree(buf);
-error_buf_alloc:
- d_fnend(4, dev, "(i2400m %p) = %d\n", i2400mu, ret);
- return ret;
-}
-
-
-/*
- * Tear down of the notification mechanism
- *
- * @i2400m: device descriptor
- *
- * Kill the interrupt endpoint urb, free any allocated resources.
- *
- * We need to check if we have done it before as for example,
- * _suspend() call this; if after a suspend() we get a _disconnect()
- * (as the case is when hibernating), nothing bad happens.
- */
-void i2400mu_notification_release(struct i2400mu *i2400mu)
-{
- struct device *dev = &i2400mu->usb_iface->dev;
-
- d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
- if (i2400mu->notif_urb != NULL) {
- usb_kill_urb(i2400mu->notif_urb);
- kfree(i2400mu->notif_urb->transfer_buffer);
- usb_free_urb(i2400mu->notif_urb);
- i2400mu->notif_urb = NULL;
- }
- d_fnend(4, dev, "(i2400mu %p)\n", i2400mu);
-}
diff --git a/drivers/staging/wimax/i2400m/usb-rx.c b/drivers/staging/wimax/i2400m/usb-rx.c
deleted file mode 100644
index 5b64bda7d9e7..000000000000
--- a/drivers/staging/wimax/i2400m/usb-rx.c
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * USB RX handling
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * 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 Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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
- * OWNER 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.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * - Initial implementation
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * - Use skb_clone(), break up processing in chunks
- * - Split transport/device specific
- * - Make buffer size dynamic to exert less memory pressure
- *
- *
- * This handles the RX path on USB.
- *
- * When a notification is received that says 'there is RX data ready',
- * we call i2400mu_rx_kick(); that wakes up the RX kthread, which
- * reads a buffer from USB and passes it to i2400m_rx() in the generic
- * handling code. The RX buffer has an specific format that is
- * described in rx.c.
- *
- * We use a kernel thread in a loop because:
- *
- * - we want to be able to call the USB power management get/put
- * functions (blocking) before each transaction.
- *
- * - We might get a lot of notifications and we don't want to submit
- * a zillion reads; by serializing, we are throttling.
- *
- * - RX data processing can get heavy enough so that it is not
- * appropriate for doing it in the USB callback; thus we run it in a
- * process context.
- *
- * We provide a read buffer of an arbitrary size (short of a page); if
- * the callback reports -EOVERFLOW, it means it was too small, so we
- * just double the size and retry (being careful to append, as
- * sometimes the device provided some data). Every now and then we
- * check if the average packet size is smaller than the current packet
- * size and if so, we halve it. At the end, the size of the
- * preallocated buffer should be following the average received
- * transaction size, adapting dynamically to it.
- *
- * ROADMAP
- *
- * i2400mu_rx_kick() Called from notif.c when we get a
- * 'data ready' notification
- * i2400mu_rxd() Kernel RX daemon
- * i2400mu_rx() Receive USB data
- * i2400m_rx() Send data to generic i2400m RX handling
- *
- * i2400mu_rx_setup() called from i2400mu_bus_dev_start()
- *
- * i2400mu_rx_release() called from i2400mu_bus_dev_stop()
- */
-#include <linux/workqueue.h>
-#include <linux/slab.h>
-#include <linux/usb.h>
-#include "i2400m-usb.h"
-
-
-#define D_SUBMODULE rx
-#include "usb-debug-levels.h"
-
-/*
- * Dynamic RX size
- *
- * We can't let the rx_size be a multiple of 512 bytes (the RX
- * endpoint's max packet size). On some USB host controllers (we
- * haven't been able to fully characterize which), if the device is
- * about to send (for example) X bytes and we only post a buffer to
- * receive n*512, it will fail to mark that as babble (so that
- * i2400mu_rx() [case -EOVERFLOW] can resize the buffer and get the
- * rest).
- *
- * So on growing or shrinking, if it is a multiple of the
- * maxpacketsize, we remove some (instead of incresing some, so in a
- * buddy allocator we try to waste less space).
- *
- * Note we also need a hook for this on i2400mu_rx() -- when we do the
- * first read, we are sure we won't hit this spot because
- * i240mm->rx_size has been set properly. However, if we have to
- * double because of -EOVERFLOW, when we launch the read to get the
- * rest of the data, we *have* to make sure that also is not a
- * multiple of the max_pkt_size.
- */
-
-static
-size_t i2400mu_rx_size_grow(struct i2400mu *i2400mu)
-{
- struct device *dev = &i2400mu->usb_iface->dev;
- size_t rx_size;
- const size_t max_pkt_size = 512;
-
- rx_size = 2 * i2400mu->rx_size;
- if (rx_size % max_pkt_size == 0) {
- rx_size -= 8;
- d_printf(1, dev,
- "RX: expected size grew to %zu [adjusted -8] "
- "from %zu\n",
- rx_size, i2400mu->rx_size);
- } else
- d_printf(1, dev,
- "RX: expected size grew to %zu from %zu\n",
- rx_size, i2400mu->rx_size);
- return rx_size;
-}
-
-
-static
-void i2400mu_rx_size_maybe_shrink(struct i2400mu *i2400mu)
-{
- const size_t max_pkt_size = 512;
- struct device *dev = &i2400mu->usb_iface->dev;
-
- if (unlikely(i2400mu->rx_size_cnt >= 100
- && i2400mu->rx_size_auto_shrink)) {
- size_t avg_rx_size =
- i2400mu->rx_size_acc / i2400mu->rx_size_cnt;
- size_t new_rx_size = i2400mu->rx_size / 2;
- if (avg_rx_size < new_rx_size) {
- if (new_rx_size % max_pkt_size == 0) {
- new_rx_size -= 8;
- d_printf(1, dev,
- "RX: expected size shrank to %zu "
- "[adjusted -8] from %zu\n",
- new_rx_size, i2400mu->rx_size);
- } else
- d_printf(1, dev,
- "RX: expected size shrank to %zu "
- "from %zu\n",
- new_rx_size, i2400mu->rx_size);
- i2400mu->rx_size = new_rx_size;
- i2400mu->rx_size_cnt = 0;
- i2400mu->rx_size_acc = i2400mu->rx_size;
- }
- }
-}
-
-/*
- * Receive a message with payloads from the USB bus into an skb
- *
- * @i2400mu: USB device descriptor
- * @rx_skb: skb where to place the received message
- *
- * Deals with all the USB-specifics of receiving, dynamically
- * increasing the buffer size if so needed. Returns the payload in the
- * skb, ready to process. On a zero-length packet, we retry.
- *
- * On soft USB errors, we retry (until they become too frequent and
- * then are promoted to hard); on hard USB errors, we reset the
- * device. On other errors (skb realloacation, we just drop it and
- * hope for the next invocation to solve it).
- *
- * Returns: pointer to the skb if ok, ERR_PTR on error.
- * NOTE: this function might realloc the skb (if it is too small),
- * so always update with the one returned.
- * ERR_PTR() is < 0 on error.
- * Will return NULL if it cannot reallocate -- this can be
- * considered a transient retryable error.
- */
-static
-struct sk_buff *i2400mu_rx(struct i2400mu *i2400mu, struct sk_buff *rx_skb)
-{
- int result = 0;
- struct device *dev = &i2400mu->usb_iface->dev;
- int usb_pipe, read_size, rx_size, do_autopm;
- struct usb_endpoint_descriptor *epd;
- const size_t max_pkt_size = 512;
-
- d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
- do_autopm = atomic_read(&i2400mu->do_autopm);
- result = do_autopm ?
- usb_autopm_get_interface(i2400mu->usb_iface) : 0;
- if (result < 0) {
- dev_err(dev, "RX: can't get autopm: %d\n", result);
- do_autopm = 0;
- }
- epd = usb_get_epd(i2400mu->usb_iface, i2400mu->endpoint_cfg.bulk_in);
- usb_pipe = usb_rcvbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
-retry:
- rx_size = skb_end_pointer(rx_skb) - rx_skb->data - rx_skb->len;
- if (unlikely(rx_size % max_pkt_size == 0)) {
- rx_size -= 8;
- d_printf(1, dev, "RX: rx_size adapted to %d [-8]\n", rx_size);
- }
- result = usb_bulk_msg(
- i2400mu->usb_dev, usb_pipe, rx_skb->data + rx_skb->len,
- rx_size, &read_size, 200);
- usb_mark_last_busy(i2400mu->usb_dev);
- switch (result) {
- case 0:
- if (read_size == 0)
- goto retry; /* ZLP, just resubmit */
- skb_put(rx_skb, read_size);
- break;
- case -EPIPE:
- /*
- * Stall -- maybe the device is choking with our
- * requests. Clear it and give it some time. If they
- * happen to often, it might be another symptom, so we
- * reset.
- *
- * No error handling for usb_clear_halt(0; if it
- * works, the retry works; if it fails, this switch
- * does the error handling for us.
- */
- if (edc_inc(&i2400mu->urb_edc,
- 10 * EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
- dev_err(dev, "BM-CMD: too many stalls in "
- "URB; resetting device\n");
- goto do_reset;
- }
- usb_clear_halt(i2400mu->usb_dev, usb_pipe);
- msleep(10); /* give the device some time */
- goto retry;
- case -EINVAL: /* while removing driver */
- case -ENODEV: /* dev disconnect ... */
- case -ENOENT: /* just ignore it */
- case -ESHUTDOWN:
- case -ECONNRESET:
- break;
- case -EOVERFLOW: { /* too small, reallocate */
- struct sk_buff *new_skb;
- rx_size = i2400mu_rx_size_grow(i2400mu);
- if (rx_size <= (1 << 16)) /* cap it */
- i2400mu->rx_size = rx_size;
- else if (printk_ratelimit()) {
- dev_err(dev, "BUG? rx_size up to %d\n", rx_size);
- result = -EINVAL;
- goto out;
- }
- skb_put(rx_skb, read_size);
- new_skb = skb_copy_expand(rx_skb, 0, rx_size - rx_skb->len,
- GFP_KERNEL);
- if (new_skb == NULL) {
- kfree_skb(rx_skb);
- rx_skb = NULL;
- goto out; /* drop it...*/
- }
- kfree_skb(rx_skb);
- rx_skb = new_skb;
- i2400mu->rx_size_cnt = 0;
- i2400mu->rx_size_acc = i2400mu->rx_size;
- d_printf(1, dev, "RX: size changed to %d, received %d, "
- "copied %d, capacity %ld\n",
- rx_size, read_size, rx_skb->len,
- (long) skb_end_offset(new_skb));
- goto retry;
- }
- /* In most cases, it happens due to the hardware scheduling a
- * read when there was no data - unfortunately, we have no way
- * to tell this timeout from a USB timeout. So we just ignore
- * it. */
- case -ETIMEDOUT:
- dev_err(dev, "RX: timeout: %d\n", result);
- result = 0;
- break;
- default: /* Any error */
- if (edc_inc(&i2400mu->urb_edc,
- EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME))
- goto error_reset;
- dev_err(dev, "RX: error receiving URB: %d, retrying\n", result);
- goto retry;
- }
-out:
- if (do_autopm)
- usb_autopm_put_interface(i2400mu->usb_iface);
- d_fnend(4, dev, "(i2400mu %p) = %p\n", i2400mu, rx_skb);
- return rx_skb;
-
-error_reset:
- dev_err(dev, "RX: maximum errors in URB exceeded; "
- "resetting device\n");
-do_reset:
- usb_queue_reset_device(i2400mu->usb_iface);
- rx_skb = ERR_PTR(result);
- goto out;
-}
-
-
-/*
- * Kernel thread for USB reception of data
- *
- * This thread waits for a kick; once kicked, it will allocate an skb
- * and receive a single message to it from USB (using
- * i2400mu_rx()). Once received, it is passed to the generic i2400m RX
- * code for processing.
- *
- * When done processing, it runs some dirty statistics to verify if
- * the last 100 messages received were smaller than half of the
- * current RX buffer size. In that case, the RX buffer size is
- * halved. This will helps lowering the pressure on the memory
- * allocator.
- *
- * Hard errors force the thread to exit.
- */
-static
-int i2400mu_rxd(void *_i2400mu)
-{
- int result = 0;
- struct i2400mu *i2400mu = _i2400mu;
- struct i2400m *i2400m = &i2400mu->i2400m;
- struct device *dev = &i2400mu->usb_iface->dev;
- struct net_device *net_dev = i2400m->wimax_dev.net_dev;
- size_t pending;
- int rx_size;
- struct sk_buff *rx_skb;
- unsigned long flags;
-
- d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- BUG_ON(i2400mu->rx_kthread != NULL);
- i2400mu->rx_kthread = current;
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- while (1) {
- d_printf(2, dev, "RX: waiting for messages\n");
- pending = 0;
- wait_event_interruptible(
- i2400mu->rx_wq,
- (kthread_should_stop() /* check this first! */
- || (pending = atomic_read(&i2400mu->rx_pending_count)))
- );
- if (kthread_should_stop())
- break;
- if (pending == 0)
- continue;
- rx_size = i2400mu->rx_size;
- d_printf(2, dev, "RX: reading up to %d bytes\n", rx_size);
- rx_skb = __netdev_alloc_skb(net_dev, rx_size, GFP_KERNEL);
- if (rx_skb == NULL) {
- dev_err(dev, "RX: can't allocate skb [%d bytes]\n",
- rx_size);
- msleep(50); /* give it some time? */
- continue;
- }
-
- /* Receive the message with the payloads */
- rx_skb = i2400mu_rx(i2400mu, rx_skb);
- result = PTR_ERR(rx_skb);
- if (IS_ERR(rx_skb))
- goto out;
- atomic_dec(&i2400mu->rx_pending_count);
- if (rx_skb == NULL || rx_skb->len == 0) {
- /* some "ignorable" condition */
- kfree_skb(rx_skb);
- continue;
- }
-
- /* Deliver the message to the generic i2400m code */
- i2400mu->rx_size_cnt++;
- i2400mu->rx_size_acc += rx_skb->len;
- result = i2400m_rx(i2400m, rx_skb);
- if (result == -EIO
- && edc_inc(&i2400mu->urb_edc,
- EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
- goto error_reset;
- }
-
- /* Maybe adjust RX buffer size */
- i2400mu_rx_size_maybe_shrink(i2400mu);
- }
- result = 0;
-out:
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- i2400mu->rx_kthread = NULL;
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- d_fnend(4, dev, "(i2400mu %p) = %d\n", i2400mu, result);
- return result;
-
-error_reset:
- dev_err(dev, "RX: maximum errors in received buffer exceeded; "
- "resetting device\n");
- usb_queue_reset_device(i2400mu->usb_iface);
- goto out;
-}
-
-
-/*
- * Start reading from the device
- *
- * @i2400m: device instance
- *
- * Notify the RX thread that there is data pending.
- */
-void i2400mu_rx_kick(struct i2400mu *i2400mu)
-{
- struct i2400m *i2400m = &i2400mu->i2400m;
- struct device *dev = &i2400mu->usb_iface->dev;
-
- d_fnstart(3, dev, "(i2400mu %p)\n", i2400m);
- atomic_inc(&i2400mu->rx_pending_count);
- wake_up_all(&i2400mu->rx_wq);
- d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
-
-
-int i2400mu_rx_setup(struct i2400mu *i2400mu)
-{
- int result = 0;
- struct i2400m *i2400m = &i2400mu->i2400m;
- struct device *dev = &i2400mu->usb_iface->dev;
- struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
- struct task_struct *kthread;
-
- kthread = kthread_run(i2400mu_rxd, i2400mu, "%s-rx",
- wimax_dev->name);
- /* the kthread function sets i2400mu->rx_thread */
- if (IS_ERR(kthread)) {
- result = PTR_ERR(kthread);
- dev_err(dev, "RX: cannot start thread: %d\n", result);
- }
- return result;
-}
-
-
-void i2400mu_rx_release(struct i2400mu *i2400mu)
-{
- unsigned long flags;
- struct i2400m *i2400m = &i2400mu->i2400m;
- struct device *dev = i2400m_dev(i2400m);
- struct task_struct *kthread;
-
- spin_lock_irqsave(&i2400m->rx_lock, flags);
- kthread = i2400mu->rx_kthread;
- i2400mu->rx_kthread = NULL;
- spin_unlock_irqrestore(&i2400m->rx_lock, flags);
- if (kthread)
- kthread_stop(kthread);
- else
- d_printf(1, dev, "RX: kthread had already exited\n");
-}
-
diff --git a/drivers/staging/wimax/i2400m/usb-tx.c b/drivers/staging/wimax/i2400m/usb-tx.c
deleted file mode 100644
index 3ba9d70cca1b..000000000000
--- a/drivers/staging/wimax/i2400m/usb-tx.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Intel Wireless WiMAX Connection 2400m
- * USB specific TX handling
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * 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 Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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
- * OWNER 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.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- * - Initial implementation
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * - Split transport/device specific
- *
- *
- * Takes the TX messages in the i2400m's driver TX FIFO and sends them
- * to the device until there are no more.
- *
- * If we fail sending the message, we just drop it. There isn't much
- * we can do at this point. We could also retry, but the USB stack has
- * already retried and still failed, so there is not much of a
- * point. As well, most of the traffic is network, which has recovery
- * methods for dropped packets.
- *
- * For sending we just obtain a FIFO buffer to send, send it to the
- * USB bulk out, tell the TX FIFO code we have sent it; query for
- * another one, etc... until done.
- *
- * We use a thread so we can call usb_autopm_enable() and
- * usb_autopm_disable() for each transaction; this way when the device
- * goes idle, it will suspend. It also has less overhead than a
- * dedicated workqueue, as it is being used for a single task.
- *
- * ROADMAP
- *
- * i2400mu_tx_setup()
- * i2400mu_tx_release()
- *
- * i2400mu_bus_tx_kick() - Called by the tx.c code when there
- * is new data in the FIFO.
- * i2400mu_txd()
- * i2400m_tx_msg_get()
- * i2400m_tx_msg_sent()
- */
-#include "i2400m-usb.h"
-
-
-#define D_SUBMODULE tx
-#include "usb-debug-levels.h"
-
-
-/*
- * Get the next TX message in the TX FIFO and send it to the device
- *
- * Note that any iteration consumes a message to be sent, no matter if
- * it succeeds or fails (we have no real way to retry or complain).
- *
- * Return: 0 if ok, < 0 errno code on hard error.
- */
-static
-int i2400mu_tx(struct i2400mu *i2400mu, struct i2400m_msg_hdr *tx_msg,
- size_t tx_msg_size)
-{
- int result = 0;
- struct i2400m *i2400m = &i2400mu->i2400m;
- struct device *dev = &i2400mu->usb_iface->dev;
- int usb_pipe, sent_size, do_autopm;
- struct usb_endpoint_descriptor *epd;
-
- d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
- do_autopm = atomic_read(&i2400mu->do_autopm);
- result = do_autopm ?
- usb_autopm_get_interface(i2400mu->usb_iface) : 0;
- if (result < 0) {
- dev_err(dev, "TX: can't get autopm: %d\n", result);
- do_autopm = 0;
- }
- epd = usb_get_epd(i2400mu->usb_iface, i2400mu->endpoint_cfg.bulk_out);
- usb_pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
-retry:
- result = usb_bulk_msg(i2400mu->usb_dev, usb_pipe,
- tx_msg, tx_msg_size, &sent_size, 200);
- usb_mark_last_busy(i2400mu->usb_dev);
- switch (result) {
- case 0:
- if (sent_size != tx_msg_size) { /* Too short? drop it */
- dev_err(dev, "TX: short write (%d B vs %zu "
- "expected)\n", sent_size, tx_msg_size);
- result = -EIO;
- }
- break;
- case -EPIPE:
- /*
- * Stall -- maybe the device is choking with our
- * requests. Clear it and give it some time. If they
- * happen to often, it might be another symptom, so we
- * reset.
- *
- * No error handling for usb_clear_halt(0; if it
- * works, the retry works; if it fails, this switch
- * does the error handling for us.
- */
- if (edc_inc(&i2400mu->urb_edc,
- 10 * EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
- dev_err(dev, "BM-CMD: too many stalls in "
- "URB; resetting device\n");
- usb_queue_reset_device(i2400mu->usb_iface);
- } else {
- usb_clear_halt(i2400mu->usb_dev, usb_pipe);
- msleep(10); /* give the device some time */
- goto retry;
- }
- fallthrough;
- case -EINVAL: /* while removing driver */
- case -ENODEV: /* dev disconnect ... */
- case -ENOENT: /* just ignore it */
- case -ESHUTDOWN: /* and exit */
- case -ECONNRESET:
- result = -ESHUTDOWN;
- break;
- default: /* Some error? */
- if (edc_inc(&i2400mu->urb_edc,
- EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
- dev_err(dev, "TX: maximum errors in URB "
- "exceeded; resetting device\n");
- usb_queue_reset_device(i2400mu->usb_iface);
- } else {
- dev_err(dev, "TX: cannot send URB; retrying. "
- "tx_msg @%zu %zu B [%d sent]: %d\n",
- (void *) tx_msg - i2400m->tx_buf,
- tx_msg_size, sent_size, result);
- goto retry;
- }
- }
- if (do_autopm)
- usb_autopm_put_interface(i2400mu->usb_iface);
- d_fnend(4, dev, "(i2400mu %p) = result\n", i2400mu);
- return result;
-}
-
-
-/*
- * Get the next TX message in the TX FIFO and send it to the device
- *
- * Note we exit the loop if i2400mu_tx() fails; that function only
- * fails on hard error (failing to tx a buffer not being one of them,
- * see its doc).
- *
- * Return: 0
- */
-static
-int i2400mu_txd(void *_i2400mu)
-{
- struct i2400mu *i2400mu = _i2400mu;
- struct i2400m *i2400m = &i2400mu->i2400m;
- struct device *dev = &i2400mu->usb_iface->dev;
- struct i2400m_msg_hdr *tx_msg;
- size_t tx_msg_size;
- unsigned long flags;
-
- d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
-
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- BUG_ON(i2400mu->tx_kthread != NULL);
- i2400mu->tx_kthread = current;
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-
- while (1) {
- d_printf(2, dev, "TX: waiting for messages\n");
- tx_msg = NULL;
- wait_event_interruptible(
- i2400mu->tx_wq,
- (kthread_should_stop() /* check this first! */
- || (tx_msg = i2400m_tx_msg_get(i2400m, &tx_msg_size)))
- );
- if (kthread_should_stop())
- break;
- WARN_ON(tx_msg == NULL); /* should not happen...*/
- d_printf(2, dev, "TX: submitting %zu bytes\n", tx_msg_size);
- d_dump(5, dev, tx_msg, tx_msg_size);
- /* Yeah, we ignore errors ... not much we can do */
- i2400mu_tx(i2400mu, tx_msg, tx_msg_size);
- i2400m_tx_msg_sent(i2400m); /* ack it, advance the FIFO */
- }
-
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- i2400mu->tx_kthread = NULL;
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
-
- d_fnend(4, dev, "(i2400mu %p)\n", i2400mu);
- return 0;
-}
-
-
-/*
- * i2400m TX engine notifies us that there is data in the FIFO ready
- * for TX
- *
- * If there is a URB in flight, don't do anything; when it finishes,
- * it will see there is data in the FIFO and send it. Else, just
- * submit a write.
- */
-void i2400mu_bus_tx_kick(struct i2400m *i2400m)
-{
- struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
- struct device *dev = &i2400mu->usb_iface->dev;
-
- d_fnstart(3, dev, "(i2400m %p) = void\n", i2400m);
- wake_up_all(&i2400mu->tx_wq);
- d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
-
-
-int i2400mu_tx_setup(struct i2400mu *i2400mu)
-{
- int result = 0;
- struct i2400m *i2400m = &i2400mu->i2400m;
- struct device *dev = &i2400mu->usb_iface->dev;
- struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
- struct task_struct *kthread;
-
- kthread = kthread_run(i2400mu_txd, i2400mu, "%s-tx",
- wimax_dev->name);
- /* the kthread function sets i2400mu->tx_thread */
- if (IS_ERR(kthread)) {
- result = PTR_ERR(kthread);
- dev_err(dev, "TX: cannot start thread: %d\n", result);
- }
- return result;
-}
-
-void i2400mu_tx_release(struct i2400mu *i2400mu)
-{
- unsigned long flags;
- struct i2400m *i2400m = &i2400mu->i2400m;
- struct device *dev = i2400m_dev(i2400m);
- struct task_struct *kthread;
-
- spin_lock_irqsave(&i2400m->tx_lock, flags);
- kthread = i2400mu->tx_kthread;
- i2400mu->tx_kthread = NULL;
- spin_unlock_irqrestore(&i2400m->tx_lock, flags);
- if (kthread)
- kthread_stop(kthread);
- else
- d_printf(1, dev, "TX: kthread had already exited\n");
-}
diff --git a/drivers/staging/wimax/i2400m/usb.c b/drivers/staging/wimax/i2400m/usb.c
deleted file mode 100644
index 481b1ccde983..000000000000
--- a/drivers/staging/wimax/i2400m/usb.c
+++ /dev/null
@@ -1,765 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel Wireless WiMAX Connection 2400m
- * Linux driver model glue for USB device, reset & fw upload
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * Yanir Lubetkin <yanirx.lubetkin@intel.com>
- *
- * See i2400m-usb.h for a general description of this driver.
- *
- * This file implements driver model glue, and hook ups for the
- * generic driver to implement the bus-specific functions (device
- * communication setup/tear down, firmware upload and resetting).
- *
- * ROADMAP
- *
- * i2400mu_probe()
- * alloc_netdev()...
- * i2400mu_netdev_setup()
- * i2400mu_init()
- * i2400m_netdev_setup()
- * i2400m_setup()...
- *
- * i2400mu_disconnect
- * i2400m_release()
- * free_netdev()
- *
- * i2400mu_suspend()
- * i2400m_cmd_enter_powersave()
- * i2400mu_notification_release()
- *
- * i2400mu_resume()
- * i2400mu_notification_setup()
- *
- * i2400mu_bus_dev_start() Called by i2400m_dev_start() [who is
- * i2400mu_tx_setup() called by i2400m_setup()]
- * i2400mu_rx_setup()
- * i2400mu_notification_setup()
- *
- * i2400mu_bus_dev_stop() Called by i2400m_dev_stop() [who is
- * i2400mu_notification_release() called by i2400m_release()]
- * i2400mu_rx_release()
- * i2400mu_tx_release()
- *
- * i2400mu_bus_reset() Called by i2400m_reset
- * __i2400mu_reset()
- * __i2400mu_send_barker()
- * usb_reset_device()
- */
-#include "i2400m-usb.h"
-#include "linux-wimax-i2400m.h"
-#include <linux/debugfs.h>
-#include <linux/ethtool.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-
-
-#define D_SUBMODULE usb
-#include "usb-debug-levels.h"
-
-static char i2400mu_debug_params[128];
-module_param_string(debug, i2400mu_debug_params, sizeof(i2400mu_debug_params),
- 0644);
-MODULE_PARM_DESC(debug,
- "String of space-separated NAME:VALUE pairs, where NAMEs "
- "are the different debug submodules and VALUE are the "
- "initial debug value to set.");
-
-/* Our firmware file name */
-static const char *i2400mu_bus_fw_names_5x50[] = {
-#define I2400MU_FW_FILE_NAME_v1_5 "i2400m-fw-usb-1.5.sbcf"
- I2400MU_FW_FILE_NAME_v1_5,
-#define I2400MU_FW_FILE_NAME_v1_4 "i2400m-fw-usb-1.4.sbcf"
- I2400MU_FW_FILE_NAME_v1_4,
- NULL,
-};
-
-
-static const char *i2400mu_bus_fw_names_6050[] = {
-#define I6050U_FW_FILE_NAME_v1_5 "i6050-fw-usb-1.5.sbcf"
- I6050U_FW_FILE_NAME_v1_5,
- NULL,
-};
-
-
-static
-int i2400mu_bus_dev_start(struct i2400m *i2400m)
-{
- int result;
- struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
- struct device *dev = &i2400mu->usb_iface->dev;
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
- result = i2400mu_tx_setup(i2400mu);
- if (result < 0)
- goto error_usb_tx_setup;
- result = i2400mu_rx_setup(i2400mu);
- if (result < 0)
- goto error_usb_rx_setup;
- result = i2400mu_notification_setup(i2400mu);
- if (result < 0)
- goto error_notif_setup;
- d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
- return result;
-
-error_notif_setup:
- i2400mu_rx_release(i2400mu);
-error_usb_rx_setup:
- i2400mu_tx_release(i2400mu);
-error_usb_tx_setup:
- d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
- return result;
-}
-
-
-static
-void i2400mu_bus_dev_stop(struct i2400m *i2400m)
-{
- struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
- struct device *dev = &i2400mu->usb_iface->dev;
-
- d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
- i2400mu_notification_release(i2400mu);
- i2400mu_rx_release(i2400mu);
- i2400mu_tx_release(i2400mu);
- d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
-}
-
-
-/*
- * Sends a barker buffer to the device
- *
- * This helper will allocate a kmalloced buffer and use it to transmit
- * (then free it). Reason for this is that other arches cannot use
- * stack/vmalloc/text areas for DMA transfers.
- *
- * Error recovery here is simpler: anything is considered a hard error
- * and will move the reset code to use a last-resort bus-based reset.
- */
-static
-int __i2400mu_send_barker(struct i2400mu *i2400mu,
- const __le32 *barker,
- size_t barker_size,
- unsigned endpoint)
-{
- struct usb_endpoint_descriptor *epd = NULL;
- int pipe, actual_len, ret;
- struct device *dev = &i2400mu->usb_iface->dev;
- void *buffer;
- int do_autopm = 1;
-
- ret = usb_autopm_get_interface(i2400mu->usb_iface);
- if (ret < 0) {
- dev_err(dev, "RESET: can't get autopm: %d\n", ret);
- do_autopm = 0;
- }
- ret = -ENOMEM;
- buffer = kmalloc(barker_size, GFP_KERNEL);
- if (buffer == NULL)
- goto error_kzalloc;
- epd = usb_get_epd(i2400mu->usb_iface, endpoint);
- pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
- memcpy(buffer, barker, barker_size);
-retry:
- ret = usb_bulk_msg(i2400mu->usb_dev, pipe, buffer, barker_size,
- &actual_len, 200);
- switch (ret) {
- case 0:
- if (actual_len != barker_size) { /* Too short? drop it */
- dev_err(dev, "E: %s: short write (%d B vs %zu "
- "expected)\n",
- __func__, actual_len, barker_size);
- ret = -EIO;
- }
- break;
- case -EPIPE:
- /*
- * Stall -- maybe the device is choking with our
- * requests. Clear it and give it some time. If they
- * happen to often, it might be another symptom, so we
- * reset.
- *
- * No error handling for usb_clear_halt(0; if it
- * works, the retry works; if it fails, this switch
- * does the error handling for us.
- */
- if (edc_inc(&i2400mu->urb_edc,
- 10 * EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
- dev_err(dev, "E: %s: too many stalls in "
- "URB; resetting device\n", __func__);
- usb_queue_reset_device(i2400mu->usb_iface);
- /* fallthrough */
- } else {
- usb_clear_halt(i2400mu->usb_dev, pipe);
- msleep(10); /* give the device some time */
- goto retry;
- }
- fallthrough;
- case -EINVAL: /* while removing driver */
- case -ENODEV: /* dev disconnect ... */
- case -ENOENT: /* just ignore it */
- case -ESHUTDOWN: /* and exit */
- case -ECONNRESET:
- ret = -ESHUTDOWN;
- break;
- default: /* Some error? */
- if (edc_inc(&i2400mu->urb_edc,
- EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
- dev_err(dev, "E: %s: maximum errors in URB "
- "exceeded; resetting device\n",
- __func__);
- usb_queue_reset_device(i2400mu->usb_iface);
- } else {
- dev_warn(dev, "W: %s: cannot send URB: %d\n",
- __func__, ret);
- goto retry;
- }
- }
- kfree(buffer);
-error_kzalloc:
- if (do_autopm)
- usb_autopm_put_interface(i2400mu->usb_iface);
- return ret;
-}
-
-
-/*
- * Reset a device at different levels (warm, cold or bus)
- *
- * @i2400m: device descriptor
- * @reset_type: soft, warm or bus reset (I2400M_RT_WARM/SOFT/BUS)
- *
- * Warm and cold resets get a USB reset if they fail.
- *
- * Warm reset:
- *
- * The device will be fully reset internally, but won't be
- * disconnected from the USB bus (so no reenumeration will
- * happen). Firmware upload will be necessary.
- *
- * The device will send a reboot barker in the notification endpoint
- * that will trigger the driver to reinitialize the state
- * automatically from notif.c:i2400m_notification_grok() into
- * i2400m_dev_bootstrap_delayed().
- *
- * Cold and bus (USB) reset:
- *
- * The device will be fully reset internally, disconnected from the
- * USB bus an a reenumeration will happen. Firmware upload will be
- * necessary. Thus, we don't do any locking or struct
- * reinitialization, as we are going to be fully disconnected and
- * reenumerated.
- *
- * Note we need to return -ENODEV if a warm reset was requested and we
- * had to resort to a bus reset. See i2400m_op_reset(), wimax_reset()
- * and wimax_dev->op_reset.
- *
- * WARNING: no driver state saved/fixed
- */
-static
-int i2400mu_bus_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
-{
- int result;
- struct i2400mu *i2400mu =
- container_of(i2400m, struct i2400mu, i2400m);
- struct device *dev = i2400m_dev(i2400m);
- static const __le32 i2400m_WARM_BOOT_BARKER[4] = {
- cpu_to_le32(I2400M_WARM_RESET_BARKER),
- cpu_to_le32(I2400M_WARM_RESET_BARKER),
- cpu_to_le32(I2400M_WARM_RESET_BARKER),
- cpu_to_le32(I2400M_WARM_RESET_BARKER),
- };
- static const __le32 i2400m_COLD_BOOT_BARKER[4] = {
- cpu_to_le32(I2400M_COLD_RESET_BARKER),
- cpu_to_le32(I2400M_COLD_RESET_BARKER),
- cpu_to_le32(I2400M_COLD_RESET_BARKER),
- cpu_to_le32(I2400M_COLD_RESET_BARKER),
- };
-
- d_fnstart(3, dev, "(i2400m %p rt %u)\n", i2400m, rt);
- if (rt == I2400M_RT_WARM)
- result = __i2400mu_send_barker(
- i2400mu, i2400m_WARM_BOOT_BARKER,
- sizeof(i2400m_WARM_BOOT_BARKER),
- i2400mu->endpoint_cfg.bulk_out);
- else if (rt == I2400M_RT_COLD)
- result = __i2400mu_send_barker(
- i2400mu, i2400m_COLD_BOOT_BARKER,
- sizeof(i2400m_COLD_BOOT_BARKER),
- i2400mu->endpoint_cfg.reset_cold);
- else if (rt == I2400M_RT_BUS) {
- result = usb_reset_device(i2400mu->usb_dev);
- switch (result) {
- case 0:
- case -EINVAL: /* device is gone */
- case -ENODEV:
- case -ENOENT:
- case -ESHUTDOWN:
- result = 0;
- break; /* We assume the device is disconnected */
- default:
- dev_err(dev, "USB reset failed (%d), giving up!\n",
- result);
- }
- } else {
- result = -EINVAL; /* shut gcc up in certain arches */
- BUG();
- }
- if (result < 0
- && result != -EINVAL /* device is gone */
- && rt != I2400M_RT_BUS) {
- /*
- * Things failed -- resort to lower level reset, that
- * we queue in another context; the reason for this is
- * that the pre and post reset functionality requires
- * the i2400m->init_mutex; RT_WARM and RT_COLD can
- * come from areas where i2400m->init_mutex is taken.
- */
- dev_err(dev, "%s reset failed (%d); trying USB reset\n",
- rt == I2400M_RT_WARM ? "warm" : "cold", result);
- usb_queue_reset_device(i2400mu->usb_iface);
- result = -ENODEV;
- }
- d_fnend(3, dev, "(i2400m %p rt %u) = %d\n", i2400m, rt, result);
- return result;
-}
-
-static void i2400mu_get_drvinfo(struct net_device *net_dev,
- struct ethtool_drvinfo *info)
-{
- struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
- struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
- struct usb_device *udev = i2400mu->usb_dev;
-
- strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
- strscpy(info->fw_version, i2400m->fw_name ? : "",
- sizeof(info->fw_version));
- usb_make_path(udev, info->bus_info, sizeof(info->bus_info));
-}
-
-static const struct ethtool_ops i2400mu_ethtool_ops = {
- .get_drvinfo = i2400mu_get_drvinfo,
- .get_link = ethtool_op_get_link,
-};
-
-static
-void i2400mu_netdev_setup(struct net_device *net_dev)
-{
- struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
- struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
- i2400mu_init(i2400mu);
- i2400m_netdev_setup(net_dev);
- net_dev->ethtool_ops = &i2400mu_ethtool_ops;
-}
-
-
-/*
- * Debug levels control; see debug.h
- */
-struct d_level D_LEVEL[] = {
- D_SUBMODULE_DEFINE(usb),
- D_SUBMODULE_DEFINE(fw),
- D_SUBMODULE_DEFINE(notif),
- D_SUBMODULE_DEFINE(rx),
- D_SUBMODULE_DEFINE(tx),
-};
-size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
-
-static
-void i2400mu_debugfs_add(struct i2400mu *i2400mu)
-{
- struct dentry *dentry = i2400mu->i2400m.wimax_dev.debugfs_dentry;
-
- dentry = debugfs_create_dir("i2400m-usb", dentry);
- i2400mu->debugfs_dentry = dentry;
-
- d_level_register_debugfs("dl_", usb, dentry);
- d_level_register_debugfs("dl_", fw, dentry);
- d_level_register_debugfs("dl_", notif, dentry);
- d_level_register_debugfs("dl_", rx, dentry);
- d_level_register_debugfs("dl_", tx, dentry);
-
- /* Don't touch these if you don't know what you are doing */
- debugfs_create_u8("rx_size_auto_shrink", 0600, dentry,
- &i2400mu->rx_size_auto_shrink);
-
- debugfs_create_size_t("rx_size", 0600, dentry, &i2400mu->rx_size);
-}
-
-
-static struct device_type i2400mu_type = {
- .name = "wimax",
-};
-
-/*
- * Probe a i2400m interface and register it
- *
- * @iface: USB interface to link to
- * @id: USB class/subclass/protocol id
- * @returns: 0 if ok, < 0 errno code on error.
- *
- * Alloc a net device, initialize the bus-specific details and then
- * calls the bus-generic initialization routine. That will register
- * the wimax and netdev devices, upload the firmware [using
- * _bus_bm_*()], call _bus_dev_start() to finalize the setup of the
- * communication with the device and then will start to talk to it to
- * finnish setting it up.
- */
-static
-int i2400mu_probe(struct usb_interface *iface,
- const struct usb_device_id *id)
-{
- int result;
- struct net_device *net_dev;
- struct device *dev = &iface->dev;
- struct i2400m *i2400m;
- struct i2400mu *i2400mu;
- struct usb_device *usb_dev = interface_to_usbdev(iface);
-
- if (iface->cur_altsetting->desc.bNumEndpoints < 4)
- return -ENODEV;
-
- if (usb_dev->speed != USB_SPEED_HIGH)
- dev_err(dev, "device not connected as high speed\n");
-
- /* Allocate instance [calls i2400m_netdev_setup() on it]. */
- result = -ENOMEM;
- net_dev = alloc_netdev(sizeof(*i2400mu), "wmx%d", NET_NAME_UNKNOWN,
- i2400mu_netdev_setup);
- if (net_dev == NULL) {
- dev_err(dev, "no memory for network device instance\n");
- goto error_alloc_netdev;
- }
- SET_NETDEV_DEV(net_dev, dev);
- SET_NETDEV_DEVTYPE(net_dev, &i2400mu_type);
- i2400m = net_dev_to_i2400m(net_dev);
- i2400mu = container_of(i2400m, struct i2400mu, i2400m);
- i2400m->wimax_dev.net_dev = net_dev;
- i2400mu->usb_dev = usb_get_dev(usb_dev);
- i2400mu->usb_iface = iface;
- usb_set_intfdata(iface, i2400mu);
-
- i2400m->bus_tx_block_size = I2400MU_BLK_SIZE;
- /*
- * Room required in the Tx queue for USB message to accommodate
- * a smallest payload while allocating header space is 16 bytes.
- * Adding this room for the new tx message increases the
- * possibilities of including any payload with size <= 16 bytes.
- */
- i2400m->bus_tx_room_min = I2400MU_BLK_SIZE;
- i2400m->bus_pl_size_max = I2400MU_PL_SIZE_MAX;
- i2400m->bus_setup = NULL;
- i2400m->bus_dev_start = i2400mu_bus_dev_start;
- i2400m->bus_dev_stop = i2400mu_bus_dev_stop;
- i2400m->bus_release = NULL;
- i2400m->bus_tx_kick = i2400mu_bus_tx_kick;
- i2400m->bus_reset = i2400mu_bus_reset;
- i2400m->bus_bm_retries = I2400M_USB_BOOT_RETRIES;
- i2400m->bus_bm_cmd_send = i2400mu_bus_bm_cmd_send;
- i2400m->bus_bm_wait_for_ack = i2400mu_bus_bm_wait_for_ack;
- i2400m->bus_bm_mac_addr_impaired = 0;
-
- switch (id->idProduct) {
- case USB_DEVICE_ID_I6050:
- case USB_DEVICE_ID_I6050_2:
- case USB_DEVICE_ID_I6150:
- case USB_DEVICE_ID_I6150_2:
- case USB_DEVICE_ID_I6150_3:
- case USB_DEVICE_ID_I6250:
- i2400mu->i6050 = 1;
- break;
- default:
- break;
- }
-
- if (i2400mu->i6050) {
- i2400m->bus_fw_names = i2400mu_bus_fw_names_6050;
- i2400mu->endpoint_cfg.bulk_out = 0;
- i2400mu->endpoint_cfg.notification = 3;
- i2400mu->endpoint_cfg.reset_cold = 2;
- i2400mu->endpoint_cfg.bulk_in = 1;
- } else {
- i2400m->bus_fw_names = i2400mu_bus_fw_names_5x50;
- i2400mu->endpoint_cfg.bulk_out = 0;
- i2400mu->endpoint_cfg.notification = 1;
- i2400mu->endpoint_cfg.reset_cold = 2;
- i2400mu->endpoint_cfg.bulk_in = 3;
- }
-#ifdef CONFIG_PM
- iface->needs_remote_wakeup = 1; /* autosuspend (15s delay) */
- device_init_wakeup(dev, 1);
- pm_runtime_set_autosuspend_delay(&usb_dev->dev, 15000);
- usb_enable_autosuspend(usb_dev);
-#endif
-
- result = i2400m_setup(i2400m, I2400M_BRI_MAC_REINIT);
- if (result < 0) {
- dev_err(dev, "cannot setup device: %d\n", result);
- goto error_setup;
- }
- i2400mu_debugfs_add(i2400mu);
- return 0;
-
-error_setup:
- usb_set_intfdata(iface, NULL);
- usb_put_dev(i2400mu->usb_dev);
- free_netdev(net_dev);
-error_alloc_netdev:
- return result;
-}
-
-
-/*
- * Disconnect a i2400m from the system.
- *
- * i2400m_stop() has been called before, so al the rx and tx contexts
- * have been taken down already. Make sure the queue is stopped,
- * unregister netdev and i2400m, free and kill.
- */
-static
-void i2400mu_disconnect(struct usb_interface *iface)
-{
- struct i2400mu *i2400mu = usb_get_intfdata(iface);
- struct i2400m *i2400m = &i2400mu->i2400m;
- struct net_device *net_dev = i2400m->wimax_dev.net_dev;
- struct device *dev = &iface->dev;
-
- d_fnstart(3, dev, "(iface %p i2400m %p)\n", iface, i2400m);
-
- debugfs_remove_recursive(i2400mu->debugfs_dentry);
- i2400m_release(i2400m);
- usb_set_intfdata(iface, NULL);
- usb_put_dev(i2400mu->usb_dev);
- free_netdev(net_dev);
- d_fnend(3, dev, "(iface %p i2400m %p) = void\n", iface, i2400m);
-}
-
-
-/*
- * Get the device ready for USB port or system standby and hibernation
- *
- * USB port and system standby are handled the same.
- *
- * When the system hibernates, the USB device is powered down and then
- * up, so we don't really have to do much here, as it will be seen as
- * a reconnect. Still for simplicity we consider this case the same as
- * suspend, so that the device has a chance to do notify the base
- * station (if connected).
- *
- * So at the end, the three cases require common handling.
- *
- * If at the time of this call the device's firmware is not loaded,
- * nothing has to be done. Note we can be "loose" about not reading
- * i2400m->updown under i2400m->init_mutex. If it happens to change
- * inmediately, other parts of the call flow will fail and effectively
- * catch it.
- *
- * If the firmware is loaded, we need to:
- *
- * - tell the device to go into host interface power save mode, wait
- * for it to ack
- *
- * This is quite more interesting than it is; we need to execute a
- * command, but this time, we don't want the code in usb-{tx,rx}.c
- * to call the usb_autopm_get/put_interface() barriers as it'd
- * deadlock, so we need to decrement i2400mu->do_autopm, that acts
- * as a poor man's semaphore. Ugly, but it works.
- *
- * As well, the device might refuse going to sleep for whichever
- * reason. In this case we just fail. For system suspend/hibernate,
- * we *can't* fail. We check PMSG_IS_AUTO to see if the
- * suspend call comes from the USB stack or from the system and act
- * in consequence.
- *
- * - stop the notification endpoint polling
- */
-static
-int i2400mu_suspend(struct usb_interface *iface, pm_message_t pm_msg)
-{
- int result = 0;
- struct device *dev = &iface->dev;
- struct i2400mu *i2400mu = usb_get_intfdata(iface);
- unsigned is_autosuspend = 0;
- struct i2400m *i2400m = &i2400mu->i2400m;
-
-#ifdef CONFIG_PM
- if (PMSG_IS_AUTO(pm_msg))
- is_autosuspend = 1;
-#endif
-
- d_fnstart(3, dev, "(iface %p pm_msg %u)\n", iface, pm_msg.event);
- rmb(); /* see i2400m->updown's documentation */
- if (i2400m->updown == 0)
- goto no_firmware;
- if (i2400m->state == I2400M_SS_DATA_PATH_CONNECTED && is_autosuspend) {
- /* ugh -- the device is connected and this suspend
- * request is an autosuspend one (not a system standby
- * / hibernate).
- *
- * The only way the device can go to standby is if the
- * link with the base station is in IDLE mode; that
- * were the case, we'd be in status
- * I2400M_SS_CONNECTED_IDLE. But we are not.
- *
- * If we *tell* him to go power save now, it'll reset
- * as a precautionary measure, so if this is an
- * autosuspend thing, say no and it'll come back
- * later, when the link is IDLE
- */
- result = -EBADF;
- d_printf(1, dev, "fw up, link up, not-idle, autosuspend: "
- "not entering powersave\n");
- goto error_not_now;
- }
- d_printf(1, dev, "fw up: entering powersave\n");
- atomic_dec(&i2400mu->do_autopm);
- result = i2400m_cmd_enter_powersave(i2400m);
- atomic_inc(&i2400mu->do_autopm);
- if (result < 0 && !is_autosuspend) {
- /* System suspend, can't fail */
- dev_err(dev, "failed to suspend, will reset on resume\n");
- result = 0;
- }
- if (result < 0)
- goto error_enter_powersave;
- i2400mu_notification_release(i2400mu);
- d_printf(1, dev, "powersave requested\n");
-error_enter_powersave:
-error_not_now:
-no_firmware:
- d_fnend(3, dev, "(iface %p pm_msg %u) = %d\n",
- iface, pm_msg.event, result);
- return result;
-}
-
-
-static
-int i2400mu_resume(struct usb_interface *iface)
-{
- int ret = 0;
- struct device *dev = &iface->dev;
- struct i2400mu *i2400mu = usb_get_intfdata(iface);
- struct i2400m *i2400m = &i2400mu->i2400m;
-
- d_fnstart(3, dev, "(iface %p)\n", iface);
- rmb(); /* see i2400m->updown's documentation */
- if (i2400m->updown == 0) {
- d_printf(1, dev, "fw was down, no resume needed\n");
- goto out;
- }
- d_printf(1, dev, "fw was up, resuming\n");
- i2400mu_notification_setup(i2400mu);
- /* USB has flow control, so we don't need to give it time to
- * come back; otherwise, we'd use something like a get-state
- * command... */
-out:
- d_fnend(3, dev, "(iface %p) = %d\n", iface, ret);
- return ret;
-}
-
-
-static
-int i2400mu_reset_resume(struct usb_interface *iface)
-{
- int result;
- struct device *dev = &iface->dev;
- struct i2400mu *i2400mu = usb_get_intfdata(iface);
- struct i2400m *i2400m = &i2400mu->i2400m;
-
- d_fnstart(3, dev, "(iface %p)\n", iface);
- result = i2400m_dev_reset_handle(i2400m, "device reset on resume");
- d_fnend(3, dev, "(iface %p) = %d\n", iface, result);
- return result < 0 ? result : 0;
-}
-
-
-/*
- * Another driver or user space is triggering a reset on the device
- * which contains the interface passed as an argument. Cease IO and
- * save any device state you need to restore.
- *
- * If you need to allocate memory here, use GFP_NOIO or GFP_ATOMIC, if
- * you are in atomic context.
- */
-static
-int i2400mu_pre_reset(struct usb_interface *iface)
-{
- struct i2400mu *i2400mu = usb_get_intfdata(iface);
- return i2400m_pre_reset(&i2400mu->i2400m);
-}
-
-
-/*
- * The reset has completed. Restore any saved device state and begin
- * using the device again.
- *
- * If you need to allocate memory here, use GFP_NOIO or GFP_ATOMIC, if
- * you are in atomic context.
- */
-static
-int i2400mu_post_reset(struct usb_interface *iface)
-{
- struct i2400mu *i2400mu = usb_get_intfdata(iface);
- return i2400m_post_reset(&i2400mu->i2400m);
-}
-
-
-static
-struct usb_device_id i2400mu_id_table[] = {
- { USB_DEVICE(0x8086, USB_DEVICE_ID_I6050) },
- { USB_DEVICE(0x8086, USB_DEVICE_ID_I6050_2) },
- { USB_DEVICE(0x8087, USB_DEVICE_ID_I6150) },
- { USB_DEVICE(0x8087, USB_DEVICE_ID_I6150_2) },
- { USB_DEVICE(0x8087, USB_DEVICE_ID_I6150_3) },
- { USB_DEVICE(0x8086, USB_DEVICE_ID_I6250) },
- { USB_DEVICE(0x8086, 0x0181) },
- { USB_DEVICE(0x8086, 0x1403) },
- { USB_DEVICE(0x8086, 0x1405) },
- { USB_DEVICE(0x8086, 0x0180) },
- { USB_DEVICE(0x8086, 0x0182) },
- { USB_DEVICE(0x8086, 0x1406) },
- { USB_DEVICE(0x8086, 0x1403) },
- { },
-};
-MODULE_DEVICE_TABLE(usb, i2400mu_id_table);
-
-
-static
-struct usb_driver i2400mu_driver = {
- .name = KBUILD_MODNAME,
- .suspend = i2400mu_suspend,
- .resume = i2400mu_resume,
- .reset_resume = i2400mu_reset_resume,
- .probe = i2400mu_probe,
- .disconnect = i2400mu_disconnect,
- .pre_reset = i2400mu_pre_reset,
- .post_reset = i2400mu_post_reset,
- .id_table = i2400mu_id_table,
- .supports_autosuspend = 1,
-};
-
-static
-int __init i2400mu_driver_init(void)
-{
- d_parse_params(D_LEVEL, D_LEVEL_SIZE, i2400mu_debug_params,
- "i2400m_usb.debug");
- return usb_register(&i2400mu_driver);
-}
-module_init(i2400mu_driver_init);
-
-
-static
-void __exit i2400mu_driver_exit(void)
-{
- usb_deregister(&i2400mu_driver);
-}
-module_exit(i2400mu_driver_exit);
-
-MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
-MODULE_DESCRIPTION("Driver for USB based Intel Wireless WiMAX Connection 2400M "
- "(5x50 & 6050)");
-MODULE_LICENSE("GPL");
-MODULE_FIRMWARE(I2400MU_FW_FILE_NAME_v1_5);
-MODULE_FIRMWARE(I6050U_FW_FILE_NAME_v1_5);
diff --git a/drivers/staging/wimax/id-table.c b/drivers/staging/wimax/id-table.c
deleted file mode 100644
index 0e6f4aa87bc9..000000000000
--- a/drivers/staging/wimax/id-table.c
+++ /dev/null
@@ -1,130 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * Mappping of generic netlink family IDs to net devices
- *
- * Copyright (C) 2005-2006 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * We assign a single generic netlink family ID to each device (to
- * simplify lookup).
- *
- * We need a way to map family ID to a wimax_dev pointer.
- *
- * The idea is to use a very simple lookup. Using a netlink attribute
- * with (for example) the interface name implies a heavier search over
- * all the network devices; seemed kind of a waste given that we know
- * we are looking for a WiMAX device and that most systems will have
- * just a single WiMAX adapter.
- *
- * We put all the WiMAX devices in the system in a linked list and
- * match the generic link family ID against the list.
- *
- * By using a linked list, the case of a single adapter in the system
- * becomes (almost) no overhead, while still working for many more. If
- * it ever goes beyond two, I'll be surprised.
- */
-#include <linux/device.h>
-#include <net/genetlink.h>
-#include <linux/netdevice.h>
-#include <linux/list.h>
-#include "linux-wimax.h"
-#include "wimax-internal.h"
-
-
-#define D_SUBMODULE id_table
-#include "debug-levels.h"
-
-
-static DEFINE_SPINLOCK(wimax_id_table_lock);
-static struct list_head wimax_id_table = LIST_HEAD_INIT(wimax_id_table);
-
-
-/*
- * wimax_id_table_add - add a gennetlink familiy ID / wimax_dev mapping
- *
- * @wimax_dev: WiMAX device descriptor to associate to the Generic
- * Netlink family ID.
- *
- * Look for an empty spot in the ID table; if none found, double the
- * table's size and get the first spot.
- */
-void wimax_id_table_add(struct wimax_dev *wimax_dev)
-{
- d_fnstart(3, NULL, "(wimax_dev %p)\n", wimax_dev);
- spin_lock(&wimax_id_table_lock);
- list_add(&wimax_dev->id_table_node, &wimax_id_table);
- spin_unlock(&wimax_id_table_lock);
- d_fnend(3, NULL, "(wimax_dev %p)\n", wimax_dev);
-}
-
-
-/*
- * wimax_get_netdev_by_info - lookup a wimax_dev from the gennetlink info
- *
- * The generic netlink family ID has been filled out in the
- * nlmsghdr->nlmsg_type field, so we pull it from there, look it up in
- * the mapping table and reference the wimax_dev.
- *
- * When done, the reference should be dropped with
- * 'dev_put(wimax_dev->net_dev)'.
- */
-struct wimax_dev *wimax_dev_get_by_genl_info(
- struct genl_info *info, int ifindex)
-{
- struct wimax_dev *wimax_dev = NULL;
-
- d_fnstart(3, NULL, "(info %p ifindex %d)\n", info, ifindex);
- spin_lock(&wimax_id_table_lock);
- list_for_each_entry(wimax_dev, &wimax_id_table, id_table_node) {
- if (wimax_dev->net_dev->ifindex == ifindex) {
- dev_hold(wimax_dev->net_dev);
- goto found;
- }
- }
- wimax_dev = NULL;
- d_printf(1, NULL, "wimax: no devices found with ifindex %d\n",
- ifindex);
-found:
- spin_unlock(&wimax_id_table_lock);
- d_fnend(3, NULL, "(info %p ifindex %d) = %p\n",
- info, ifindex, wimax_dev);
- return wimax_dev;
-}
-
-
-/*
- * wimax_id_table_rm - Remove a gennetlink familiy ID / wimax_dev mapping
- *
- * @id: family ID to remove from the table
- */
-void wimax_id_table_rm(struct wimax_dev *wimax_dev)
-{
- spin_lock(&wimax_id_table_lock);
- list_del_init(&wimax_dev->id_table_node);
- spin_unlock(&wimax_id_table_lock);
-}
-
-
-/*
- * Release the gennetlink family id / mapping table
- *
- * On debug, verify that the table is empty upon removal. We want the
- * code always compiled, to ensure it doesn't bit rot. It will be
- * compiled out if CONFIG_BUG is disabled.
- */
-void wimax_id_table_release(void)
-{
- struct wimax_dev *wimax_dev;
-
-#ifndef CONFIG_BUG
- return;
-#endif
- spin_lock(&wimax_id_table_lock);
- list_for_each_entry(wimax_dev, &wimax_id_table, id_table_node) {
- pr_err("BUG: %s wimax_dev %p ifindex %d not cleared\n",
- __func__, wimax_dev, wimax_dev->net_dev->ifindex);
- WARN_ON(1);
- }
- spin_unlock(&wimax_id_table_lock);
-}
diff --git a/drivers/staging/wimax/linux-wimax-debug.h b/drivers/staging/wimax/linux-wimax-debug.h
deleted file mode 100644
index 5b5ec405143b..000000000000
--- a/drivers/staging/wimax/linux-wimax-debug.h
+++ /dev/null
@@ -1,491 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Linux WiMAX
- * Collection of tools to manage debug operations.
- *
- * Copyright (C) 2005-2007 Intel Corporation
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * Don't #include this file directly, read on!
- *
- * EXECUTING DEBUGGING ACTIONS OR NOT
- *
- * The main thing this framework provides is decission power to take a
- * debug action (like printing a message) if the current debug level
- * allows it.
- *
- * The decission power is at two levels: at compile-time (what does
- * not make it is compiled out) and at run-time. The run-time
- * selection is done per-submodule (as they are declared by the user
- * of the framework).
- *
- * A call to d_test(L) (L being the target debug level) returns true
- * if the action should be taken because the current debug levels
- * allow it (both compile and run time).
- *
- * It follows that a call to d_test() that can be determined to be
- * always false at compile time will get the code depending on it
- * compiled out by optimization.
- *
- * DEBUG LEVELS
- *
- * It is up to the caller to define how much a debugging level is.
- *
- * Convention sets 0 as "no debug" (so an action marked as debug level 0
- * will always be taken). The increasing debug levels are used for
- * increased verbosity.
- *
- * USAGE
- *
- * Group the code in modules and submodules inside each module [which
- * in most cases maps to Linux modules and .c files that compose
- * those].
- *
- * For each module, there is:
- *
- * - a MODULENAME (single word, legal C identifier)
- *
- * - a debug-levels.h header file that declares the list of
- * submodules and that is included by all .c files that use
- * the debugging tools. The file name can be anything.
- *
- * - some (optional) .c code to manipulate the runtime debug levels
- * through debugfs.
- *
- * The debug-levels.h file would look like:
- *
- * #ifndef __debug_levels__h__
- * #define __debug_levels__h__
- *
- * #define D_MODULENAME modulename
- * #define D_MASTER 10
- *
- * #include "linux-wimax-debug.h"
- *
- * enum d_module {
- * D_SUBMODULE_DECLARE(submodule_1),
- * D_SUBMODULE_DECLARE(submodule_2),
- * ...
- * D_SUBMODULE_DECLARE(submodule_N)
- * };
- *
- * #endif
- *
- * D_MASTER is the maximum compile-time debug level; any debug actions
- * above this will be out. D_MODULENAME is the module name (legal C
- * identifier), which has to be unique for each module (to avoid
- * namespace collisions during linkage). Note those #defines need to
- * be done before #including debug.h
- *
- * We declare N different submodules whose debug level can be
- * independently controlled during runtime.
- *
- * In a .c file of the module (and only in one of them), define the
- * following code:
- *
- * struct d_level D_LEVEL[] = {
- * D_SUBMODULE_DEFINE(submodule_1),
- * D_SUBMODULE_DEFINE(submodule_2),
- * ...
- * D_SUBMODULE_DEFINE(submodule_N),
- * };
- * size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
- *
- * Externs for d_level_MODULENAME and d_level_size_MODULENAME are used
- * and declared in this file using the D_LEVEL and D_LEVEL_SIZE macros
- * #defined also in this file.
- *
- * To manipulate from user space the levels, create a debugfs dentry
- * and then register each submodule with:
- *
- * d_level_register_debugfs("PREFIX_", submodule_X, parent);
- *
- * Where PREFIX_ is a name of your chosing. This will create debugfs
- * file with a single numeric value that can be use to tweak it. To
- * remove the entires, just use debugfs_remove_recursive() on 'parent'.
- *
- * NOTE: remember that even if this will show attached to some
- * particular instance of a device, the settings are *global*.
- *
- * On each submodule (for example, .c files), the debug infrastructure
- * should be included like this:
- *
- * #define D_SUBMODULE submodule_x // matches one in debug-levels.h
- * #include "debug-levels.h"
- *
- * after #including all your include files.
- *
- * Now you can use the d_*() macros below [d_test(), d_fnstart(),
- * d_fnend(), d_printf(), d_dump()].
- *
- * If their debug level is greater than D_MASTER, they will be
- * compiled out.
- *
- * If their debug level is lower or equal than D_MASTER but greater
- * than the current debug level of their submodule, they'll be
- * ignored.
- *
- * Otherwise, the action will be performed.
- */
-#ifndef __debug__h__
-#define __debug__h__
-
-#include <linux/types.h>
-#include <linux/slab.h>
-
-struct device;
-
-/* Backend stuff */
-
-/*
- * Debug backend: generate a message header from a 'struct device'
- *
- * @head: buffer where to place the header
- * @head_size: length of @head
- * @dev: pointer to device used to generate a header from. If NULL,
- * an empty ("") header is generated.
- */
-static inline
-void __d_head(char *head, size_t head_size,
- struct device *dev)
-{
- if (dev == NULL)
- head[0] = 0;
- else if ((unsigned long)dev < 4096) {
- printk(KERN_ERR "E: Corrupt dev %p\n", dev);
- WARN_ON(1);
- } else
- snprintf(head, head_size, "%s %s: ",
- dev_driver_string(dev), dev_name(dev));
-}
-
-
-/*
- * Debug backend: log some message if debugging is enabled
- *
- * @l: intended debug level
- * @tag: tag to prefix the message with
- * @dev: 'struct device' associated to this message
- * @f: printf-like format and arguments
- *
- * Note this is optimized out if it doesn't pass the compile-time
- * check; however, it is *always* compiled. This is useful to make
- * sure the printf-like formats and variables are always checked and
- * they don't get bit rot if you have all the debugging disabled.
- */
-#define _d_printf(l, tag, dev, f, a...) \
-do { \
- char head[64]; \
- if (!d_test(l)) \
- break; \
- __d_head(head, sizeof(head), dev); \
- printk(KERN_ERR "%s%s%s: " f, head, __func__, tag, ##a); \
-} while (0)
-
-
-/*
- * CPP syntactic sugar to generate A_B like symbol names when one of
- * the arguments is a preprocessor #define.
- */
-#define __D_PASTE__(varname, modulename) varname##_##modulename
-#define __D_PASTE(varname, modulename) (__D_PASTE__(varname, modulename))
-#define _D_SUBMODULE_INDEX(_name) (D_SUBMODULE_DECLARE(_name))
-
-
-/*
- * Store a submodule's runtime debug level and name
- */
-struct d_level {
- u8 level;
- const char *name;
-};
-
-
-/*
- * List of available submodules and their debug levels
- *
- * We call them d_level_MODULENAME and d_level_size_MODULENAME; the
- * macros D_LEVEL and D_LEVEL_SIZE contain the name already for
- * convenience.
- *
- * This array and the size are defined on some .c file that is part of
- * the current module.
- */
-#define D_LEVEL __D_PASTE(d_level, D_MODULENAME)
-#define D_LEVEL_SIZE __D_PASTE(d_level_size, D_MODULENAME)
-
-extern struct d_level D_LEVEL[];
-extern size_t D_LEVEL_SIZE;
-
-
-/*
- * Frontend stuff
- *
- *
- * Stuff you need to declare prior to using the actual "debug" actions
- * (defined below).
- */
-
-#ifndef D_MODULENAME
-#error D_MODULENAME is not defined in your debug-levels.h file
-/**
- * D_MODULE - Name of the current module
- *
- * #define in your module's debug-levels.h, making sure it is
- * unique. This has to be a legal C identifier.
- */
-#define D_MODULENAME undefined_modulename
-#endif
-
-
-#ifndef D_MASTER
-#warning D_MASTER not defined, but debug.h included! [see docs]
-/**
- * D_MASTER - Compile time maximum debug level
- *
- * #define in your debug-levels.h file to the maximum debug level the
- * runtime code will be allowed to have. This allows you to provide a
- * main knob.
- *
- * Anything above that level will be optimized out of the compile.
- *
- * Defaults to zero (no debug code compiled in).
- *
- * Maximum one definition per module (at the debug-levels.h file).
- */
-#define D_MASTER 0
-#endif
-
-#ifndef D_SUBMODULE
-#error D_SUBMODULE not defined, but debug.h included! [see docs]
-/**
- * D_SUBMODULE - Name of the current submodule
- *
- * #define in your submodule .c file before #including debug-levels.h
- * to the name of the current submodule as previously declared and
- * defined with D_SUBMODULE_DECLARE() (in your module's
- * debug-levels.h) and D_SUBMODULE_DEFINE().
- *
- * This is used to provide runtime-control over the debug levels.
- *
- * Maximum one per .c file! Can be shared among different .c files
- * (meaning they belong to the same submodule categorization).
- */
-#define D_SUBMODULE undefined_module
-#endif
-
-
-/**
- * D_SUBMODULE_DECLARE - Declare a submodule for runtime debug level control
- *
- * @_name: name of the submodule, restricted to the chars that make up a
- * valid C identifier ([a-zA-Z0-9_]).
- *
- * Declare in the module's debug-levels.h header file as:
- *
- * enum d_module {
- * D_SUBMODULE_DECLARE(submodule_1),
- * D_SUBMODULE_DECLARE(submodule_2),
- * D_SUBMODULE_DECLARE(submodule_3),
- * };
- *
- * Some corresponding .c file needs to have a matching
- * D_SUBMODULE_DEFINE().
- */
-#define D_SUBMODULE_DECLARE(_name) __D_SUBMODULE_##_name
-
-
-/**
- * D_SUBMODULE_DEFINE - Define a submodule for runtime debug level control
- *
- * @_name: name of the submodule, restricted to the chars that make up a
- * valid C identifier ([a-zA-Z0-9_]).
- *
- * Use once per module (in some .c file) as:
- *
- * static
- * struct d_level d_level_SUBMODULENAME[] = {
- * D_SUBMODULE_DEFINE(submodule_1),
- * D_SUBMODULE_DEFINE(submodule_2),
- * D_SUBMODULE_DEFINE(submodule_3),
- * };
- * size_t d_level_size_SUBDMODULENAME = ARRAY_SIZE(d_level_SUBDMODULENAME);
- *
- * Matching D_SUBMODULE_DECLARE()s have to be present in a
- * debug-levels.h header file.
- */
-#define D_SUBMODULE_DEFINE(_name) \
-[__D_SUBMODULE_##_name] = { \
- .level = 0, \
- .name = #_name \
-}
-
-
-
-/* The actual "debug" operations */
-
-
-/**
- * d_test - Returns true if debugging should be enabled
- *
- * @l: intended debug level (unsigned)
- *
- * If the master debug switch is enabled and the current settings are
- * higher or equal to the requested level, then debugging
- * output/actions should be enabled.
- *
- * NOTE:
- *
- * This needs to be coded so that it can be evaluated in compile
- * time; this is why the ugly BUG_ON() is placed in there, so the
- * D_MASTER evaluation compiles all out if it is compile-time false.
- */
-#define d_test(l) \
-({ \
- unsigned __l = l; /* type enforcer */ \
- (D_MASTER) >= __l \
- && ({ \
- BUG_ON(_D_SUBMODULE_INDEX(D_SUBMODULE) >= D_LEVEL_SIZE);\
- D_LEVEL[_D_SUBMODULE_INDEX(D_SUBMODULE)].level >= __l; \
- }); \
-})
-
-
-/**
- * d_fnstart - log message at function start if debugging enabled
- *
- * @l: intended debug level
- * @_dev: 'struct device' pointer, NULL if none (for context)
- * @f: printf-like format and arguments
- */
-#define d_fnstart(l, _dev, f, a...) _d_printf(l, " FNSTART", _dev, f, ## a)
-
-
-/**
- * d_fnend - log message at function end if debugging enabled
- *
- * @l: intended debug level
- * @_dev: 'struct device' pointer, NULL if none (for context)
- * @f: printf-like format and arguments
- */
-#define d_fnend(l, _dev, f, a...) _d_printf(l, " FNEND", _dev, f, ## a)
-
-
-/**
- * d_printf - log message if debugging enabled
- *
- * @l: intended debug level
- * @_dev: 'struct device' pointer, NULL if none (for context)
- * @f: printf-like format and arguments
- */
-#define d_printf(l, _dev, f, a...) _d_printf(l, "", _dev, f, ## a)
-
-
-/**
- * d_dump - log buffer hex dump if debugging enabled
- *
- * @l: intended debug level
- * @_dev: 'struct device' pointer, NULL if none (for context)
- * @f: printf-like format and arguments
- */
-#define d_dump(l, dev, ptr, size) \
-do { \
- char head[64]; \
- if (!d_test(l)) \
- break; \
- __d_head(head, sizeof(head), dev); \
- print_hex_dump(KERN_ERR, head, 0, 16, 1, \
- ((void *) ptr), (size), 0); \
-} while (0)
-
-
-/**
- * Export a submodule's debug level over debugfs as PREFIXSUBMODULE
- *
- * @prefix: string to prefix the name with
- * @submodule: name of submodule (not a string, just the name)
- * @dentry: debugfs parent dentry
- *
- * For removing, just use debugfs_remove_recursive() on the parent.
- */
-#define d_level_register_debugfs(prefix, name, parent) \
-({ \
- debugfs_create_u8( \
- prefix #name, 0600, parent, \
- &(D_LEVEL[__D_SUBMODULE_ ## name].level)); \
-})
-
-
-static inline
-void d_submodule_set(struct d_level *d_level, size_t d_level_size,
- const char *submodule, u8 level, const char *tag)
-{
- struct d_level *itr, *top;
- int index = -1;
-
- for (itr = d_level, top = itr + d_level_size; itr < top; itr++) {
- index++;
- if (itr->name == NULL) {
- printk(KERN_ERR "%s: itr->name NULL?? (%p, #%d)\n",
- tag, itr, index);
- continue;
- }
- if (!strcmp(itr->name, submodule)) {
- itr->level = level;
- return;
- }
- }
- printk(KERN_ERR "%s: unknown submodule %s\n", tag, submodule);
-}
-
-
-/**
- * d_parse_params - Parse a string with debug parameters from the
- * command line
- *
- * @d_level: level structure (D_LEVEL)
- * @d_level_size: number of items in the level structure
- * (D_LEVEL_SIZE).
- * @_params: string with the parameters; this is a space (not tab!)
- * separated list of NAME:VALUE, where value is the debug level
- * and NAME is the name of the submodule.
- * @tag: string for error messages (example: MODULE.ARGNAME).
- */
-static inline
-void d_parse_params(struct d_level *d_level, size_t d_level_size,
- const char *_params, const char *tag)
-{
- char submodule[130], *params, *params_orig, *token, *colon;
- unsigned level, tokens;
-
- if (_params == NULL)
- return;
- params_orig = kstrdup(_params, GFP_KERNEL);
- params = params_orig;
- while (1) {
- token = strsep(&params, " ");
- if (token == NULL)
- break;
- if (*token == '\0') /* eat joint spaces */
- continue;
- /* kernel's sscanf %s eats until whitespace, so we
- * replace : by \n so it doesn't get eaten later by
- * strsep */
- colon = strchr(token, ':');
- if (colon != NULL)
- *colon = '\n';
- tokens = sscanf(token, "%s\n%u", submodule, &level);
- if (colon != NULL)
- *colon = ':'; /* set back, for error messages */
- if (tokens == 2)
- d_submodule_set(d_level, d_level_size,
- submodule, level, tag);
- else
- printk(KERN_ERR "%s: can't parse '%s' as a "
- "SUBMODULE:LEVEL (%d tokens)\n",
- tag, token, tokens);
- }
- kfree(params_orig);
-}
-
-#endif /* #ifndef __debug__h__ */
diff --git a/drivers/staging/wimax/linux-wimax.h b/drivers/staging/wimax/linux-wimax.h
deleted file mode 100644
index 9f6b77af2f6d..000000000000
--- a/drivers/staging/wimax/linux-wimax.h
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Linux WiMax
- * API for user space
- *
- *
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
- *
- * 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 Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * 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
- * OWNER 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.
- *
- *
- * Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- * - Initial implementation
- *
- *
- * This file declares the user/kernel protocol that is spoken over
- * Generic Netlink, as well as any type declaration that is to be used
- * by kernel and user space.
- *
- * It is intended for user space to clone it verbatim to use it as a
- * primary reference for definitions.
- *
- * Stuff intended for kernel usage as well as full protocol and stack
- * documentation is rooted in include/net/wimax.h.
- */
-
-#ifndef __LINUX__WIMAX_H__
-#define __LINUX__WIMAX_H__
-
-#include <linux/types.h>
-
-enum {
- /**
- * Version of the interface (unsigned decimal, MMm, max 25.5)
- * M - Major: change if removing or modifying an existing call.
- * m - minor: change when adding a new call
- */
- WIMAX_GNL_VERSION = 01,
- /* Generic NetLink attributes */
- WIMAX_GNL_ATTR_INVALID = 0x00,
- WIMAX_GNL_ATTR_MAX = 10,
-};
-
-
-/*
- * Generic NetLink operations
- *
- * Most of these map to an API call; _OP_ stands for operation, _RP_
- * for reply and _RE_ for report (aka: signal).
- */
-enum {
- WIMAX_GNL_OP_MSG_FROM_USER, /* User to kernel message */
- WIMAX_GNL_OP_MSG_TO_USER, /* Kernel to user message */
- WIMAX_GNL_OP_RFKILL, /* Run wimax_rfkill() */
- WIMAX_GNL_OP_RESET, /* Run wimax_rfkill() */
- WIMAX_GNL_RE_STATE_CHANGE, /* Report: status change */
- WIMAX_GNL_OP_STATE_GET, /* Request for current state */
-};
-
-
-/* Message from user / to user */
-enum {
- WIMAX_GNL_MSG_IFIDX = 1,
- WIMAX_GNL_MSG_PIPE_NAME,
- WIMAX_GNL_MSG_DATA,
-};
-
-
-/*
- * wimax_rfkill()
- *
- * The state of the radio (ON/OFF) is mapped to the rfkill subsystem's
- * switch state (DISABLED/ENABLED).
- */
-enum wimax_rf_state {
- WIMAX_RF_OFF = 0, /* Radio is off, rfkill on/enabled */
- WIMAX_RF_ON = 1, /* Radio is on, rfkill off/disabled */
- WIMAX_RF_QUERY = 2,
-};
-
-/* Attributes */
-enum {
- WIMAX_GNL_RFKILL_IFIDX = 1,
- WIMAX_GNL_RFKILL_STATE,
-};
-
-
-/* Attributes for wimax_reset() */
-enum {
- WIMAX_GNL_RESET_IFIDX = 1,
-};
-
-/* Attributes for wimax_state_get() */
-enum {
- WIMAX_GNL_STGET_IFIDX = 1,
-};
-
-/*
- * Attributes for the Report State Change
- *
- * For now we just have the old and new states; new attributes might
- * be added later on.
- */
-enum {
- WIMAX_GNL_STCH_IFIDX = 1,
- WIMAX_GNL_STCH_STATE_OLD,
- WIMAX_GNL_STCH_STATE_NEW,
-};
-
-
-/**
- * enum wimax_st - The different states of a WiMAX device
- * @__WIMAX_ST_NULL: The device structure has been allocated and zeroed,
- * but still wimax_dev_add() hasn't been called. There is no state.
- *
- * @WIMAX_ST_DOWN: The device has been registered with the WiMAX and
- * networking stacks, but it is not initialized (normally that is
- * done with 'ifconfig DEV up' [or equivalent], which can upload
- * firmware and enable communications with the device).
- * In this state, the device is powered down and using as less
- * power as possible.
- * This state is the default after a call to wimax_dev_add(). It
- * is ok to have drivers move directly to %WIMAX_ST_UNINITIALIZED
- * or %WIMAX_ST_RADIO_OFF in _probe() after the call to
- * wimax_dev_add().
- * It is recommended that the driver leaves this state when
- * calling 'ifconfig DEV up' and enters it back on 'ifconfig DEV
- * down'.
- *
- * @__WIMAX_ST_QUIESCING: The device is being torn down, so no API
- * operations are allowed to proceed except the ones needed to
- * complete the device clean up process.
- *
- * @WIMAX_ST_UNINITIALIZED: [optional] Communication with the device
- * is setup, but the device still requires some configuration
- * before being operational.
- * Some WiMAX API calls might work.
- *
- * @WIMAX_ST_RADIO_OFF: The device is fully up; radio is off (wether
- * by hardware or software switches).
- * It is recommended to always leave the device in this state
- * after initialization.
- *
- * @WIMAX_ST_READY: The device is fully up and radio is on.
- *
- * @WIMAX_ST_SCANNING: [optional] The device has been instructed to
- * scan. In this state, the device cannot be actively connected to
- * a network.
- *
- * @WIMAX_ST_CONNECTING: The device is connecting to a network. This
- * state exists because in some devices, the connect process can
- * include a number of negotiations between user space, kernel
- * space and the device. User space needs to know what the device
- * is doing. If the connect sequence in a device is atomic and
- * fast, the device can transition directly to CONNECTED
- *
- * @WIMAX_ST_CONNECTED: The device is connected to a network.
- *
- * @__WIMAX_ST_INVALID: This is an invalid state used to mark the
- * maximum numeric value of states.
- *
- * Description:
- *
- * Transitions from one state to another one are atomic and can only
- * be caused in kernel space with wimax_state_change(). To read the
- * state, use wimax_state_get().
- *
- * States starting with __ are internal and shall not be used or
- * referred to by drivers or userspace. They look ugly, but that's the
- * point -- if any use is made non-internal to the stack, it is easier
- * to catch on review.
- *
- * All API operations [with well defined exceptions] will take the
- * device mutex before starting and then check the state. If the state
- * is %__WIMAX_ST_NULL, %WIMAX_ST_DOWN, %WIMAX_ST_UNINITIALIZED or
- * %__WIMAX_ST_QUIESCING, it will drop the lock and quit with
- * -%EINVAL, -%ENOMEDIUM, -%ENOTCONN or -%ESHUTDOWN.
- *
- * The order of the definitions is important, so we can do numerical
- * comparisons (eg: < %WIMAX_ST_RADIO_OFF means the device is not ready
- * to operate).
- */
-/*
- * The allowed state transitions are described in the table below
- * (states in rows can go to states in columns where there is an X):
- *
- * UNINI RADIO READY SCAN CONNEC CONNEC
- * NULL DOWN QUIESCING TIALIZED OFF NING TING TED
- * NULL - x
- * DOWN - x x x
- * QUIESCING x -
- * UNINITIALIZED x - x
- * RADIO_OFF x - x
- * READY x x - x x x
- * SCANNING x x x - x x
- * CONNECTING x x x x - x
- * CONNECTED x x x -
- *
- * This table not available in kernel-doc because the formatting messes it up.
- */
- enum wimax_st {
- __WIMAX_ST_NULL = 0,
- WIMAX_ST_DOWN,
- __WIMAX_ST_QUIESCING,
- WIMAX_ST_UNINITIALIZED,
- WIMAX_ST_RADIO_OFF,
- WIMAX_ST_READY,
- WIMAX_ST_SCANNING,
- WIMAX_ST_CONNECTING,
- WIMAX_ST_CONNECTED,
- __WIMAX_ST_INVALID /* Always keep last */
-};
-
-
-#endif /* #ifndef __LINUX__WIMAX_H__ */
diff --git a/drivers/staging/wimax/net-wimax.h b/drivers/staging/wimax/net-wimax.h
deleted file mode 100644
index f578e345e2bd..000000000000
--- a/drivers/staging/wimax/net-wimax.h
+++ /dev/null
@@ -1,503 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Linux WiMAX
- * Kernel space API for accessing WiMAX devices
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * The WiMAX stack provides an API for controlling and managing the
- * system's WiMAX devices. This API affects the control plane; the
- * data plane is accessed via the network stack (netdev).
- *
- * Parts of the WiMAX stack API and notifications are exported to
- * user space via Generic Netlink. In user space, libwimax (part of
- * the wimax-tools package) provides a shim layer for accessing those
- * calls.
- *
- * The API is standarized for all WiMAX devices and different drivers
- * implement the backend support for it. However, device-specific
- * messaging pipes are provided that can be used to issue commands and
- * receive notifications in free form.
- *
- * Currently the messaging pipes are the only means of control as it
- * is not known (due to the lack of more devices in the market) what
- * will be a good abstraction layer. Expect this to change as more
- * devices show in the market. This API is designed to be growable in
- * order to address this problem.
- *
- * USAGE
- *
- * Embed a `struct wimax_dev` at the beginning of the device's
- * private structure, initialize and register it. For details, see
- * `struct wimax_dev`s documentation.
- *
- * Once this is done, wimax-tools's libwimaxll can be used to
- * communicate with the driver from user space. You user space
- * application does not have to forcibily use libwimaxll and can talk
- * the generic netlink protocol directly if desired.
- *
- * Remember this is a very low level API that will to provide all of
- * WiMAX features. Other daemons and services running in user space
- * are the expected clients of it. They offer a higher level API that
- * applications should use (an example of this is the Intel's WiMAX
- * Network Service for the i2400m).
- *
- * DESIGN
- *
- * Although not set on final stone, this very basic interface is
- * mostly completed. Remember this is meant to grow as new common
- * operations are decided upon. New operations will be added to the
- * interface, intent being on keeping backwards compatibility as much
- * as possible.
- *
- * This layer implements a set of calls to control a WiMAX device,
- * exposing a frontend to the rest of the kernel and user space (via
- * generic netlink) and a backend implementation in the driver through
- * function pointers.
- *
- * WiMAX devices have a state, and a kernel-only API allows the
- * drivers to manipulate that state. State transitions are atomic, and
- * only some of them are allowed (see `enum wimax_st`).
- *
- * Most API calls will set the state automatically; in most cases
- * drivers have to only report state changes due to external
- * conditions.
- *
- * All API operations are 'atomic', serialized through a mutex in the
- * `struct wimax_dev`.
- *
- * EXPORTING TO USER SPACE THROUGH GENERIC NETLINK
- *
- * The API is exported to user space using generic netlink (other
- * methods can be added as needed).
- *
- * There is a Generic Netlink Family named "WiMAX", where interfaces
- * supporting the WiMAX interface receive commands and broadcast their
- * signals over a multicast group named "msg".
- *
- * Mapping to the source/destination interface is done by an interface
- * index attribute.
- *
- * For user-to-kernel traffic (commands) we use a function call
- * marshalling mechanism, where a message X with attributes A, B, C
- * sent from user space to kernel space means executing the WiMAX API
- * call wimax_X(A, B, C), sending the results back as a message.
- *
- * Kernel-to-user (notifications or signals) communication is sent
- * over multicast groups. This allows to have multiple applications
- * monitoring them.
- *
- * Each command/signal gets assigned it's own attribute policy. This
- * way the validator will verify that all the attributes in there are
- * only the ones that should be for each command/signal. Thing of an
- * attribute mapping to a type+argumentname for each command/signal.
- *
- * If we had a single policy for *all* commands/signals, after running
- * the validator we'd have to check "does this attribute belong in
- * here"? for each one. It can be done manually, but it's just easier
- * to have the validator do that job with multiple policies. As well,
- * it makes it easier to later expand each command/signal signature
- * without affecting others and keeping the namespace more or less
- * sane. Not that it is too complicated, but it makes it even easier.
- *
- * No state information is maintained in the kernel for each user
- * space connection (the connection is stateless).
- *
- * TESTING FOR THE INTERFACE AND VERSIONING
- *
- * If network interface X is a WiMAX device, there will be a Generic
- * Netlink family named "WiMAX X" and the device will present a
- * "wimax" directory in it's network sysfs directory
- * (/sys/class/net/DEVICE/wimax) [used by HAL].
- *
- * The inexistence of any of these means the device does not support
- * this WiMAX API.
- *
- * By querying the generic netlink controller, versioning information
- * and the multicast groups available can be found. Applications using
- * the interface can either rely on that or use the generic netlink
- * controller to figure out which generic netlink commands/signals are
- * supported.
- *
- * NOTE: this versioning is a last resort to avoid hard
- * incompatibilities. It is the intention of the design of this
- * stack not to introduce backward incompatible changes.
- *
- * The version code has to fit in one byte (restrictions imposed by
- * generic netlink); we use `version / 10` for the major version and
- * `version % 10` for the minor. This gives 9 minors for each major
- * and 25 majors.
- *
- * The version change protocol is as follow:
- *
- * - Major versions: needs to be increased if an existing message/API
- * call is changed or removed. Doesn't need to be changed if a new
- * message is added.
- *
- * - Minor version: needs to be increased if new messages/API calls are
- * being added or some other consideration that doesn't impact the
- * user-kernel interface too much (like some kind of bug fix) and
- * that is kind of left up in the air to common sense.
- *
- * User space code should not try to work if the major version it was
- * compiled for differs from what the kernel offers. As well, if the
- * minor version of the kernel interface is lower than the one user
- * space is expecting (the one it was compiled for), the kernel
- * might be missing API calls; user space shall be ready to handle
- * said condition. Use the generic netlink controller operations to
- * find which ones are supported and which not.
- *
- * libwimaxll:wimaxll_open() takes care of checking versions.
- *
- * THE OPERATIONS:
- *
- * Each operation is defined in its on file (drivers/net/wimax/op-*.c)
- * for clarity. The parts needed for an operation are:
- *
- * - a function pointer in `struct wimax_dev`: optional, as the
- * operation might be implemented by the stack and not by the
- * driver.
- *
- * All function pointers are named wimax_dev->op_*(), and drivers
- * must implement them except where noted otherwise.
- *
- * - When exported to user space, a `struct nla_policy` to define the
- * attributes of the generic netlink command and a `struct genl_ops`
- * to define the operation.
- *
- * All the declarations for the operation codes (WIMAX_GNL_OP_<NAME>)
- * and generic netlink attributes (WIMAX_GNL_<NAME>_*) are declared in
- * include/linux/wimax.h; this file is intended to be cloned by user
- * space to gain access to those declarations.
- *
- * A few caveats to remember:
- *
- * - Need to define attribute numbers starting in 1; otherwise it
- * fails.
- *
- * - the `struct genl_family` requires a maximum attribute id; when
- * defining the `struct nla_policy` for each message, it has to have
- * an array size of WIMAX_GNL_ATTR_MAX+1.
- *
- * The op_*() function pointers will not be called if the wimax_dev is
- * in a state <= %WIMAX_ST_UNINITIALIZED. The exception is:
- *
- * - op_reset: can be called at any time after wimax_dev_add() has
- * been called.
- *
- * THE PIPE INTERFACE:
- *
- * This interface is kept intentionally simple. The driver can send
- * and receive free-form messages to/from user space through a
- * pipe. See drivers/net/wimax/op-msg.c for details.
- *
- * The kernel-to-user messages are sent with
- * wimax_msg(). user-to-kernel messages are delivered via
- * wimax_dev->op_msg_from_user().
- *
- * RFKILL:
- *
- * RFKILL support is built into the wimax_dev layer; the driver just
- * needs to call wimax_report_rfkill_{hw,sw}() to inform of changes in
- * the hardware or software RF kill switches. When the stack wants to
- * turn the radio off, it will call wimax_dev->op_rfkill_sw_toggle(),
- * which the driver implements.
- *
- * User space can set the software RF Kill switch by calling
- * wimax_rfkill().
- *
- * The code for now only supports devices that don't require polling;
- * If the device needs to be polled, create a self-rearming delayed
- * work struct for polling or look into adding polled support to the
- * WiMAX stack.
- *
- * When initializing the hardware (_probe), after calling
- * wimax_dev_add(), query the device for it's RF Kill switches status
- * and feed it back to the WiMAX stack using
- * wimax_report_rfkill_{hw,sw}(). If any switch is missing, always
- * report it as ON.
- *
- * NOTE: the wimax stack uses an inverted terminology to that of the
- * RFKILL subsystem:
- *
- * - ON: radio is ON, RFKILL is DISABLED or OFF.
- * - OFF: radio is OFF, RFKILL is ENABLED or ON.
- *
- * MISCELLANEOUS OPS:
- *
- * wimax_reset() can be used to reset the device to power on state; by
- * default it issues a warm reset that maintains the same device
- * node. If that is not possible, it falls back to a cold reset
- * (device reconnect). The driver implements the backend to this
- * through wimax_dev->op_reset().
- */
-
-#ifndef __NET__WIMAX_H__
-#define __NET__WIMAX_H__
-
-#include "linux-wimax.h"
-#include <net/genetlink.h>
-#include <linux/netdevice.h>
-
-struct net_device;
-struct genl_info;
-struct wimax_dev;
-
-/**
- * struct wimax_dev - Generic WiMAX device
- *
- * @net_dev: [fill] Pointer to the &struct net_device this WiMAX
- * device implements.
- *
- * @op_msg_from_user: [fill] Driver-specific operation to
- * handle a raw message from user space to the driver. The
- * driver can send messages to user space using with
- * wimax_msg_to_user().
- *
- * @op_rfkill_sw_toggle: [fill] Driver-specific operation to act on
- * userspace (or any other agent) requesting the WiMAX device to
- * change the RF Kill software switch (WIMAX_RF_ON or
- * WIMAX_RF_OFF).
- * If such hardware support is not present, it is assumed the
- * radio cannot be switched off and it is always on (and the stack
- * will error out when trying to switch it off). In such case,
- * this function pointer can be left as NULL.
- *
- * @op_reset: [fill] Driver specific operation to reset the
- * device.
- * This operation should always attempt first a warm reset that
- * does not disconnect the device from the bus and return 0.
- * If that fails, it should resort to some sort of cold or bus
- * reset (even if it implies a bus disconnection and device
- * disappearance). In that case, -ENODEV should be returned to
- * indicate the device is gone.
- * This operation has to be synchronous, and return only when the
- * reset is complete. In case of having had to resort to bus/cold
- * reset implying a device disconnection, the call is allowed to
- * return immediately.
- * NOTE: wimax_dev->mutex is NOT locked when this op is being
- * called; however, wimax_dev->mutex_reset IS locked to ensure
- * serialization of calls to wimax_reset().
- * See wimax_reset()'s documentation.
- *
- * @name: [fill] A way to identify this device. We need to register a
- * name with many subsystems (rfkill, workqueue creation, etc).
- * We can't use the network device name as that
- * might change and in some instances we don't know it yet (until
- * we don't call register_netdev()). So we generate an unique one
- * using the driver name and device bus id, place it here and use
- * it across the board. Recommended naming:
- * DRIVERNAME-BUSNAME:BUSID (dev->bus->name, dev->bus_id).
- *
- * @id_table_node: [private] link to the list of wimax devices kept by
- * id-table.c. Protected by it's own spinlock.
- *
- * @mutex: [private] Serializes all concurrent access and execution of
- * operations.
- *
- * @mutex_reset: [private] Serializes reset operations. Needs to be a
- * different mutex because as part of the reset operation, the
- * driver has to call back into the stack to do things such as
- * state change, that require wimax_dev->mutex.
- *
- * @state: [private] Current state of the WiMAX device.
- *
- * @rfkill: [private] integration into the RF-Kill infrastructure.
- *
- * @rf_sw: [private] State of the software radio switch (OFF/ON)
- *
- * @rf_hw: [private] State of the hardware radio switch (OFF/ON)
- *
- * @debugfs_dentry: [private] Used to hook up a debugfs entry. This
- * shows up in the debugfs root as wimax\:DEVICENAME.
- *
- * Description:
- * This structure defines a common interface to access all WiMAX
- * devices from different vendors and provides a common API as well as
- * a free-form device-specific messaging channel.
- *
- * Usage:
- * 1. Embed a &struct wimax_dev at *the beginning* the network
- * device structure so that netdev_priv() points to it.
- *
- * 2. memset() it to zero
- *
- * 3. Initialize with wimax_dev_init(). This will leave the WiMAX
- * device in the %__WIMAX_ST_NULL state.
- *
- * 4. Fill all the fields marked with [fill]; once called
- * wimax_dev_add(), those fields CANNOT be modified.
- *
- * 5. Call wimax_dev_add() *after* registering the network
- * device. This will leave the WiMAX device in the %WIMAX_ST_DOWN
- * state.
- * Protect the driver's net_device->open() against succeeding if
- * the wimax device state is lower than %WIMAX_ST_DOWN.
- *
- * 6. Select when the device is going to be turned on/initialized;
- * for example, it could be initialized on 'ifconfig up' (when the
- * netdev op 'open()' is called on the driver).
- *
- * When the device is initialized (at `ifconfig up` time, or right
- * after calling wimax_dev_add() from _probe(), make sure the
- * following steps are taken
- *
- * a. Move the device to %WIMAX_ST_UNINITIALIZED. This is needed so
- * some API calls that shouldn't work until the device is ready
- * can be blocked.
- *
- * b. Initialize the device. Make sure to turn the SW radio switch
- * off and move the device to state %WIMAX_ST_RADIO_OFF when
- * done. When just initialized, a device should be left in RADIO
- * OFF state until user space devices to turn it on.
- *
- * c. Query the device for the state of the hardware rfkill switch
- * and call wimax_rfkill_report_hw() and wimax_rfkill_report_sw()
- * as needed. See below.
- *
- * wimax_dev_rm() undoes before unregistering the network device. Once
- * wimax_dev_add() is called, the driver can get called on the
- * wimax_dev->op_* function pointers
- *
- * CONCURRENCY:
- *
- * The stack provides a mutex for each device that will disallow API
- * calls happening concurrently; thus, op calls into the driver
- * through the wimax_dev->op*() function pointers will always be
- * serialized and *never* concurrent.
- *
- * For locking, take wimax_dev->mutex is taken; (most) operations in
- * the API have to check for wimax_dev_is_ready() to return 0 before
- * continuing (this is done internally).
- *
- * REFERENCE COUNTING:
- *
- * The WiMAX device is reference counted by the associated network
- * device. The only operation that can be used to reference the device
- * is wimax_dev_get_by_genl_info(), and the reference it acquires has
- * to be released with dev_put(wimax_dev->net_dev).
- *
- * RFKILL:
- *
- * At startup, both HW and SW radio switchess are assumed to be off.
- *
- * At initialization time [after calling wimax_dev_add()], have the
- * driver query the device for the status of the software and hardware
- * RF kill switches and call wimax_report_rfkill_hw() and
- * wimax_rfkill_report_sw() to indicate their state. If any is
- * missing, just call it to indicate it is ON (radio always on).
- *
- * Whenever the driver detects a change in the state of the RF kill
- * switches, it should call wimax_report_rfkill_hw() or
- * wimax_report_rfkill_sw() to report it to the stack.
- */
-struct wimax_dev {
- struct net_device *net_dev;
- struct list_head id_table_node;
- struct mutex mutex; /* Protects all members and API calls */
- struct mutex mutex_reset;
- enum wimax_st state;
-
- int (*op_msg_from_user)(struct wimax_dev *wimax_dev,
- const char *,
- const void *, size_t,
- const struct genl_info *info);
- int (*op_rfkill_sw_toggle)(struct wimax_dev *wimax_dev,
- enum wimax_rf_state);
- int (*op_reset)(struct wimax_dev *wimax_dev);
-
- struct rfkill *rfkill;
- unsigned int rf_hw;
- unsigned int rf_sw;
- char name[32];
-
- struct dentry *debugfs_dentry;
-};
-
-
-
-/*
- * WiMAX stack public API for device drivers
- * -----------------------------------------
- *
- * These functions are not exported to user space.
- */
-void wimax_dev_init(struct wimax_dev *);
-int wimax_dev_add(struct wimax_dev *, struct net_device *);
-void wimax_dev_rm(struct wimax_dev *);
-
-static inline
-struct wimax_dev *net_dev_to_wimax(struct net_device *net_dev)
-{
- return netdev_priv(net_dev);
-}
-
-static inline
-struct device *wimax_dev_to_dev(struct wimax_dev *wimax_dev)
-{
- return wimax_dev->net_dev->dev.parent;
-}
-
-void wimax_state_change(struct wimax_dev *, enum wimax_st);
-enum wimax_st wimax_state_get(struct wimax_dev *);
-
-/*
- * Radio Switch state reporting.
- *
- * enum wimax_rf_state is declared in linux/wimax.h so the exports
- * to user space can use it.
- */
-void wimax_report_rfkill_hw(struct wimax_dev *, enum wimax_rf_state);
-void wimax_report_rfkill_sw(struct wimax_dev *, enum wimax_rf_state);
-
-
-/*
- * Free-form messaging to/from user space
- *
- * Sending a message:
- *
- * wimax_msg(wimax_dev, pipe_name, buf, buf_size, GFP_KERNEL);
- *
- * Broken up:
- *
- * skb = wimax_msg_alloc(wimax_dev, pipe_name, buf_size, GFP_KERNEL);
- * ...fill up skb...
- * wimax_msg_send(wimax_dev, pipe_name, skb);
- *
- * Be sure not to modify skb->data in the middle (ie: don't use
- * skb_push()/skb_pull()/skb_reserve() on the skb).
- *
- * "pipe_name" is any string, that can be interpreted as the name of
- * the pipe or recipient; the interpretation of it is driver
- * specific, so the recipient can multiplex it as wished. It can be
- * NULL, it won't be used - an example is using a "diagnostics" tag to
- * send diagnostics information that a device-specific diagnostics
- * tool would be interested in.
- */
-struct sk_buff *wimax_msg_alloc(struct wimax_dev *, const char *, const void *,
- size_t, gfp_t);
-int wimax_msg_send(struct wimax_dev *, struct sk_buff *);
-int wimax_msg(struct wimax_dev *, const char *, const void *, size_t, gfp_t);
-
-const void *wimax_msg_data_len(struct sk_buff *, size_t *);
-const void *wimax_msg_data(struct sk_buff *);
-ssize_t wimax_msg_len(struct sk_buff *);
-
-
-/*
- * WiMAX stack user space API
- * --------------------------
- *
- * This API is what gets exported to user space for general
- * operations. As well, they can be called from within the kernel,
- * (with a properly referenced `struct wimax_dev`).
- *
- * Properly referenced means: the 'struct net_device' that embeds the
- * device's control structure and (as such) the 'struct wimax_dev' is
- * referenced by the caller.
- */
-int wimax_rfkill(struct wimax_dev *, enum wimax_rf_state);
-int wimax_reset(struct wimax_dev *);
-
-#endif /* #ifndef __NET__WIMAX_H__ */
diff --git a/drivers/staging/wimax/op-msg.c b/drivers/staging/wimax/op-msg.c
deleted file mode 100644
index e20ac7d84e82..000000000000
--- a/drivers/staging/wimax/op-msg.c
+++ /dev/null
@@ -1,391 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * Generic messaging interface between userspace and driver/device
- *
- * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * This implements a direct communication channel between user space and
- * the driver/device, by which free form messages can be sent back and
- * forth.
- *
- * This is intended for device-specific features, vendor quirks, etc.
- *
- * See include/net/wimax.h
- *
- * GENERIC NETLINK ENCODING AND CAPACITY
- *
- * A destination "pipe name" is added to each message; it is up to the
- * drivers to assign or use those names (if using them at all).
- *
- * Messages are encoded as a binary netlink attribute using nla_put()
- * using type NLA_UNSPEC (as some versions of libnl still in
- * deployment don't yet understand NLA_BINARY).
- *
- * The maximum capacity of this transport is PAGESIZE per message (so
- * the actual payload will be bit smaller depending on the
- * netlink/generic netlink attributes and headers).
- *
- * RECEPTION OF MESSAGES
- *
- * When a message is received from user space, it is passed verbatim
- * to the driver calling wimax_dev->op_msg_from_user(). The return
- * value from this function is passed back to user space as an ack
- * over the generic netlink protocol.
- *
- * The stack doesn't do any processing or interpretation of these
- * messages.
- *
- * SENDING MESSAGES
- *
- * Messages can be sent with wimax_msg().
- *
- * If the message delivery needs to happen on a different context to
- * that of its creation, wimax_msg_alloc() can be used to get a
- * pointer to the message that can be delivered later on with
- * wimax_msg_send().
- *
- * ROADMAP
- *
- * wimax_gnl_doit_msg_from_user() Process a message from user space
- * wimax_dev_get_by_genl_info()
- * wimax_dev->op_msg_from_user() Delivery of message to the driver
- *
- * wimax_msg() Send a message to user space
- * wimax_msg_alloc()
- * wimax_msg_send()
- */
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <net/genetlink.h>
-#include <linux/netdevice.h>
-#include "linux-wimax.h"
-#include <linux/security.h>
-#include <linux/export.h>
-#include "wimax-internal.h"
-
-
-#define D_SUBMODULE op_msg
-#include "debug-levels.h"
-
-
-/**
- * wimax_msg_alloc - Create a new skb for sending a message to userspace
- *
- * @wimax_dev: WiMAX device descriptor
- * @pipe_name: "named pipe" the message will be sent to
- * @msg: pointer to the message data to send
- * @size: size of the message to send (in bytes), including the header.
- * @gfp_flags: flags for memory allocation.
- *
- * Returns: %0 if ok, negative errno code on error
- *
- * Description:
- *
- * Allocates an skb that will contain the message to send to user
- * space over the messaging pipe and initializes it, copying the
- * payload.
- *
- * Once this call is done, you can deliver it with
- * wimax_msg_send().
- *
- * IMPORTANT:
- *
- * Don't use skb_push()/skb_pull()/skb_reserve() on the skb, as
- * wimax_msg_send() depends on skb->data being placed at the
- * beginning of the user message.
- *
- * Unlike other WiMAX stack calls, this call can be used way early,
- * even before wimax_dev_add() is called, as long as the
- * wimax_dev->net_dev pointer is set to point to a proper
- * net_dev. This is so that drivers can use it early in case they need
- * to send stuff around or communicate with user space.
- */
-struct sk_buff *wimax_msg_alloc(struct wimax_dev *wimax_dev,
- const char *pipe_name,
- const void *msg, size_t size,
- gfp_t gfp_flags)
-{
- int result;
- struct device *dev = wimax_dev_to_dev(wimax_dev);
- size_t msg_size;
- void *genl_msg;
- struct sk_buff *skb;
-
- msg_size = nla_total_size(size)
- + nla_total_size(sizeof(u32))
- + (pipe_name ? nla_total_size(strlen(pipe_name)) : 0);
- result = -ENOMEM;
- skb = genlmsg_new(msg_size, gfp_flags);
- if (skb == NULL)
- goto error_new;
- genl_msg = genlmsg_put(skb, 0, 0, &wimax_gnl_family,
- 0, WIMAX_GNL_OP_MSG_TO_USER);
- if (genl_msg == NULL) {
- dev_err(dev, "no memory to create generic netlink message\n");
- goto error_genlmsg_put;
- }
- result = nla_put_u32(skb, WIMAX_GNL_MSG_IFIDX,
- wimax_dev->net_dev->ifindex);
- if (result < 0) {
- dev_err(dev, "no memory to add ifindex attribute\n");
- goto error_nla_put;
- }
- if (pipe_name) {
- result = nla_put_string(skb, WIMAX_GNL_MSG_PIPE_NAME,
- pipe_name);
- if (result < 0) {
- dev_err(dev, "no memory to add pipe_name attribute\n");
- goto error_nla_put;
- }
- }
- result = nla_put(skb, WIMAX_GNL_MSG_DATA, size, msg);
- if (result < 0) {
- dev_err(dev, "no memory to add payload (msg %p size %zu) in "
- "attribute: %d\n", msg, size, result);
- goto error_nla_put;
- }
- genlmsg_end(skb, genl_msg);
- return skb;
-
-error_nla_put:
-error_genlmsg_put:
-error_new:
- nlmsg_free(skb);
- return ERR_PTR(result);
-}
-EXPORT_SYMBOL_GPL(wimax_msg_alloc);
-
-
-/**
- * wimax_msg_data_len - Return a pointer and size of a message's payload
- *
- * @msg: Pointer to a message created with wimax_msg_alloc()
- * @size: Pointer to where to store the message's size
- *
- * Returns the pointer to the message data.
- */
-const void *wimax_msg_data_len(struct sk_buff *msg, size_t *size)
-{
- struct nlmsghdr *nlh = (void *) msg->head;
- struct nlattr *nla;
-
- nla = nlmsg_find_attr(nlh, sizeof(struct genlmsghdr),
- WIMAX_GNL_MSG_DATA);
- if (nla == NULL) {
- pr_err("Cannot find attribute WIMAX_GNL_MSG_DATA\n");
- return NULL;
- }
- *size = nla_len(nla);
- return nla_data(nla);
-}
-EXPORT_SYMBOL_GPL(wimax_msg_data_len);
-
-
-/**
- * wimax_msg_data - Return a pointer to a message's payload
- *
- * @msg: Pointer to a message created with wimax_msg_alloc()
- */
-const void *wimax_msg_data(struct sk_buff *msg)
-{
- struct nlmsghdr *nlh = (void *) msg->head;
- struct nlattr *nla;
-
- nla = nlmsg_find_attr(nlh, sizeof(struct genlmsghdr),
- WIMAX_GNL_MSG_DATA);
- if (nla == NULL) {
- pr_err("Cannot find attribute WIMAX_GNL_MSG_DATA\n");
- return NULL;
- }
- return nla_data(nla);
-}
-EXPORT_SYMBOL_GPL(wimax_msg_data);
-
-
-/**
- * wimax_msg_len - Return a message's payload length
- *
- * @msg: Pointer to a message created with wimax_msg_alloc()
- */
-ssize_t wimax_msg_len(struct sk_buff *msg)
-{
- struct nlmsghdr *nlh = (void *) msg->head;
- struct nlattr *nla;
-
- nla = nlmsg_find_attr(nlh, sizeof(struct genlmsghdr),
- WIMAX_GNL_MSG_DATA);
- if (nla == NULL) {
- pr_err("Cannot find attribute WIMAX_GNL_MSG_DATA\n");
- return -EINVAL;
- }
- return nla_len(nla);
-}
-EXPORT_SYMBOL_GPL(wimax_msg_len);
-
-
-/**
- * wimax_msg_send - Send a pre-allocated message to user space
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * @skb: &struct sk_buff returned by wimax_msg_alloc(). Note the
- * ownership of @skb is transferred to this function.
- *
- * Returns: 0 if ok, < 0 errno code on error
- *
- * Description:
- *
- * Sends a free-form message that was preallocated with
- * wimax_msg_alloc() and filled up.
- *
- * Assumes that once you pass an skb to this function for sending, it
- * owns it and will release it when done (on success).
- *
- * IMPORTANT:
- *
- * Don't use skb_push()/skb_pull()/skb_reserve() on the skb, as
- * wimax_msg_send() depends on skb->data being placed at the
- * beginning of the user message.
- *
- * Unlike other WiMAX stack calls, this call can be used way early,
- * even before wimax_dev_add() is called, as long as the
- * wimax_dev->net_dev pointer is set to point to a proper
- * net_dev. This is so that drivers can use it early in case they need
- * to send stuff around or communicate with user space.
- */
-int wimax_msg_send(struct wimax_dev *wimax_dev, struct sk_buff *skb)
-{
- struct device *dev = wimax_dev_to_dev(wimax_dev);
- void *msg = skb->data;
- size_t size = skb->len;
- might_sleep();
-
- d_printf(1, dev, "CTX: wimax msg, %zu bytes\n", size);
- d_dump(2, dev, msg, size);
- genlmsg_multicast(&wimax_gnl_family, skb, 0, 0, GFP_KERNEL);
- d_printf(1, dev, "CTX: genl multicast done\n");
- return 0;
-}
-EXPORT_SYMBOL_GPL(wimax_msg_send);
-
-
-/**
- * wimax_msg - Send a message to user space
- *
- * @wimax_dev: WiMAX device descriptor (properly referenced)
- * @pipe_name: "named pipe" the message will be sent to
- * @buf: pointer to the message to send.
- * @size: size of the buffer pointed to by @buf (in bytes).
- * @gfp_flags: flags for memory allocation.
- *
- * Returns: %0 if ok, negative errno code on error.
- *
- * Description:
- *
- * Sends a free-form message to user space on the device @wimax_dev.
- *
- * NOTES:
- *
- * Once the @skb is given to this function, who will own it and will
- * release it when done (unless it returns error).
- */
-int wimax_msg(struct wimax_dev *wimax_dev, const char *pipe_name,
- const void *buf, size_t size, gfp_t gfp_flags)
-{
- int result = -ENOMEM;
- struct sk_buff *skb;
-
- skb = wimax_msg_alloc(wimax_dev, pipe_name, buf, size, gfp_flags);
- if (IS_ERR(skb))
- result = PTR_ERR(skb);
- else
- result = wimax_msg_send(wimax_dev, skb);
- return result;
-}
-EXPORT_SYMBOL_GPL(wimax_msg);
-
-/*
- * Relays a message from user space to the driver
- *
- * The skb is passed to the driver-specific function with the netlink
- * and generic netlink headers already stripped.
- *
- * This call will block while handling/relaying the message.
- */
-int wimax_gnl_doit_msg_from_user(struct sk_buff *skb, struct genl_info *info)
-{
- int result, ifindex;
- struct wimax_dev *wimax_dev;
- struct device *dev;
- struct nlmsghdr *nlh = info->nlhdr;
- char *pipe_name;
- void *msg_buf;
- size_t msg_len;
-
- might_sleep();
- d_fnstart(3, NULL, "(skb %p info %p)\n", skb, info);
- result = -ENODEV;
- if (info->attrs[WIMAX_GNL_MSG_IFIDX] == NULL) {
- pr_err("WIMAX_GNL_MSG_FROM_USER: can't find IFIDX attribute\n");
- goto error_no_wimax_dev;
- }
- ifindex = nla_get_u32(info->attrs[WIMAX_GNL_MSG_IFIDX]);
- wimax_dev = wimax_dev_get_by_genl_info(info, ifindex);
- if (wimax_dev == NULL)
- goto error_no_wimax_dev;
- dev = wimax_dev_to_dev(wimax_dev);
-
- /* Unpack arguments */
- result = -EINVAL;
- if (info->attrs[WIMAX_GNL_MSG_DATA] == NULL) {
- dev_err(dev, "WIMAX_GNL_MSG_FROM_USER: can't find MSG_DATA "
- "attribute\n");
- goto error_no_data;
- }
- msg_buf = nla_data(info->attrs[WIMAX_GNL_MSG_DATA]);
- msg_len = nla_len(info->attrs[WIMAX_GNL_MSG_DATA]);
-
- if (info->attrs[WIMAX_GNL_MSG_PIPE_NAME] == NULL)
- pipe_name = NULL;
- else {
- struct nlattr *attr = info->attrs[WIMAX_GNL_MSG_PIPE_NAME];
- size_t attr_len = nla_len(attr);
- /* libnl-1.1 does not yet support NLA_NUL_STRING */
- result = -ENOMEM;
- pipe_name = kstrndup(nla_data(attr), attr_len + 1, GFP_KERNEL);
- if (pipe_name == NULL)
- goto error_alloc;
- pipe_name[attr_len] = 0;
- }
- mutex_lock(&wimax_dev->mutex);
- result = wimax_dev_is_ready(wimax_dev);
- if (result == -ENOMEDIUM)
- result = 0;
- if (result < 0)
- goto error_not_ready;
- result = -ENOSYS;
- if (wimax_dev->op_msg_from_user == NULL)
- goto error_noop;
-
- d_printf(1, dev,
- "CRX: nlmsghdr len %u type %u flags 0x%04x seq 0x%x pid %u\n",
- nlh->nlmsg_len, nlh->nlmsg_type, nlh->nlmsg_flags,
- nlh->nlmsg_seq, nlh->nlmsg_pid);
- d_printf(1, dev, "CRX: wimax message %zu bytes\n", msg_len);
- d_dump(2, dev, msg_buf, msg_len);
-
- result = wimax_dev->op_msg_from_user(wimax_dev, pipe_name,
- msg_buf, msg_len, info);
-error_noop:
-error_not_ready:
- mutex_unlock(&wimax_dev->mutex);
-error_alloc:
- kfree(pipe_name);
-error_no_data:
- dev_put(wimax_dev->net_dev);
-error_no_wimax_dev:
- d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result);
- return result;
-}
diff --git a/drivers/staging/wimax/op-reset.c b/drivers/staging/wimax/op-reset.c
deleted file mode 100644
index b3f000cbe112..000000000000
--- a/drivers/staging/wimax/op-reset.c
+++ /dev/null
@@ -1,108 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * Implement and export a method for resetting a WiMAX device
- *
- * Copyright (C) 2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * This implements a simple synchronous call to reset a WiMAX device.
- *
- * Resets aim at being warm, keeping the device handles active;
- * however, when that fails, it falls back to a cold reset (that will
- * disconnect and reconnect the device).
- */
-
-#include "net-wimax.h"
-#include <net/genetlink.h>
-#include "linux-wimax.h"
-#include <linux/security.h>
-#include <linux/export.h>
-#include "wimax-internal.h"
-
-#define D_SUBMODULE op_reset
-#include "debug-levels.h"
-
-
-/**
- * wimax_reset - Reset a WiMAX device
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * Returns:
- *
- * %0 if ok and a warm reset was done (the device still exists in
- * the system).
- *
- * -%ENODEV if a cold/bus reset had to be done (device has
- * disconnected and reconnected, so current handle is not valid
- * any more).
- *
- * -%EINVAL if the device is not even registered.
- *
- * Any other negative error code shall be considered as
- * non-recoverable.
- *
- * Description:
- *
- * Called when wanting to reset the device for any reason. Device is
- * taken back to power on status.
- *
- * This call blocks; on successful return, the device has completed the
- * reset process and is ready to operate.
- */
-int wimax_reset(struct wimax_dev *wimax_dev)
-{
- int result = -EINVAL;
- struct device *dev = wimax_dev_to_dev(wimax_dev);
- enum wimax_st state;
-
- might_sleep();
- d_fnstart(3, dev, "(wimax_dev %p)\n", wimax_dev);
- mutex_lock(&wimax_dev->mutex);
- dev_hold(wimax_dev->net_dev);
- state = wimax_dev->state;
- mutex_unlock(&wimax_dev->mutex);
-
- if (state >= WIMAX_ST_DOWN) {
- mutex_lock(&wimax_dev->mutex_reset);
- result = wimax_dev->op_reset(wimax_dev);
- mutex_unlock(&wimax_dev->mutex_reset);
- }
- dev_put(wimax_dev->net_dev);
-
- d_fnend(3, dev, "(wimax_dev %p) = %d\n", wimax_dev, result);
- return result;
-}
-EXPORT_SYMBOL(wimax_reset);
-
-
-/*
- * Exporting to user space over generic netlink
- *
- * Parse the reset command from user space, return error code.
- *
- * No attributes.
- */
-int wimax_gnl_doit_reset(struct sk_buff *skb, struct genl_info *info)
-{
- int result, ifindex;
- struct wimax_dev *wimax_dev;
-
- d_fnstart(3, NULL, "(skb %p info %p)\n", skb, info);
- result = -ENODEV;
- if (info->attrs[WIMAX_GNL_RESET_IFIDX] == NULL) {
- pr_err("WIMAX_GNL_OP_RFKILL: can't find IFIDX attribute\n");
- goto error_no_wimax_dev;
- }
- ifindex = nla_get_u32(info->attrs[WIMAX_GNL_RESET_IFIDX]);
- wimax_dev = wimax_dev_get_by_genl_info(info, ifindex);
- if (wimax_dev == NULL)
- goto error_no_wimax_dev;
- /* Execute the operation and send the result back to user space */
- result = wimax_reset(wimax_dev);
- dev_put(wimax_dev->net_dev);
-error_no_wimax_dev:
- d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result);
- return result;
-}
diff --git a/drivers/staging/wimax/op-rfkill.c b/drivers/staging/wimax/op-rfkill.c
deleted file mode 100644
index 78b294481a59..000000000000
--- a/drivers/staging/wimax/op-rfkill.c
+++ /dev/null
@@ -1,431 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * RF-kill framework integration
- *
- * Copyright (C) 2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * This integrates into the Linux Kernel rfkill susbystem so that the
- * drivers just have to do the bare minimal work, which is providing a
- * method to set the software RF-Kill switch and to report changes in
- * the software and hardware switch status.
- *
- * A non-polled generic rfkill device is embedded into the WiMAX
- * subsystem's representation of a device.
- *
- * FIXME: Need polled support? Let drivers provide a poll routine
- * and hand it to rfkill ops then?
- *
- * All device drivers have to do is after wimax_dev_init(), call
- * wimax_report_rfkill_hw() and wimax_report_rfkill_sw() to update
- * initial state and then every time it changes. See wimax.h:struct
- * wimax_dev for more information.
- *
- * ROADMAP
- *
- * wimax_gnl_doit_rfkill() User space calling wimax_rfkill()
- * wimax_rfkill() Kernel calling wimax_rfkill()
- * __wimax_rf_toggle_radio()
- *
- * wimax_rfkill_set_radio_block() RF-Kill subsystem calling
- * __wimax_rf_toggle_radio()
- *
- * __wimax_rf_toggle_radio()
- * wimax_dev->op_rfkill_sw_toggle() Driver backend
- * __wimax_state_change()
- *
- * wimax_report_rfkill_sw() Driver reports state change
- * __wimax_state_change()
- *
- * wimax_report_rfkill_hw() Driver reports state change
- * __wimax_state_change()
- *
- * wimax_rfkill_add() Initialize/shutdown rfkill support
- * wimax_rfkill_rm() [called by wimax_dev_add/rm()]
- */
-
-#include "net-wimax.h"
-#include <net/genetlink.h>
-#include "linux-wimax.h"
-#include <linux/security.h>
-#include <linux/rfkill.h>
-#include <linux/export.h>
-#include "wimax-internal.h"
-
-#define D_SUBMODULE op_rfkill
-#include "debug-levels.h"
-
-/**
- * wimax_report_rfkill_hw - Reports changes in the hardware RF switch
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * @state: New state of the RF Kill switch. %WIMAX_RF_ON radio on,
- * %WIMAX_RF_OFF radio off.
- *
- * When the device detects a change in the state of thehardware RF
- * switch, it must call this function to let the WiMAX kernel stack
- * know that the state has changed so it can be properly propagated.
- *
- * The WiMAX stack caches the state (the driver doesn't need to). As
- * well, as the change is propagated it will come back as a request to
- * change the software state to mirror the hardware state.
- *
- * If the device doesn't have a hardware kill switch, just report
- * it on initialization as always on (%WIMAX_RF_ON, radio on).
- */
-void wimax_report_rfkill_hw(struct wimax_dev *wimax_dev,
- enum wimax_rf_state state)
-{
- int result;
- struct device *dev = wimax_dev_to_dev(wimax_dev);
- enum wimax_st wimax_state;
-
- d_fnstart(3, dev, "(wimax_dev %p state %u)\n", wimax_dev, state);
- BUG_ON(state == WIMAX_RF_QUERY);
- BUG_ON(state != WIMAX_RF_ON && state != WIMAX_RF_OFF);
-
- mutex_lock(&wimax_dev->mutex);
- result = wimax_dev_is_ready(wimax_dev);
- if (result < 0)
- goto error_not_ready;
-
- if (state != wimax_dev->rf_hw) {
- wimax_dev->rf_hw = state;
- if (wimax_dev->rf_hw == WIMAX_RF_ON &&
- wimax_dev->rf_sw == WIMAX_RF_ON)
- wimax_state = WIMAX_ST_READY;
- else
- wimax_state = WIMAX_ST_RADIO_OFF;
-
- result = rfkill_set_hw_state(wimax_dev->rfkill,
- state == WIMAX_RF_OFF);
-
- __wimax_state_change(wimax_dev, wimax_state);
- }
-error_not_ready:
- mutex_unlock(&wimax_dev->mutex);
- d_fnend(3, dev, "(wimax_dev %p state %u) = void [%d]\n",
- wimax_dev, state, result);
-}
-EXPORT_SYMBOL_GPL(wimax_report_rfkill_hw);
-
-
-/**
- * wimax_report_rfkill_sw - Reports changes in the software RF switch
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * @state: New state of the RF kill switch. %WIMAX_RF_ON radio on,
- * %WIMAX_RF_OFF radio off.
- *
- * Reports changes in the software RF switch state to the WiMAX stack.
- *
- * The main use is during initialization, so the driver can query the
- * device for its current software radio kill switch state and feed it
- * to the system.
- *
- * On the side, the device does not change the software state by
- * itself. In practice, this can happen, as the device might decide to
- * switch (in software) the radio off for different reasons.
- */
-void wimax_report_rfkill_sw(struct wimax_dev *wimax_dev,
- enum wimax_rf_state state)
-{
- int result;
- struct device *dev = wimax_dev_to_dev(wimax_dev);
- enum wimax_st wimax_state;
-
- d_fnstart(3, dev, "(wimax_dev %p state %u)\n", wimax_dev, state);
- BUG_ON(state == WIMAX_RF_QUERY);
- BUG_ON(state != WIMAX_RF_ON && state != WIMAX_RF_OFF);
-
- mutex_lock(&wimax_dev->mutex);
- result = wimax_dev_is_ready(wimax_dev);
- if (result < 0)
- goto error_not_ready;
-
- if (state != wimax_dev->rf_sw) {
- wimax_dev->rf_sw = state;
- if (wimax_dev->rf_hw == WIMAX_RF_ON &&
- wimax_dev->rf_sw == WIMAX_RF_ON)
- wimax_state = WIMAX_ST_READY;
- else
- wimax_state = WIMAX_ST_RADIO_OFF;
- __wimax_state_change(wimax_dev, wimax_state);
- rfkill_set_sw_state(wimax_dev->rfkill, state == WIMAX_RF_OFF);
- }
-error_not_ready:
- mutex_unlock(&wimax_dev->mutex);
- d_fnend(3, dev, "(wimax_dev %p state %u) = void [%d]\n",
- wimax_dev, state, result);
-}
-EXPORT_SYMBOL_GPL(wimax_report_rfkill_sw);
-
-
-/*
- * Callback for the RF Kill toggle operation
- *
- * This function is called by:
- *
- * - The rfkill subsystem when the RF-Kill key is pressed in the
- * hardware and the driver notifies through
- * wimax_report_rfkill_hw(). The rfkill subsystem ends up calling back
- * here so the software RF Kill switch state is changed to reflect
- * the hardware switch state.
- *
- * - When the user sets the state through sysfs' rfkill/state file
- *
- * - When the user calls wimax_rfkill().
- *
- * This call blocks!
- *
- * WARNING! When we call rfkill_unregister(), this will be called with
- * state 0!
- *
- * WARNING: wimax_dev must be locked
- */
-static
-int __wimax_rf_toggle_radio(struct wimax_dev *wimax_dev,
- enum wimax_rf_state state)
-{
- int result = 0;
- struct device *dev = wimax_dev_to_dev(wimax_dev);
- enum wimax_st wimax_state;
-
- might_sleep();
- d_fnstart(3, dev, "(wimax_dev %p state %u)\n", wimax_dev, state);
- if (wimax_dev->rf_sw == state)
- goto out_no_change;
- if (wimax_dev->op_rfkill_sw_toggle != NULL)
- result = wimax_dev->op_rfkill_sw_toggle(wimax_dev, state);
- else if (state == WIMAX_RF_OFF) /* No op? can't turn off */
- result = -ENXIO;
- else /* No op? can turn on */
- result = 0; /* should never happen tho */
- if (result >= 0) {
- result = 0;
- wimax_dev->rf_sw = state;
- wimax_state = state == WIMAX_RF_ON ?
- WIMAX_ST_READY : WIMAX_ST_RADIO_OFF;
- __wimax_state_change(wimax_dev, wimax_state);
- }
-out_no_change:
- d_fnend(3, dev, "(wimax_dev %p state %u) = %d\n",
- wimax_dev, state, result);
- return result;
-}
-
-
-/*
- * Translate from rfkill state to wimax state
- *
- * NOTE: Special state handling rules here
- *
- * Just pretend the call didn't happen if we are in a state where
- * we know for sure it cannot be handled (WIMAX_ST_DOWN or
- * __WIMAX_ST_QUIESCING). rfkill() needs it to register and
- * unregister, as it will run this path.
- *
- * NOTE: This call will block until the operation is completed.
- */
-static int wimax_rfkill_set_radio_block(void *data, bool blocked)
-{
- int result;
- struct wimax_dev *wimax_dev = data;
- struct device *dev = wimax_dev_to_dev(wimax_dev);
- enum wimax_rf_state rf_state;
-
- d_fnstart(3, dev, "(wimax_dev %p blocked %u)\n", wimax_dev, blocked);
- rf_state = WIMAX_RF_ON;
- if (blocked)
- rf_state = WIMAX_RF_OFF;
- mutex_lock(&wimax_dev->mutex);
- if (wimax_dev->state <= __WIMAX_ST_QUIESCING)
- result = 0;
- else
- result = __wimax_rf_toggle_radio(wimax_dev, rf_state);
- mutex_unlock(&wimax_dev->mutex);
- d_fnend(3, dev, "(wimax_dev %p blocked %u) = %d\n",
- wimax_dev, blocked, result);
- return result;
-}
-
-static const struct rfkill_ops wimax_rfkill_ops = {
- .set_block = wimax_rfkill_set_radio_block,
-};
-
-/**
- * wimax_rfkill - Set the software RF switch state for a WiMAX device
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * @state: New RF state.
- *
- * Returns:
- *
- * >= 0 toggle state if ok, < 0 errno code on error. The toggle state
- * is returned as a bitmap, bit 0 being the hardware RF state, bit 1
- * the software RF state.
- *
- * 0 means disabled (%WIMAX_RF_ON, radio on), 1 means enabled radio
- * off (%WIMAX_RF_OFF).
- *
- * Description:
- *
- * Called by the user when he wants to request the WiMAX radio to be
- * switched on (%WIMAX_RF_ON) or off (%WIMAX_RF_OFF). With
- * %WIMAX_RF_QUERY, just the current state is returned.
- *
- * NOTE:
- *
- * This call will block until the operation is complete.
- */
-int wimax_rfkill(struct wimax_dev *wimax_dev, enum wimax_rf_state state)
-{
- int result;
- struct device *dev = wimax_dev_to_dev(wimax_dev);
-
- d_fnstart(3, dev, "(wimax_dev %p state %u)\n", wimax_dev, state);
- mutex_lock(&wimax_dev->mutex);
- result = wimax_dev_is_ready(wimax_dev);
- if (result < 0) {
- /* While initializing, < 1.4.3 wimax-tools versions use
- * this call to check if the device is a valid WiMAX
- * device; so we allow it to proceed always,
- * considering the radios are all off. */
- if (result == -ENOMEDIUM && state == WIMAX_RF_QUERY)
- result = WIMAX_RF_OFF << 1 | WIMAX_RF_OFF;
- goto error_not_ready;
- }
- switch (state) {
- case WIMAX_RF_ON:
- case WIMAX_RF_OFF:
- result = __wimax_rf_toggle_radio(wimax_dev, state);
- if (result < 0)
- goto error;
- rfkill_set_sw_state(wimax_dev->rfkill, state == WIMAX_RF_OFF);
- break;
- case WIMAX_RF_QUERY:
- break;
- default:
- result = -EINVAL;
- goto error;
- }
- result = wimax_dev->rf_sw << 1 | wimax_dev->rf_hw;
-error:
-error_not_ready:
- mutex_unlock(&wimax_dev->mutex);
- d_fnend(3, dev, "(wimax_dev %p state %u) = %d\n",
- wimax_dev, state, result);
- return result;
-}
-EXPORT_SYMBOL(wimax_rfkill);
-
-
-/*
- * Register a new WiMAX device's RF Kill support
- *
- * WARNING: wimax_dev->mutex must be unlocked
- */
-int wimax_rfkill_add(struct wimax_dev *wimax_dev)
-{
- int result;
- struct rfkill *rfkill;
- struct device *dev = wimax_dev_to_dev(wimax_dev);
-
- d_fnstart(3, dev, "(wimax_dev %p)\n", wimax_dev);
- /* Initialize RF Kill */
- result = -ENOMEM;
- rfkill = rfkill_alloc(wimax_dev->name, dev, RFKILL_TYPE_WIMAX,
- &wimax_rfkill_ops, wimax_dev);
- if (rfkill == NULL)
- goto error_rfkill_allocate;
-
- d_printf(1, dev, "rfkill %p\n", rfkill);
-
- wimax_dev->rfkill = rfkill;
-
- rfkill_init_sw_state(rfkill, 1);
- result = rfkill_register(wimax_dev->rfkill);
- if (result < 0)
- goto error_rfkill_register;
-
- /* If there is no SW toggle op, SW RFKill is always on */
- if (wimax_dev->op_rfkill_sw_toggle == NULL)
- wimax_dev->rf_sw = WIMAX_RF_ON;
-
- d_fnend(3, dev, "(wimax_dev %p) = 0\n", wimax_dev);
- return 0;
-
-error_rfkill_register:
- rfkill_destroy(wimax_dev->rfkill);
-error_rfkill_allocate:
- d_fnend(3, dev, "(wimax_dev %p) = %d\n", wimax_dev, result);
- return result;
-}
-
-
-/*
- * Deregister a WiMAX device's RF Kill support
- *
- * Ick, we can't call rfkill_free() after rfkill_unregister()...oh
- * well.
- *
- * WARNING: wimax_dev->mutex must be unlocked
- */
-void wimax_rfkill_rm(struct wimax_dev *wimax_dev)
-{
- struct device *dev = wimax_dev_to_dev(wimax_dev);
- d_fnstart(3, dev, "(wimax_dev %p)\n", wimax_dev);
- rfkill_unregister(wimax_dev->rfkill);
- rfkill_destroy(wimax_dev->rfkill);
- d_fnend(3, dev, "(wimax_dev %p)\n", wimax_dev);
-}
-
-
-/*
- * Exporting to user space over generic netlink
- *
- * Parse the rfkill command from user space, return a combination
- * value that describe the states of the different toggles.
- *
- * Only one attribute: the new state requested (on, off or no change,
- * just query).
- */
-
-int wimax_gnl_doit_rfkill(struct sk_buff *skb, struct genl_info *info)
-{
- int result, ifindex;
- struct wimax_dev *wimax_dev;
- struct device *dev;
- enum wimax_rf_state new_state;
-
- d_fnstart(3, NULL, "(skb %p info %p)\n", skb, info);
- result = -ENODEV;
- if (info->attrs[WIMAX_GNL_RFKILL_IFIDX] == NULL) {
- pr_err("WIMAX_GNL_OP_RFKILL: can't find IFIDX attribute\n");
- goto error_no_wimax_dev;
- }
- ifindex = nla_get_u32(info->attrs[WIMAX_GNL_RFKILL_IFIDX]);
- wimax_dev = wimax_dev_get_by_genl_info(info, ifindex);
- if (wimax_dev == NULL)
- goto error_no_wimax_dev;
- dev = wimax_dev_to_dev(wimax_dev);
- result = -EINVAL;
- if (info->attrs[WIMAX_GNL_RFKILL_STATE] == NULL) {
- dev_err(dev, "WIMAX_GNL_RFKILL: can't find RFKILL_STATE "
- "attribute\n");
- goto error_no_pid;
- }
- new_state = nla_get_u32(info->attrs[WIMAX_GNL_RFKILL_STATE]);
-
- /* Execute the operation and send the result back to user space */
- result = wimax_rfkill(wimax_dev, new_state);
-error_no_pid:
- dev_put(wimax_dev->net_dev);
-error_no_wimax_dev:
- d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result);
- return result;
-}
diff --git a/drivers/staging/wimax/op-state-get.c b/drivers/staging/wimax/op-state-get.c
deleted file mode 100644
index c5bfbed505f5..000000000000
--- a/drivers/staging/wimax/op-state-get.c
+++ /dev/null
@@ -1,52 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * Implement and export a method for getting a WiMAX device current state
- *
- * Copyright (C) 2009 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
- *
- * Based on previous WiMAX core work by:
- * Copyright (C) 2008 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- */
-
-#include "net-wimax.h"
-#include <net/genetlink.h>
-#include "linux-wimax.h"
-#include <linux/security.h>
-#include "wimax-internal.h"
-
-#define D_SUBMODULE op_state_get
-#include "debug-levels.h"
-
-
-/*
- * Exporting to user space over generic netlink
- *
- * Parse the state get command from user space, return a combination
- * value that describe the current state.
- *
- * No attributes.
- */
-int wimax_gnl_doit_state_get(struct sk_buff *skb, struct genl_info *info)
-{
- int result, ifindex;
- struct wimax_dev *wimax_dev;
-
- d_fnstart(3, NULL, "(skb %p info %p)\n", skb, info);
- result = -ENODEV;
- if (info->attrs[WIMAX_GNL_STGET_IFIDX] == NULL) {
- pr_err("WIMAX_GNL_OP_STATE_GET: can't find IFIDX attribute\n");
- goto error_no_wimax_dev;
- }
- ifindex = nla_get_u32(info->attrs[WIMAX_GNL_STGET_IFIDX]);
- wimax_dev = wimax_dev_get_by_genl_info(info, ifindex);
- if (wimax_dev == NULL)
- goto error_no_wimax_dev;
- /* Execute the operation and send the result back to user space */
- result = wimax_state_get(wimax_dev);
- dev_put(wimax_dev->net_dev);
-error_no_wimax_dev:
- d_fnend(3, NULL, "(skb %p info %p) = %d\n", skb, info, result);
- return result;
-}
diff --git a/drivers/staging/wimax/stack.c b/drivers/staging/wimax/stack.c
deleted file mode 100644
index ace24a6dfd2d..000000000000
--- a/drivers/staging/wimax/stack.c
+++ /dev/null
@@ -1,616 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Linux WiMAX
- * Initialization, addition and removal of wimax devices
- *
- * Copyright (C) 2005-2006 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * This implements:
- *
- * - basic life cycle of 'struct wimax_dev' [wimax_dev_*()]; on
- * addition/registration initialize all subfields and allocate
- * generic netlink resources for user space communication. On
- * removal/unregistration, undo all that.
- *
- * - device state machine [wimax_state_change()] and support to send
- * reports to user space when the state changes
- * [wimax_gnl_re_state_change*()].
- *
- * See include/net/wimax.h for rationales and design.
- *
- * ROADMAP
- *
- * [__]wimax_state_change() Called by drivers to update device's state
- * wimax_gnl_re_state_change_alloc()
- * wimax_gnl_re_state_change_send()
- *
- * wimax_dev_init() Init a device
- * wimax_dev_add() Register
- * wimax_rfkill_add()
- * wimax_gnl_add() Register all the generic netlink resources.
- * wimax_id_table_add()
- * wimax_dev_rm() Unregister
- * wimax_id_table_rm()
- * wimax_gnl_rm()
- * wimax_rfkill_rm()
- */
-#include <linux/device.h>
-#include <linux/gfp.h>
-#include <net/genetlink.h>
-#include <linux/netdevice.h>
-#include "linux-wimax.h"
-#include <linux/module.h>
-#include "wimax-internal.h"
-
-
-#define D_SUBMODULE stack
-#include "debug-levels.h"
-
-static char wimax_debug_params[128];
-module_param_string(debug, wimax_debug_params, sizeof(wimax_debug_params),
- 0644);
-MODULE_PARM_DESC(debug,
- "String of space-separated NAME:VALUE pairs, where NAMEs "
- "are the different debug submodules and VALUE are the "
- "initial debug value to set.");
-
-/*
- * Authoritative source for the RE_STATE_CHANGE attribute policy
- *
- * We don't really use it here, but /me likes to keep the definition
- * close to where the data is generated.
- */
-/*
-static const struct nla_policy wimax_gnl_re_status_change[WIMAX_GNL_ATTR_MAX + 1] = {
- [WIMAX_GNL_STCH_STATE_OLD] = { .type = NLA_U8 },
- [WIMAX_GNL_STCH_STATE_NEW] = { .type = NLA_U8 },
-};
-*/
-
-
-/*
- * Allocate a Report State Change message
- *
- * @header: save it, you need it for _send()
- *
- * Creates and fills a basic state change message; different code
- * paths can then add more attributes to the message as needed.
- *
- * Use wimax_gnl_re_state_change_send() to send the returned skb.
- *
- * Returns: skb with the genl message if ok, IS_ERR() ptr on error
- * with an errno code.
- */
-static
-struct sk_buff *wimax_gnl_re_state_change_alloc(
- struct wimax_dev *wimax_dev,
- enum wimax_st new_state, enum wimax_st old_state,
- void **header)
-{
- int result;
- struct device *dev = wimax_dev_to_dev(wimax_dev);
- void *data;
- struct sk_buff *report_skb;
-
- d_fnstart(3, dev, "(wimax_dev %p new_state %u old_state %u)\n",
- wimax_dev, new_state, old_state);
- result = -ENOMEM;
- report_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
- if (report_skb == NULL) {
- dev_err(dev, "RE_STCH: can't create message\n");
- goto error_new;
- }
- /* FIXME: sending a group ID as the seq is wrong */
- data = genlmsg_put(report_skb, 0, wimax_gnl_family.mcgrp_offset,
- &wimax_gnl_family, 0, WIMAX_GNL_RE_STATE_CHANGE);
- if (data == NULL) {
- dev_err(dev, "RE_STCH: can't put data into message\n");
- goto error_put;
- }
- *header = data;
-
- result = nla_put_u8(report_skb, WIMAX_GNL_STCH_STATE_OLD, old_state);
- if (result < 0) {
- dev_err(dev, "RE_STCH: Error adding OLD attr: %d\n", result);
- goto error_put;
- }
- result = nla_put_u8(report_skb, WIMAX_GNL_STCH_STATE_NEW, new_state);
- if (result < 0) {
- dev_err(dev, "RE_STCH: Error adding NEW attr: %d\n", result);
- goto error_put;
- }
- result = nla_put_u32(report_skb, WIMAX_GNL_STCH_IFIDX,
- wimax_dev->net_dev->ifindex);
- if (result < 0) {
- dev_err(dev, "RE_STCH: Error adding IFINDEX attribute\n");
- goto error_put;
- }
- d_fnend(3, dev, "(wimax_dev %p new_state %u old_state %u) = %p\n",
- wimax_dev, new_state, old_state, report_skb);
- return report_skb;
-
-error_put:
- nlmsg_free(report_skb);
-error_new:
- d_fnend(3, dev, "(wimax_dev %p new_state %u old_state %u) = %d\n",
- wimax_dev, new_state, old_state, result);
- return ERR_PTR(result);
-}
-
-
-/*
- * Send a Report State Change message (as created with _alloc).
- *
- * @report_skb: as returned by wimax_gnl_re_state_change_alloc()
- * @header: as returned by wimax_gnl_re_state_change_alloc()
- *
- * Returns: 0 if ok, < 0 errno code on error.
- *
- * If the message is NULL, pretend it didn't happen.
- */
-static
-int wimax_gnl_re_state_change_send(
- struct wimax_dev *wimax_dev, struct sk_buff *report_skb,
- void *header)
-{
- int result = 0;
- struct device *dev = wimax_dev_to_dev(wimax_dev);
- d_fnstart(3, dev, "(wimax_dev %p report_skb %p)\n",
- wimax_dev, report_skb);
- if (report_skb == NULL) {
- result = -ENOMEM;
- goto out;
- }
- genlmsg_end(report_skb, header);
- genlmsg_multicast(&wimax_gnl_family, report_skb, 0, 0, GFP_KERNEL);
-out:
- d_fnend(3, dev, "(wimax_dev %p report_skb %p) = %d\n",
- wimax_dev, report_skb, result);
- return result;
-}
-
-
-static
-void __check_new_state(enum wimax_st old_state, enum wimax_st new_state,
- unsigned int allowed_states_bm)
-{
- if (WARN_ON(((1 << new_state) & allowed_states_bm) == 0)) {
- pr_err("SW BUG! Forbidden state change %u -> %u\n",
- old_state, new_state);
- }
-}
-
-
-/*
- * Set the current state of a WiMAX device [unlocking version of
- * wimax_state_change().
- */
-void __wimax_state_change(struct wimax_dev *wimax_dev, enum wimax_st new_state)
-{
- struct device *dev = wimax_dev_to_dev(wimax_dev);
- enum wimax_st old_state = wimax_dev->state;
- struct sk_buff *stch_skb;
- void *header;
-
- d_fnstart(3, dev, "(wimax_dev %p new_state %u [old %u])\n",
- wimax_dev, new_state, old_state);
-
- if (WARN_ON(new_state >= __WIMAX_ST_INVALID)) {
- dev_err(dev, "SW BUG: requesting invalid state %u\n",
- new_state);
- goto out;
- }
- if (old_state == new_state)
- goto out;
- header = NULL; /* gcc complains? can't grok why */
- stch_skb = wimax_gnl_re_state_change_alloc(
- wimax_dev, new_state, old_state, &header);
-
- /* Verify the state transition and do exit-from-state actions */
- switch (old_state) {
- case __WIMAX_ST_NULL:
- __check_new_state(old_state, new_state,
- 1 << WIMAX_ST_DOWN);
- break;
- case WIMAX_ST_DOWN:
- __check_new_state(old_state, new_state,
- 1 << __WIMAX_ST_QUIESCING
- | 1 << WIMAX_ST_UNINITIALIZED
- | 1 << WIMAX_ST_RADIO_OFF);
- break;
- case __WIMAX_ST_QUIESCING:
- __check_new_state(old_state, new_state, 1 << WIMAX_ST_DOWN);
- break;
- case WIMAX_ST_UNINITIALIZED:
- __check_new_state(old_state, new_state,
- 1 << __WIMAX_ST_QUIESCING
- | 1 << WIMAX_ST_RADIO_OFF);
- break;
- case WIMAX_ST_RADIO_OFF:
- __check_new_state(old_state, new_state,
- 1 << __WIMAX_ST_QUIESCING
- | 1 << WIMAX_ST_READY);
- break;
- case WIMAX_ST_READY:
- __check_new_state(old_state, new_state,
- 1 << __WIMAX_ST_QUIESCING
- | 1 << WIMAX_ST_RADIO_OFF
- | 1 << WIMAX_ST_SCANNING
- | 1 << WIMAX_ST_CONNECTING
- | 1 << WIMAX_ST_CONNECTED);
- break;
- case WIMAX_ST_SCANNING:
- __check_new_state(old_state, new_state,
- 1 << __WIMAX_ST_QUIESCING
- | 1 << WIMAX_ST_RADIO_OFF
- | 1 << WIMAX_ST_READY
- | 1 << WIMAX_ST_CONNECTING
- | 1 << WIMAX_ST_CONNECTED);
- break;
- case WIMAX_ST_CONNECTING:
- __check_new_state(old_state, new_state,
- 1 << __WIMAX_ST_QUIESCING
- | 1 << WIMAX_ST_RADIO_OFF
- | 1 << WIMAX_ST_READY
- | 1 << WIMAX_ST_SCANNING
- | 1 << WIMAX_ST_CONNECTED);
- break;
- case WIMAX_ST_CONNECTED:
- __check_new_state(old_state, new_state,
- 1 << __WIMAX_ST_QUIESCING
- | 1 << WIMAX_ST_RADIO_OFF
- | 1 << WIMAX_ST_READY);
- netif_tx_disable(wimax_dev->net_dev);
- netif_carrier_off(wimax_dev->net_dev);
- break;
- case __WIMAX_ST_INVALID:
- default:
- dev_err(dev, "SW BUG: wimax_dev %p is in unknown state %u\n",
- wimax_dev, wimax_dev->state);
- WARN_ON(1);
- goto out;
- }
-
- /* Execute the actions of entry to the new state */
- switch (new_state) {
- case __WIMAX_ST_NULL:
- dev_err(dev, "SW BUG: wimax_dev %p entering NULL state "
- "from %u\n", wimax_dev, wimax_dev->state);
- WARN_ON(1); /* Nobody can enter this state */
- break;
- case WIMAX_ST_DOWN:
- break;
- case __WIMAX_ST_QUIESCING:
- break;
- case WIMAX_ST_UNINITIALIZED:
- break;
- case WIMAX_ST_RADIO_OFF:
- break;
- case WIMAX_ST_READY:
- break;
- case WIMAX_ST_SCANNING:
- break;
- case WIMAX_ST_CONNECTING:
- break;
- case WIMAX_ST_CONNECTED:
- netif_carrier_on(wimax_dev->net_dev);
- netif_wake_queue(wimax_dev->net_dev);
- break;
- case __WIMAX_ST_INVALID:
- default:
- BUG();
- }
- __wimax_state_set(wimax_dev, new_state);
- if (!IS_ERR(stch_skb))
- wimax_gnl_re_state_change_send(wimax_dev, stch_skb, header);
-out:
- d_fnend(3, dev, "(wimax_dev %p new_state %u [old %u]) = void\n",
- wimax_dev, new_state, old_state);
-}
-
-
-/**
- * wimax_state_change - Set the current state of a WiMAX device
- *
- * @wimax_dev: WiMAX device descriptor (properly referenced)
- * @new_state: New state to switch to
- *
- * This implements the state changes for the wimax devices. It will
- *
- * - verify that the state transition is legal (for now it'll just
- * print a warning if not) according to the table in
- * linux/wimax.h's documentation for 'enum wimax_st'.
- *
- * - perform the actions needed for leaving the current state and
- * whichever are needed for entering the new state.
- *
- * - issue a report to user space indicating the new state (and an
- * optional payload with information about the new state).
- *
- * NOTE: @wimax_dev must be locked
- */
-void wimax_state_change(struct wimax_dev *wimax_dev, enum wimax_st new_state)
-{
- /*
- * A driver cannot take the wimax_dev out of the
- * __WIMAX_ST_NULL state unless by calling wimax_dev_add(). If
- * the wimax_dev's state is still NULL, we ignore any request
- * to change its state because it means it hasn't been yet
- * registered.
- *
- * There is no need to complain about it, as routines that
- * call this might be shared from different code paths that
- * are called before or after wimax_dev_add() has done its
- * job.
- */
- mutex_lock(&wimax_dev->mutex);
- if (wimax_dev->state > __WIMAX_ST_NULL)
- __wimax_state_change(wimax_dev, new_state);
- mutex_unlock(&wimax_dev->mutex);
-}
-EXPORT_SYMBOL_GPL(wimax_state_change);
-
-
-/**
- * wimax_state_get() - Return the current state of a WiMAX device
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * Returns: Current state of the device according to its driver.
- */
-enum wimax_st wimax_state_get(struct wimax_dev *wimax_dev)
-{
- enum wimax_st state;
- mutex_lock(&wimax_dev->mutex);
- state = wimax_dev->state;
- mutex_unlock(&wimax_dev->mutex);
- return state;
-}
-EXPORT_SYMBOL_GPL(wimax_state_get);
-
-
-/**
- * wimax_dev_init - initialize a newly allocated instance
- *
- * @wimax_dev: WiMAX device descriptor to initialize.
- *
- * Initializes fields of a freshly allocated @wimax_dev instance. This
- * function assumes that after allocation, the memory occupied by
- * @wimax_dev was zeroed.
- */
-void wimax_dev_init(struct wimax_dev *wimax_dev)
-{
- INIT_LIST_HEAD(&wimax_dev->id_table_node);
- __wimax_state_set(wimax_dev, __WIMAX_ST_NULL);
- mutex_init(&wimax_dev->mutex);
- mutex_init(&wimax_dev->mutex_reset);
-}
-EXPORT_SYMBOL_GPL(wimax_dev_init);
-
-/*
- * There are multiple enums reusing the same values, adding
- * others is only possible if they use a compatible policy.
- */
-static const struct nla_policy wimax_gnl_policy[WIMAX_GNL_ATTR_MAX + 1] = {
- /*
- * WIMAX_GNL_RESET_IFIDX, WIMAX_GNL_RFKILL_IFIDX,
- * WIMAX_GNL_STGET_IFIDX, WIMAX_GNL_MSG_IFIDX
- */
- [1] = { .type = NLA_U32, },
- /*
- * WIMAX_GNL_RFKILL_STATE, WIMAX_GNL_MSG_PIPE_NAME
- */
- [2] = { .type = NLA_U32, }, /* enum wimax_rf_state */
- /*
- * WIMAX_GNL_MSG_DATA
- */
- [3] = { .type = NLA_UNSPEC, }, /* libnl doesn't grok BINARY yet */
-};
-
-static const struct genl_small_ops wimax_gnl_ops[] = {
- {
- .cmd = WIMAX_GNL_OP_MSG_FROM_USER,
- .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
- .flags = GENL_ADMIN_PERM,
- .doit = wimax_gnl_doit_msg_from_user,
- },
- {
- .cmd = WIMAX_GNL_OP_RESET,
- .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
- .flags = GENL_ADMIN_PERM,
- .doit = wimax_gnl_doit_reset,
- },
- {
- .cmd = WIMAX_GNL_OP_RFKILL,
- .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
- .flags = GENL_ADMIN_PERM,
- .doit = wimax_gnl_doit_rfkill,
- },
- {
- .cmd = WIMAX_GNL_OP_STATE_GET,
- .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
- .flags = GENL_ADMIN_PERM,
- .doit = wimax_gnl_doit_state_get,
- },
-};
-
-
-static
-size_t wimax_addr_scnprint(char *addr_str, size_t addr_str_size,
- unsigned char *addr, size_t addr_len)
-{
- unsigned int cnt, total;
-
- for (total = cnt = 0; cnt < addr_len; cnt++)
- total += scnprintf(addr_str + total, addr_str_size - total,
- "%02x%c", addr[cnt],
- cnt == addr_len - 1 ? '\0' : ':');
- return total;
-}
-
-
-/**
- * wimax_dev_add - Register a new WiMAX device
- *
- * @wimax_dev: WiMAX device descriptor (as embedded in your @net_dev's
- * priv data). You must have called wimax_dev_init() on it before.
- *
- * @net_dev: net device the @wimax_dev is associated with. The
- * function expects SET_NETDEV_DEV() and register_netdev() were
- * already called on it.
- *
- * Registers the new WiMAX device, sets up the user-kernel control
- * interface (generic netlink) and common WiMAX infrastructure.
- *
- * Note that the parts that will allow interaction with user space are
- * setup at the very end, when the rest is in place, as once that
- * happens, the driver might get user space control requests via
- * netlink or from debugfs that might translate into calls into
- * wimax_dev->op_*().
- */
-int wimax_dev_add(struct wimax_dev *wimax_dev, struct net_device *net_dev)
-{
- int result;
- struct device *dev = net_dev->dev.parent;
- char addr_str[32];
-
- d_fnstart(3, dev, "(wimax_dev %p net_dev %p)\n", wimax_dev, net_dev);
-
- /* Do the RFKILL setup before locking, as RFKILL will call
- * into our functions.
- */
- wimax_dev->net_dev = net_dev;
- result = wimax_rfkill_add(wimax_dev);
- if (result < 0)
- goto error_rfkill_add;
-
- /* Set up user-space interaction */
- mutex_lock(&wimax_dev->mutex);
- wimax_id_table_add(wimax_dev);
- wimax_debugfs_add(wimax_dev);
-
- __wimax_state_set(wimax_dev, WIMAX_ST_DOWN);
- mutex_unlock(&wimax_dev->mutex);
-
- wimax_addr_scnprint(addr_str, sizeof(addr_str),
- net_dev->dev_addr, net_dev->addr_len);
- dev_err(dev, "WiMAX interface %s (%s) ready\n",
- net_dev->name, addr_str);
- d_fnend(3, dev, "(wimax_dev %p net_dev %p) = 0\n", wimax_dev, net_dev);
- return 0;
-
-error_rfkill_add:
- d_fnend(3, dev, "(wimax_dev %p net_dev %p) = %d\n",
- wimax_dev, net_dev, result);
- return result;
-}
-EXPORT_SYMBOL_GPL(wimax_dev_add);
-
-
-/**
- * wimax_dev_rm - Unregister an existing WiMAX device
- *
- * @wimax_dev: WiMAX device descriptor
- *
- * Unregisters a WiMAX device previously registered for use with
- * wimax_add_rm().
- *
- * IMPORTANT! Must call before calling unregister_netdev().
- *
- * After this function returns, you will not get any more user space
- * control requests (via netlink or debugfs) and thus to wimax_dev->ops.
- *
- * Reentrancy control is ensured by setting the state to
- * %__WIMAX_ST_QUIESCING. rfkill operations coming through
- * wimax_*rfkill*() will be stopped by the quiescing state; ops coming
- * from the rfkill subsystem will be stopped by the support being
- * removed by wimax_rfkill_rm().
- */
-void wimax_dev_rm(struct wimax_dev *wimax_dev)
-{
- d_fnstart(3, NULL, "(wimax_dev %p)\n", wimax_dev);
-
- mutex_lock(&wimax_dev->mutex);
- __wimax_state_change(wimax_dev, __WIMAX_ST_QUIESCING);
- wimax_debugfs_rm(wimax_dev);
- wimax_id_table_rm(wimax_dev);
- __wimax_state_change(wimax_dev, WIMAX_ST_DOWN);
- mutex_unlock(&wimax_dev->mutex);
- wimax_rfkill_rm(wimax_dev);
- d_fnend(3, NULL, "(wimax_dev %p) = void\n", wimax_dev);
-}
-EXPORT_SYMBOL_GPL(wimax_dev_rm);
-
-
-/* Debug framework control of debug levels */
-struct d_level D_LEVEL[] = {
- D_SUBMODULE_DEFINE(debugfs),
- D_SUBMODULE_DEFINE(id_table),
- D_SUBMODULE_DEFINE(op_msg),
- D_SUBMODULE_DEFINE(op_reset),
- D_SUBMODULE_DEFINE(op_rfkill),
- D_SUBMODULE_DEFINE(op_state_get),
- D_SUBMODULE_DEFINE(stack),
-};
-size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
-
-
-static const struct genl_multicast_group wimax_gnl_mcgrps[] = {
- { .name = "msg", },
-};
-
-struct genl_family wimax_gnl_family __ro_after_init = {
- .name = "WiMAX",
- .version = WIMAX_GNL_VERSION,
- .hdrsize = 0,
- .maxattr = WIMAX_GNL_ATTR_MAX,
- .policy = wimax_gnl_policy,
- .module = THIS_MODULE,
- .small_ops = wimax_gnl_ops,
- .n_small_ops = ARRAY_SIZE(wimax_gnl_ops),
- .mcgrps = wimax_gnl_mcgrps,
- .n_mcgrps = ARRAY_SIZE(wimax_gnl_mcgrps),
-};
-
-
-
-/* Shutdown the wimax stack */
-static
-int __init wimax_subsys_init(void)
-{
- int result;
-
- d_fnstart(4, NULL, "()\n");
- d_parse_params(D_LEVEL, D_LEVEL_SIZE, wimax_debug_params,
- "wimax.debug");
-
- result = genl_register_family(&wimax_gnl_family);
- if (unlikely(result < 0)) {
- pr_err("cannot register generic netlink family: %d\n", result);
- goto error_register_family;
- }
-
- d_fnend(4, NULL, "() = 0\n");
- return 0;
-
-error_register_family:
- d_fnend(4, NULL, "() = %d\n", result);
- return result;
-
-}
-module_init(wimax_subsys_init);
-
-
-/* Shutdown the wimax stack */
-static
-void __exit wimax_subsys_exit(void)
-{
- wimax_id_table_release();
- genl_unregister_family(&wimax_gnl_family);
-}
-module_exit(wimax_subsys_exit);
-
-MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
-MODULE_DESCRIPTION("Linux WiMAX stack");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/wimax/wimax-internal.h b/drivers/staging/wimax/wimax-internal.h
deleted file mode 100644
index a6b6990642a1..000000000000
--- a/drivers/staging/wimax/wimax-internal.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Linux WiMAX
- * Internal API for kernel space WiMAX stack
- *
- * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
- * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
- *
- * This header file is for declarations and definitions internal to
- * the WiMAX stack. For public APIs and documentation, see
- * include/net/wimax.h and include/linux/wimax.h.
- */
-
-#ifndef __WIMAX_INTERNAL_H__
-#define __WIMAX_INTERNAL_H__
-#ifdef __KERNEL__
-
-#ifdef pr_fmt
-#undef pr_fmt
-#endif
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/device.h>
-#include "net-wimax.h"
-
-
-/*
- * Decide if a (locked) device is ready for use
- *
- * Before using the device structure, it must be locked
- * (wimax_dev->mutex). As well, most operations need to call this
- * function to check if the state is the right one.
- *
- * An error value will be returned if the state is not the right
- * one. In that case, the caller should not attempt to use the device
- * and just unlock it.
- */
-static inline __must_check
-int wimax_dev_is_ready(struct wimax_dev *wimax_dev)
-{
- if (wimax_dev->state == __WIMAX_ST_NULL)
- return -EINVAL; /* Device is not even registered! */
- if (wimax_dev->state == WIMAX_ST_DOWN)
- return -ENOMEDIUM;
- if (wimax_dev->state == __WIMAX_ST_QUIESCING)
- return -ESHUTDOWN;
- return 0;
-}
-
-
-static inline
-void __wimax_state_set(struct wimax_dev *wimax_dev, enum wimax_st state)
-{
- wimax_dev->state = state;
-}
-void __wimax_state_change(struct wimax_dev *, enum wimax_st);
-
-#ifdef CONFIG_DEBUG_FS
-void wimax_debugfs_add(struct wimax_dev *);
-void wimax_debugfs_rm(struct wimax_dev *);
-#else
-static inline void wimax_debugfs_add(struct wimax_dev *wimax_dev) {}
-static inline void wimax_debugfs_rm(struct wimax_dev *wimax_dev) {}
-#endif
-
-void wimax_id_table_add(struct wimax_dev *);
-struct wimax_dev *wimax_dev_get_by_genl_info(struct genl_info *, int);
-void wimax_id_table_rm(struct wimax_dev *);
-void wimax_id_table_release(void);
-
-int wimax_rfkill_add(struct wimax_dev *);
-void wimax_rfkill_rm(struct wimax_dev *);
-
-/* generic netlink */
-extern struct genl_family wimax_gnl_family;
-
-/* ops */
-int wimax_gnl_doit_msg_from_user(struct sk_buff *skb, struct genl_info *info);
-int wimax_gnl_doit_reset(struct sk_buff *skb, struct genl_info *info);
-int wimax_gnl_doit_rfkill(struct sk_buff *skb, struct genl_info *info);
-int wimax_gnl_doit_state_get(struct sk_buff *skb, struct genl_info *info);
-
-#endif /* #ifdef __KERNEL__ */
-#endif /* #ifndef __WIMAX_INTERNAL_H__ */
diff --git a/drivers/staging/wlan-ng/p80211conv.h b/drivers/staging/wlan-ng/p80211conv.h
index 827002ca9930..15fd635d9770 100644
--- a/drivers/staging/wlan-ng/p80211conv.h
+++ b/drivers/staging/wlan-ng/p80211conv.h
@@ -122,9 +122,6 @@ struct p80211_caphdr {
__be32 encoding;
};
-/* buffer free method pointer type */
-typedef void (*freebuf_method_t) (void *buf, int size);
-
struct p80211_metawep {
void *data;
u8 iv[4];
diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c
index 6f9666dc0277..70570e8a5ad2 100644
--- a/drivers/staging/wlan-ng/p80211netdev.c
+++ b/drivers/staging/wlan-ng/p80211netdev.c
@@ -569,7 +569,7 @@ static int p80211knetdev_do_ioctl(struct net_device *dev,
goto bail;
}
- msgbuf = memdup_user(req->data, req->len);
+ msgbuf = memdup_user((void __user *)req->data, req->len);
if (IS_ERR(msgbuf)) {
result = PTR_ERR(msgbuf);
goto bail;