Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 129c3f61 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron
Browse files

staging:iio:sca3000: Switch to new config interface



Switch the sca3000 driver to the new IIO event config interface as the old one
is going to be removed.

Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 693101dd
Loading
Loading
Loading
Loading
+36 −22
Original line number Diff line number Diff line
@@ -419,8 +419,11 @@ static IIO_DEVICE_ATTR(measurement_mode, S_IRUGO | S_IWUSR,

static IIO_DEVICE_ATTR(revision, S_IRUGO, sca3000_show_rev, NULL, 0);

#define SCA3000_EVENT_MASK					\
	(IIO_EV_BIT(IIO_EV_TYPE_MAG, IIO_EV_DIR_RISING))
static const struct iio_event_spec sca3000_event = {
	.type = IIO_EV_TYPE_MAG,
	.dir = IIO_EV_DIR_RISING,
	.mask_separate = BIT(IIO_EV_INFO_VALUE) | BIT(IIO_EV_INFO_ENABLE),
};

#define SCA3000_CHAN(index, mod)				\
	{							\
@@ -437,7 +440,8 @@ static IIO_DEVICE_ATTR(revision, S_IRUGO, sca3000_show_rev, NULL, 0);
			.storagebits = 16,			\
			.shift = 5,				\
		},						\
		.event_mask = SCA3000_EVENT_MASK,		\
		.event_spec = &sca3000_event,			\
		.num_event_specs = 1,				\
	 }

static const struct iio_chan_spec sca3000_channels[] = {
@@ -703,12 +707,15 @@ static IIO_CONST_ATTR_TEMP_OFFSET("-214.6");
 * sca3000_read_thresh() - query of a threshold
 **/
static int sca3000_read_thresh(struct iio_dev *indio_dev,
			       u64 e,
			       int *val)
			       const struct iio_chan_spec *chan,
			       enum iio_event_type type,
			       enum iio_event_direction dir,
			       enum iio_event_info info,
			       int *val, int *val2)
{
	int ret, i;
	struct sca3000_state *st = iio_priv(indio_dev);
	int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e);
	int num = chan->channel2;
	mutex_lock(&st->lock);
	ret = sca3000_read_ctrl_reg(st, sca3000_addresses[num][1]);
	mutex_unlock(&st->lock);
@@ -724,18 +731,21 @@ static int sca3000_read_thresh(struct iio_dev *indio_dev,
				 ARRAY_SIZE(st->info->mot_det_mult_xz))
			*val += st->info->mot_det_mult_xz[i];

	return 0;
	return IIO_VAL_INT;
}

/**
 * sca3000_write_thresh() control of threshold
 **/
static int sca3000_write_thresh(struct iio_dev *indio_dev,
				u64 e,
				int val)
				const struct iio_chan_spec *chan,
				enum iio_event_type type,
				enum iio_event_direction dir,
				enum iio_event_info info,
				int val, int val2)
{
	struct sca3000_state *st = iio_priv(indio_dev);
	int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e);
	int num = chan->channel2;
	int ret;
	int i;
	u8 nonlinear = 0;
@@ -866,12 +876,14 @@ static irqreturn_t sca3000_event_handler(int irq, void *private)
 * sca3000_read_event_config() what events are enabled
 **/
static int sca3000_read_event_config(struct iio_dev *indio_dev,
				     u64 e)
				     const struct iio_chan_spec *chan,
				     enum iio_event_type type,
				     enum iio_event_direction dir)
{
	struct sca3000_state *st = iio_priv(indio_dev);
	int ret;
	u8 protect_mask = 0x03;
	int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e);
	int num = chan->channel2;

	/* read current value of mode register */
	mutex_lock(&st->lock);
@@ -969,13 +981,15 @@ static ssize_t sca3000_set_free_fall_mode(struct device *dev,
 * this mode is disabled.  Currently normal mode is assumed.
 **/
static int sca3000_write_event_config(struct iio_dev *indio_dev,
				      u64 e,
				      const struct iio_chan_spec *chan,
				      enum iio_event_type type,
				      enum iio_event_direction dir,
				      int state)
{
	struct sca3000_state *st = iio_priv(indio_dev);
	int ret, ctrlval;
	u8 protect_mask = 0x03;
	int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e);
	int num = chan->channel2;

	mutex_lock(&st->lock);
	/* First read the motion detector config to find out if
@@ -1112,20 +1126,20 @@ static const struct iio_info sca3000_info = {
	.attrs = &sca3000_attribute_group,
	.read_raw = &sca3000_read_raw,
	.event_attrs = &sca3000_event_attribute_group,
	.read_event_value = &sca3000_read_thresh,
	.write_event_value = &sca3000_write_thresh,
	.read_event_config = &sca3000_read_event_config,
	.write_event_config = &sca3000_write_event_config,
	.read_event_value_new = &sca3000_read_thresh,
	.write_event_value_new = &sca3000_write_thresh,
	.read_event_config_new = &sca3000_read_event_config,
	.write_event_config_new = &sca3000_write_event_config,
	.driver_module = THIS_MODULE,
};

static const struct iio_info sca3000_info_with_temp = {
	.attrs = &sca3000_attribute_group_with_temp,
	.read_raw = &sca3000_read_raw,
	.read_event_value = &sca3000_read_thresh,
	.write_event_value = &sca3000_write_thresh,
	.read_event_config = &sca3000_read_event_config,
	.write_event_config = &sca3000_write_event_config,
	.read_event_value_new = &sca3000_read_thresh,
	.write_event_value_new = &sca3000_write_thresh,
	.read_event_config_new = &sca3000_read_event_config,
	.write_event_config_new = &sca3000_write_event_config,
	.driver_module = THIS_MODULE,
};