Second set of IIO fixes for the 4.12 cycle.
* buffer-dma / buffer-dmaengine - Fix missing include of buffer_impl.h after the split of buffer.h. No driver in mainline is currently using these buffers so it wasn't picked up by automated build tests. * ad7152 - Fix a deadlock in ad7152_write_raw_samp_freq as the chip_state lock was already held. * inv_mpu6050 - Add low pass filter setting for chips newer than the MPU6500. None of use previously picked up no the fact it was different on these newer chips. It is separately set for the acceleration on these parts. There is no normal reason to set it differently so the userspace interface remains the same as for early parts. * meson-saradc: - Fix a potential crash by NULL pointer dereference in meson_sar_adc_clear_fifo. * mxs-lradc - Fix a return value check where IS_ERR is used on a function that returns NULL on error -----BEGIN PGP SIGNATURE----- iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAllARKwRHGppYzIzQGtl cm5lbC5vcmcACgkQVIU0mcT0FogGDQ/+Px3R3gtIha1velSGg8MU+pjYZpblhEtM GVfY+1uN0uEL9KHJqnnAPJHxlpkKr1BUg6fR7/EwJkRULg8YkWbSb2ZKcdZqiE+U LyEfLpZrNdw3P5q+u44LkX+HBvhr5QUqlnHj7fG8T7oG2W/mryVZPDTfv/gBXJo3 SiiCv1HKWvdU99lrcALG1T/CZRx8PDrBKcxHhaTYWGFUmyIS67AGIRV3+khs7m9e pWgSd1iV2AUEhWaRQ/KSpbv9c7pvymjEq8AHCqTvXjc0kcwETUkxuiGXh8zI53Nr +rOzuB18RO+9o87uWSDBzfqntinMeIQYmgr471UsgpjaB0CDP/V8cGwnmzlf1/39 gWm2PF5AReagkPaf8cMBUdTJJsUYNcGI9B8w9MNt5DRIxGWPsl/RhP4hd+h9Ncfx gHByZYVV3KEt0GCw6JweEmi4P+GgRpoFRAYBwhrlr6a6zau27q9LqjEenj1wNoA1 VlTluEULB8HPDuDeI9wSFvzX2mOua4Ogo7QvKwDa+6QYukMbuOwaZ+/D7HxrFLzE XT7kcbuSXvVSQny+OHTRbYjq7VFMvYBURNkjQiSRL76ADO0VPt3sEafAsoiVVlIm C7NG/U8on051scb1VzmnEHeC0S5UkftCiBKrsIrWHU+6CiGpro7Avi9a+iar2hYj feFKQwMn978= =BU6h -----END PGP SIGNATURE----- Merge tag 'iio-fixes-for-4.12b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus Jonathan writes: Second set of IIO fixes for the 4.12 cycle. * buffer-dma / buffer-dmaengine - Fix missing include of buffer_impl.h after the split of buffer.h. No driver in mainline is currently using these buffers so it wasn't picked up by automated build tests. * ad7152 - Fix a deadlock in ad7152_write_raw_samp_freq as the chip_state lock was already held. * inv_mpu6050 - Add low pass filter setting for chips newer than the MPU6500. None of use previously picked up no the fact it was different on these newer chips. It is separately set for the acceleration on these parts. There is no normal reason to set it differently so the userspace interface remains the same as for early parts. * meson-saradc: - Fix a potential crash by NULL pointer dereference in meson_sar_adc_clear_fifo. * mxs-lradc - Fix a return value check where IS_ERR is used on a function that returns NULL on error
This commit is contained in:
commit
64c667fe29
|
@ -468,13 +468,13 @@ static void meson_sar_adc_unlock(struct iio_dev *indio_dev)
|
|||
static void meson_sar_adc_clear_fifo(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
|
||||
int count;
|
||||
unsigned int count, tmp;
|
||||
|
||||
for (count = 0; count < MESON_SAR_ADC_MAX_FIFO_SIZE; count++) {
|
||||
if (!meson_sar_adc_get_fifo_count(indio_dev))
|
||||
break;
|
||||
|
||||
regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0);
|
||||
regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, &tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -718,9 +718,12 @@ static int mxs_lradc_adc_probe(struct platform_device *pdev)
|
|||
adc->dev = dev;
|
||||
|
||||
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!iores)
|
||||
return -EINVAL;
|
||||
|
||||
adc->base = devm_ioremap(dev, iores->start, resource_size(iores));
|
||||
if (IS_ERR(adc->base))
|
||||
return PTR_ERR(adc->base);
|
||||
if (!adc->base)
|
||||
return -ENOMEM;
|
||||
|
||||
init_completion(&adc->completion);
|
||||
spin_lock_init(&adc->lock);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <linux/sched.h>
|
||||
#include <linux/poll.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include <linux/iio/buffer_impl.h>
|
||||
#include <linux/iio/buffer-dma.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/sizes.h>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include <linux/iio/buffer_impl.h>
|
||||
#include <linux/iio/buffer-dma.h>
|
||||
#include <linux/iio/buffer-dmaengine.h>
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ static const int accel_scale[] = {598, 1196, 2392, 4785};
|
|||
static const struct inv_mpu6050_reg_map reg_set_6500 = {
|
||||
.sample_rate_div = INV_MPU6050_REG_SAMPLE_RATE_DIV,
|
||||
.lpf = INV_MPU6050_REG_CONFIG,
|
||||
.accel_lpf = INV_MPU6500_REG_ACCEL_CONFIG_2,
|
||||
.user_ctrl = INV_MPU6050_REG_USER_CTRL,
|
||||
.fifo_en = INV_MPU6050_REG_FIFO_EN,
|
||||
.gyro_config = INV_MPU6050_REG_GYRO_CONFIG,
|
||||
|
@ -210,6 +211,37 @@ int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st, bool power_on)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(inv_mpu6050_set_power_itg);
|
||||
|
||||
/**
|
||||
* inv_mpu6050_set_lpf_regs() - set low pass filter registers, chip dependent
|
||||
*
|
||||
* MPU60xx/MPU9150 use only 1 register for accelerometer + gyroscope
|
||||
* MPU6500 and above have a dedicated register for accelerometer
|
||||
*/
|
||||
static int inv_mpu6050_set_lpf_regs(struct inv_mpu6050_state *st,
|
||||
enum inv_mpu6050_filter_e val)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = regmap_write(st->map, st->reg->lpf, val);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
switch (st->chip_type) {
|
||||
case INV_MPU6050:
|
||||
case INV_MPU6000:
|
||||
case INV_MPU9150:
|
||||
/* old chips, nothing to do */
|
||||
result = 0;
|
||||
break;
|
||||
default:
|
||||
/* set accel lpf */
|
||||
result = regmap_write(st->map, st->reg->accel_lpf, val);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* inv_mpu6050_init_config() - Initialize hardware, disable FIFO.
|
||||
*
|
||||
|
@ -233,8 +265,7 @@ static int inv_mpu6050_init_config(struct iio_dev *indio_dev)
|
|||
if (result)
|
||||
return result;
|
||||
|
||||
d = INV_MPU6050_FILTER_20HZ;
|
||||
result = regmap_write(st->map, st->reg->lpf, d);
|
||||
result = inv_mpu6050_set_lpf_regs(st, INV_MPU6050_FILTER_20HZ);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
|
@ -537,6 +568,8 @@ error_write_raw:
|
|||
* would be alising. This function basically search for the
|
||||
* correct low pass parameters based on the fifo rate, e.g,
|
||||
* sampling frequency.
|
||||
*
|
||||
* lpf is set automatically when setting sampling rate to avoid any aliases.
|
||||
*/
|
||||
static int inv_mpu6050_set_lpf(struct inv_mpu6050_state *st, int rate)
|
||||
{
|
||||
|
@ -552,7 +585,7 @@ static int inv_mpu6050_set_lpf(struct inv_mpu6050_state *st, int rate)
|
|||
while ((h < hz[i]) && (i < ARRAY_SIZE(d) - 1))
|
||||
i++;
|
||||
data = d[i];
|
||||
result = regmap_write(st->map, st->reg->lpf, data);
|
||||
result = inv_mpu6050_set_lpf_regs(st, data);
|
||||
if (result)
|
||||
return result;
|
||||
st->chip_config.lpf = data;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
* struct inv_mpu6050_reg_map - Notable registers.
|
||||
* @sample_rate_div: Divider applied to gyro output rate.
|
||||
* @lpf: Configures internal low pass filter.
|
||||
* @accel_lpf: Configures accelerometer low pass filter.
|
||||
* @user_ctrl: Enables/resets the FIFO.
|
||||
* @fifo_en: Determines which data will appear in FIFO.
|
||||
* @gyro_config: gyro config register.
|
||||
|
@ -47,6 +48,7 @@
|
|||
struct inv_mpu6050_reg_map {
|
||||
u8 sample_rate_div;
|
||||
u8 lpf;
|
||||
u8 accel_lpf;
|
||||
u8 user_ctrl;
|
||||
u8 fifo_en;
|
||||
u8 gyro_config;
|
||||
|
@ -188,6 +190,7 @@ struct inv_mpu6050_state {
|
|||
#define INV_MPU6050_FIFO_THRESHOLD 500
|
||||
|
||||
/* mpu6500 registers */
|
||||
#define INV_MPU6500_REG_ACCEL_CONFIG_2 0x1D
|
||||
#define INV_MPU6500_REG_ACCEL_OFFSET 0x77
|
||||
|
||||
/* delay time in milliseconds */
|
||||
|
|
|
@ -231,16 +231,12 @@ static int ad7152_write_raw_samp_freq(struct device *dev, int val)
|
|||
if (i >= ARRAY_SIZE(ad7152_filter_rate_table))
|
||||
i = ARRAY_SIZE(ad7152_filter_rate_table) - 1;
|
||||
|
||||
mutex_lock(&chip->state_lock);
|
||||
ret = i2c_smbus_write_byte_data(chip->client,
|
||||
AD7152_REG_CFG2, AD7152_CFG2_OSR(i));
|
||||
if (ret < 0) {
|
||||
mutex_unlock(&chip->state_lock);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
chip->filter_rate_setup = i;
|
||||
mutex_unlock(&chip->state_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue