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

Commit 79335140 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Greg Kroah-Hartman
Browse files

staging:iio: Drop {mark,unmark}_in_use callbacks



These callbacks are currently used by the individual buffer implementations to
ensure that the request_update callback is not issued while the buffer is in use.
But the core already provides sufficient measures to prevent this from happening
in the first place. So it is safe to remove them.

There is one functional change due to this patch. Since the buffer is no longer
marked as in use when the chrdev is opened, it is now possible to enable the
buffer while it is opened. This did not work before, because mark_param_change
did fail if the buffer was marked as in use.

Acked-by: default avatarJonathan Cameron <jic23@kernel.org>
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 869871b5
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -23,10 +23,6 @@ The function pointers within here are used to allow the core to handle
as much buffer functionality as possible. Note almost all of these
are optional.

mark_in_use, unmark_in_use
  Basically indicate that not changes should be made to the buffer state that
  will effect the form of the data being captures (e.g. scan elements or length)

store_to
  If possible, push data to the buffer.

+0 −5
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@ struct iio_buffer;

/**
 * struct iio_buffer_access_funcs - access functions for buffers.
 * @mark_in_use:	reference counting, typically to prevent module removal
 * @unmark_in_use:	reduce reference count when no longer using buffer
 * @store_to:		actually store stuff to the buffer
 * @read_first_n:	try to get a specified number of bytes (must exist)
 * @request_update:	if a parameter change has been marked, update underlying
@@ -38,9 +36,6 @@ struct iio_buffer;
 * any of them not existing.
 **/
struct iio_buffer_access_funcs {
	void (*mark_in_use)(struct iio_buffer *buffer);
	void (*unmark_in_use)(struct iio_buffer *buffer);

	int (*store_to)(struct iio_buffer *buffer, u8 *data, s64 timestamp);
	int (*read_first_n)(struct iio_buffer *buffer,
			    size_t n,
+0 −11
Original line number Diff line number Diff line
@@ -33,9 +33,6 @@ int __iio_add_chan_devattr(const char *postfix,
#ifdef CONFIG_IIO_BUFFER
struct poll_table_struct;

int iio_chrdev_buffer_open(struct iio_dev *indio_dev);
void iio_chrdev_buffer_release(struct iio_dev *indio_dev);

unsigned int iio_buffer_poll(struct file *filp,
			     struct poll_table_struct *wait);
ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
@@ -47,14 +44,6 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,

#else

static inline int iio_chrdev_buffer_open(struct iio_dev *indio_dev)
{
	return 0;
}

static inline void iio_chrdev_buffer_release(struct iio_dev *indio_dev)
{}

#define iio_buffer_poll_addr NULL
#define iio_buffer_read_first_n_outer_addr NULL

+0 −28
Original line number Diff line number Diff line
@@ -64,26 +64,6 @@ unsigned int iio_buffer_poll(struct file *filp,
	return 0;
}

int iio_chrdev_buffer_open(struct iio_dev *indio_dev)
{
	struct iio_buffer *rb = indio_dev->buffer;
	if (!rb)
		return 0;
	if (rb->access->mark_in_use)
		rb->access->mark_in_use(rb);
	return 0;
}

void iio_chrdev_buffer_release(struct iio_dev *indio_dev)
{
	struct iio_buffer *rb = indio_dev->buffer;

	if (!rb)
		return;
	if (rb->access->unmark_in_use)
		rb->access->unmark_in_use(rb);
}

void iio_buffer_init(struct iio_buffer *buffer)
{
	INIT_LIST_HEAD(&buffer->demux_list);
@@ -447,16 +427,12 @@ ssize_t iio_buffer_store_enable(struct device *dev,
				goto error_ret;
			}
		}
		if (buffer->access->mark_in_use)
			buffer->access->mark_in_use(buffer);
		/* Definitely possible for devices to support both of these.*/
		if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) {
			if (!indio_dev->trig) {
				printk(KERN_INFO
				       "Buffer not started: no trigger\n");
				ret = -EINVAL;
				if (buffer->access->unmark_in_use)
					buffer->access->unmark_in_use(buffer);
				goto error_ret;
			}
			indio_dev->currentmode = INDIO_BUFFER_TRIGGERED;
@@ -473,8 +449,6 @@ ssize_t iio_buffer_store_enable(struct device *dev,
				printk(KERN_INFO
				       "Buffer not started:"
				       "postenable failed\n");
				if (buffer->access->unmark_in_use)
					buffer->access->unmark_in_use(buffer);
				indio_dev->currentmode = previous_mode;
				if (indio_dev->setup_ops->postdisable)
					indio_dev->setup_ops->
@@ -488,8 +462,6 @@ ssize_t iio_buffer_store_enable(struct device *dev,
			if (ret)
				goto error_ret;
		}
		if (buffer->access->unmark_in_use)
			buffer->access->unmark_in_use(buffer);
		indio_dev->currentmode = INDIO_DIRECT_MODE;
		if (indio_dev->setup_ops->postdisable) {
			ret = indio_dev->setup_ops->postdisable(indio_dev);
+1 −7
Original line number Diff line number Diff line
@@ -1083,18 +1083,13 @@ static int iio_chrdev_open(struct inode *inode, struct file *filp)
{
	struct iio_dev *indio_dev = container_of(inode->i_cdev,
						struct iio_dev, chrdev);
	unsigned int ret;

	if (test_and_set_bit(IIO_BUSY_BIT_POS, &indio_dev->flags))
		return -EBUSY;

	filp->private_data = indio_dev;

	ret = iio_chrdev_buffer_open(indio_dev);
	if (ret < 0)
		clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);

	return ret;
	return 0;
}

/**
@@ -1104,7 +1099,6 @@ static int iio_chrdev_release(struct inode *inode, struct file *filp)
{
	struct iio_dev *indio_dev = container_of(inode->i_cdev,
						struct iio_dev, chrdev);
	iio_chrdev_buffer_release(indio_dev);
	clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);
	return 0;
}
Loading