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

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

staging:iio: remove ability to escalate events.



Whilst it is possible to output events to say buffers have passed
a particular level there are no obvious reasons to actually do so.

The upshot of this patch is that buffers will only ever have
one threshold turned on at a time.

For now sca3000 has it's ring buffer effectively disabled.
Fixed later in series.

Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 298cd976
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -45,9 +45,12 @@
 * Currently does not provide timestamps.  As the hardware doesn't add them they
 * can only be inferred approximately from ring buffer events such as 50% full
 * and knowledge of when buffer was last emptied.  This is left to userspace.
 *
 * Temporarily deliberately broken.
 **/
static int sca3000_read_first_n_hw_rb(struct iio_ring_buffer *r,
				      size_t count, u8 **data, int *dead_offset)
				      size_t count, char __user *buf,
				      int *dead_offset)
{
	struct iio_hw_ring_buffer *hw_ring = iio_to_hw_ring_buf(r);
	struct iio_dev *indio_dev = hw_ring->private;
@@ -56,6 +59,8 @@ static int sca3000_read_first_n_hw_rb(struct iio_ring_buffer *r,
	s16 *samples;
	int ret, i, num_available, num_read = 0;
	int bytes_per_sample = 1;
	u8 *datas;
	u8 **data = &datas;

	if (st->bpse == 11)
		bytes_per_sample = 2;
@@ -353,7 +358,7 @@ void sca3000_register_ring_funcs(struct iio_dev *indio_dev)
void sca3000_ring_int_process(u8 val, struct iio_ring_buffer *ring)
{
	if (val & SCA3000_INT_STATUS_THREE_QUARTERS)
		iio_push_or_escallate_ring_event(ring,
		iio_push_ring_event(ring,
				    IIO_EVENT_CODE_RING_75_FULL,
				    0);
	else if (val & SCA3000_INT_STATUS_HALF)
+0 −13
Original line number Diff line number Diff line
@@ -45,23 +45,10 @@ struct iio_event_data {
 * struct iio_detected_event_list - list element for events that have occurred
 * @list:		linked list header
 * @ev:			the event itself
 * @shared_pointer:	used when the event is shared - i.e. can be escallated
 *			on demand (eg ring buffer 50%->100% full)
 */
struct iio_detected_event_list {
	struct list_head		list;
	struct iio_event_data		ev;
	struct iio_shared_ev_pointer	*shared_pointer;
};
/**
 * struct iio_shared_ev_pointer - allows shared events to identify if currently
 *				in the detected event list
 * @ev_p:	pointer to detected event list element (null if not in list)
 * @lock:	protect this element to prevent simultaneous edit and remove
 */
struct iio_shared_ev_pointer {
	struct iio_detected_event_list	*ev_p;
	spinlock_t			lock;
};

/**
+2 −14
Original line number Diff line number Diff line
@@ -394,20 +394,8 @@ int iio_push_event(struct iio_dev *dev_info,
 * @ev_int:		the event interface to which we are pushing the event
 * @ev_code:		the outgoing event code
 * @timestamp:		timestamp of the event
 * @shared_pointer_p:	the shared event pointer
 **/
int __iio_push_event(struct iio_event_interface *ev_int,
		    int ev_code,
		    s64 timestamp,
		    struct iio_shared_ev_pointer*
		    shared_pointer_p);
/**
 * __iio_change_event() - change an event code in case of event escalation
 * @ev:			the event to be changed
 * @ev_code:		new event code
 * @timestamp:		new timestamp
 **/
void __iio_change_event(struct iio_detected_event_list *ev,
		     int ev_code,
		     s64 timestamp);

+2 −28
Original line number Diff line number Diff line
@@ -82,15 +82,6 @@ static const char * const iio_chan_info_postfix[] = {
	[IIO_CHAN_INFO_CALIBBIAS_SHARED/2] = "calibbias",
};

void __iio_change_event(struct iio_detected_event_list *ev,
			int ev_code,
			s64 timestamp)
{
	ev->ev.id = ev_code;
	ev->ev.timestamp = timestamp;
}
EXPORT_SYMBOL(__iio_change_event);

/* Used both in the interrupt line put events and the ring buffer ones */

/* Note that in it's current form someone has to be listening before events
@@ -99,9 +90,7 @@ EXPORT_SYMBOL(__iio_change_event);
 */
int __iio_push_event(struct iio_event_interface *ev_int,
		     int ev_code,
		     s64 timestamp,
		     struct iio_shared_ev_pointer *
		     shared_pointer_p)
		     s64 timestamp)
{
	struct iio_detected_event_list *ev;
	int ret = 0;
@@ -121,9 +110,6 @@ int __iio_push_event(struct iio_event_interface *ev_int,
		}
		ev->ev.id = ev_code;
		ev->ev.timestamp = timestamp;
		ev->shared_pointer = shared_pointer_p;
		if (ev->shared_pointer)
			shared_pointer_p->ev_p = ev;

		list_add_tail(&ev->list, &ev_int->det_events.list);
		ev_int->current_events++;
@@ -143,7 +129,7 @@ int iio_push_event(struct iio_dev *dev_info,
		   s64 timestamp)
{
	return __iio_push_event(&dev_info->event_interfaces[ev_line],
				ev_code, timestamp, NULL);
				ev_code, timestamp);
}
EXPORT_SYMBOL(iio_push_event);

@@ -311,18 +297,6 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
	list_del(&el->list);
	ev_int->current_events--;
	mutex_unlock(&ev_int->event_list_lock);
	/*
	 * Possible concurency issue if an update of this event is on its way
	 * through. May lead to new event being removed whilst the reported
	 * event was the unescalated event. In typical use case this is not a
	 * problem as userspace will say read half the buffer due to a 50%
	 * full event which would make the correct 100% full incorrect anyway.
	 */
	if (el->shared_pointer) {
		spin_lock(&el->shared_pointer->lock);
		(el->shared_pointer->ev_p) = NULL;
		spin_unlock(&el->shared_pointer->lock);
	}
	kfree(el);

	return len;
+2 −21
Original line number Diff line number Diff line
@@ -27,27 +27,10 @@ int iio_push_ring_event(struct iio_ring_buffer *ring_buf,
		       s64 timestamp)
{
	return __iio_push_event(&ring_buf->ev_int,
			       event_code,
			       timestamp,
			       &ring_buf->shared_ev_pointer);
}
EXPORT_SYMBOL(iio_push_ring_event);

int iio_push_or_escallate_ring_event(struct iio_ring_buffer *ring_buf,
				    int event_code,
				    s64 timestamp)
{
	if (ring_buf->shared_ev_pointer.ev_p)
		__iio_change_event(ring_buf->shared_ev_pointer.ev_p,
				   event_code,
				   timestamp);
	else
		return iio_push_ring_event(ring_buf,
				event_code,
				timestamp);
	return 0;
}
EXPORT_SYMBOL(iio_push_or_escallate_ring_event);
EXPORT_SYMBOL(iio_push_ring_event);

/**
 * iio_ring_open() - chrdev file open for ring buffer access
@@ -228,8 +211,6 @@ void iio_ring_buffer_init(struct iio_ring_buffer *ring,
	ring->indio_dev = dev_info;
	ring->ev_int.private = ring;
	ring->access_handler.private = ring;
	ring->shared_ev_pointer.ev_p = NULL;
	spin_lock_init(&ring->shared_ev_pointer.lock);
}
EXPORT_SYMBOL(iio_ring_buffer_init);

Loading