iio: cm32181: Change cm32181 ambient light sensor driver
Integration time of cm32181 is guessed about milliseconds. But cm32181_read_als_it function return IIO_VAL_INT. So fixed to return IIO_VAL_INT_PLUS_MICRO. Next, add .write_raw_get_fmt callback function for call iio_str_to_fixpoint. v2: cm32181_write_als_id function fixed as it was. Cc: Kevin Tsai <ktsai@capellamicro.com> Signed-off-by: Beomho Seo <beomho.seo@samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
26c17a1c56
commit
1463a166b4
@ -103,13 +103,13 @@ static int cm32181_reg_init(struct cm32181_chip *cm32181)
|
|||||||
/**
|
/**
|
||||||
* cm32181_read_als_it() - Get sensor integration time (ms)
|
* cm32181_read_als_it() - Get sensor integration time (ms)
|
||||||
* @cm32181: pointer of struct cm32181
|
* @cm32181: pointer of struct cm32181
|
||||||
* @val: pointer of int to load the als_it value.
|
* @val2: pointer of int to load the als_it value.
|
||||||
*
|
*
|
||||||
* Report the current integartion time by millisecond.
|
* Report the current integartion time by millisecond.
|
||||||
*
|
*
|
||||||
* Return: IIO_VAL_INT for success, otherwise -EINVAL.
|
* Return: IIO_VAL_INT_PLUS_MICRO for success, otherwise -EINVAL.
|
||||||
*/
|
*/
|
||||||
static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val)
|
static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val2)
|
||||||
{
|
{
|
||||||
u16 als_it;
|
u16 als_it;
|
||||||
int i;
|
int i;
|
||||||
@ -119,8 +119,8 @@ static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val)
|
|||||||
als_it >>= CM32181_CMD_ALS_IT_SHIFT;
|
als_it >>= CM32181_CMD_ALS_IT_SHIFT;
|
||||||
for (i = 0; i < ARRAY_SIZE(als_it_bits); i++) {
|
for (i = 0; i < ARRAY_SIZE(als_it_bits); i++) {
|
||||||
if (als_it == als_it_bits[i]) {
|
if (als_it == als_it_bits[i]) {
|
||||||
*val = als_it_value[i];
|
*val2 = als_it_value[i];
|
||||||
return IIO_VAL_INT;
|
return IIO_VAL_INT_PLUS_MICRO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ static int cm32181_read_raw(struct iio_dev *indio_dev,
|
|||||||
*val = cm32181->calibscale;
|
*val = cm32181->calibscale;
|
||||||
return IIO_VAL_INT;
|
return IIO_VAL_INT;
|
||||||
case IIO_CHAN_INFO_INT_TIME:
|
case IIO_CHAN_INFO_INT_TIME:
|
||||||
ret = cm32181_read_als_it(cm32181, val);
|
ret = cm32181_read_als_it(cm32181, val2);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ static int cm32181_write_raw(struct iio_dev *indio_dev,
|
|||||||
cm32181->calibscale = val;
|
cm32181->calibscale = val;
|
||||||
return val;
|
return val;
|
||||||
case IIO_CHAN_INFO_INT_TIME:
|
case IIO_CHAN_INFO_INT_TIME:
|
||||||
ret = cm32181_write_als_it(cm32181, val);
|
ret = cm32181_write_als_it(cm32181, val2);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ static ssize_t cm32181_get_it_available(struct device *dev,
|
|||||||
|
|
||||||
n = ARRAY_SIZE(als_it_value);
|
n = ARRAY_SIZE(als_it_value);
|
||||||
for (i = 0, len = 0; i < n; i++)
|
for (i = 0, len = 0; i < n; i++)
|
||||||
len += sprintf(buf + len, "%d ", als_it_value[i]);
|
len += sprintf(buf + len, "0.%06u ", als_it_value[i]);
|
||||||
return len + sprintf(buf + len, "\n");
|
return len + sprintf(buf + len, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user