Commit 809a591b authored by Roberta Dobrescu's avatar Roberta Dobrescu Committed by Jonathan Cameron

staging: iio: light: isl29018: Rename lux_scale to calibscale

This patch renames lux_scale to calibscale and lux_uscale to
ucalibscale.

This is done in order to avoid confusion since these parameters are
used for hardware applied calibration.
Signed-off-by: default avatarRoberta Dobrescu <roberta.dobrescu@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent e98ceca0
...@@ -71,8 +71,8 @@ struct isl29018_chip { ...@@ -71,8 +71,8 @@ struct isl29018_chip {
struct regmap *regmap; struct regmap *regmap;
struct mutex lock; struct mutex lock;
int type; int type;
unsigned int lux_scale; unsigned int calibscale;
unsigned int lux_uscale; unsigned int ucalibscale;
unsigned int range; unsigned int range;
unsigned int adc_bit; unsigned int adc_bit;
int prox_scheme; int prox_scheme;
...@@ -165,12 +165,12 @@ static int isl29018_read_lux(struct isl29018_chip *chip, int *lux) ...@@ -165,12 +165,12 @@ static int isl29018_read_lux(struct isl29018_chip *chip, int *lux)
/* To support fractional scaling, separate the unshifted lux /* To support fractional scaling, separate the unshifted lux
* into two calculations: int scaling and micro-scaling. * into two calculations: int scaling and micro-scaling.
* lux_uscale ranges from 0-999999, so about 20 bits. Split * ucalibscale ranges from 0-999999, so about 20 bits. Split
* the /1,000,000 in two to reduce the risk of over/underflow. * the /1,000,000 in two to reduce the risk of over/underflow.
*/ */
data_x_range = lux_data * chip->range; data_x_range = lux_data * chip->range;
lux_unshifted = data_x_range * chip->lux_scale; lux_unshifted = data_x_range * chip->calibscale;
lux_unshifted += data_x_range / 1000 * chip->lux_uscale / 1000; lux_unshifted += data_x_range / 1000 * chip->ucalibscale / 1000;
*lux = lux_unshifted >> chip->adc_bit; *lux = lux_unshifted >> chip->adc_bit;
return 0; return 0;
...@@ -277,9 +277,9 @@ static int isl29018_write_raw(struct iio_dev *indio_dev, ...@@ -277,9 +277,9 @@ static int isl29018_write_raw(struct iio_dev *indio_dev,
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
if (mask == IIO_CHAN_INFO_CALIBSCALE && chan->type == IIO_LIGHT) { if (mask == IIO_CHAN_INFO_CALIBSCALE && chan->type == IIO_LIGHT) {
chip->lux_scale = val; chip->calibscale = val;
/* With no write_raw_get_fmt(), val2 is a MICRO fraction. */ /* With no write_raw_get_fmt(), val2 is a MICRO fraction. */
chip->lux_uscale = val2; chip->ucalibscale = val2;
ret = 0; ret = 0;
} }
mutex_unlock(&chip->lock); mutex_unlock(&chip->lock);
...@@ -323,8 +323,8 @@ static int isl29018_read_raw(struct iio_dev *indio_dev, ...@@ -323,8 +323,8 @@ static int isl29018_read_raw(struct iio_dev *indio_dev,
break; break;
case IIO_CHAN_INFO_CALIBSCALE: case IIO_CHAN_INFO_CALIBSCALE:
if (chan->type == IIO_LIGHT) { if (chan->type == IIO_LIGHT) {
*val = chip->lux_scale; *val = chip->calibscale;
*val2 = chip->lux_uscale; *val2 = chip->ucalibscale;
ret = IIO_VAL_INT_PLUS_MICRO; ret = IIO_VAL_INT_PLUS_MICRO;
} }
break; break;
...@@ -607,8 +607,8 @@ static int isl29018_probe(struct i2c_client *client, ...@@ -607,8 +607,8 @@ static int isl29018_probe(struct i2c_client *client,
mutex_init(&chip->lock); mutex_init(&chip->lock);
chip->type = dev_id; chip->type = dev_id;
chip->lux_scale = 1; chip->calibscale = 1;
chip->lux_uscale = 0; chip->ucalibscale = 0;
chip->range = 1000; chip->range = 1000;
chip->adc_bit = 16; chip->adc_bit = 16;
chip->suspended = false; chip->suspended = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment