An (*insn_read) can only happen if the subdevice is in a non-busy state,
i.e. an async command is not running. The board reset and subdevice
(*cancel) will ensure that the control bits (devpriv->ctrl) are already
cleared.
The (*insn_read) only needs to enable the software trigger before reading
samples. It should also disable the software trigger when done. Fix the
(*insn_read) to do this.
For aesthetics, rename the function so it has namespace associated with
the driver.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
There are a number of descrepencies in the various manuals for the boards
that this driver supports. Some show a 10 MHz clock for counters 1 and 2
others show a 1 MHz clock. Counter 0 can use either a div 10 of that clock
or an external clock (up to 10 MHz).
Currently this driver initializes counters 1 and 2 with a 10 MHz clock.
For consistency, return 1 MHz (10 MHz/10) for counter 0 when the user
queries the internal clock source with INSN_CONFIG_GET_CLOCK_SRC.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: adv_pci1710: tidy up pci1710_reset()
Change the return type to void, this function always succeeds and the
caller does not check the return value anyway.
Fix the initial programming of the control register. The SW bit enables
the software trigger and should not be set here. Setting CNT0 selects the
external clock source for counter 0 (the user counter). It makes more
sense to select the internal 1 MHz clock.
Remove the unnecessary initialization of the private data members. This
function is only called during the (*auto_attach) after the private
data was kzalloc'ed.
Remove the redundant clearing of the A/D FIFO and pending interrupts.
Just do it once.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: adv_pci1710: post increment 'subdev' in (*auto_attach)
For aesthetics, post-increment the 'subdev' index when used to get a
comedi_subdevice pointer instead of incrementing it after the subdevice
is initialized.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: adv_pci1710: tidy up analog input subdev_flags
Remove the SDF_COMMON flag, the analog reference is not programmable and
the default aref (AREF_GROUND -> SDF_GROUND) provides adequate information
about the reference.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: adv_pci1710: tidy up analog output subdev_flags
Remove the SDF_COMMON flag, the analog reference is not programmable and
the default aref (AREF_GROUND -> SDF_GROUND) provides adequate information
about the reference.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: adv_pci1710: support external analog output reference
The analog outputs can use an external reference to create the D/A output
range. Add an entry to the comedi_lrange table for it and modify the
(*insn_write) to support it.
Note that the D/A output range is 0 to +Vref with a -Vref. The comedi_lrange
does not include the sign of the range. It simmply allows the user to convert
between the 12-bit samples values (0x0000 - 0x0fff) and a physical value (0.0
to 1.0) using the comedilib comedi_to_phys() and comedi_from_phys() functions.
A physical value of 0.0 would actually be 0V with a -Vref and -V with a +Vref
and 1.0 would be +V with a -Vref and 0V with a -Vref. Ths user will need to
work this out but at least they can now use the external reference.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: adv_pci1710: remove 'has_large_fifo' and 'has_diff_ai' boardinfo
The pci1711/31 boards are the only ones that have a smaller FIFO (1K vs 4K) and
single-ended analog inputs (no differential).
Replace the 'has_large_fifo' and 'has_diff_ai' members of the boardinfo with
'is_pci1711' and use that to determine how to initialize the analog input
subdev_flags as well as the private data 'max_samples'.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This member of the boardinfo isn't really necessary. All the boards
except the pci1713 have 16 digital inputs and 16 digital outputs.
There is already a 'is_pci1713' member in the boardinfo so that can
be used to determine the subdevices for the digital inputs and outputs
need to be allocated and initialized.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: adv_pci1710: refactor ai range programming
The gain codes used to program the analog output range are currently
stored in const char arrays. The values look a bit "magic" and it's
not clear how they associate with the comedi_lrange without looking
through user manuals.
Refactor the ai range programming to clarify the driver and remove
the magic numbers. Also, refine the bits in the range register that
set the differential and unipolar modes.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: adv_pci1710: don't "reset" board when detaching
Currently this driver calls pci1710_reset() during the (*detach) of
the driver. That function does the following:
1) program the control register to stop any operations
2) clears the analog input FIFO
3) clears any pending interrupts
4) sets all the analog output channels to unipolar 5V range and 0V output
5) sets all the digital outputs to 0V
Before detaching the comedi core will (*cancel) any running async commands.
This will handle 1-3 above.
Depending on the application, it might not be safe to reset the analog and
digital outputs when the driver is detached.
Remove the board reset when detaching and just use comedi_pci_detach()
directly for the driver (*detach).
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
All the boards supported by this driver have a 8254 counter. Channels
1 and 2 are used to create the cascaded 32-bit analog input pacer.
Counter 0 is available for the user on all the boards except the PCI-1713.
Remove the 'has_counter' boardinfo and use the 'is_pci1713' boardinfo to
determine if the user counter subdevice needs to be allocated and
initialized.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: comedi: adv_pci_dio: separate out PCI-1760 support
The PCI-1760 is board unique. It uses an outgoing/incoming mailbox
programming sequence to access the hardware. The other boards supported
by this driver use simple register mapping. Including support for the
PCI-1760 in this driver just makes it harder to understand.
Separate out the PCI-1760 support into a new driver, adv_pci1760.
Clean up the new driver. The original code had a bunch of CamelCase and
other checkpatch.pl issues.
The code used to access the outgoing/incoming mailboxes was also a bit
awkward with the passing of the arrays for the outgoing and incoming
mailbox bytes. Replace them with two new functions that send a command
and return the feedback data from the command based on the programming
flow chart in the datasheet for the PCI-1760.
The new adv_pci1760 driver also fixes the incomplete timer subdevice.
This subdevice is actually the 2 PWM outputs so the subdevice type
has been changed to COMEDI_SUBD_PWM.
The counter subdevice support was not complete in the original code.
They are also a bit strange since they are up counters connected to
each of the digital inputs. For now that subdevice has been disabled
(COMEDI_SUBD_UNUSED).
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Glen Lee [Fri, 18 Dec 2015 09:26:02 +0000 (18:26 +0900)]
staging: wilc1000: fix a bug when unload driver
kernel crashes when load and unload driver several times. I used git bisect to
track down and found that removing NULL setting caused the panic.
This reverts only related codes of the patch(a4ab1ade75a3).
Fixes: a4ab1ade75a3 ("staging: wilc1000: replace drvHandler and hWFIDrv with hif_drv") Signed-off-by: Glen Lee <glen.lee@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch fixes the checks reported by checkpatch.pl
for Blank lines aren't necessary after an open brace '{' and
Blank lines aren't necessary before a close brace '}'.
Signed-off-by: Leo Kim <leo.kim@atmel.com> Signed-off-by: Glen Lee <glen.lee@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
There are over-commenting in the wilc_wfi_cfgoperations.c file and most of them
are not helpful to explain what the code does and generate 80 ending
line over warnings. So, all of comments are removed in this patch and the
comments will later be added if necessary with the preferred Linux style.
Signed-off-by: Leo Kim <leo.kim@atmel.com> Signed-off-by: Glen Lee <glen.lee@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Leo Kim [Thu, 19 Nov 2015 06:56:32 +0000 (15:56 +0900)]
staging: wilc1000: rename pstrNetworkInfo in CfgScanResult function
This patch renames pstrNetworkInfo to network_info that is
second argument of CfgScanResult function to avoid camelcase.
And, remove the relation comment.
Signed-off-by: Leo Kim <leo.kim@atmel.com> Signed-off-by: Glen Lee <glen.lee@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch removes pUserVoid that is first argument of
update_scan_time function because it is not used in this function.
Remove argument in the function call also.
Signed-off-by: Leo Kim <leo.kim@atmel.com> Signed-off-by: Glen Lee <glen.lee@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch removes pUserVoid that is first argument of
reset_shadow_found function because it is not used in this function.
Remove argument in the function call also.
Signed-off-by: Leo Kim <leo.kim@atmel.com> Signed-off-by: Glen Lee <glen.lee@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch removes pUserVoid that is first argument of
clear_shadow_scan function because it is not used in this function.
Remove argument in the function call also.
Signed-off-by: Leo Kim <leo.kim@atmel.com> Signed-off-by: Glen Lee <glen.lee@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch passes struct wilc to wilc_send_config_pkt. The function
wilc_wlan_cfg_set and wilc_wlan_cfg_get function will get wilc to replace
wilc_dev with it.
Signed-off-by: Glen Lee <glen.lee@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Glen Lee [Wed, 18 Nov 2015 06:11:26 +0000 (15:11 +0900)]
staging: wilc1000: pass wilc to all function pointers of wilc_hif_func
This patch adds new function parameter struct wilc to all function pointers
of struct wilc_hif_func, and all functions of wilc_sdio.c and wilc_spi.c
need to be changed as it's function pointer is changed.
Pass wilc in all the functions call as well.
The wilc will be passed to functions in linux_wlan_sdio.c and linux_wlan_spi.c
to replace with global variable wilc_dev in the next patch.
Signed-off-by: Glen Lee <glen.lee@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Glen Lee [Wed, 18 Nov 2015 06:11:25 +0000 (15:11 +0900)]
staging: wilc1000: pass struct wilc to the functions which use hif_func
This patch passes struct wilc to the functions which use hif_func inside.
The function pointers of wilc_hif_func will pass wilc also in the later
patch. Pass wilc to the functions if necessary.
This patch removes PLAT_WMS8304 and it's related codes as well. We will not
use this way of supporting other platform. This will be supported if necessary
by device tree later.
Signed-off-by: Glen Lee <glen.lee@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Glen Lee [Wed, 18 Nov 2015 06:11:23 +0000 (15:11 +0900)]
staging: wilc1000: remove spi speed control codes
This patch removes spi speed control codes. We are not using define SPEED to
specify speed of spi, it is not proper way of doing this. It will be
provided by the device tree.
The following functions and variable are removed.
MIN_SPEED, MAX_SPEED, SPEED
wilc_spi_set_max_speed
wilc_spi_max_bus_speed
wilc_spi_default_bus_speed
hif_set_max_bus_speed
hif_set_default_bus_speed
Signed-off-by: Glen Lee <glen.lee@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Glen Lee [Wed, 18 Nov 2015 06:11:22 +0000 (15:11 +0900)]
staging: wilc1000: remove sdio speed control codes
This patch removes spi speed control related functions and variable. We cannot
get exact clock what we need in this way and it can causes some problem in host
side by setting the clock, so remove the codes.
Speed control codes in spi also will removed in next patch, so it's ok to
remove functions in linux_wlan.c and wilc_wlan.c which also not used anymore.
The Following functions and varialbe are removed.
MAX_SPEED, sdio_default_speed
wilc_bus_set_default_speed
wilc_bus_set_max_speed
linux_sdio_set_speed
linux_sdio_get_speed
wilc_sdio_set_max_speed
wilc_sdio_set_default_speed
Signed-off-by: Glen Lee <glen.lee@atmel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Arnd Bergmann [Mon, 16 Nov 2015 14:05:10 +0000 (15:05 +0100)]
staging/wilc1000: pass struct wilc to most linux_wlan.c functions
We want to get rid of all global variables in this driver, and
instead pass device structures from one function to another.
This changes the linux_wlan.c and wilc_wlan.c to do this
for the most part. There are a few exceptions where these
functions are themselves called from another part of the driver
that does not have an instance pointer at hand. Changing those
would be a follow-up step.
There are a few other globals that will have to get moved
into struct wilc at a later point.
Arnd Bergmann [Mon, 16 Nov 2015 14:05:09 +0000 (15:05 +0100)]
staging/wilc1000: use more regular probing
So far, my patches tried to do equivalent conversions of the
existing code. This one goes beyond that by restructuring
how the devices get probed. In particular, the spi driver
no longer creates the netdev until the device is probed,
and I've removed the global wilc_sdio_func and wilc_spi_dev
variables in favor of retrieving them from the wilc_dev
variable that will eventually get passed through all functions
instead of using a global.
Arnd Bergmann [Mon, 16 Nov 2015 14:05:08 +0000 (15:05 +0100)]
staging/wilc1000: split out bus specific modules
The SPI and SDIO specific code is now separate enough that
we just need to restructure the Makefile and Kconfig logic
a bit and export a couple of symbols from the common module
to have separate bus glue drivers.
The last remaining user of WILC_SDIO macro checks for the correct
time to wait in an interrupt for the PLL to settle. We can
replace this with a runtime check and remove both WILC_SDIO and
WILC_SPI, as we no longer need conditional compilation based on
the hardware type.
Arnd Bergmann [Mon, 16 Nov 2015 14:05:06 +0000 (15:05 +0100)]
staging/wilc1000: turn enable_irq/disable_irq into callbacks
As a preparation for turning the SDIO side of wilc1000 into a separate
module, this removes the last direct caller from the core module into
the sdio specific portion. All calls to wilc_sdio_enable_interrupt()
and wilc_sdio_disable_interrupt() now go through a function pointer
in wilc_hif_func. We also change arguments slightly to pass the device,
as we are already touching those lines and the change will be needed
later to remove the global variables.
Arnd Bergmann [Mon, 16 Nov 2015 14:05:05 +0000 (15:05 +0100)]
staging/wilc1000: pass hif operations through initialization
The wilc_hif_spi and wilc_hif_sdio structures are part of
the bus specific code, and the generic code should have no knowledge
of their addresses.
This changes the code to reference them only from the bus
specific initialization code, which we can then use to split
up the driver into separate modules.
Arnd Bergmann [Mon, 16 Nov 2015 14:05:04 +0000 (15:05 +0100)]
staging/wilc1000: get rid of WILC_SDIO_IRQ_GPIO
Whether the SDIO function uses an internal or external interrupt
should not be a compiletime decision but be determined at runtime.
This changes the code to pass a GPIO number from the init code
as early as possible, and leaves just one #ifdef WILC_SDIO_IRQ_GPIO
to preserve the previous behavior.
All other locations that check for the interrupt method are turned
into runtime checks based on the gpio number (>=0) or the interrupt
number (>0).
Arnd Bergmann [Mon, 16 Nov 2015 14:05:03 +0000 (15:05 +0100)]
staging/wilc1000: use device pointer for phy creation
wilc_create_wiphy tries to get a pointer to a device from the
global wilc_sdio_func variable. This is a layering violation
and we can use the wilc_dev->dev pointer instead.
Arnd Bergmann [Mon, 16 Nov 2015 14:05:01 +0000 (15:05 +0100)]
staging/wilc1000: unify device pointer
struct wilc has two pointers to store the device, one for sdio_func
and one for spi_device. By changing the pointer to a 'struct device',
we can simplify the logic and avoid a few #ifdefs.
Arnd Bergmann [Mon, 16 Nov 2015 14:05:00 +0000 (15:05 +0100)]
staging/wilc1000: move init/exit functions to driver files
The driver interfaces are in linux_wlan_sdio.c and linux_wlan_spi.c, so
this is where the init and exit functions should be. Splitting this up
enables further cleanups, including eventually allowing both modules
to be built together.
Arnd Bergmann [Mon, 16 Nov 2015 14:04:59 +0000 (15:04 +0100)]
staging/wilc1000: move wilc_wlan_inp_t into struct wilc
wilc_wlan_inp_t is an unnecessary indirection and requires linux_wlan.c
to have knowledge of the specific sdio and spi front-ends. This
removes the structure and places io_type directly inside the struct wilc.
The driver provides an interface for custom power management
and detection that is meant to be filled by people customizing
the driver. The default implementation of this is empty, and
we don't actually want people to have to modify the source code.
If anybody needs this, they need to describe the respective
hardware specifics using device tree or platform data and make
the driver handle this is a more general way.
Arnd Bergmann [Mon, 16 Nov 2015 14:04:57 +0000 (15:04 +0100)]
staging/wilc1000: avoid static definitions in header
The wilc_wfi_cfgoperations.h header defines the ieee80211_txrx_stypes
and cipher_suites variables that are only used in wilc_wfi_cfgoperations.c
and should not be shared in a header file.
This moves over all that data into the .c file, and also moves all
the macro definitions from the file that are also not needed here.
Arnd Bergmann [Mon, 16 Nov 2015 14:04:56 +0000 (15:04 +0100)]
staging/wilc1000: use NO_SECURITY instead of NO_ENCRYPT
The linux_wlan.c file uses a set of enums from wilc_wlan_if.h,
with the exception of the NO_ENCRYPT that comes from
wilc_wfi_cfgoperations.h. The two sets of enums clearly have
the same intention but are defined a bit different.
To prepare to clean up the ones in wilc_wfi_cfgoperations.h, this
first changes over the only other user.
Arnd Bergmann [Mon, 16 Nov 2015 14:04:54 +0000 (15:04 +0100)]
staging/wilc1000: use proper naming for global symbols
There are many global symbols in the wilc1000 driver, some of them
with names like "DEBUG_LEVEL" or "probe" that are not acceptable
for globals in the linux kernel as they may easily conflict with other
(equally broken) drivers.
This renames all the globals that do not already start with
wilc or a variation of that to start with wilc_ and to follow
the usual naming conventions.
Arnd Bergmann [Mon, 16 Nov 2015 14:04:53 +0000 (15:04 +0100)]
staging/wilc1000: make symbols static if possible
All symbols that are only referenced in the file that defines
them can be declared 'static' to avoid namespace pollution,
to produce better object code, and to make the source more
readable.
This patch removes host_int_get_rx_power_level function definition and
declaration that is defined at host_interface.c and host_interface.h.
This function is defined but not used anywhere in this driver so just
remove it.
This patch removes host_int_get_assoc_req_info function definition and
declaration that is defined at host_interface.c and host_interface.h.
This function is defined but not used anywhere in this driver so just
remove it.
This patch removes host_int_disconnect_station function definition and
declaration that is defined at host_interface.c and host_interface.h.
This function is defined but not used anywhere so just remove it.