Skip to content

Commit d91f9ec

Browse files
committed
Merge tag 'iio-fixes-for-3.14c' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus
Jonathan writes: Third round of fixes for IIO in the 3.14 cycle. Fixes to 2 Capella light sensor drivers where the units of the integration time reported to userspace were out be a factor of a thousand. These patches are as large as they are purely due to a variable rename tied up with the incorrect scale. The actual change is only a couple of lines. 1 patch dropping L3GD20H from the st gyroscope driver. It never actually worked as the address set is different from any others supported by the driver currently. An additional patch enables correct support for this part but is too large to sensibly apply as a fix to some support that never actually allowed the driver to be successfully probed on this part.
2 parents accb884 + a065771 commit d91f9ec

File tree

7 files changed

+36
-39
lines changed

7 files changed

+36
-39
lines changed

drivers/iio/gyro/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ config IIO_ST_GYRO_3AXIS
7070
select IIO_TRIGGERED_BUFFER if (IIO_BUFFER)
7171
help
7272
Say yes here to build support for STMicroelectronics gyroscopes:
73-
L3G4200D, LSM330DL, L3GD20, L3GD20H, LSM330DLC, L3G4IS, LSM330.
73+
L3G4200D, LSM330DL, L3GD20, LSM330DLC, L3G4IS, LSM330.
7474

7575
This driver can also be built as a module. If so, these modules
7676
will be created:

drivers/iio/gyro/st_gyro.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#define LSM330DL_GYRO_DEV_NAME "lsm330dl_gyro"
2020
#define LSM330DLC_GYRO_DEV_NAME "lsm330dlc_gyro"
2121
#define L3GD20_GYRO_DEV_NAME "l3gd20"
22-
#define L3GD20H_GYRO_DEV_NAME "l3gd20h"
2322
#define L3G4IS_GYRO_DEV_NAME "l3g4is_ui"
2423
#define LSM330_GYRO_DEV_NAME "lsm330_gyro"
2524

