aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-20 18:40:05 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-20 18:40:05 -0500
commitd91f9ecfd147bbb2d3089b2e2a603087c668db82 (patch)
treed1455073c88f86b7d6ab6deb257b4bd7b5b7fe36
parentaccb884b32e82f943340688c9cd30290531e73e0 (diff)
parenta0657716416f834ef7710a9044614d50a36c3bdc (diff)
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.
-rw-r--r--drivers/iio/gyro/Kconfig2
-rw-r--r--drivers/iio/gyro/st_gyro.h1
-rw-r--r--drivers/iio/gyro/st_gyro_core.c9
-rw-r--r--drivers/iio/gyro/st_gyro_i2c.c1
-rw-r--r--drivers/iio/gyro/st_gyro_spi.c1
-rw-r--r--drivers/iio/light/cm32181.c16
-rw-r--r--drivers/iio/light/cm36651.c45
7 files changed, 36 insertions, 39 deletions
diff --git a/drivers/iio/gyro/Kconfig b/drivers/iio/gyro/Kconfig
index 41c64a43bcab..ac2d69e34c8c 100644
--- a/drivers/iio/gyro/Kconfig
+++ b/drivers/iio/gyro/Kconfig
@@ -70,7 +70,7 @@ config IIO_ST_GYRO_3AXIS
70 select IIO_TRIGGERED_BUFFER if (IIO_BUFFER) 70 select IIO_TRIGGERED_BUFFER if (IIO_BUFFER)
71 help 71 help
72 Say yes here to build support for STMicroelectronics gyroscopes: 72 Say yes here to build support for STMicroelectronics gyroscopes:
73 L3G4200D, LSM330DL, L3GD20, L3GD20H, LSM330DLC, L3G4IS, LSM330. 73 L3G4200D, LSM330DL, L3GD20, LSM330DLC, L3G4IS, LSM330.
74 74
75 This driver can also be built as a module. If so, these modules 75 This driver can also be built as a module. If so, these modules
76 will be created: 76 will be created:
diff --git a/drivers/iio/gyro/st_gyro.h b/drivers/iio/gyro/st_gyro.h
index f8f2bf84a5a2..c197360c450b 100644
--- a/drivers/iio/gyro/st_gyro.h
+++ b/drivers/iio/gyro/st_gyro.h
@@ -19,7 +19,6 @@
19#define LSM330DL_GYRO_DEV_NAME "lsm330dl_gyro" 19#define LSM330DL_GYRO_DEV_NAME "lsm330dl_gyro"
20#define LSM330DLC_GYRO_DEV_NAME "lsm330dlc_gyro" 20#define LSM330DLC_GYRO_DEV_NAME "lsm330dlc_gyro"
21#define L3GD20_GYRO_DEV_NAME "l3gd20" 21#define L3GD20_GYRO_DEV_NAME "l3gd20"
22#define L3GD20H_GYRO_DEV_NAME "l3gd20h"
23#define L3G4IS_GYRO_DEV_NAME "l3g4is_ui" 22#define L3G4IS_GYRO_DEV_NAME "l3g4is_ui"
24#define LSM330_GYRO_DEV_NAME "lsm330_gyro" 23#define LSM330_GYRO_DEV_NAME "lsm330_gyro"
25 24
diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c
index d53d91adfb55..a8e174a47bc4 100644
--- a/drivers/iio/gyro/st_gyro_core.c
+++ b/drivers/iio/gyro/st_gyro_core.c
@@ -167,11 +167,10 @@ static const struct st_sensors st_gyro_sensors[] = {
167 .wai = ST_GYRO_2_WAI_EXP, 167 .wai = ST_GYRO_2_WAI_EXP,
168 .sensors_supported = { 168 .sensors_supported = {
169 [0] = L3GD20_GYRO_DEV_NAME, 169 [0] = L3GD20_GYRO_DEV_NAME,
170 [1] = L3GD20H_GYRO_DEV_NAME, 170 [1] = LSM330D_GYRO_DEV_NAME,
171 [2] = LSM330D_GYRO_DEV_NAME, 171 [2] = LSM330DLC_GYRO_DEV_NAME,
172 [3] = LSM330DLC_GYRO_DEV_NAME, 172 [3] = L3G4IS_GYRO_DEV_NAME,
173 [4] = L3G4IS_GYRO_DEV_NAME, 173 [4] = LSM330_GYRO_DEV_NAME,
174 [5] = LSM330_GYRO_DEV_NAME,
175 }, 174 },
176 .ch = (struct iio_chan_spec *)st_gyro_16bit_channels, 175 .ch = (struct iio_chan_spec *)st_gyro_16bit_channels,
177 .odr = { 176 .odr = {
diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c
index 16b8b8d70bf1..23c12f361b05 100644
--- a/drivers/iio/gyro/st_gyro_i2c.c
+++ b/drivers/iio/gyro/st_gyro_i2c.c
@@ -55,7 +55,6 @@ static const struct i2c_device_id st_gyro_id_table[] = {
55 { LSM330DL_GYRO_DEV_NAME }, 55 { LSM330DL_GYRO_DEV_NAME },
56 { LSM330DLC_GYRO_DEV_NAME }, 56 { LSM330DLC_GYRO_DEV_NAME },
57 { L3GD20_GYRO_DEV_NAME }, 57 { L3GD20_GYRO_DEV_NAME },
58 { L3GD20H_GYRO_DEV_NAME },
59 { L3G4IS_GYRO_DEV_NAME }, 58 { L3G4IS_GYRO_DEV_NAME },
60 { LSM330_GYRO_DEV_NAME }, 59 { LSM330_GYRO_DEV_NAME },
61 {}, 60 {},
diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c
index 94763e25caf9..b4ad3be26687 100644
--- a/drivers/iio/gyro/st_gyro_spi.c
+++ b/drivers/iio/gyro/st_gyro_spi.c
@@ -54,7 +54,6 @@ static const struct spi_device_id st_gyro_id_table[] = {
54 { LSM330DL_GYRO_DEV_NAME }, 54 { LSM330DL_GYRO_DEV_NAME },
55 { LSM330DLC_GYRO_DEV_NAME }, 55 { LSM330DLC_GYRO_DEV_NAME },
56 { L3GD20_GYRO_DEV_NAME }, 56 { L3GD20_GYRO_DEV_NAME },
57 { L3GD20H_GYRO_DEV_NAME },
58 { L3G4IS_GYRO_DEV_NAME }, 57 { L3G4IS_GYRO_DEV_NAME },
59 { LSM330_GYRO_DEV_NAME }, 58 { LSM330_GYRO_DEV_NAME },
60 {}, 59 {},
diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
index f17b4e6183c6..47a6dbac2d0c 100644
--- a/drivers/iio/light/cm32181.c
+++ b/drivers/iio/light/cm32181.c
@@ -103,13 +103,13 @@ static int cm32181_reg_init(struct cm32181_chip *cm32181)
103/** 103/**
104 * cm32181_read_als_it() - Get sensor integration time (ms) 104 * cm32181_read_als_it() - Get sensor integration time (ms)
105 * @cm32181: pointer of struct cm32181 105 * @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.
107 * 107 *
108 * Report the current integartion time by millisecond. 108 * Report the current integartion time by millisecond.
109 * 109 *
110 * Return: IIO_VAL_INT for success, otherwise -EINVAL. 110 * Return: IIO_VAL_INT_PLUS_MICRO for success, otherwise -EINVAL.
111 */ 111 */
112static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val) 112static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val2)
113{ 113{
114 u16 als_it; 114 u16 als_it;
115 int i; 115 int i;
@@ -119,8 +119,8 @@ static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val)
119 als_it >>= CM32181_CMD_ALS_IT_SHIFT; 119 als_it >>= CM32181_CMD_ALS_IT_SHIFT;
120 for (i = 0; i < ARRAY_SIZE(als_it_bits); i++) { 120 for (i = 0; i < ARRAY_SIZE(als_it_bits); i++) {
121 if (als_it == als_it_bits[i]) { 121 if (als_it == als_it_bits[i]) {
122 *val = als_it_value[i]; 122 *val2 = als_it_value[i];
123 return IIO_VAL_INT; 123 return IIO_VAL_INT_PLUS_MICRO;
124 } 124 }
125 } 125 }
126 126
@@ -221,7 +221,7 @@ static int cm32181_read_raw(struct iio_dev *indio_dev,
221 *val = cm32181->calibscale; 221 *val = cm32181->calibscale;
222 return IIO_VAL_INT; 222 return IIO_VAL_INT;
223 case IIO_CHAN_INFO_INT_TIME: 223 case IIO_CHAN_INFO_INT_TIME:
224 ret = cm32181_read_als_it(cm32181, val); 224 ret = cm32181_read_als_it(cm32181, val2);
225 return ret; 225 return ret;
226 } 226 }
227 227
@@ -240,7 +240,7 @@ static int cm32181_write_raw(struct iio_dev *indio_dev,
240 cm32181->calibscale = val; 240 cm32181->calibscale = val;
241 return val; 241 return val;
242 case IIO_CHAN_INFO_INT_TIME: 242 case IIO_CHAN_INFO_INT_TIME:
243 ret = cm32181_write_als_it(cm32181, val); 243 ret = cm32181_write_als_it(cm32181, val2);
244 return ret; 244 return ret;
245 } 245 }
246 246
@@ -264,7 +264,7 @@ static ssize_t cm32181_get_it_available(struct device *dev,
264 264
265 n = ARRAY_SIZE(als_it_value); 265 n = ARRAY_SIZE(als_it_value);
266 for (i = 0, len = 0; i < n; i++) 266 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]);
268 return len + sprintf(buf + len, "\n"); 268 return len + sprintf(buf + len, "\n");
269} 269}
270 270
diff --git a/drivers/iio/light/cm36651.c b/drivers/iio/light/cm36651.c
index 0a142af83e25..a45e07492db3 100644
--- a/drivers/iio/light/cm36651.c
+++ b/drivers/iio/light/cm36651.c
@@ -50,10 +50,10 @@
50#define CM36651_CS_CONF2_DEFAULT_BIT 0x08 50#define CM36651_CS_CONF2_DEFAULT_BIT 0x08
51 51
52/* CS_CONF3 channel integration time */ 52/* CS_CONF3 channel integration time */
53#define CM36651_CS_IT1 0x00 /* Integration time 80000 usec */ 53#define CM36651_CS_IT1 0x00 /* Integration time 80 msec */
54#define CM36651_CS_IT2 0x40 /* Integration time 160000 usec */ 54#define CM36651_CS_IT2 0x40 /* Integration time 160 msec */
55#define CM36651_CS_IT3 0x80 /* Integration time 320000 usec */ 55#define CM36651_CS_IT3 0x80 /* Integration time 320 msec */
56#define CM36651_CS_IT4 0xC0 /* Integration time 640000 usec */ 56#define CM36651_CS_IT4 0xC0 /* Integration time 640 msec */
57 57
58/* PS_CONF1 command code */ 58/* PS_CONF1 command code */
59#define CM36651_PS_ENABLE 0x00 59#define CM36651_PS_ENABLE 0x00
@@ -64,10 +64,10 @@
64#define CM36651_PS_PERS4 0x0C 64#define CM36651_PS_PERS4 0x0C
65 65
66/* PS_CONF1 command code: integration time */ 66/* PS_CONF1 command code: integration time */
67#define CM36651_PS_IT1 0x00 /* Integration time 320 usec */ 67#define CM36651_PS_IT1 0x00 /* Integration time 0.32 msec */
68#define CM36651_PS_IT2 0x10 /* Integration time 420 usec */ 68#define CM36651_PS_IT2 0x10 /* Integration time 0.42 msec */
69#define CM36651_PS_IT3 0x20 /* Integration time 520 usec */ 69#define CM36651_PS_IT3 0x20 /* Integration time 0.52 msec */
70#define CM36651_PS_IT4 0x30 /* Integration time 640 usec */ 70#define CM36651_PS_IT4 0x30 /* Integration time 0.64 msec */
71 71
72/* PS_CONF1 command code: duty ratio */ 72/* PS_CONF1 command code: duty ratio */
73#define CM36651_PS_DR1 0x00 /* Duty ratio 1/80 */ 73#define CM36651_PS_DR1 0x00 /* Duty ratio 1/80 */
@@ -93,8 +93,8 @@
93#define CM36651_CLOSE_PROXIMITY 0x32 93#define CM36651_CLOSE_PROXIMITY 0x32
94#define CM36651_FAR_PROXIMITY 0x33 94#define CM36651_FAR_PROXIMITY 0x33
95 95
96#define CM36651_CS_INT_TIME_AVAIL "80000 160000 320000 640000" 96#define CM36651_CS_INT_TIME_AVAIL "0.08 0.16 0.32 0.64"
97#define CM36651_PS_INT_TIME_AVAIL "320 420 520 640" 97#define CM36651_PS_INT_TIME_AVAIL "0.000320 0.000420 0.000520 0.000640"
98 98
99enum cm36651_operation_mode { 99enum cm36651_operation_mode {
100 CM36651_LIGHT_EN, 100 CM36651_LIGHT_EN,
@@ -356,30 +356,30 @@ static int cm36651_read_channel(struct cm36651_data *cm36651,
356} 356}
357 357
358static int cm36651_read_int_time(struct cm36651_data *cm36651, 358static 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)
360{ 360{
361 switch (chan->type) { 361 switch (chan->type) {
362 case IIO_LIGHT: 362 case IIO_LIGHT:
363 if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT1) 363 if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT1)
364 *val = 80000; 364 *val2 = 80000;
365 else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT2) 365 else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT2)
366 *val = 160000; 366 *val2 = 160000;
367 else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT3) 367 else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT3)
368 *val = 320000; 368 *val2 = 320000;
369 else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT4) 369 else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT4)
370 *val = 640000; 370 *val2 = 640000;
371 else 371 else
372 return -EINVAL; 372 return -EINVAL;
373 break; 373 break;
374 case IIO_PROXIMITY: 374 case IIO_PROXIMITY:
375 if (cm36651->ps_int_time == CM36651_PS_IT1) 375 if (cm36651->ps_int_time == CM36651_PS_IT1)
376 *val = 320; 376 *val2 = 320;
377 else if (cm36651->ps_int_time == CM36651_PS_IT2) 377 else if (cm36651->ps_int_time == CM36651_PS_IT2)
378 *val = 420; 378 *val2 = 420;
379 else if (cm36651->ps_int_time == CM36651_PS_IT3) 379 else if (cm36651->ps_int_time == CM36651_PS_IT3)
380 *val = 520; 380 *val2 = 520;
381 else if (cm36651->ps_int_time == CM36651_PS_IT4) 381 else if (cm36651->ps_int_time == CM36651_PS_IT4)
382 *val = 640; 382 *val2 = 640;
383 else 383 else
384 return -EINVAL; 384 return -EINVAL;
385 break; 385 break;
@@ -387,7 +387,7 @@ static int cm36651_read_int_time(struct cm36651_data *cm36651,
387 return -EINVAL; 387 return -EINVAL;
388 } 388 }
389 389
390 return IIO_VAL_INT; 390 return IIO_VAL_INT_PLUS_MICRO;
391} 391}
392 392
393static int cm36651_write_int_time(struct cm36651_data *cm36651, 393static int cm36651_write_int_time(struct cm36651_data *cm36651,
@@ -459,7 +459,8 @@ static int cm36651_read_raw(struct iio_dev *indio_dev,
459 ret = cm36651_read_channel(cm36651, chan, val); 459 ret = cm36651_read_channel(cm36651, chan, val);
460 break; 460 break;
461 case IIO_CHAN_INFO_INT_TIME: 461 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);
463 break; 464 break;
464 default: 465 default:
465 ret = -EINVAL; 466 ret = -EINVAL;
@@ -479,7 +480,7 @@ static int cm36651_write_raw(struct iio_dev *indio_dev,
479 int ret = -EINVAL; 480 int ret = -EINVAL;
480 481
481 if (mask == IIO_CHAN_INFO_INT_TIME) { 482 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);
483 if (ret < 0) 484 if (ret < 0)
484 dev_err(&client->dev, "Integration time write failed\n"); 485 dev_err(&client->dev, "Integration time write failed\n");
485 } 486 }