Skip to content

Commit 1463a16

Browse files
Beomho Seojic23
authored andcommitted
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>
1 parent 26c17a1 commit 1463a16

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/iio/light/cm32181.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ static int cm32181_reg_init(struct cm32181_chip *cm32181)
103103
/**
104104
* cm32181_read_als_it() - Get sensor integration time (ms)
105105
* @cm32181: pointer of struct cm32181
106-
* @val: pointer of int to load the als_it value.
106+
* @val2: pointer of int to load the als_it value.
107107
*
108108
* Report the current integartion time by millisecond.
109109
*
110-
* Return: IIO_VAL_INT for success, otherwise -EINVAL.
110+
* Return: IIO_VAL_INT_PLUS_MICRO for success, otherwise -EINVAL.
111111
*/
112-
static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val)
112+
static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val2)
113113
{
114114
u16 als_it;
115115
int i;
@@ -119,8 +119,8 @@ static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val)
119119
als_it >>= CM32181_CMD_ALS_IT_SHIFT;
120120
for (i = 0; i < ARRAY_SIZE(als_it_bits); i++) {
121121
if (als_it == als_it_bits[i]) {
122-
*val = als_it_value[i];
123-
return IIO_VAL_INT;
122+
*val2 = als_it_value[i];
123+
return IIO_VAL_INT_PLUS_MICRO;
124124
}
125125
}
126126

@@ -221,7 +221,7 @@ static int cm32181_read_raw(struct iio_dev *indio_dev,
221221
*val = cm32181->calibscale;
222222
return IIO_VAL_INT;
223223
case IIO_CHAN_INFO_INT_TIME:
224-
ret = cm32181_read_als_it(cm32181, val);
224+
ret = cm32181_read_als_it(cm32181, val2);
225225
return ret;
226226
}
227227

@@ -240,7 +240,7 @@ static int cm32181_write_raw(struct iio_dev *indio_dev,
240240
cm32181->calibscale = val;
241241
return val;
242242
case IIO_CHAN_INFO_INT_TIME:
243-
ret = cm32181_write_als_it(cm32181, val);
243+
ret = cm32181_write_als_it(cm32181, val2);
244244
return ret;
245245
}
246246

@@ -264,7 +264,7 @@ static ssize_t cm32181_get_it_available(struct device *dev,
264264

265265
n = ARRAY_SIZE(als_it_value);
266266
for (i = 0, len = 0; i < n; i++)
267-
len += sprintf(buf + len, "%d ", als_it_value[i]);
267+
len += sprintf(buf + len, "0.%06u ", als_it_value[i]);
268268
return len + sprintf(buf + len, "\n");
269269
}
270270

0 commit comments

Comments
 (0)