drivers/iio/gyro/st_gyro_core.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,10 @@ static const struct st_sensors st_gyro_sensors[] = {
167167
.wai = ST_GYRO_2_WAI_EXP,
168168
.sensors_supported = {
169169
[0] = L3GD20_GYRO_DEV_NAME,
170-
[1] = L3GD20H_GYRO_DEV_NAME,
171-
[2] = LSM330D_GYRO_DEV_NAME,
172-
[3] = LSM330DLC_GYRO_DEV_NAME,
173-
[4] = L3G4IS_GYRO_DEV_NAME,
174-
[5] = LSM330_GYRO_DEV_NAME,
170+
[1] = LSM330D_GYRO_DEV_NAME,
171+
[2] = LSM330DLC_GYRO_DEV_NAME,
172+
[3] = L3G4IS_GYRO_DEV_NAME,
173+
[4] = LSM330_GYRO_DEV_NAME,
175174
},
176175
.ch = (struct iio_chan_spec *)st_gyro_16bit_channels,
177176
.odr = {

drivers/iio/gyro/st_gyro_i2c.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ static const struct i2c_device_id st_gyro_id_table[] = {
5555
{ LSM330DL_GYRO_DEV_NAME },
5656
{ LSM330DLC_GYRO_DEV_NAME },
5757
{ L3GD20_GYRO_DEV_NAME },
58-
{ L3GD20H_GYRO_DEV_NAME },
5958
{ L3G4IS_GYRO_DEV_NAME },
6059
{ LSM330_GYRO_DEV_NAME },
6160
{},

drivers/iio/gyro/st_gyro_spi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ static const struct spi_device_id st_gyro_id_table[] = {
5454
{ LSM330DL_GYRO_DEV_NAME },
5555
{ LSM330DLC_GYRO_DEV_NAME },
5656
{ L3GD20_GYRO_DEV_NAME },
57-
{ L3GD20H_GYRO_DEV_NAME },
5857
{ L3G4IS_GYRO_DEV_NAME },
5958
{ LSM330_GYRO_DEV_NAME },
6059
{},

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

drivers/iio/light/cm36651.c

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
#define CM36651_CS_CONF2_DEFAULT_BIT 0x08
5151

5252
/* CS_CONF3 channel integration time */
53-
#define CM36651_CS_IT1 0x00 /* Integration time 80000 usec */
54-
#define CM36651_CS_IT2 0x40 /* Integration time 160000 usec */
55-
#define CM36651_CS_IT3 0x80 /* Integration time 320000 usec */
56-
#define CM36651_CS_IT4 0xC0 /* Integration time 640000 usec */
53+
#define CM36651_CS_IT1 0x00 /* Integration time 80 msec */
54+
#define CM36651_CS_IT2 0x40 /* Integration time 160 msec */
55+
#define CM36651_CS_IT3 0x80 /* Integration time 320 msec */
56+
#define CM36651_CS_IT4 0xC0 /* Integration time 640 msec */
5757

5858
/* PS_CONF1 command code */
5959
#define CM36651_PS_ENABLE 0x00
@@ -64,10 +64,10 @@
6464
#define CM36651_PS_PERS4 0x0C
6565

6666
/* PS_CONF1 command code: integration time */
67-
#define CM36651_PS_IT1 0x00 /* Integration time 320 usec */
68-
#define CM36651_PS_IT2 0x10 /* Integration time 420 usec */
69-
#define CM36651_PS_IT3 0x20 /* Integration time 520 usec */
70-
#define CM36651_PS_IT4 0x30 /* Integration time 640 usec */
67+
#define CM36651_PS_IT1 0x00 /* Integration time 0.32 msec */
68+
#define CM36651_PS_IT2 0x10 /* Integration time 0.42 msec */
69+
#define CM36651_PS_IT3 0x20 /* Integration time 0.52 msec */
70+
#define CM36651_PS_IT4 0x30 /* Integration time 0.64 msec */
7171

7272
/* PS_CONF1 command code: duty ratio */
7373
#define CM36651_PS_DR1 0x00 /* Duty ratio 1/80 */
@@ -93,8 +93,8 @@
9393
#define CM36651_CLOSE_PROXIMITY 0x32
9494
#define CM36651_FAR_PROXIMITY 0x33
9595

96-
#define CM36651_CS_INT_TIME_AVAIL "80000 160000 320000 640000"
97-
#define CM36651_PS_INT_TIME_AVAIL "320 420 520 640"
96+
#define CM36651_CS_INT_TIME_AVAIL "0.08 0.16 0.32 0.64"
97+
#define CM36651_PS_INT_TIME_AVAIL "0.000320 0.000420 0.000520 0.000640"
9898

9999
enum cm36651_operation_mode {
100100
CM36651_LIGHT_EN,
@@ -356,38 +356,38 @@ static int cm36651_read_channel(struct cm36651_data *cm36651,
356356
}
357357

358358
static int cm36651_read_int_time(struct cm36651_data *cm36651,
359-
struct iio_chan_spec const *chan, int *val)
359+
struct iio_chan_spec const *chan, int *val2)
360360
{
361361
switch (chan->type) {
362362
case IIO_LIGHT:
363363
if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT1)
364-
*val = 80000;
364+
*val2 = 80000;
365365
else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT2)
366-
*val = 160000;
366+
*val2 = 160000;
367367
else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT3)
368-
*val = 320000;
368+
*val2 = 320000;
369369
else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT4)
370-
*val = 640000;
370+
*val2 = 640000;
371371
else
372372
return -EINVAL;
373373
break;
374374
case IIO_PROXIMITY:
375375
if (cm36651->ps_int_time == CM36651_PS_IT1)
376-
*val = 320;
376+
*val2 = 320;
377377
else if (cm36651->ps_int_time == CM36651_PS_IT2)
378-
*val = 420;
378+
*val2 = 420;
379379
else if (cm36651->ps_int_time == CM36651_PS_IT3)
380-
*val = 520;
380+
*val2 = 520;
381381
else if (cm36651->ps_int_time == CM36651_PS_IT4)
382-
*val = 640;
382+
*val2 = 640;
383383
else
384384
return -EINVAL;
385385
break;
386386
default:
387387
return -EINVAL;
388388
}
389389

390-
return IIO_VAL_INT;
390+
return IIO_VAL_INT_PLUS_MICRO;
391391
}
392392

393393
static int cm36651_write_int_time(struct cm36651_data *cm36651,
@@ -459,7 +459,8 @@ static int cm36651_read_raw(struct iio_dev *indio_dev,
459459
ret = cm36651_read_channel(cm36651, chan, val);
460460
break;
461461
case IIO_CHAN_INFO_INT_TIME:
462-
ret = cm36651_read_int_time(cm36651, chan, val);
462+
*val = 0;
463+
ret = cm36651_read_int_time(cm36651, chan, val2);
463464
break;
464465
default:
465466
ret = -EINVAL;
@@ -479,7 +480,7 @@ static int cm36651_write_raw(struct iio_dev *indio_dev,
479480
int ret = -EINVAL;
480481

481482
if (mask == IIO_CHAN_INFO_INT_TIME) {
482-
ret = cm36651_write_int_time(cm36651, chan, val);
483+
ret = cm36651_write_int_time(cm36651, chan, val2);
483484
if (ret < 0)
484485
dev_err(&client->dev, "Integration time write failed\n");
485486
}

0 commit comments

Comments
 (0)