mirror of
https://github.com/torvalds/linux.git
synced 2024-12-25 20:32:22 +00:00
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. -----BEGIN PGP SIGNATURE----- iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAljhUpERHGppYzIzQGtl cm5lbC5vcmcACgkQVIU0mcT0FohP6hAAlxAc6ym+jhevC8E4KXoZ+zoOGiHfjo/a 89LEMXO9+xonhELQ+80taljOLm/PFUFzoCyhTjBFGf2UJQurev31f3goKrGU9YiC FFInSUBrF3XoC3mOv49exI30hQg/9jghYiQplHDF/Zc8x0k49IlrJ48AvW4obvsP rcHUEqTrQ8Pg7aHa/OxSAGhLyjD/DpbdGDB5W8MaWz0/MxRkx8cYx44F6lLSIeni zN52msf9HtZIGiQ8bA0qgGJHgCg37A8x8JKYVRJ0MQpWYwuq/w+B1R8qOTRHVQiI WOdUr/a0W85WVxEX0/fUtJYnqNphs03Tmc/TGFKf/HAkbaX/QXp6zadWo6D/mY1a slQ6nGkEiY4OcA1McueHDurFP6KxbWX/VtJ2MsZG8tWyOUERRZWYbxdLfKKT0DrI A9EGOnbvJ1QlYlIDU/0NF6ACn6kbPVtpS06KGlVGb4LQSxm0yojKHaDZyQ3bSkCV XbAeu+dfIXUEoKHbsgiRgSu6hRCqSvP+JcavNI24vkWwyCEWO5s8GmZGXs6Zz/6I EjCZuBv19lGmN+xO+/ThsyaAUUdq6C9ft0LUKup80u9B914VuDC2kqYfbZSzqD7e /7CJojQfuaxaK0ZQfclRJ3njvdc0rbmQmXv+DG3mPBrvW0mmfRRWmFVH+Gk4HD1X SvgIjZFdiV8= =ike+ -----END PGP SIGNATURE----- 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.
This commit is contained in:
commit
a6d361404d
@ -370,10 +370,12 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
|
||||
name = "accel_3d";
|
||||
channel_spec = accel_3d_channels;
|
||||
channel_size = sizeof(accel_3d_channels);
|
||||
indio_dev->num_channels = ARRAY_SIZE(accel_3d_channels);
|
||||
} else {
|
||||
name = "gravity";
|
||||
channel_spec = gravity_channels;
|
||||
channel_size = sizeof(gravity_channels);
|
||||
indio_dev->num_channels = ARRAY_SIZE(gravity_channels);
|
||||
}
|
||||
ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage,
|
||||
&accel_state->common_attributes);
|
||||
@ -395,7 +397,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
|
||||
goto error_free_dev_mem;
|
||||
}
|
||||
|
||||
indio_dev->num_channels = ARRAY_SIZE(accel_3d_channels);
|
||||
indio_dev->dev.parent = &pdev->dev;
|
||||
indio_dev->info = &accel_3d_info;
|
||||
indio_dev->name = name;
|
||||
|
@ -61,7 +61,7 @@ static int cros_ec_sensors_read(struct iio_dev *indio_dev,
|
||||
ret = st->core.read_ec_sensors_data(indio_dev, 1 << idx, &data);
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
ret = IIO_VAL_INT;
|
||||
*val = data;
|
||||
break;
|
||||
case IIO_CHAN_INFO_CALIBBIAS:
|
||||
@ -76,7 +76,7 @@ static int cros_ec_sensors_read(struct iio_dev *indio_dev,
|
||||
for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++)
|
||||
st->core.calib[i] =
|
||||
st->core.resp->sensor_offset.offset[i];
|
||||
|
||||
ret = IIO_VAL_INT;
|
||||
*val = st->core.calib[idx];
|
||||
break;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
|
@ -379,6 +379,8 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
|
||||
{
|
||||
|
||||
struct hid_sensor_hub_attribute_info timestamp;
|
||||
s32 value;
|
||||
int ret;
|
||||
|
||||
hid_sensor_get_reporting_interval(hsdev, usage_id, st);
|
||||
|
||||
@ -417,6 +419,14 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
|
||||
st->sensitivity.index, st->sensitivity.report_id,
|
||||
timestamp.index, timestamp.report_id);
|
||||
|
||||
ret = sensor_hub_get_feature(hsdev,
|
||||
st->power_state.report_id,
|
||||
st->power_state.index, sizeof(value), &value);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (value < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(hid_sensor_parse_common_attributes);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <linux/iio/trigger_consumer.h>
|
||||
#include <linux/iio/triggered_buffer.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/delay.h>
|
||||
#include "bmg160.h"
|
||||
|
||||
#define BMG160_IRQ_NAME "bmg160_event"
|
||||
@ -52,6 +53,9 @@
|
||||
#define BMG160_DEF_BW 100
|
||||
#define BMG160_REG_PMU_BW_RES BIT(7)
|
||||
|
||||
#define BMG160_GYRO_REG_RESET 0x14
|
||||
#define BMG160_GYRO_RESET_VAL 0xb6
|
||||
|
||||
#define BMG160_REG_INT_MAP_0 0x17
|
||||
#define BMG160_INT_MAP_0_BIT_ANY BIT(1)
|
||||
|
||||
@ -236,6 +240,14 @@ static int bmg160_chip_init(struct bmg160_data *data)
|
||||
int ret;
|
||||
unsigned int val;
|
||||
|
||||
/*
|
||||
* Reset chip to get it in a known good state. A delay of 30ms after
|
||||
* reset is required according to the datasheet.
|
||||
*/
|
||||
regmap_write(data->regmap, BMG160_GYRO_REG_RESET,
|
||||
BMG160_GYRO_RESET_VAL);
|
||||
usleep_range(30000, 30700);
|
||||
|
||||
ret = regmap_read(data->regmap, BMG160_REG_CHIP_ID, &val);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Error reading reg_chip_id\n");
|
||||
|
@ -610,10 +610,9 @@ static ssize_t __iio_format_value(char *buf, size_t len, unsigned int type,
|
||||
tmp0 = (int)div_s64_rem(tmp, 1000000000, &tmp1);
|
||||
return snprintf(buf, len, "%d.%09u", tmp0, abs(tmp1));
|
||||
case IIO_VAL_FRACTIONAL_LOG2:
|
||||
tmp = (s64)vals[0] * 1000000000LL >> vals[1];
|
||||
tmp1 = do_div(tmp, 1000000000LL);
|
||||
tmp0 = tmp;
|
||||
return snprintf(buf, len, "%d.%09u", tmp0, tmp1);
|
||||
tmp = shift_right((s64)vals[0] * 1000000000LL, vals[1]);
|
||||
tmp0 = (int)div_s64_rem(tmp, 1000000000LL, &tmp1);
|
||||
return snprintf(buf, len, "%d.%09u", tmp0, abs(tmp1));
|
||||
case IIO_VAL_INT_MULTIPLE:
|
||||
{
|
||||
int i;
|
||||
|
@ -457,6 +457,7 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
|
||||
.addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR,
|
||||
},
|
||||
.multi_read_bit = true,
|
||||
.bootime = 2,
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user