Commit Graph

400148 Commits

Author SHA1 Message Date
Masanari Iida
a0ae9e3c33 staging: vt6655: vt6656: Fix typo in comments
Correct spelling typo in staging/vt6655 and staging/vt6656

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 16:25:40 -07:00
Masanari Iida
811a751984 staging: octeon: Fix typo in staging/octeon
Correct spelling typo in staging/octeon

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 16:25:40 -07:00
Avinash kumar
a9dfd408a9 drivers: staging: netlogic.h: removed WARNING: extern prototypes should be avoided in .h files
removed checpatch warning : WARNING: extern prototypes should be avoided in .h files

Signed-off-by: Avinash Kumar <avi.kp.137@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 16:22:31 -07:00
Jon Bernard
ec40a9af1a Staging: lustre: fix switch case statement indenting
This is a patch to lvfs_linux.c that fixes incorrect switch case statement
indenting found by checkpatch.pl.

Signed-off-by: Jon Bernard <jbernard@tuxion.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 16:22:31 -07:00
Jon Bernard
8afd983ce4 Staging: lustre: remove assignment in if conditions
This is a patch to lvfs_linux.c that removes the use of variable assignment
within an if condition found by checkpatch.pl.

Signed-off-by: Jon Bernard <jbernard@tuxion.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 16:22:31 -07:00
Masanari Iida
bef31c7804 staging: lustre: Fix typo in lustre/llite
Correct spelling typo in lustre/llite
Correct double words "to to"

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 16:22:31 -07:00
Masanari Iida
3230c0cc98 staging: lustre: Fix typo in lustre/libcfs
Correct spelling typos in comment and debug message,
within  luster/libcfs

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 16:22:31 -07:00
Lidza Louina
fcfeef6c51 staging: dgap: tty.c: removes smatch warnings "redundant null check"
This patch removes these smatch warnings:
redundant null check on dgap_TmpWriteBuf calling kfree()
redundant null check on brd->SerialDriver->ttys calling kfree()
redundant null check on brd->PrintDriver->ttys calling kfree()

The code checked to see if these variables are null
before freeing. This check isn't needed.

Signed-off-by: Lidza Louina <lidza.louina@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 16:18:10 -07:00
Lidza Louina
913b6f8e0d staging: dgap: tty.c: removes smatch warning "ignoring unreachable code"
This patch removes this smatch warning:
info: ignoring unreachable code.

There were instances where there was extra code after
the default action in switch statements. These default
actions ended with a break so the code wasn't being run
at anytime. This patch removes that extra code.

Signed-off-by: Lidza Louina <lidza.louina@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 16:18:10 -07:00
Lidza Louina
57a42192e6 staging: dgap: driver.c: removes smatch warning "redundant null check"
This patch removes these smatch warnings from dgap_driver.c:

redundant null check on dgap_config_buf calling kfree()
redundant null check on brd->flipbuf calling kfree()
redundant null check on brd->flipflagbuf calling kfree()

Signed-off-by: Lidza Louina <lidza.louina@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 16:09:24 -07:00
Chen Gang
6319c61aec drivers: staging: dgap: move DG_NAME and DG_PART from "Makefile" to "dgap_driver.h"
Normally, the macros from command line are system specific macros (e.g
__linux, __KERNEL__ ...), and module own macros are usually defined in
their header files.

DG_NAME and DG_PART are driver 'dgap' owned macros which are used by
multiple files within driver, and need be defined in the driver main
header file.

So move DG_NAME and DG_PART to "dgap_driver.h", it not only can make
code clearer, but also can avoid compiling failure when EXTRA_CFLAGS
appended to make command line (e.g. "EXTRA_CFLAGS=-W").

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 16:09:24 -07:00
Lidza Louina
b74c746120 staging: dgnc: removes LINUX_VERSION_CODE conditionals
This patch removes the conditionals that make sure
the driver supports various versions of the kernel.
They aren't needed.

