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.
Unified · Split
| @@ -1234,10 +1234,8 @@ Description: · 1233 unmodified lines | |||
| 1234 | object is near the sensor, usually be observing | 1234 | object is near the sensor, usually be observing |
| 1235 | reflectivity of infrared or ultrasound emitted. | 1235 | reflectivity of infrared or ultrasound emitted. |
| 1236 | Often these sensors are unit less and as such conversion | 1236 | Often these sensors are unit less and as such conversion |
| 1237 | to SI units is not possible. Where it is, the units should | 1237 | to SI units is not possible. Higher proximity measurements |
| 1238 | be meters. If such a conversion is not possible, the reported | 1238 | indicate closer objects, and vice versa. |
| 1239 | values should behave in the same way as a distance, i.e. lower | ||
| 1240 | values indicate something is closer to the sensor. | ||
| 1241 | 1239 | ||
| 1242 | What: /sys/.../iio:deviceX/in_illuminance_input | 1240 | What: /sys/.../iio:deviceX/in_illuminance_input |
| 1243 | What: /sys/.../iio:deviceX/in_illuminance_raw | 1241 | What: /sys/.../iio:deviceX/in_illuminance_raw |
| @@ -1464,7 +1464,7 @@ static void bmc150_accel_unregister_triggers(struct bmc150_accel_data *data, · 1463 unmodified lines | |||
| 1464 | { | 1464 | { |
| 1465 | int i; | 1465 | int i; |
| 1466 | 1466 | ||
| 1467 | for (i = from; i >= 0; i++) { | 1467 | for (i = from; i >= 0; i--) { |
| 1468 | if (data->triggers[i].indio_trig) { | 1468 | if (data->triggers[i].indio_trig) { |
| 1469 | iio_trigger_unregister(data->triggers[i].indio_trig); | 1469 | iio_trigger_unregister(data->triggers[i].indio_trig); |
| 1470 | data->triggers[i].indio_trig = NULL; | 1470 | data->triggers[i].indio_trig = NULL; |
| @@ -153,8 +153,7 @@ config DA9150_GPADC · 152 unmodified lines | |||
| 153 | 153 | ||
| 154 | config CC10001_ADC | 154 | config CC10001_ADC |
| 155 | tristate "Cosmic Circuits 10001 ADC driver" | 155 | tristate "Cosmic Circuits 10001 ADC driver" |
| 156 | depends on HAVE_CLK || REGULATOR | 156 | depends on HAS_IOMEM && HAVE_CLK && REGULATOR |
| 157 | depends on HAS_IOMEM | ||
| 158 | select IIO_BUFFER | 157 | select IIO_BUFFER |
| 159 | select IIO_TRIGGERED_BUFFER | 158 | select IIO_TRIGGERED_BUFFER |
| 160 | help | 159 | help |
| @@ -182,7 +182,7 @@ struct at91_adc_caps { · 181 unmodified lines | |||
| 182 | u8 ts_pen_detect_sensitivity; | 182 | u8 ts_pen_detect_sensitivity; |
| 183 | 183 | ||
| 184 | /* startup time calculate function */ | 184 | /* 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); |
| 186 | 186 | ||
| 187 | u8 num_channels; | 187 | u8 num_channels; |
| 188 | struct at91_adc_reg_desc registers; | 188 | struct at91_adc_reg_desc registers; |
| @@ -201,7 +201,7 @@ struct at91_adc_state { · 12 unmodified lines | |||
| 201 | u8 num_channels; | 201 | u8 num_channels; |
| 202 | void __iomem *reg_base; | 202 | void __iomem *reg_base; |
| 203 | struct at91_adc_reg_desc *registers; | 203 | struct at91_adc_reg_desc *registers; |
| 204 | u8 startup_time; | 204 | u32 startup_time; |
| 205 | u8 sample_hold_time; | 205 | u8 sample_hold_time; |
| 206 | bool sleep_mode; | 206 | bool sleep_mode; |
| 207 | struct iio_trigger **trig; | 207 | struct iio_trigger **trig; |
| @@ -779,7 +779,7 @@ ret: · 571 unmodified lines | |||
| 779 | return ret; | 779 | return ret; |
| 780 | } | 780 | } |
| 781 | 781 | ||
| 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) |
| 783 | { | 783 | { |
| 784 | /* | 784 | /* |
| 785 | * Number of ticks needed to cover the startup time of the ADC | 785 | * 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 | |||
| 790 | return round_up((startup_time * adc_clk_khz / 1000) - 1, 8) / 8; | 790 | return round_up((startup_time * adc_clk_khz / 1000) - 1, 8) / 8; |
| 791 | } | 791 | } |
| 792 | 792 | ||
| 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) |
| 794 | { | 794 | { |
| 795 | /* | 795 | /* |
| 796 | * For sama5d3x and at91sam9x5, the formula changes to: | 796 | * For sama5d3x and at91sam9x5, the formula changes to: |
| @@ -349,3 +349,7 @@ static struct platform_driver rockchip_saradc_driver = { · 348 unmodified lines | |||
| 349 | }; | 349 | }; |
| 350 | 350 | ||
| 351 | module_platform_driver(rockchip_saradc_driver); | 351 | 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"); | ||
| @@ -833,7 +833,8 @@ static int twl4030_madc_probe(struct platform_device *pdev) · 832 unmodified lines | |||
| 833 | irq = platform_get_irq(pdev, 0); | 833 | irq = platform_get_irq(pdev, 0); |
| 834 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, | 834 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
| 835 | twl4030_madc_threaded_irq_handler, | 835 | twl4030_madc_threaded_irq_handler, |
| 836 | IRQF_TRIGGER_RISING, "twl4030_madc", madc); | 836 | IRQF_TRIGGER_RISING | IRQF_ONESHOT, |
| 837 | "twl4030_madc", madc); | ||
| 837 | if (ret) { | 838 | if (ret) { |
| 838 | dev_err(&pdev->dev, "could not request irq\n"); | 839 | dev_err(&pdev->dev, "could not request irq\n"); |
| 839 | goto err_i2c; | 840 | goto err_i2c; |
| @@ -36,6 +36,8 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state) · 35 unmodified lines | |||
| 36 | s32 poll_value = 0; | 36 | s32 poll_value = 0; |
| 37 | 37 | ||
| 38 | if (state) { | 38 | if (state) { |
| 39 | if (!atomic_read(&st->user_requested_state)) | ||
| 40 | return 0; | ||
| 39 | if (sensor_hub_device_open(st->hsdev)) | 41 | if (sensor_hub_device_open(st->hsdev)) |
| 40 | return -EIO; | 42 | return -EIO; |
| 41 | 43 | ||
| @@ -52,8 +54,12 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state) · 10 unmodified lines | |||
| 52 | 54 | ||
| 53 | poll_value = hid_sensor_read_poll_value(st); | 55 | poll_value = hid_sensor_read_poll_value(st); |
| 54 | } else { | 56 | } 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) | ||
| 56 | return 0; | 61 | return 0; |
| 62 | |||
| 57 | sensor_hub_device_close(st->hsdev); | 63 | sensor_hub_device_close(st->hsdev); |
| 58 | state_val = hid_sensor_get_usage_index(st->hsdev, | 64 | state_val = hid_sensor_get_usage_index(st->hsdev, |
| 59 | st->power_state.report_id, | 65 | st->power_state.report_id, |
| @@ -92,9 +98,11 @@ EXPORT_SYMBOL(hid_sensor_power_state); · 32 unmodified lines | |||
| 92 | 98 | ||
| 93 | int hid_sensor_power_state(struct hid_sensor_common *st, bool state) | 99 | int hid_sensor_power_state(struct hid_sensor_common *st, bool state) |
| 94 | { | 100 | { |
| 101 | |||
| 95 | #ifdef CONFIG_PM | 102 | #ifdef CONFIG_PM |
| 96 | int ret; | 103 | int ret; |
| 97 | 104 | ||
| 105 | atomic_set(&st->user_requested_state, state); | ||
| 98 | if (state) | 106 | if (state) |
| 99 | ret = pm_runtime_get_sync(&st->pdev->dev); | 107 | ret = pm_runtime_get_sync(&st->pdev->dev); |
| 100 | else { | 108 | else { |
| @@ -109,6 +117,7 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state) · 8 unmodified lines | |||
| 109 | 117 | ||
| 110 | return 0; | 118 | return 0; |
| 111 | #else | 119 | #else |
| 120 | atomic_set(&st->user_requested_state, state); | ||
| 112 | return _hid_sensor_power_state(st, state); | 121 | return _hid_sensor_power_state(st, state); |
| 113 | #endif | 122 | #endif |
| 114 | } | 123 | } |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | #include "ad5624r.h" | 22 | #include "ad5624r.h" |
| 23 | 23 | ||
| 24 | static int ad5624r_spi_write(struct spi_device *spi, | 24 | 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) |
| 26 | { | 26 | { |
| 27 | u32 data; | 27 | u32 data; |
| 28 | u8 msg[3]; | 28 | u8 msg[3]; |
| @@ -35,7 +35,7 @@ static int ad5624r_spi_write(struct spi_device *spi, · 6 unmodified lines | |||
| 35 | * 14-, 12-bit input code followed by 0, 2, or 4 don't care bits, | 35 | * 14-, 12-bit input code followed by 0, 2, or 4 don't care bits, |
| 36 | * for the AD5664R, AD5644R, and AD5624R, respectively. | 36 | * for the AD5664R, AD5644R, and AD5624R, respectively. |
| 37 | */ | 37 | */ |
| 38 | data = (0 << 22) | (cmd << 19) | (addr << 16) | (val << (16 - len)); | 38 | data = (0 << 22) | (cmd << 19) | (addr << 16) | (val << shift); |
| 39 | msg[0] = data >> 16; | 39 | msg[0] = data >> 16; |
| 40 | msg[1] = data >> 8; | 40 | msg[1] = data >> 8; |
| 41 | msg[2] = data; | 41 | msg[2] = data; |
| @@ -431,6 +431,23 @@ static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val) · 430 unmodified lines | |||
| 431 | return -EINVAL; | 431 | return -EINVAL; |
| 432 | } | 432 | } |
| 433 | 433 | ||
| 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 | } | ||
| 434 | static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val) | 451 | static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val) |
| 435 | { | 452 | { |
| 436 | int result, i; | 453 | int result, i; |
| @@ -696,6 +713,7 @@ static const struct iio_info mpu_info = { · 259 unmodified lines | |||
| 696 | .driver_module = THIS_MODULE, | 713 | .driver_module = THIS_MODULE, |
| 697 | .read_raw = &inv_mpu6050_read_raw, | 714 | .read_raw = &inv_mpu6050_read_raw, |
| 698 | .write_raw = &inv_mpu6050_write_raw, | 715 | .write_raw = &inv_mpu6050_write_raw, |
| 716 | .write_raw_get_fmt = &inv_write_raw_get_fmt, | ||
| 699 | .attrs = &inv_attribute_group, | 717 | .attrs = &inv_attribute_group, |
| 700 | .validate_trigger = inv_mpu6050_validate_trigger, | 718 | .validate_trigger = inv_mpu6050_validate_trigger, |
| 701 | }; | 719 | }; |
| @@ -123,7 +123,7 @@ static int cm3323_set_it_bits(struct cm3323_data *data, int val, int val2) · 122 unmodified lines | |||
| 123 | for (i = 0; i < ARRAY_SIZE(cm3323_int_time); i++) { | 123 | for (i = 0; i < ARRAY_SIZE(cm3323_int_time); i++) { |
| 124 | if (val == cm3323_int_time[i].val && | 124 | if (val == cm3323_int_time[i].val && |
| 125 | val2 == cm3323_int_time[i].val2) { | 125 | val2 == cm3323_int_time[i].val2) { |
| 126 | reg_conf = data->reg_conf; | 126 | reg_conf = data->reg_conf & ~CM3323_CONF_IT_MASK; |
| 127 | reg_conf |= i << CM3323_CONF_IT_SHIFT; | 127 | reg_conf |= i << CM3323_CONF_IT_SHIFT; |
| 128 | 128 | ||
| 129 | ret = i2c_smbus_write_word_data(data->client, | 129 | ret = i2c_smbus_write_word_data(data->client, |
| @@ -185,7 +185,7 @@ static int tcs3414_write_raw(struct iio_dev *indio_dev, · 184 unmodified lines | |||
| 185 | if (val != 0) | 185 | if (val != 0) |
| 186 | return -EINVAL; | 186 | return -EINVAL; |
| 187 | for (i = 0; i < ARRAY_SIZE(tcs3414_times); i++) { | 187 | for (i = 0; i < ARRAY_SIZE(tcs3414_times); i++) { |
| 188 | if (val == tcs3414_times[i] * 1000) { | 188 | if (val2 == tcs3414_times[i] * 1000) { |
| 189 | data->timing &= ~TCS3414_INTEG_MASK; | 189 | data->timing &= ~TCS3414_INTEG_MASK; |
| 190 | data->timing |= i; | 190 | data->timing |= i; |
| 191 | return i2c_smbus_write_byte_data( | 191 | return i2c_smbus_write_byte_data( |
| @@ -281,7 +281,7 @@ static int sx9500_read_prox_data(struct sx9500_data *data, · 280 unmodified lines | |||
| 281 | if (ret < 0) | 281 | if (ret < 0) |
| 282 | return ret; | 282 | return ret; |
| 283 | 283 | ||
| 284 | *val = 32767 - (s16)be16_to_cpu(regval); | 284 | *val = be16_to_cpu(regval); |
| 285 | 285 | ||
| 286 | return IIO_VAL_INT; | 286 | return IIO_VAL_INT; |
| 287 | } | 287 | } |
| @@ -230,6 +230,7 @@ struct hid_sensor_common { · 229 unmodified lines | |||
| 230 | struct platform_device *pdev; | 230 | struct platform_device *pdev; |
| 231 | unsigned usage_id; | 231 | unsigned usage_id; |
| 232 | atomic_t data_ready; | 232 | atomic_t data_ready; |
| 233 | atomic_t user_requested_state; | ||
| 233 | struct iio_trigger *trigger; | 234 | struct iio_trigger *trigger; |
| 234 | struct hid_sensor_hub_attribute_info poll; | 235 | struct hid_sensor_hub_attribute_info poll; |
| 235 | struct hid_sensor_hub_attribute_info report_state; | 236 | struct hid_sensor_hub_attribute_info report_state; |