Re: [PATCH v1 5/5] iio: accel: bma400: Add step change event

From: Andy Shevchenko
Date: Mon Mar 21 2022 - 04:46:51 EST


On Sat, Mar 19, 2022 at 8:10 PM Jagath Jog J <jagathjog1996@xxxxxxxxx> wrote:
>
> Added support for event when there is a detection of single step
> or double step change. INT1 pin is used to interrupt and event
> is pushed to userspace.

...

> #include <linux/iio/trigger.h>
> #include <linux/iio/triggered_buffer.h>
> #include <linux/iio/trigger_consumer.h>
> +#include <linux/iio/events.h>

Keep this block ordered,

...

> + switch (chan->type) {
> + case IIO_STEPS:
> + switch (type) {
> + case IIO_EV_TYPE_CHANGE:
> + return data->steps_enabled;
> + default:
> + return -EINVAL;
> + }
> + default:
> + return -EINVAL;
> + }

> + return 0;

Dead code.

...

> + case IIO_STEPS:
> + switch (type) {
> + case IIO_EV_TYPE_CHANGE:
> + mutex_lock(&data->mutex);
> + ret = regmap_update_bits(data->regmap,
> + BMA400_INT12_MAP_REG,
> + BMA400_STEP_INT_MSK,
> + FIELD_PREP(BMA400_STEP_INT_MSK,
> + state));
> + mutex_unlock(&data->mutex);
> + if (ret)
> + return ret;
> + data->steps_enabled = state;
> + return 0;
> + default:
> + return -EINVAL;
> + }
> + default:
> + return -EINVAL;
> + }

> + return 0;

Ditto.

--
With Best Regards,
Andy Shevchenko