Signed-off-by: Lidza Louina <lidza.louina@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-25 16:07:12 -07:00
H Hartley Sweeten
0555744518 staging: comedi: pcl711: change MODULE_DESCRIPTION
Change the MODULE_DESCRIPTION to something useful instead of the
generic "Comedi low-level 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>
2013-09-25 16:00:01 -07:00
H Hartley Sweeten
014e0dbd25 staging: comedi: pcl711: reorder includes
For aesthetics, reorder the includes a bit.

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>
2013-09-25 16:00:01 -07:00
H Hartley Sweeten
34833558ef staging: comedi: pcl711: tidy up multi line comments
Tidy up the multi line comments to follow the CodingStyle.

Remove the multi line comment about an alternate driver for the
PCL-711. The http address does not work and the driver history
in the comment is unnecessary.

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>
2013-09-25 16:00:01 -07:00
H Hartley Sweeten
102e95cd2a staging: comedi: pcl711: rename some of the register map defines
Rename some of the register map defines so they all have the same
format. Add a couple new defines to tidy up some of the magic
numbers used with the registers.

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>
2013-09-25 16:00:01 -07:00
H Hartley Sweeten
8fbf1f4569 staging: comedi: pcl711: no need to calc the timer values twice
The comedi core always calls the (*do_cmdtest) function to validate
a command before it calls the (*do_cmd) function.

Since the (*do_cmdtest) has already calculated the timer values in
order to validate the cmd->scan_begin_arg there is no reason to
recalc the values in the (*do_cmd).

This also fixes a bug in the driver. The (*do_cmdtest) was using a
time base value of 100 and but the (*do_cmd) was using a time base
of 500. These result in different timer values. The functions used
to calculate the values are actually the same due to a #define in
the 8253.h header.

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>
2013-09-25 16:00:01 -07:00
H Hartley Sweeten
326d875da3 staging: comedi: pcl711: remove 'i8253_osc_base'
This static const int variable is only used one place in the code.
Remove it and just open code the value.

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>
2013-09-25 16:00:00 -07:00
H Hartley Sweeten
7bd0573bec staging: comedi: pcl711: use 8253.h helper to set the timers
To better document the code, use the i8254_load() helper to set the
timers instead of doing the outb() instructions.

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>
2013-09-25 16:00:00 -07:00
H Hartley Sweeten
98c6ccd009 staging: comedi: pcl711: remove unused private data members
Remove all the private data variables that are not used by 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>
2013-09-25 16:00:00 -07:00
H Hartley Sweeten
0fd8ebea1b staging: comedi: pcl711: remove 'is_pcl711b' from boardinfo
This member in the board info is used to indicate if the board is
a PCL711B. This board uses bits in the mode register to select the
IRQ used for interrupts. These bits do nothing on the other boards
supported by this driver.

Remove the 'is_pcl711b' variable from the boardinfo. Also, remove
the 'mode' variable from the private data and just calculate the
mode bits when needed.

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>
2013-09-25 16:00:00 -07:00
H Hartley Sweeten
54f0db981a staging: comedi: pcl711: remove 'is_8112' from boardinfo
This member in the boardinfo is redundant. All the 8112 style boards
have > 8 analog input channels (16 actually). We can use that information
instead and remove the extra boardinfo.

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>
2013-09-25 16:00:00 -07:00
H Hartley Sweeten
95bee441c9 staging: comedi: pcl711: tidy up pcl711_ai_insn()
For aesthetic reasons, rename this function to help with greps.

Tidy up the function a bit to follow the comedi driver norm.

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>
2013-09-25 16:00:00 -07:00
H Hartley Sweeten
1c4babb246 staging: comedi: pcl711: fix software trigger for board->is_8112
The acl-8112 boards also need to write a value to the software
trigger register in order to start an A/D conversion. Remove the
if (!board->is_8112) test so that the write is always done.

Also, the analog input mode does not need to be set each time for
multiple samples. Move the pcl711_ai_set_mode() out of the for loop.

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>
2013-09-25 15:59:59 -07:00
H Hartley Sweeten
075eaef87e staging: comedi: pcl711: remove unnecessary test of 'board->is_8112'
At the end of an asynchronous command, the analog input is returned
to software triggered mode. For the non-8112 style boards the mode
PCL711_MODE_DEFAULT and PCL711_MODE_SOFTTRIG are identical. Just set
the mode to PCL711_MODE_SOFTTRIG and remove the test.

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>
2013-09-25 15:59:59 -07:00
H Hartley Sweeten
fd8b1b8c16 staging: comedi: pcl711: define the mode register magic numbers
Define the magic numbers used with the mode register.

