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

Commit aaf370db authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman
Browse files

staging:iio: Remove legacy event handling.



This requires all drivers using the channel registration code and
events to change in one go.

V3: remove unwanted irq enable from event handler.
V2: rebase related fixes to move to new IIO_CHAN macro. All trivial.

Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 72148f6e
Loading
Loading
Loading
Loading
+9 −27
Original line number Diff line number Diff line
@@ -416,10 +416,9 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,

static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("280 560 1120 4480");

static irqreturn_t lis3l02dq_event_handler(int irq, void *_int_info)
static irqreturn_t lis3l02dq_event_handler(int irq, void *private)
{
	struct iio_interrupt *int_info = _int_info;
	struct iio_dev *indio_dev = int_info->dev_info;
	struct iio_dev *indio_dev = private;
	struct iio_sw_ring_helper_state *h
		= iio_dev_get_devdata(indio_dev);
	struct lis3l02dq_state *st = lis3l02dq_h_to_s(h);
@@ -442,14 +441,11 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *_int_info)

static struct iio_chan_spec lis3l02dq_channels[] = {
	IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X, LIS3L02DQ_INFO_MASK,
		 0, 0, IIO_ST('s', 12, 16, 0),
		 LIS3L02DQ_EVENT_MASK, NULL),
		 0, 0, IIO_ST('s', 12, 16, 0), LIS3L02DQ_EVENT_MASK),
	IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y, LIS3L02DQ_INFO_MASK,
		 1, 1, IIO_ST('s', 12, 16, 0),
		 LIS3L02DQ_EVENT_MASK, NULL),
		 1, 1, IIO_ST('s', 12, 16, 0), LIS3L02DQ_EVENT_MASK),
	IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z, LIS3L02DQ_INFO_MASK,
		 2, 2, IIO_ST('s', 12, 16, 0),
		 LIS3L02DQ_EVENT_MASK, NULL),
		 2, 2, IIO_ST('s', 12, 16, 0), LIS3L02DQ_EVENT_MASK),
	IIO_CHAN_SOFT_TIMESTAMP(3)
};

@@ -508,7 +504,7 @@ int lis3l02dq_disable_all_events(struct iio_dev *indio_dev)
		goto error_ret;

	if (irqtofree)
		free_irq(st->us->irq, indio_dev->interrupts[0]);
		free_irq(st->us->irq, indio_dev);

	ret = control;
error_ret:
@@ -517,7 +513,6 @@ error_ret:

static int lis3l02dq_write_event_config(struct iio_dev *indio_dev,
					int event_code,
					struct iio_event_handler_list *list_el,
					int state)
{
	struct iio_sw_ring_helper_state *h
@@ -559,7 +554,7 @@ static int lis3l02dq_write_event_config(struct iio_dev *indio_dev,
					  &lis3l02dq_event_handler,
					  IRQF_TRIGGER_RISING,
					  "lis3l02dq_event",
					  indio_dev->interrupts[0]);
					  indio_dev);
			if (ret)
				goto error_ret;
		}
@@ -580,7 +575,7 @@ static int lis3l02dq_write_event_config(struct iio_dev *indio_dev,

		/* remove interrupt handler if nothing is still on */
		if (!(val & 0x3f))
			free_irq(st->us->irq, indio_dev->interrupts[0]);
			free_irq(st->us->irq, indio_dev);
	}

error_ret:
@@ -743,16 +738,9 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)

	if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) {
		st->inter = 0;
		ret = iio_register_interrupt_line(spi->irq,
						  st->help.indio_dev,
						  0,
						  IRQF_TRIGGER_RISING,
						  "lis3l02dq");
		if (ret)
			goto error_uninitialize_ring;
		ret = lis3l02dq_probe_trigger(st->help.indio_dev);
		if (ret)
			goto error_unregister_line;
			goto error_uninitialize_ring;
	}

	/* Get the device into a sane initial state */
