/* switch internal clock to PLL */
mgmt_1 |= INV_CLK_PLL;
result = regmap_write(st->map,
- st->reg->pwr_mgmt_1, mgmt_1);
+ st->reg->pwr_mgmt_1, mgmt_1);
if (result)
return result;
}
return result;
memcpy(&st->chip_config, hw_info[st->chip_type].config,
- sizeof(struct inv_mpu6050_chip_config));
+ sizeof(struct inv_mpu6050_chip_config));
result = inv_mpu6050_set_power_itg(st, false);
return result;
}
static int inv_mpu6050_sensor_show(struct inv_mpu6050_state *st, int reg,
- int axis, int *val)
+ int axis, int *val)
{
int ind, result;
__be16 d;
return IIO_VAL_INT;
}
-static int inv_mpu6050_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long mask) {
+static int
+inv_mpu6050_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2, long mask)
+{
struct inv_mpu6050_state *st = iio_priv(indio_dev);
switch (mask) {
switch (chan->type) {
case IIO_ANGL_VEL:
if (!st->chip_config.gyro_fifo_enable ||
- !st->chip_config.enable) {
+ !st->chip_config.enable) {
result = inv_mpu6050_switch_engine(st, true,
INV_MPU6050_BIT_PWR_GYRO_STBY);
if (result)
goto error_read_raw;
}
ret = inv_mpu6050_sensor_show(st, st->reg->raw_gyro,
- chan->channel2, val);
+ chan->channel2, val);
if (!st->chip_config.gyro_fifo_enable ||
- !st->chip_config.enable) {
+ !st->chip_config.enable) {
result = inv_mpu6050_switch_engine(st, false,
INV_MPU6050_BIT_PWR_GYRO_STBY);
if (result)
break;
case IIO_ACCEL:
if (!st->chip_config.accl_fifo_enable ||
- !st->chip_config.enable) {
+ !st->chip_config.enable) {
result = inv_mpu6050_switch_engine(st, true,
INV_MPU6050_BIT_PWR_ACCL_STBY);
if (result)
goto error_read_raw;
}
ret = inv_mpu6050_sensor_show(st, st->reg->raw_accl,
- chan->channel2, val);
+ chan->channel2, val);
if (!st->chip_config.accl_fifo_enable ||
- !st->chip_config.enable) {
+ !st->chip_config.enable) {
result = inv_mpu6050_switch_engine(st, false,
INV_MPU6050_BIT_PWR_ACCL_STBY);
if (result)
/* wait for stablization */
msleep(INV_MPU6050_SENSOR_UP_TIME);
inv_mpu6050_sensor_show(st, st->reg->temperature,
- IIO_MOD_X, val);
+ IIO_MOD_X, val);
break;
default:
ret = -EINVAL;
}
static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val,
- int val2,
- long mask) {
+ struct iio_chan_spec const *chan,
+ int val, int val2, long mask)
+{
struct inv_mpu6050_state *st = iio_priv(indio_dev);
int result;
/**
* inv_mpu6050_fifo_rate_store() - Set fifo rate.
*/
-static ssize_t inv_mpu6050_fifo_rate_store(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t
+inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
{
s32 fifo_rate;
u8 d;
if (kstrtoint(buf, 10, &fifo_rate))
return -EINVAL;
if (fifo_rate < INV_MPU6050_MIN_FIFO_RATE ||
- fifo_rate > INV_MPU6050_MAX_FIFO_RATE)
+ fifo_rate > INV_MPU6050_MAX_FIFO_RATE)
return -EINVAL;
if (fifo_rate == st->chip_config.fifo_rate)
return count;
/**
* inv_fifo_rate_show() - Get the current sampling rate.
*/
-static ssize_t inv_fifo_rate_show(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t
+inv_fifo_rate_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct inv_mpu6050_state *st = iio_priv(dev_to_iio_dev(dev));
* inv_attr_show() - calling this function will show current
* parameters.
*/
-static ssize_t inv_attr_show(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t inv_attr_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct inv_mpu6050_state *st = iio_priv(dev_to_iio_dev(dev));
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
return result;
result = inv_mpu6050_switch_engine(st, false,
- INV_MPU6050_BIT_PWR_ACCL_STBY);
+ INV_MPU6050_BIT_PWR_ACCL_STBY);
if (result)
return result;
result = inv_mpu6050_switch_engine(st, false,
- INV_MPU6050_BIT_PWR_GYRO_STBY);
+ INV_MPU6050_BIT_PWR_GYRO_STBY);
if (result)
return result;
/* reset FIFO*/
result = regmap_write(st->map, st->reg->user_ctrl,
- INV_MPU6050_BIT_FIFO_RST);
+ INV_MPU6050_BIT_FIFO_RST);
if (result)
goto reset_fifo_fail;
if (st->chip_config.accl_fifo_enable ||
st->chip_config.gyro_fifo_enable) {
result = regmap_write(st->map, st->reg->int_enable,
- INV_MPU6050_BIT_DATA_RDY_EN);
+ INV_MPU6050_BIT_DATA_RDY_EN);
if (result)
return result;
}
/* enable FIFO reading and I2C master interface*/
result = regmap_write(st->map, st->reg->user_ctrl,
- INV_MPU6050_BIT_FIFO_EN);
+ INV_MPU6050_BIT_FIFO_EN);
if (result)
goto reset_fifo_fail;
/* enable sensor output to FIFO */
reset_fifo_fail:
dev_err(regmap_get_device(st->map), "reset fifo failed %d\n", result);
result = regmap_write(st->map, st->reg->int_enable,
- INV_MPU6050_BIT_DATA_RDY_EN);
+ INV_MPU6050_BIT_DATA_RDY_EN);
return result;
}
timestamp = iio_get_time_ns();
kfifo_in_spinlocked(&st->timestamps, ×tamp, 1,
- &st->time_stamp_lock);
+ &st->time_stamp_lock);
return IRQ_WAKE_THREAD;
}
* read fifo_count register to know how many bytes inside FIFO
* right now
*/
- result = regmap_bulk_read(st->map,
- st->reg->fifo_count_h,
- data, INV_MPU6050_FIFO_COUNT_BYTE);
+ result = regmap_bulk_read(st->map, st->reg->fifo_count_h, data,
+ INV_MPU6050_FIFO_COUNT_BYTE);
if (result)
goto end_session;
fifo_count = be16_to_cpup((__be16 *)(&data[0]));
timestamp = 0;
result = iio_push_to_buffers_with_timestamp(indio_dev, data,
- timestamp);
+ timestamp);
if (result)
goto flush_fifo;
fifo_count -= bytes_per_datum;
st->chip_config.gyro_fifo_enable =
test_bit(INV_MPU6050_SCAN_GYRO_X,
- indio_dev->active_scan_mask) ||
- test_bit(INV_MPU6050_SCAN_GYRO_Y,
- indio_dev->active_scan_mask) ||
- test_bit(INV_MPU6050_SCAN_GYRO_Z,
- indio_dev->active_scan_mask);
+ indio_dev->active_scan_mask) ||
+ test_bit(INV_MPU6050_SCAN_GYRO_Y,
+ indio_dev->active_scan_mask) ||
+ test_bit(INV_MPU6050_SCAN_GYRO_Z,
+ indio_dev->active_scan_mask);
st->chip_config.accl_fifo_enable =
test_bit(INV_MPU6050_SCAN_ACCL_X,
- indio_dev->active_scan_mask) ||
- test_bit(INV_MPU6050_SCAN_ACCL_Y,
- indio_dev->active_scan_mask) ||
- test_bit(INV_MPU6050_SCAN_ACCL_Z,
- indio_dev->active_scan_mask);
+ indio_dev->active_scan_mask) ||
+ test_bit(INV_MPU6050_SCAN_ACCL_Y,
+ indio_dev->active_scan_mask) ||
+ test_bit(INV_MPU6050_SCAN_ACCL_Z,
+ indio_dev->active_scan_mask);
}
/**
* @state: Desired trigger state
*/
static int inv_mpu_data_rdy_trigger_set_state(struct iio_trigger *trig,
- bool state)
+ bool state)
{
return inv_mpu6050_set_enable(iio_trigger_get_drvdata(trig), state);
}