iio: add Capella CM32181 ambient light sensor driver.

Add Capella Microsystem CM32181 Ambient Light Sensor IIO driver.
This driver will convert raw data to lux value under open-air
condition. Change the calibscale based on the cover material.

Signed-off-by: Kevin Tsai <ktsai@capellamicro.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: mxs-lradc: add scale attribute to channels

Some LRADC channels have fixed pre-dividers and all have an optional
divider by two which allows a maximum input voltage of VDDIO - 50mV.

This patch
 - adds the scaling info flag to all channels
 - grabs the max reference voltage per channel
   (where the fixed pre-dividers apply)
 - allows to read the scaling attribute (computed from the Vref)

Signed-off-by: Hector Palacios <hector.palacios@digi.com>.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: mxs-lradc: add scale_available file to channels

Adds in_voltageX_scale_available file for every channel to read
the different available scales.
There are two scales per channel:
 [0] = divider_by_two disabled (default)
 [1] = divider_by_two enabled
The scale is a struct made of integer and nano parts to build
a long decimal number.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: mxs-lradc: add write_raw function to modify scale

Added write_raw function to manipulate the optional divider_by_two
through the scaling attribute out of the available scales.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: mxs-lradc: convert is_divided to a bitmap

mxs_lradc.is_divided was an unsigned long array. Convert it to a bitmap to save
some memory.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Staging: vt6656: Fix indentation of bssdb.c

Corrects indentation by using tabs instead of spaces. This also
includes modification of the alignment of multi-line expressions and
statements.

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: vt6656: Adjust comments in bssdb.c

Changes C99-style comments to C89-style ones to conform to the linux
coding guidelines. Additionally removes plus and minus signs from the
function description comments.

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: vt6656: Remove unnecessary semicolons

After some blocks in bssdb.c there are semicolons that are not
required to be there. Therefore they are removed with this patch.

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: vt6656: Correct operator coding style

Adds spaces around operators (like &&, ||, !=, +, ...) and removes
spaces before postfix increment and decrement operators. Parentheses
around return values are removed, too.

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: vt6656: Correct single space mistakes

Adds missing spaces between an if-statement and its condition as well
as between the condition and the following curly brace. At casts
there is also a space added between the type and the variable.

Spaces that either follow an opening parenthese or the sizeof operator
or that preceed semicolons are removed as well.

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: vt6656: Remove line feeds before else

An else belongs in the same line as the closing curly brace of the
previous block. Hence, this patch removes line feeds separating a
curly brace from the corresponding else.

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: vt6656: Remove unnecessary spaces in format strings

A space in a format string is unnecessary if it is followed by a line
feed. These spaces are removed by this patch.

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: vt6656: Combine "else { if" to "else if"

This patch combines single ifs within the block of an else to a single
else if statement.

Therefore code that looks like that

else {
	if (cond) {
		statements;
	} else {
		other_statements;
	}
}

is converted to code that looks like that

else if (cond) {
	statements;
} else {
	other_statements;
}

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: vt6656: Correct usage of braces

Conforming to the linux coding style guidelines, a single line block
of an if statement does not require curly braces unless another block
of the if cascade requires them. Therefore unnecessary curly braces
are removed by this patch and missing ones are added.

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: vt6656: Combined nested conditions

This patch reduces the level of indentation in bssdb.c of the vt6656
driver by transforming nested conditions to a series of logical
conjunctions. E.g.

if (cond1) {
        if (cond2) {
                block();
        }
}

is transformed to

if (cond1 && cond2) {
        block();
}

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: vt6656: Remove bogus parentheses in conditions

Removes unrequired parentheses around comparisons in complex
conditions.

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: vt6656: Remove explicit comparisons against NULL

Explicit comparisons of pointers agains NULL
(like if (p != NULL) ...) are not as readable as the implicit
comparison (like if (p) ...). This patch converts all these explicit
comparisons to implicit ones.

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Staging: vt6656: Reduce line length of bssdb.c

Long lines are split into multiple ones to reduce the line length.
Additionally some alignment fixes are made that previous patches
missed.

Unfortunately, due to the high indentation levels present in parts of
bssdb.c, this patch leaves some lines which are longer than 80
characters.

Signed-off-by: Sebastian Rachuj <sebastian.rachuj@studium.uni-erlangen.de>
Signed-off-by: Simon Schuster <linux@rationality.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: vt6656: CARDqGetNextTBTT correct uLowNextTBTT

value uLowNextTBTT yields wrong value.

ULL is needed with qwTSF

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Cc: stable@vger.kernel.org # v3.9+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: vt6656: CARDqGetNextTBTT replace code using do_div.

uBeaconInterval becomes u32

get next TBTT value using vendor's equation as shown.

This patch was checked against the original code
and yields exactly the same value.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>