mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 23:52:08 +02:00
IIO: 2nd set of fixes for the 6.8 cycle.
Given this is very late these can wait for the 6.9 cycle if you would prefer. adi,adxl367 - Sleep for 15ms after reset to avoid reading before the device is awake. - Fix FIFO register address. asc,dlhl60d - Avoid uninitialized data leak to user-space. Also suppress a false positive clang warning by refactoring a loop. bosch,bmp280 - Fix missing extra byte in SPI reads from BMP38x and BMP390 parts invensense,mpu6050 - Fix handing of empty FIFO which can happen due to a race condition. - Make sure frequency can be updated more than once when the FIFO is not enabled. -----BEGIN PGP SIGNATURE----- iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmXg4zARHGppYzIzQGtl cm5lbC5vcmcACgkQVIU0mcT0FojvOA/9ElIJd9yBUa4jMXI5802ehOH8DbKvbge1 3LKL9UpGphsaWqPnPsffRAlmAu0dZR52M5wfbiZqJnMHNK6soiXqOINsdYkHPVFk 7mb3mlnkZIA5H5mIaeHz+cwBK3xESryN8G8hEjtTLHh7TgBbq/ooEYbBIznJjIhx 3TMpqVQwi264L6vYbQ1gOuc9ordtAzBGqnxSRaBKO4InZpxMYz9M9gzqmLFuXlum GPl7c8BhgoiqzD7p+V7nZh4FKlTw7++pdEdFEk28uU0rkMhtMYpC8nG5K9OJyvMM HMvnxPgCzL/ig4oLP40W7va8CRZezA1Klw9V5iVfcqBF3rrv4ynPWTP6KeyUjCJU qttftBkSrAt6S5f6pC/h9BCTYx/A76S05UHJ/ssjT/B65F+RMuVSgkNb6H+qtI4d 708BXTDSLTzOLKvzWW9r/0ZBmayZFyxAUFTfdISJUQu6ZGMYjZegzonSRrWm+bSJ KxvboQ4y9MOH2w58xshv0GvbIqYKGsCXBnP2CKPmJ26jHeLzxl7IGDMwNWNabsWN +1gKxRZjLov6/0CAP05K4p6iEB0frfndkXtbzvL+25Qhgx8uiVcFcblJ88CeNukG BHXCwFV0k8HeiUTjSDEsNVu8Fk+JzjqZBHL193gED+srKazG+NK559b4ZElpTeSg +rD65E/1w9k= =RRmO -----END PGP SIGNATURE----- Merge tag 'iio-fixes-for-6.8b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus Jonathan writes: IIO: 2nd set of fixes for the 6.8 cycle. Given this is very late these can wait for the 6.9 cycle if you would prefer. adi,adxl367 - Sleep for 15ms after reset to avoid reading before the device is awake. - Fix FIFO register address. asc,dlhl60d - Avoid uninitialized data leak to user-space. Also suppress a false positive clang warning by refactoring a loop. bosch,bmp280 - Fix missing extra byte in SPI reads from BMP38x and BMP390 parts invensense,mpu6050 - Fix handing of empty FIFO which can happen due to a race condition. - Make sure frequency can be updated more than once when the FIFO is not enabled. * tag 'iio-fixes-for-6.8b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: accel: adxl367: fix I2C FIFO data register iio: accel: adxl367: fix DEVID read after reset iio: pressure: dlhl60d: Initialize empty DLH bytes iio: imu: inv_mpu6050: fix frequency setting when chip is off iio: pressure: Fixes BMP38x and BMP390 SPI support iio: imu: inv_mpu6050: fix FIFO parsing when empty
This commit is contained in:
commit
da85c25cdb
|
|
@ -1429,9 +1429,11 @@ static int adxl367_verify_devid(struct adxl367_state *st)
|
|||
unsigned int val;
|
||||
int ret;
|
||||
|
||||
ret = regmap_read_poll_timeout(st->regmap, ADXL367_REG_DEVID, val,
|
||||
val == ADXL367_DEVID_AD, 1000, 10000);
|
||||
ret = regmap_read(st->regmap, ADXL367_REG_DEVID, &val);
|
||||
if (ret)
|
||||
return dev_err_probe(st->dev, ret, "Failed to read dev id\n");
|
||||
|
||||
if (val != ADXL367_DEVID_AD)
|
||||
return dev_err_probe(st->dev, -ENODEV,
|
||||
"Invalid dev id 0x%02X, expected 0x%02X\n",
|
||||
val, ADXL367_DEVID_AD);
|
||||
|
|
@ -1510,6 +1512,8 @@ int adxl367_probe(struct device *dev, const struct adxl367_ops *ops,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
fsleep(15000);
|
||||
|
||||
ret = adxl367_verify_devid(st);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "adxl367.h"
|
||||
|
||||
#define ADXL367_I2C_FIFO_DATA 0x42
|
||||
#define ADXL367_I2C_FIFO_DATA 0x18
|
||||
|
||||
struct adxl367_i2c_state {
|
||||
struct regmap *regmap;
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
|
|||
/* compute and process only all complete datum */
|
||||
nb = fifo_count / bytes_per_datum;
|
||||
fifo_count = nb * bytes_per_datum;
|
||||
if (nb == 0)
|
||||
goto end_session;
|
||||
/* Each FIFO data contains all sensors, so same number for FIFO and sensor data */
|
||||
fifo_period = NSEC_PER_SEC / INV_MPU6050_DIVIDER_TO_FIFO_RATE(st->chip_config.divider);
|
||||
inv_sensors_timestamp_interrupt(&st->timestamp, fifo_period, nb, nb, pf->timestamp);
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ int inv_mpu6050_prepare_fifo(struct inv_mpu6050_state *st, bool enable)
|
|||
if (enable) {
|
||||
/* reset timestamping */
|
||||
inv_sensors_timestamp_reset(&st->timestamp);
|
||||
inv_sensors_timestamp_apply_odr(&st->timestamp, 0, 0, 0);
|
||||
/* reset FIFO */
|
||||
d = st->chip_config.user_ctrl | INV_MPU6050_BIT_FIFO_RST;
|
||||
ret = regmap_write(st->map, st->reg->user_ctrl, d);
|
||||
|
|
@ -184,6 +185,10 @@ static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable)
|
|||
if (result)
|
||||
goto error_power_off;
|
||||
} else {
|
||||
st->chip_config.gyro_fifo_enable = 0;
|
||||
st->chip_config.accl_fifo_enable = 0;
|
||||
st->chip_config.temp_fifo_enable = 0;
|
||||
st->chip_config.magn_fifo_enable = 0;
|
||||
result = inv_mpu6050_prepare_fifo(st, false);
|
||||
if (result)
|
||||
goto error_power_off;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
*
|
||||
* Inspired by the older BMP085 driver drivers/misc/bmp085-spi.c
|
||||
*/
|
||||
#include <linux/bits.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/err.h>
|
||||
|
|
@ -35,6 +36,34 @@ static int bmp280_regmap_spi_read(void *context, const void *reg,
|
|||
return spi_write_then_read(spi, reg, reg_size, val, val_size);
|
||||
}
|
||||
|
||||
static int bmp380_regmap_spi_read(void *context, const void *reg,
|
||||
size_t reg_size, void *val, size_t val_size)
|
||||
{
|
||||
struct spi_device *spi = to_spi_device(context);
|
||||
u8 rx_buf[4];
|
||||
ssize_t status;
|
||||
|
||||
/*
|
||||
* Maximum number of consecutive bytes read for a temperature or
|
||||
* pressure measurement is 3.
|
||||
*/
|
||||
if (val_size > 3)
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
* According to the BMP3xx datasheets, for a basic SPI read opertion,
|
||||
* the first byte needs to be dropped and the rest are the requested
|
||||
* data.
|
||||
*/
|
||||
status = spi_write_then_read(spi, reg, 1, rx_buf, val_size + 1);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
memcpy(val, rx_buf + 1, val_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct regmap_bus bmp280_regmap_bus = {
|
||||
.write = bmp280_regmap_spi_write,
|
||||
.read = bmp280_regmap_spi_read,
|
||||
|
|
@ -42,10 +71,19 @@ static struct regmap_bus bmp280_regmap_bus = {
|
|||
.val_format_endian_default = REGMAP_ENDIAN_BIG,
|
||||
};
|
||||
|
||||
static struct regmap_bus bmp380_regmap_bus = {
|
||||
.write = bmp280_regmap_spi_write,
|
||||
.read = bmp380_regmap_spi_read,
|
||||
.read_flag_mask = BIT(7),
|
||||
.reg_format_endian_default = REGMAP_ENDIAN_BIG,
|
||||
.val_format_endian_default = REGMAP_ENDIAN_BIG,
|
||||
};
|
||||
|
||||
static int bmp280_spi_probe(struct spi_device *spi)
|
||||
{
|
||||
const struct spi_device_id *id = spi_get_device_id(spi);
|
||||
const struct bmp280_chip_info *chip_info;
|
||||
struct regmap_bus *bmp_regmap_bus;
|
||||
struct regmap *regmap;
|
||||
int ret;
|
||||
|
||||
|
|
@ -58,8 +96,18 @@ static int bmp280_spi_probe(struct spi_device *spi)
|
|||
|
||||
chip_info = spi_get_device_match_data(spi);
|
||||
|
||||
switch (chip_info->chip_id[0]) {
|
||||
case BMP380_CHIP_ID:
|
||||
case BMP390_CHIP_ID:
|
||||
bmp_regmap_bus = &bmp380_regmap_bus;
|
||||
break;
|
||||
default:
|
||||
bmp_regmap_bus = &bmp280_regmap_bus;
|
||||
break;
|
||||
}
|
||||
|
||||
regmap = devm_regmap_init(&spi->dev,
|
||||
&bmp280_regmap_bus,
|
||||
bmp_regmap_bus,
|
||||
&spi->dev,
|
||||
chip_info->regmap_config);
|
||||
if (IS_ERR(regmap)) {
|
||||
|
|
|
|||
|
|
@ -250,18 +250,17 @@ static irqreturn_t dlh_trigger_handler(int irq, void *private)
|
|||
struct dlh_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
unsigned int chn, i = 0;
|
||||
__be32 tmp_buf[2];
|
||||
__be32 tmp_buf[2] = { };
|
||||
|
||||
ret = dlh_start_capture_and_read(st);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
for_each_set_bit(chn, indio_dev->active_scan_mask,
|
||||
indio_dev->masklength) {
|
||||
memcpy(tmp_buf + i,
|
||||
indio_dev->masklength) {
|
||||
memcpy(&tmp_buf[i++],
|
||||
&st->rx_buf[1] + chn * DLH_NUM_DATA_BYTES,
|
||||
DLH_NUM_DATA_BYTES);
|
||||
i++;
|
||||
}
|
||||
|
||||
iio_push_to_buffers(indio_dev, tmp_buf);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user