For the PCL711B board, the mode register also contains the irq number
that is being used. Introduce a helper function to write to the mode
register so that this irq number is always included when needed.

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>
2013-09-25 15:59:59 -07:00
H Hartley Sweeten
08cd3e1684 staging: comedi: pcl711: add differential input support for 8112 boards
The ACL-8112 boards can do differential analog inputs. Add support for
this mode.

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>
2013-09-25 15:59:59 -07:00
H Hartley Sweeten
fe4489a5b2 staging: comedi: pcl711: fix pcl711_set_changain()
Currently the board->is_8112 handling in this function does not write
the value to the mux register. Also, the value for channels >= 8 is
calculated incorrectly.

Define the magic numbers used with the mux register and fix the function
so 8112 boards work correctly.

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>
2013-09-25 15:59:59 -07:00
H Hartley Sweeten
dd89a8b609 staging: comedi: pcl711: factor out the ai end-of-conversion wait
Factor out the analog input end-of-conversion wait to clarify the
pcl711_ai_insn() function a bit.

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>
2013-09-25 15:59:59 -07:00
H Hartley Sweeten
8f494fe626 staging: comedi: pcl711: use dev->read_subdev in interrupt handler
The comedi_subdevice used in the interrupt handler is the dev->read_subdev
that was initialized during the attach of the board. Use that instead of
accessing the dev->subdevices array directly.

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>
2013-09-25 15:59:58 -07:00
H Hartley Sweeten
8f394ee163 staging: comedi: pcl711: introduce pcl711_ai_get_sample()
Introduce a helper function to read the analog input data from the
hardware.

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>
2013-09-25 15:59:58 -07:00
H Hartley Sweeten
dfb7567613 staging: comedi: pcl711: tidy up pcl711_ao_insn_read()
Tidy up this function to follow the normal form in comedi drivers.

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>
2013-09-25 15:59:58 -07:00
H Hartley Sweeten
871b43cec9 staging: comedi: pcl711: tidy up pcl711_ao_insn()
For aesthetics, rename this function to help with greps.

Introduce a helper function to write the values to the analog
output channel registers. Modify the defines for the D/A registers
to avoid the ? : tests based on the chan number.

Only the final value written needs to be saved for read back.

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>
2013-09-25 15:59:58 -07:00
H Hartley Sweeten
8509e6d8ec staging: comedi: pcl711: tidy up the register map defines
Add some whitespace to the register map defines to make the code
easier to read.

For aesthetics, convert all the values to hex. This is more common
in comedi drivers.

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>
2013-09-25 15:59:58 -07:00
H Hartley Sweeten
b9a8bbf911 staging: comedi: pcl711: save the irq for the pcl711b only when used
Move the storing of the irq in the mode register for the pcl711b board
so it's only done when the irq is actually used by 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>
2013-09-25 15:59:57 -07:00
H Hartley Sweeten
bca757ad53 staging: comedi: pcl711: tidy up the subdevice init
For aesthetic reasons, add some whitespace to the subdevice init.

The 's->len_chanlist' is only used with asynchronous command support.
Remove the unnecessary initialization of this member in the subdevices
that do not support commands. For the analog input subdevice, move
the initialization so it only occurs when commands are supported.

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>
2013-09-25 15:59:57 -07:00
H Hartley Sweeten
95bb941465 staging: comedi: pcl711: remove PCL711_SIZE
This define is only used in the comedi_request_region() call. It doesn't
really add any clarity to the code so remove it and just open code the
value.

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>
2013-09-25 15:59:57 -07:00
H Hartley Sweeten
baa7189131 staging: comedi: pcl711: don't fail attach if irq is unavailable
Interrupts are only needed to support asynchronous commands with the
analog input subdevice. Since the interrupt is optional during the
attach of the board, don't fail the attach if it's not available.