@@ -764,9 +752,6 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
error_remove_trigger:
	if (st->help.indio_dev->modes & INDIO_RING_TRIGGERED)
		lis3l02dq_remove_trigger(st->help.indio_dev);
error_unregister_line:
	if (st->help.indio_dev->modes & INDIO_RING_TRIGGERED)
		iio_unregister_interrupt_line(st->help.indio_dev, 0);
error_uninitialize_ring:
	iio_ring_buffer_unregister(st->help.indio_dev->ring);
error_unreg_ring_funcs:
@@ -831,9 +816,6 @@ static int lis3l02dq_remove(struct spi_device *spi)
	flush_scheduled_work();

	lis3l02dq_remove_trigger(indio_dev);
	if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
		iio_unregister_interrupt_line(indio_dev, 0);

	iio_ring_buffer_unregister(indio_dev->ring);
	lis3l02dq_unconfigure_ring(indio_dev);
	iio_device_unregister(indio_dev);
+10 −17
Original line number Diff line number Diff line
@@ -440,14 +440,11 @@ static IIO_DEV_ATTR_REV(sca3000_show_rev);

static struct iio_chan_spec sca3000_channels[] = {
	IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X, SCA3000_INFO_MASK,
		 0, 0, IIO_ST('s', 11, 16, 5),
		 SCA3000_EVENT_MASK, NULL),
		 0, 0, IIO_ST('s', 11, 16, 5), SCA3000_EVENT_MASK),
	IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y, SCA3000_INFO_MASK,
		 1, 1, IIO_ST('s', 11, 16, 5),
		 SCA3000_EVENT_MASK, NULL),
		 1, 1, IIO_ST('s', 11, 16, 5), SCA3000_EVENT_MASK),
	IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z, SCA3000_INFO_MASK,
		 2, 2, IIO_ST('s', 11, 16, 5),
		 SCA3000_EVENT_MASK, NULL),
		 2, 2, IIO_ST('s', 11, 16, 5), SCA3000_EVENT_MASK),
};

