History

Merge tag 'iio-fixes-for-4.2a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

Jonathan writes: First set of IIO fixes for the 4.2 cycle. * Fix a regression in hid sensors suspend time as a result of adding runtime pm. The normal flow of waking up devices in order to go into suspend (given the devices are normally suspended when not reading) to a regression in suspend time on some laptops (reports of an additional 8 seconds). Fix this by checking to see if a user action resulting in the wake up, and make it a null operation if it didn't. Note that for hid sensors, there is nothing useful to be done when moving into a full suspend from a runtime suspend so they might as well be left alone. * rochip_saradc: fix some missing MODULE_* data including the licence so that the driver does not taint the kernel incorrectly and can build as a module. * twl4030 - mark irq as oneshot as it always should have been. * inv-mpu - write formats for attributes not specified, leading to miss interpretation of the gyro scale channel when written. * Proximity ABI clarification. This had snuck through as a mess. Some drivers thought proximity went in one direction, some the other. We went with the most common option, documented it and fixed up the drivers going the other way. Fix for sx9500 included in this set. * ad624r - fix a wrong shift in the output data. * at91_adc - remove a false limit on the value of the STARTUP register applied by too small a type for the device tree parameter. * cm3323 - clear the bits when setting the integration time (otherwise we can only ever set more bits in the relevant field). * bmc150-accel - multiple triggers are registered, but on error were not being unwound in the opposite order leading to removal of triggers that had not yet successfully been registered (count down instead of up when unwinding). * tcs3414 - ensure right part of val / val2 pair read so that the integration time is not always 0. * cc10001_adc - bug in kconfig dependency. Use of OR when AND was intended.

Greg Kroah-Hartman committed 11 years ago

Commit a732cd42 parents cbe4f44 b2b3c3d13 files · +48 −18Browse files

Unified · Split

13 files
  1. Documentation/ABI/testing/sysfs-bus-iio +2 −4
  2. drivers/iio/accel/bmc150-accel.c +1 −1
  3. drivers/iio/adc/Kconfig +1 −2
  4. drivers/iio/adc/at91_adc.c +4 −4
  5. drivers/iio/adc/rockchip_saradc.c +4 −0
  6. drivers/iio/adc/twl4030-madc.c +2 −1
  7. drivers/iio/common/hid-sensors/hid-sensor-trigger.c +10 −1
  8. drivers/iio/dac/ad5624r_spi.c +2 −2
  9. drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +18 −0
  10. drivers/iio/light/cm3323.c +1 −1
  11. drivers/iio/light/tcs3414.c +1 −1
  12. drivers/iio/proximity/sx9500.c +1 −1
  13. include/linux/hid-sensor-hub.h +1 −0
