staging: comedi: ni_stc.h: tidy up NI_M_PLL_CTRL_REG bits
Rename the CamelCase and convert the enum into defines. Use the BIT()
macro to define the bits.
Convert the inline functions MSeries_PLL_Divisor_Bits() and
MSeries_PLL_Multiplier_Bits() to macros. The helper function
ni_mseries_get_pll_parameters() always returns valid values for the
'divisor' and 'multiplier' so the sanity checking can safely be
removed.
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: ni_stc.h: tidy up NI_M_CLK_FOUT2_REG bits
Rename the CamelCase and convert the enum into defines. Use the BIT()
macro to define the bits.
Convert the inline function MSeries_PLL_In_Source_Select_RTSI_Bits()
to a macro. The caller always passes valid values for 'RTIS_channel'
so the sanity checking can safely be removed.
Tidy up ni_mseries_set_pll_master_clock() to remove the unnecessary
extra indent level for the code that sets a RTSI channel for the
PLL source.
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: ni_stc.h: reg_type is not needed by MSeries_AI_Config_Bank_Bits()
This helper function sets the bits in the M_Offset_AI_Config_FIFO_Data register
to select the correct bank to configure a given analog output channel. The NI
M Series boards are defined by the boardinfo to have 16, 32, or 80 channels.
Only 2 of the M Series boards have 80 channels, those boards happen to have a
reg_type of ni_reg_622x.
The bank for the 16 and 32 channel boards is selected by the 'channel & 0x30'
calculation (comedi channels 0 to 15 or 31). This also selects the bank for the
first 64 channels of the 80 channel boards. The additional '|= 0x400' sets the
bank to access the extra channels (comedi channels >= 63).
Since all the non ni_reg_622x boards have at most 32 channels, the extra check
of the 'reg_type' is not required in this function. Remove it as well as the
parameter.
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 function is overly complex due to the M_Offset_PFI_Output_Select()
helper using a 1 based index for the registers and the private data using
a 0 based index for the cached values.
Modify the M_Offset_PFI_Output_Select() helper to use a 0 based index and
remove the sanity check which can never happen. The 'n' value passed is
calculated from the subdevice channel which will always be in range.
Tidy up the function by using a local variable to mask/set the pfi output
select bits.
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: ni_mio_common: open code the M-Series GPCT register offsets
Remove the enum m_series_register_offsets values that are only used in
the lookup tables for the GPCT to STC register mapping and just open
code the values. Having the extra level of indirection does not add any
additional clarity and it gets rid of some of the CamelCase symbols.
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: ni_mio_common: refactor gpct to stc register handling
The NI General Purpose Counter Timer (gpct) registers are mapped to the
STC registers with a big switch statement. Create a lookup table to handle
the mapping ot the registers. This is easier to maintain.
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: ni_mio_common: open code the M-Series regmap offsets
Remove the enum m_series_register_offsets values that are only used in
the lookup tables for the STC to M-Series register mapping and just open
code the values. Having the extra level of indirection does not add any
additional clarity and it gets rid of some of the CamelCase symbols.
Some of the registers are not currently used by the driver so the mappings
were not present in the original switch code. Add the missing register
mappings to the lookup tables.
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>
For M-Series boards (devpriv->is_m_series), the STC registers need to be
remapped. This is currently handled with some big switch statements to
convert the STC register offset to the M-Series offset. Some of the
registers also need special handling due to differences in the register
size on the M-Series boards.
Create some lookup tables to handle the remapping of the read and write
registers. These are easier to maintain and can contain the register size
so that a common function can be used instead of the separate helpers.
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>
Merge tag 'iio-for-v4.2a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
First round of new drivers, functionality and cleanups for the 4.2 cycle
New drivers / device support
* st sensors driver, lsm303dlh magnetometer support.
* ltr501 - support ltr301 and ltr559 chips.
New functionality
* IIO_CHAN_INFO_CALIBEMISSIVITY for thermopile sensors.
* kxcjk1013 - make driver operational with external trigger.
* Add iio targets to the tools Makefile.
Cleanups
* st sensors - more helpful error message if device id wrong or irq request
fails, explicitly make the Block Data Update optional rather
than relying on writes to address 0 not doing anything, make interrupt
support optional (Not always wired, and not all devices actually have
an interrupt line.)
* kxcjk-1013 white space additions for readability, add the KXCJ9000 ACPI
id as seen in the wild.
* sx9500 - GPIO reset support, refactor the GPIO interrupt code, add power
management, optimize power usage by powering down when possible, rename
the gpio interrupt pin to be more useful, trivial return path simplification,
trivial formatting fixes.
* isl29018 - move towards ABI compliance with a view to moving this driver
out of staging, add some brackets to ensure code works as expected. Note
there is no actual bug as the condition being tested is always true
(with current devices).
* ltr501 - add regmap support to get caching etc for later patches,
fix a parameter sanity check that always fails (bug introduced
earlier in this series), ACPI enumeration support,
interrupt rate control support, interrupt support in general and
integration time control support, code alignment cleanups.
* mma9553 - a number of little cleanups following a review from Hartmut
after I'd already applied the original driver patch.
* tmp006 - prefix some defines with TMP006 for consistency.
* tsl4531 - cleanup some wrong prefixes, presumably from copy and paste.
* mlx90614 - check for errors in read values, add power management,
add emissivity setting, add device tree binding documentation,
fix a duplicate const warning.
* ti_am335x_adc - refactor the DT parsing into a separate function.
Erik Arfvidson [Tue, 5 May 2015 22:37:06 +0000 (18:37 -0400)]
staging: unisys: remove timskmod.h and procobjecttree.h
This patch move the needed linux include files from timskmod.h
to the files that calls those include. Also procobjecttree.h is
removed since it is dead code.
Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com> Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Erik Arfvidson [Tue, 5 May 2015 22:37:04 +0000 (18:37 -0400)]
staging: unisys: move timskmod.h functionality
This patch removes all timksmod.h pound defines. It also removes
visorkmodutils.c since it no longer has any use by itself. Since
visorkmodutils.c is no longer needed the module_init for
visorchipset.c is modified to call visorutil_spar_detect directly
instead of the extern variable in timksmod.h.
Signed-off-by: Erik Arfvidson <erik.arfvidson@unisys.com> Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Prarit Bhargava [Tue, 5 May 2015 22:37:02 +0000 (18:37 -0400)]
staging: unisys: add acpi pnp driver
According to Unisys, another OS detects the PNP0A07 as the auto load
device. We can also do this in the linux kernel by simply converting the
driver over to the ACPI driver model.
Notes: This changes the usage of __init and it had to be removed from some
functions to avoid a !__init function calling an __init function.
Additionally I also cleaned up the headers in visorchipset.c since I was
adding a header file.
visorchannel's signal code should call visorchannel_write() directly.
This is more consistent and cleaner, and allows us to remove the last
memregion call.
Jes Sorensen [Tue, 5 May 2015 22:36:55 +0000 (18:36 -0400)]
staging: unisys: visorchannel_read(): Use memcpy_fromio() directly
Note, this changes the behavior of visorchannel_read(). The old code
would return the channel header, if the offset argument was 0, and the
caller tried to read beyond the size of the visorchannel. Note this
only worked for offset == 0, but not for
(offset > 0) && (offset < header_size), which was inconsistent.
The new implementation returns an error if someone tries to read
beyond the visorchannel size.
David Kershner [Tue, 5 May 2015 22:36:39 +0000 (18:36 -0400)]
staging: unisys: remove server crust from visorchipset.
The visorchipset driver originally serviced both servers and
clients. This implementation is client only so remove some
more server side implementation.
Signed-off-by: David Kershner <david.kershner@unisys.com> Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Jes Sorensen [Tue, 5 May 2015 22:36:32 +0000 (18:36 -0400)]
staging: unisys: memregion: Embed memregion in struct channel
This changes the API for visor_memregion_create() to require a
pre-allocated struct memregion. Embedding this in struct channel
avoids a layer of additional kmalloc()'s and error checks.
Prarit Bhargava [Tue, 5 May 2015 22:36:19 +0000 (18:36 -0400)]
staging: unisys: fix sig_read_data and sig_read_data functions
The sig_read_data() and sig_write_data() functions are involved in 2 steps
of calls. They really don't need to be and this makes for much simpler
code.
The error handling in this function was broken and while looking at that
I noticed that the whole function was in need of cleanup. This patch
fixes the error handling, specifically
if (!p) {
visorchannel_destroy(p);
channel = NULL;
}
and does a lot of cleanup. I also verified that the called functions
returned correct errors, and that led to a change in
visor_memregion_resize(), visorchannel_destroy() and
visor_memregion_destroy().
Prarit Bhargava [Tue, 5 May 2015 22:36:16 +0000 (18:36 -0400)]
staging: unisys: cleanup visorbus_private.h
visorbus_private.h contains code that is called from visorbus into the
visorchipset code. Now that the visorchipset code has been brought into
the visorbus directory, many of the declarations are not necessary and
can be cleaned up.
TODO: PARSER_WHICH_STRING enum only has one member used
(PARSERSTRING_NAME).
TODO: crash_obj_type appears to be unnecessary in the overall scheme of
code.
Prarit Bhargava [Tue, 5 May 2015 22:36:15 +0000 (18:36 -0400)]
staging: unisys: move visorchipset files to visorbus
Move visorchipset_main.c and visorchipset.h to visorbus/visorchipset.c and
visorbus/visorbus_private.h. This leaves an empty visorchipset directory
which can also be destroyed.
As a result of this patch the visorchipset init code now calls the
visorbus_init() directly. Similarily the visorchipset exit code now
cleans up by calling visorbus_exit().