iio: Stop sampling when the device is removed
Make sure to stop sampling when the device is removed, otherwise it will continue to sample forever. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
d66e0452bf
commit
a87c82e454
3 changed files with 28 additions and 1 deletions
|
@ -49,11 +49,15 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
|
|||
#define iio_buffer_poll_addr (&iio_buffer_poll)
|
||||
#define iio_buffer_read_first_n_outer_addr (&iio_buffer_read_first_n_outer)
|
||||
|
||||
void iio_disable_all_buffers(struct iio_dev *indio_dev);
|
||||
|
||||
#else
|
||||
|
||||
#define iio_buffer_poll_addr NULL
|
||||
#define iio_buffer_read_first_n_outer_addr NULL
|
||||
|
||||
static inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {}
|
||||
|
||||
#endif
|
||||
|
||||
int iio_device_register_eventset(struct iio_dev *indio_dev);
|
||||
|
|
|
@ -460,6 +460,25 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev, const long *mask,
|
|||
return bytes;
|
||||
}
|
||||
|
||||
void iio_disable_all_buffers(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct iio_buffer *buffer, *_buffer;
|
||||
|
||||
if (list_empty(&indio_dev->buffer_list))
|
||||
return;
|
||||
|
||||
if (indio_dev->setup_ops->predisable)
|
||||
indio_dev->setup_ops->predisable(indio_dev);
|
||||
|
||||
list_for_each_entry_safe(buffer, _buffer,
|
||||
&indio_dev->buffer_list, buffer_list)
|
||||
list_del_init(&buffer->buffer_list);
|
||||
|
||||
indio_dev->currentmode = INDIO_DIRECT_MODE;
|
||||
if (indio_dev->setup_ops->postdisable)
|
||||
indio_dev->setup_ops->postdisable(indio_dev);
|
||||
}
|
||||
|
||||
int iio_update_buffers(struct iio_dev *indio_dev,
|
||||
struct iio_buffer *insert_buffer,
|
||||
struct iio_buffer *remove_buffer)
|
||||
|
|
|
@ -1078,9 +1078,13 @@ EXPORT_SYMBOL(iio_device_register);
|
|||
void iio_device_unregister(struct iio_dev *indio_dev)
|
||||
{
|
||||
mutex_lock(&indio_dev->info_exist_lock);
|
||||
|
||||
device_del(&indio_dev->dev);
|
||||
|
||||
iio_disable_all_buffers(indio_dev);
|
||||
|
||||
indio_dev->info = NULL;
|
||||
mutex_unlock(&indio_dev->info_exist_lock);
|
||||
device_del(&indio_dev->dev);
|
||||
}
|
||||
EXPORT_SYMBOL(iio_device_unregister);
|
||||
subsys_initcall(iio_init);
|
||||
|
|
Loading…
Reference in a new issue