static u8 sca3000_addresses[3][3] = {
@@ -977,7 +974,6 @@ error_ret:
 **/
static int sca3000_write_event_config(struct iio_dev *indio_dev,
				      int e,
				      struct iio_event_handler_list *list_el,
				      int state)
{
	struct sca3000_state *st = indio_dev->dev_data;
@@ -1032,13 +1028,10 @@ exit_point:
	return ret;
}

/* Shared event handler for all events as single event status register */
IIO_EVENT_SH(all, NULL);

/* Free fall detector related event attribute */
IIO_EVENT_ATTR_NAMED_SH(accel_xayaz_mag_falling_en,
static IIO_DEVICE_ATTR_NAMED(accel_xayaz_mag_falling_en,
			     accel_x&y&z_mag_falling_en,
			iio_event_all,
			     S_IRUGO | S_IWUSR,
			     sca3000_query_free_fall_mode,
			     sca3000_set_free_fall_mode,
			     0);
@@ -1048,7 +1041,7 @@ static IIO_CONST_ATTR_NAMED(accel_xayaz_mag_falling_period,
			    "0.226");

static struct attribute *sca3000_event_attributes[] = {
	&iio_event_attr_accel_xayaz_mag_falling_en.dev_attr.attr,
	&iio_dev_attr_accel_xayaz_mag_falling_en.dev_attr.attr,
	&iio_const_attr_accel_xayaz_mag_falling_period.dev_attr.attr,
	NULL,
};
+0 −4
Original line number Diff line number Diff line
@@ -189,8 +189,6 @@ struct max1363_chip_info {
 * @mask_low:		bitmask for enabled low thresholds
 * @thresh_high:	high threshold values
 * @thresh_low:		low threshold values
 * @last_timestamp:	timestamp of last event interrupt
 * @thresh_work:	bh work structure for event handling
 */
struct max1363_state {
	struct i2c_client		*client;
@@ -213,8 +211,6 @@ struct max1363_state {
	/* 4x unipolar first then the fours bipolar ones */
	s16				thresh_high[8];
	s16				thresh_low[8];
	s64				last_timestamp;
	struct work_struct		thresh_work;
};

const struct max1363_mode
+39 −77
Original line number Diff line number Diff line
@@ -263,20 +263,6 @@ static const enum max1363_modes max1363_mode_list[] = {
	d0m1to2m3, d1m0to3m2,
};

static int max1363_int_th(struct iio_dev *indio_dev,
			int index,
			s64 timestamp,
			int not_test)
{
	struct max1363_state *st = iio_priv(indio_dev);

	st->last_timestamp = timestamp;
	schedule_work(&st->thresh_work);
	return 0;
}

IIO_EVENT_SH(max1363_thresh, max1363_int_th);

#define MAX1363_EV_M						\
	(IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING)	\
	 | IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING))
@@ -284,71 +270,53 @@ IIO_EVENT_SH(max1363_thresh, max1363_int_th);

static struct iio_chan_spec max1363_channels[] = {
	IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, MAX1363_INFO_MASK,
		 _s0, 0, IIO_ST('u', 12, 16, 0), MAX1363_EV_M,
		 &iio_event_max1363_thresh),
		 _s0, 0, IIO_ST('u', 12, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, MAX1363_INFO_MASK,
		 _s1, 1, IIO_ST('u', 12, 16, 0), MAX1363_EV_M,
		 &iio_event_max1363_thresh),
		 _s1, 1, IIO_ST('u', 12, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, MAX1363_INFO_MASK,
		 _s2, 2, IIO_ST('u', 12, 16, 0), MAX1363_EV_M,
		 &iio_event_max1363_thresh),
		 _s2, 2, IIO_ST('u', 12, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, MAX1363_INFO_MASK,
		 _s3, 3, IIO_ST('u', 12, 16, 0), MAX1363_EV_M,
		 &iio_event_max1363_thresh),
		 _s3, 3, IIO_ST('u', 12, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 0, 1, MAX1363_INFO_MASK,
		 d0m1, 4, IIO_ST('s', 12, 16, 0),
		 MAX1363_EV_M, &iio_event_max1363_thresh),
		 d0m1, 4, IIO_ST('s', 12, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 2, 3, MAX1363_INFO_MASK,
		 d2m3, 5, IIO_ST('s', 12, 16, 0),
		 MAX1363_EV_M, &iio_event_max1363_thresh),
		 d2m3, 5, IIO_ST('s', 12, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 1, 0, MAX1363_INFO_MASK,
		 d1m0, 6, IIO_ST('s', 12, 16, 0),
		 MAX1363_EV_M, &iio_event_max1363_thresh),
		 d1m0, 6, IIO_ST('s', 12, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 3, 2, MAX1363_INFO_MASK,
		 d3m2, 7, IIO_ST('s', 12, 16, 0),
		 MAX1363_EV_M, &iio_event_max1363_thresh),
		 d3m2, 7, IIO_ST('s', 12, 16, 0), MAX1363_EV_M),
	IIO_CHAN_SOFT_TIMESTAMP(8)
};

