diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-04-03 09:28:14 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-04-03 09:28:14 -0400 |
commit | a6d361404d81a03107a3475876afc22e1b84d5de (patch) | |
tree | 38434c6076ee2d8aee4ce952172254a0edfe1486 | |
parent | c02ed2e75ef4c74e41e421acb4ef1494671585e8 (diff) | |
parent | bba6d9e47f3ea894e501f94b086a59ffe28241ac (diff) |
Merge tag 'iio-fixes-for-4.11d' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus
4th set of IIO fixes for the 4.12 cycle.
core
- fix IIO_VAL_FRACTIONAL_LOG2 handling for negative values.
bmg160
- reset chip on probe to avoid a failure on some systems
cros_ec
- return type correctly when reading raw and calibbias data.
hid-sensor-accel
- fix a duplicate scan index error due to wrong number of channels
for gravity sensor.
hid-sensors
- ensure a get_feature is always done before the first set feature to
avoid issues with wrong cached values.
st-pressure
- initalize lps22hb boot time to avoid giving stale data.
-rw-r--r-- | drivers/iio/accel/hid-sensor-accel-3d.c | 3 | ||||
-rw-r--r-- | drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | 4 | ||||
-rw-r--r-- | drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 10 | ||||
-rw-r--r-- | drivers/iio/gyro/bmg160_core.c | 12 | ||||
-rw-r--r-- | drivers/iio/industrialio-core.c | 7 | ||||
-rw-r--r-- | drivers/iio/pressure/st_pressure_core.c | 1 |
6 files changed, 30 insertions, 7 deletions
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index ca5759c0c318..43a6cb078193 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c | |||
@@ -370,10 +370,12 @@ static int hid_accel_3d_probe(struct platform_device *pdev) | |||
370 | name = "accel_3d"; | 370 | name = "accel_3d"; |
371 | channel_spec = accel_3d_channels; | 371 | channel_spec = accel_3d_channels; |
372 | channel_size = sizeof(accel_3d_channels); | 372 | channel_size = sizeof(accel_3d_channels); |
373 | indio_dev->num_channels = ARRAY_SIZE(accel_3d_channels); | ||
373 | } else { | 374 | } else { |
374 | name = "gravity"; | 375 | name = "gravity"; |
375 | channel_spec = gravity_channels; | 376 | channel_spec = gravity_channels; |
376 | channel_size = sizeof(gravity_channels); | 377 | channel_size = sizeof(gravity_channels); |
378 | indio_dev->num_channels = ARRAY_SIZE(gravity_channels); | ||
377 | } | 379 | } |
378 | ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage, | 380 | ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage, |
379 | &accel_state->common_attributes); | 381 | &accel_state->common_attributes); |
@@ -395,7 +397,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev) | |||
395 | goto error_free_dev_mem; | 397 | goto error_free_dev_mem; |
396 | } | 398 | } |
397 | 399 | ||
398 | indio_dev->num_channels = ARRAY_SIZE(accel_3d_channels); | ||
399 | indio_dev->dev.parent = &pdev->dev; | 400 | indio_dev->dev.parent = &pdev->dev; |
400 | indio_dev->info = &accel_3d_info; | 401 | indio_dev->info = &accel_3d_info; |
401 | indio_dev->name = name; | 402 | indio_dev->name = name; |
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c index d6c372bb433b..c17596f7ed2c 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | |||
@@ -61,7 +61,7 @@ static int cros_ec_sensors_read(struct iio_dev *indio_dev, | |||
61 | ret = st->core.read_ec_sensors_data(indio_dev, 1 << idx, &data); | 61 | ret = st->core.read_ec_sensors_data(indio_dev, 1 << idx, &data); |
62 | if (ret < 0) | 62 | if (ret < 0) |
63 | break; | 63 | break; |
64 | 64 | ret = IIO_VAL_INT; | |
65 | *val = data; | 65 | *val = data; |
66 | break; | 66 | break; |
67 | case IIO_CHAN_INFO_CALIBBIAS: | 67 | case IIO_CHAN_INFO_CALIBBIAS: |
@@ -76,7 +76,7 @@ static int cros_ec_sensors_read(struct iio_dev *indio_dev, | |||
76 | for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++) | 76 | for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++) |
77 | st->core.calib[i] = | 77 | st->core.calib[i] = |
78 | st->core.resp->sensor_offset.offset[i]; | 78 | st->core.resp->sensor_offset.offset[i]; |
79 | 79 | ret = IIO_VAL_INT; | |
80 | *val = st->core.calib[idx]; | 80 | *val = st->core.calib[idx]; |
81 | break; | 81 | break; |
82 | case IIO_CHAN_INFO_SCALE: | 82 | case IIO_CHAN_INFO_SCALE: |
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c index 7afdac42ed42..01e02b9926d4 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c | |||
@@ -379,6 +379,8 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, | |||
379 | { | 379 | { |
380 | 380 | ||
381 | struct hid_sensor_hub_attribute_info timestamp; | 381 | struct hid_sensor_hub_attribute_info timestamp; |
382 | s32 value; | ||
383 | int ret; | ||
382 | 384 | ||
383 | hid_sensor_get_reporting_interval(hsdev, usage_id, st); | 385 | hid_sensor_get_reporting_interval(hsdev, usage_id, st); |
384 | 386 | ||
@@ -417,6 +419,14 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, | |||
417 | st->sensitivity.index, st->sensitivity.report_id, | 419 | st->sensitivity.index, st->sensitivity.report_id, |
418 | timestamp.index, timestamp.report_id); | 420 | timestamp.index, timestamp.report_id); |
419 | 421 | ||
422 | ret = sensor_hub_get_feature(hsdev, | ||
423 | st->power_state.report_id, | ||
424 | st->power_state.index, sizeof(value), &value); | ||
425 | if (ret < 0) | ||
426 | return ret; | ||
427 | if (value < 0) | ||
428 | return -EINVAL; | ||
429 | |||
420 | return 0; | 430 | return 0; |
421 | } | 431 | } |
422 | EXPORT_SYMBOL(hid_sensor_parse_common_attributes); | 432 | EXPORT_SYMBOL(hid_sensor_parse_common_attributes); |
diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index f7fcfa886f72..821919dd245b 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/iio/trigger_consumer.h> | 27 | #include <linux/iio/trigger_consumer.h> |
28 | #include <linux/iio/triggered_buffer.h> | 28 | #include <linux/iio/triggered_buffer.h> |
29 | #include <linux/regmap.h> | 29 | #include <linux/regmap.h> |
30 | #include <linux/delay.h> | ||
30 | #include "bmg160.h" | 31 | #include "bmg160.h" |
31 | 32 | ||
32 | #define BMG160_IRQ_NAME "bmg160_event" | 33 | #define BMG160_IRQ_NAME "bmg160_event" |
@@ -52,6 +53,9 @@ | |||
52 | #define BMG160_DEF_BW 100 | 53 | #define BMG160_DEF_BW 100 |
53 | #define BMG160_REG_PMU_BW_RES BIT(7) | 54 | #define BMG160_REG_PMU_BW_RES BIT(7) |
54 | 55 | ||
56 | #define BMG160_GYRO_REG_RESET 0x14 | ||
57 | #define BMG160_GYRO_RESET_VAL 0xb6 | ||
58 | |||
55 | #define BMG160_REG_INT_MAP_0 0x17 | 59 | #define BMG160_REG_INT_MAP_0 0x17 |
56 | #define BMG160_INT_MAP_0_BIT_ANY BIT(1) | 60 | #define BMG160_INT_MAP_0_BIT_ANY BIT(1) |
57 | 61 | ||
@@ -236,6 +240,14 @@ static int bmg160_chip_init(struct bmg160_data *data) | |||
236 | int ret; | 240 | int ret; |
237 | unsigned int val; | 241 | unsigned int val; |
238 | 242 | ||
243 | /* | ||
244 | * Reset chip to get it in a known good state. A delay of 30ms after | ||
245 | * reset is required according to the datasheet. | ||
246 | */ | ||
247 | regmap_write(data->regmap, BMG160_GYRO_REG_RESET, | ||
248 | BMG160_GYRO_RESET_VAL); | ||
249 | usleep_range(30000, 30700); | ||
250 | |||
239 | ret = regmap_read(data->regmap, BMG160_REG_CHIP_ID, &val); | 251 | ret = regmap_read(data->regmap, BMG160_REG_CHIP_ID, &val); |
240 | if (ret < 0) { | 252 | if (ret < 0) { |
241 | dev_err(dev, "Error reading reg_chip_id\n"); | 253 | dev_err(dev, "Error reading reg_chip_id\n"); |
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index d18ded45bedd..3ff91e02fee3 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c | |||
@@ -610,10 +610,9 @@ static ssize_t __iio_format_value(char *buf, size_t len, unsigned int type, | |||
610 | tmp0 = (int)div_s64_rem(tmp, 1000000000, &tmp1); | 610 | tmp0 = (int)div_s64_rem(tmp, 1000000000, &tmp1); |
611 | return snprintf(buf, len, "%d.%09u", tmp0, abs(tmp1)); | 611 | return snprintf(buf, len, "%d.%09u", tmp0, abs(tmp1)); |
612 | case IIO_VAL_FRACTIONAL_LOG2: | 612 | case IIO_VAL_FRACTIONAL_LOG2: |
613 | tmp = (s64)vals[0] * 1000000000LL >> vals[1]; | 613 | tmp = shift_right((s64)vals[0] * 1000000000LL, vals[1]); |
614 | tmp1 = do_div(tmp, 1000000000LL); | 614 | tmp0 = (int)div_s64_rem(tmp, 1000000000LL, &tmp1); |
615 | tmp0 = tmp; | 615 | return snprintf(buf, len, "%d.%09u", tmp0, abs(tmp1)); |
616 | return snprintf(buf, len, "%d.%09u", tmp0, tmp1); | ||
617 | case IIO_VAL_INT_MULTIPLE: | 616 | case IIO_VAL_INT_MULTIPLE: |
618 | { | 617 | { |
619 | int i; | 618 | int i; |
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 5f2680855552..fd0edca0e656 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c | |||
@@ -457,6 +457,7 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { | |||
457 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, | 457 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, |
458 | }, | 458 | }, |
459 | .multi_read_bit = true, | 459 | .multi_read_bit = true, |
460 | .bootime = 2, | ||
460 | }, | 461 | }, |
461 | }; | 462 | }; |
462 | 463 | ||