Documentation/ABI/testing/sysfs-bus-iio+2−4
@@ -1234,10 +1234,8 @@ Description: · 1233 unmodified lines
12341234 object is near the sensor, usually be observing
12351235 reflectivity of infrared or ultrasound emitted.
12361236 Often these sensors are unit less and as such conversion
1237− to SI units is not possible. Where it is, the units should
1238− be meters. If such a conversion is not possible, the reported
1239− values should behave in the same way as a distance, i.e. lower
1240− values indicate something is closer to the sensor.
1237+ to SI units is not possible. Higher proximity measurements
1238+ indicate closer objects, and vice versa.
12411239
12421240 What: /sys/.../iio:deviceX/in_illuminance_input
12431241 What: /sys/.../iio:deviceX/in_illuminance_raw
drivers/iio/accel/bmc150-accel.c+1−1
@@ -1464,7 +1464,7 @@ static void bmc150_accel_unregister_triggers(struct bmc150_accel_data *data, · 1463 unmodified lines
14641464 {
14651465 int i;
14661466
1467− for (i = from; i >= 0; i++) {
1467+ for (i = from; i >= 0; i--) {
14681468 if (data->triggers[i].indio_trig) {
14691469 iio_trigger_unregister(data->triggers[i].indio_trig);
14701470 data->triggers[i].indio_trig = NULL;
drivers/iio/adc/Kconfig+1−2
@@ -153,8 +153,7 @@ config DA9150_GPADC · 152 unmodified lines
153153
154154 config CC10001_ADC
155155 tristate "Cosmic Circuits 10001 ADC driver"
156− depends on HAVE_CLK || REGULATOR
157− depends on HAS_IOMEM
156+ depends on HAS_IOMEM && HAVE_CLK && REGULATOR
158157 select IIO_BUFFER
159158 select IIO_TRIGGERED_BUFFER
160159 help
drivers/iio/adc/at91_adc.c+4−4
@@ -182,7 +182,7 @@ struct at91_adc_caps { · 181 unmodified lines
182182 u8 ts_pen_detect_sensitivity;
183183
184184 /* startup time calculate function */
185− u32 (*calc_startup_ticks)(u8 startup_time, u32 adc_clk_khz);
185+ u32 (*calc_startup_ticks)(u32 startup_time, u32 adc_clk_khz);
186186
187187 u8 num_channels;
188188 struct at91_adc_reg_desc registers;
@@ -201,7 +201,7 @@ struct at91_adc_state { · 12 unmodified lines
201201 u8 num_channels;
202202 void __iomem *reg_base;
203203 struct at91_adc_reg_desc *registers;
204− u8 startup_time;
204+ u32 startup_time;
205205 u8 sample_hold_time;
206206 bool sleep_mode;
207207 struct iio_trigger **trig;
@@ -779,7 +779,7 @@ ret: · 571 unmodified lines
779779 return ret;
780780 }
781781
782−static u32 calc_startup_ticks_9260(u8 startup_time, u32 adc_clk_khz)
782+static u32 calc_startup_ticks_9260(u32 startup_time, u32 adc_clk_khz)
783783 {
784784 /*
785785 * Number of ticks needed to cover the startup time of the ADC
@@ -790,7 +790,7 @@ static u32 calc_startup_ticks_9260(u8 startup_time, u32 adc_clk_khz) · 4 unmodified lines
790790 return round_up((startup_time * adc_clk_khz / 1000) - 1, 8) / 8;
791791 }
792792
793−static u32 calc_startup_ticks_9x5(u8 startup_time, u32 adc_clk_khz)
793+static u32 calc_startup_ticks_9x5(u32 startup_time, u32 adc_clk_khz)
794794 {
795795 /*
796796 * For sama5d3x and at91sam9x5, the formula changes to:
drivers/iio/adc/rockchip_saradc.c+4−0
@@ -349,3 +349,7 @@ static struct platform_driver rockchip_saradc_driver = { · 348 unmodified lines
349349 };
350350
351351 module_platform_driver(rockchip_saradc_driver);
352+
353+MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
354+MODULE_DESCRIPTION("Rockchip SARADC driver");
355+MODULE_LICENSE("GPL v2");
drivers/iio/adc/twl4030-madc.c+2−1
@@ -833,7 +833,8 @@ static int twl4030_madc_probe(struct platform_device *pdev) · 832 unmodified lines
833833 irq = platform_get_irq(pdev, 0);
834834 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
835835 twl4030_madc_threaded_irq_handler,
836− IRQF_TRIGGER_RISING, "twl4030_madc", madc);
836+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
837+ "twl4030_madc", madc);
837838 if (ret) {
838839 dev_err(&pdev->dev, "could not request irq\n");
839840 goto err_i2c;
drivers/iio/common/hid-sensors/hid-sensor-trigger.c+10−1
@@ -36,6 +36,8 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state) · 35 unmodified lines
3636 s32 poll_value = 0;
3737
3838 if (state) {
39+ if (!atomic_read(&st->user_requested_state))
40+ return 0;
3941 if (sensor_hub_device_open(st->hsdev))
4042 return -EIO;
4143
@@ -52,8 +54,12 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state) · 10 unmodified lines
5254
5355 poll_value = hid_sensor_read_poll_value(st);
5456 } else {
55− if (!atomic_dec_and_test(&st->data_ready))
57+ int val;
58+
59+ val = atomic_dec_if_positive(&st->data_ready);
60+ if (val < 0)
5661 return 0;
62+
5763 sensor_hub_device_close(st->hsdev);
5864 state_val = hid_sensor_get_usage_index(st->hsdev,
5965 st->power_state.report_id,
@@ -92,9 +98,11 @@ EXPORT_SYMBOL(hid_sensor_power_state); · 32 unmodified lines
9298
9399 int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
94100 {
101+
95102 #ifdef CONFIG_PM
96103 int ret;
97104
105+ atomic_set(&st->user_requested_state, state);
98106 if (state)
99107 ret = pm_runtime_get_sync(&st->pdev->dev);
100108 else {
@@ -109,6 +117,7 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state) · 8 unmodified lines
109117
110118 return 0;
111119 #else
120+ atomic_set(&st->user_requested_state, state);
112121 return _hid_sensor_power_state(st, state);
113122 #endif
114123 }
drivers/iio/dac/ad5624r_spi.c+2−2
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 #include "ad5624r.h"
2323
2424 static int ad5624r_spi_write(struct spi_device *spi,
25− u8 cmd, u8 addr, u16 val, u8 len)
25+ u8 cmd, u8 addr, u16 val, u8 shift)
2626 {
2727 u32 data;
2828 u8 msg[3];
@@ -35,7 +35,7 @@ static int ad5624r_spi_write(struct spi_device *spi, · 6 unmodified lines
3535 * 14-, 12-bit input code followed by 0, 2, or 4 don't care bits,
3636 * for the AD5664R, AD5644R, and AD5624R, respectively.
3737 */
38− data = (0 << 22) | (cmd << 19) | (addr << 16) | (val << (16 - len));
38+ data = (0 << 22) | (cmd << 19) | (addr << 16) | (val << shift);
3939 msg[0] = data >> 16;
4040 msg[1] = data >> 8;
4141 msg[2] = data;
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c+18−0
@@ -431,6 +431,23 @@ static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val) · 430 unmodified lines
431431 return -EINVAL;
432432 }
433433
434+static int inv_write_raw_get_fmt(struct iio_dev *indio_dev,
435+ struct iio_chan_spec const *chan, long mask)
436+{
437+ switch (mask) {
438+ case IIO_CHAN_INFO_SCALE:
439+ switch (chan->type) {
440+ case IIO_ANGL_VEL:
441+ return IIO_VAL_INT_PLUS_NANO;
442+ default:
443+ return IIO_VAL_INT_PLUS_MICRO;
444+ }
445+ default:
446+ return IIO_VAL_INT_PLUS_MICRO;
447+ }
448+
449+ return -EINVAL;
450+}
434451 static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val)
435452 {
436453 int result, i;
@@ -696,6 +713,7 @@ static const struct iio_info mpu_info = { · 259 unmodified lines
696713 .driver_module = THIS_MODULE,
697714 .read_raw = &inv_mpu6050_read_raw,
698715 .write_raw = &inv_mpu6050_write_raw,
716+ .write_raw_get_fmt = &inv_write_raw_get_fmt,
699717 .attrs = &inv_attribute_group,
700718 .validate_trigger = inv_mpu6050_validate_trigger,
701719 };
drivers/iio/light/cm3323.c+1−1
@@ -123,7 +123,7 @@ static int cm3323_set_it_bits(struct cm3323_data *data, int val, int val2) · 122 unmodified lines
123123 for (i = 0; i < ARRAY_SIZE(cm3323_int_time); i++) {
124124 if (val == cm3323_int_time[i].val &&
125125 val2 == cm3323_int_time[i].val2) {
126− reg_conf = data->reg_conf;
126+ reg_conf = data->reg_conf & ~CM3323_CONF_IT_MASK;
127127 reg_conf |= i << CM3323_CONF_IT_SHIFT;
128128
129129 ret = i2c_smbus_write_word_data(data->client,
drivers/iio/light/tcs3414.c+1−1
@@ -185,7 +185,7 @@ static int tcs3414_write_raw(struct iio_dev *indio_dev, · 184 unmodified lines
185185 if (val != 0)
186186 return -EINVAL;
187187 for (i = 0; i < ARRAY_SIZE(tcs3414_times); i++) {
188− if (val == tcs3414_times[i] * 1000) {
188+ if (val2 == tcs3414_times[i] * 1000) {
189189 data->timing &= ~TCS3414_INTEG_MASK;
190190 data->timing |= i;
191191 return i2c_smbus_write_byte_data(
drivers/iio/proximity/sx9500.c+1−1
@@ -281,7 +281,7 @@ static int sx9500_read_prox_data(struct sx9500_data *data, · 280 unmodified lines
281281 if (ret < 0)
282282 return ret;
283283
284− *val = 32767 - (s16)be16_to_cpu(regval);
284+ *val = be16_to_cpu(regval);
285285
286286 return IIO_VAL_INT;
287287 }
include/linux/hid-sensor-hub.h+1−0
@@ -230,6 +230,7 @@ struct hid_sensor_common { · 229 unmodified lines
230230 struct platform_device *pdev;
231231 unsigned usage_id;
232232 atomic_t data_ready;
233+ atomic_t user_requested_state;
233234 struct iio_trigger *trigger;
234235 struct hid_sensor_hub_attribute_info poll;
235236 struct hid_sensor_hub_attribute_info report_state;