static struct iio_chan_spec max1361_channels[] = {
	IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, MAX1363_INFO_MASK,
		 _s0, 0, IIO_ST('u', 10, 16, 0), MAX1363_EV_M,
		 &iio_event_max1363_thresh),
		 _s0, 0, IIO_ST('u', 10, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, MAX1363_INFO_MASK,
		 _s1, 1, IIO_ST('u', 10, 16, 0), MAX1363_EV_M,
		 &iio_event_max1363_thresh),
		 _s1, 1, IIO_ST('u', 10, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, MAX1363_INFO_MASK,
		 _s2, 2, IIO_ST('u', 10, 16, 0), MAX1363_EV_M,
		 &iio_event_max1363_thresh),
		 _s2, 2, IIO_ST('u', 10, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, MAX1363_INFO_MASK,
		 _s3, 3, IIO_ST('u', 10, 16, 0), MAX1363_EV_M,
		 &iio_event_max1363_thresh),
		 _s3, 3, IIO_ST('u', 10, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 0, 1, MAX1363_INFO_MASK,
		 d0m1, 4, IIO_ST('s', 10, 16, 0),
		 MAX1363_EV_M, &iio_event_max1363_thresh),
		 d0m1, 4, IIO_ST('s', 10, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 2, 3, MAX1363_INFO_MASK,
		 d2m3, 5, IIO_ST('s', 10, 16, 0),
		 MAX1363_EV_M, &iio_event_max1363_thresh),
		 d2m3, 5, IIO_ST('s', 10, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 1, 0, MAX1363_INFO_MASK,
		 d1m0, 6, IIO_ST('s', 10, 16, 0),
		 MAX1363_EV_M, &iio_event_max1363_thresh),
		 d1m0, 6, IIO_ST('s', 10, 16, 0), MAX1363_EV_M),
	IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 3, 2, MAX1363_INFO_MASK,
		 d3m2, 7, IIO_ST('s', 10, 16, 0),
		 MAX1363_EV_M, &iio_event_max1363_thresh),
		 d3m2, 7, IIO_ST('s', 10, 16, 0), MAX1363_EV_M),
	IIO_CHAN_SOFT_TIMESTAMP(8)
};

#define MAX1363_CHAN_U(num, address, scan_index, bits)		\
	IIO_CHAN(IIO_IN, 0, 1, 0, NULL, num, 0, MAX1363_INFO_MASK,	\
		 address, scan_index, IIO_ST('u', bits,		\
					     (bits == 8) ? 8 : 16, 0),	\
		 0, NULL)
					     (bits == 8) ? 8 : 16, 0), 0)
/* bipolar channel */
#define MAX1363_CHAN_B(num, num2, address, scan_index, bits)		\
	IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, num, num2, MAX1363_INFO_MASK,\
		 address, scan_index, IIO_ST('s', bits,		\
					     (bits == 8) ? 8 : 16, 0),	\
		 0, NULL)
					     (bits == 8) ? 8 : 16, 0), 0)

#define MAX1363_4X_CHANS(bits) {		\
	MAX1363_CHAN_U(0, _s0, 0, bits),	\
@@ -907,11 +875,11 @@ static int max1363_write_thresh(struct iio_dev *indio_dev,
	return 0;
}

static void max1363_thresh_handler_bh(struct work_struct *work_s)
static irqreturn_t max1363_event_handler(int irq, void *private)
{
	struct max1363_state *st = container_of(work_s, struct max1363_state,
						thresh_work);
	struct iio_dev *indio_dev = iio_priv_to_dev(st);
	struct iio_dev *indio_dev = private;
	struct max1363_state *st = iio_priv(indio_dev);
	s64 timestamp = iio_get_time_ns();
	u8 rx;
	u8 tx[2] = { st->setupbyte,
		     MAX1363_MON_INT_ENABLE | (st->monitor_speed << 1) | 0xF0 };
@@ -921,37 +889,38 @@ static void max1363_thresh_handler_bh(struct work_struct *work_s)
	if (rx & (1 << 0))
		iio_push_event(indio_dev, 0,
			IIO_EVENT_CODE_IN_LOW_THRESH(3),
			st->last_timestamp);
			timestamp);
	if (rx & (1 << 1))
		iio_push_event(indio_dev, 0,
			IIO_EVENT_CODE_IN_HIGH_THRESH(3),
			st->last_timestamp);
			timestamp);
	if (rx & (1 << 2))
		iio_push_event(indio_dev, 0,
			IIO_EVENT_CODE_IN_LOW_THRESH(2),
			st->last_timestamp);
			timestamp);
	if (rx & (1 << 3))
		iio_push_event(indio_dev, 0,
			IIO_EVENT_CODE_IN_HIGH_THRESH(2),
			st->last_timestamp);
			timestamp);
	if (rx & (1 << 4))
		iio_push_event(indio_dev, 0,
			IIO_EVENT_CODE_IN_LOW_THRESH(1),
			st->last_timestamp);
			timestamp);
	if (rx & (1 << 5))
		iio_push_event(indio_dev, 0,
			IIO_EVENT_CODE_IN_HIGH_THRESH(1),
			st->last_timestamp);
			timestamp);
	if (rx & (1 << 6))
		iio_push_event(indio_dev, 0,
			IIO_EVENT_CODE_IN_LOW_THRESH(0),
			st->last_timestamp);
			timestamp);
	if (rx & (1 << 7))
		iio_push_event(indio_dev, 0,
			IIO_EVENT_CODE_IN_HIGH_THRESH(0),
			st->last_timestamp);
	enable_irq(st->client->irq);
			timestamp);
	i2c_master_send(st->client, tx, 2);

	return IRQ_HANDLED;
}