Also, remove the printk() noise about the irq. The user will know if
the interrupt is available due to the subdev_flag SDF_CMD_READ being
set for the analog input subdevice.

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>
2013-09-25 15:59:57 -07:00
H Hartley Sweeten
95dbf5d2ae staging: comedi: pcl711: tidy up the comedi_lrange tables
For aesthetic reasons, cleanup the whitespace in the comedi_lrange
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>
2013-09-25 15:59:57 -07:00
H Hartley Sweeten
a08ec374aa staging: comedi: pcl711: convert boardinfo flags to bit-fields
To save a bit of space, convert the 'is_pcl711b' and 'is_8112' flags
in the boardinfo to bit-fields.

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>
2013-09-25 15:59:57 -07:00
H Hartley Sweeten
e7de66da57 staging: comedi: pcl711: remove unused boardinfo
The 'is_dg' and 'n_ranges' members in the boardinfo are not used by
the driver. Remove them.

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>
2013-09-25 15:59:56 -07:00
H Hartley Sweeten
5deee09162 staging: comedi: pcl711: remove all '= 0' boardinfo
Remove all the '= 0' entries in the boardinfo. They will default to 0.

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>
2013-09-25 15:59:56 -07:00
H Hartley Sweeten
9adfdf90ec staging: comedi: pcl711: convert boardinfo declaration to C99 format
Convert the boardinfo declaration to C99 format to make it less error
prone and easier to maintain.

For aesthetics, move the declaration closer to the struct definition.

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>
2013-09-25 15:59:56 -07:00
H Hartley Sweeten
968265fd9c staging: comedi: adl_pci6208: change MODULE_DESCRIPTION
Change the MODULE_DESCRIPTION to something useful instead of the
generic "Comedi low-level 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>
2013-09-25 15:45:43 -07:00
H Hartley Sweeten
6d09991e9c staging: comedi: adl_pci6208: tidy up multi-line comments
Tidy up the multi-line comments to follow the CodingStyle.

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>
2013-09-25 15:45:43 -07:00
H Hartley Sweeten
7b5f9dbcd8 staging: comedi: adl_pci6208: remove board attach noise
Remove the final dev_info() at the end of the board attach. This is
just added noise.

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>
2013-09-25 15:45:43 -07:00
H Hartley Sweeten
c354fe06cf staging: comedi: adl_pci6208: tidy up pci6208_ao_rinsn()
For aesthetics, rename this function to help with greps,

Change the type of 'chan' to match the type of the insn->chanspec
that it is derived from using the CR_CHAN macro.

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>
2013-09-25 15:45:43 -07:00
H Hartley Sweeten
a99a294370 staging: comedi: adl_pci6208: tidy up pci6208_ao_winsn()
For aesthetics, rename this function to help with greps,

Change the type of 'chan' to match the type of the insn->chanspec
that it is derived from using the CR_CHAN macro.

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>
2013-09-25 15:45:43 -07:00
H Hartley Sweeten
8a6573a875 staging: comedi: adl_pci6208: use comedi_offset_munge()
Use comedi_offset_munge() to munge the offset binary values from the
comedi core into the two's complement form that the hardware expects.

This removes the hard coded assumption that the analog outputs are
16-bits and instead does the munging based on the s->maxdata.

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>
2013-09-25 15:45:43 -07:00
H Hartley Sweeten
f0b215d6e8 staging: comedi: core: introduce comedi_offset_munge()
The comedi core expects the data to/from analog subdevices to be
in offset binary coding. This means that a value of '0' represents
the most negative and a value of 's->maxdata' the most positive
signal of the analog subdevice.

Many comedi drivers require the data written to the analog outputs,
or returned from the analog inputs, be in two's complement format.

Introduce a helper function to munge the data for analog subdevices.
This function simply inverts the sign bit and masks the result by
's->maxdata' to keep the result in range for the subdevice. The
strange:

  return val ^ s->maxdata ^ (s->maxdata >> 1);

is equivalent to:

  return (val ^ ((s->maxdata + 1) >> 1) & s->maxdata;

as long as s->maxdata is a value of the form (1 << n) - 1. This
avoids the 32-bit unsigned overflow for a s->maxdata of 0xffffffff.

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>
2013-09-25 15:45:42 -07:00