static int max1363_read_event_config(struct iio_dev *indio_dev,
@@ -1108,7 +1077,6 @@ error_ret:

static int max1363_write_event_config(struct iio_dev *indio_dev,
				      int event_code,
				      struct iio_event_handler_list *listel,
				      int state)
{
	int ret = 0;
@@ -1140,12 +1108,6 @@ static int max1363_write_event_config(struct iio_dev *indio_dev,
			st->mask_high |= (1 << number);
		}
	}
	if (st->monitor_on && !st->mask_high && !st->mask_low)
		iio_remove_event_from_list(listel,
					   &indio_dev->interrupts[0]->ev_list);
	if (!st->monitor_on && state)
		iio_add_event_to_list(listel,
				      &indio_dev->interrupts[0]->ev_list);

	max1363_monitor_mode_update(st, !!(st->mask_high | st->mask_low));
error_ret:
@@ -1264,15 +1226,15 @@ static int __devinit max1363_probe(struct i2c_client *client,
		goto error_cleanup_ring;

	if (st->chip_info->monitor_mode && client->irq) {
		ret = iio_register_interrupt_line(client->irq,
						indio_dev,
						0,
						IRQF_TRIGGER_RISING,
						client->name);
		ret = request_threaded_irq(st->client->irq,
					   NULL,
					   &max1363_event_handler,
					   IRQF_TRIGGER_RISING | IRQF_ONESHOT,
					   "max1363_event",
					   indio_dev);

		if (ret)
			goto error_uninit_ring;
		INIT_WORK(&st->thresh_work, max1363_thresh_handler_bh);
	}

	return 0;
@@ -1304,7 +1266,7 @@ static int max1363_remove(struct i2c_client *client)
	struct regulator *reg = st->reg;

	if (st->chip_info->monitor_mode && client->irq)
		iio_unregister_interrupt_line(indio_dev, 0);
		free_irq(st->client->irq, indio_dev);
	iio_ring_buffer_unregister(indio_dev->ring);
	max1363_ring_cleanup(indio_dev);
	kfree(indio_dev->available_scan_masks);
+0 −21
Original line number Diff line number Diff line
@@ -78,28 +78,7 @@ struct iio_event_interface {
	void					*private;
	char					_name[35];
	char					_attrname[20];

	struct list_head event_attr_list;
	struct list_head dev_attr_list;
};

/**
 * struct iio_event_handler_list - element in list of handlers for events
 * @list:		list header
 * @refcount:		as the handler may be shared between multiple device
 *			side events, reference counting ensures clean removal
 * @exist_lock:		prevents race conditions related to refcount usage.
 * @handler:		event handler function - called on event if this
 *			event_handler is enabled.
 *
 * Each device has one list of these per interrupt line.
 **/
struct iio_event_handler_list {
	struct list_head	list;
	int			refcount;
	struct mutex		exist_lock;
	int (*handler)(struct iio_dev *dev_info, int index, s64 timestamp,
		       int no_test);
};

#endif
Loading