Commit 15744090 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

staging: iio: Add and convert drivers to use iio_alloc_pollfunc

Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Acked-by: default avatarBarry Song <21cnbao@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 3c9bbf58
......@@ -241,13 +241,10 @@ int adis16209_configure_ring(struct iio_dev *indio_dev)
ring->predisable = &adis16209_data_rdy_ring_predisable;
ring->owner = THIS_MODULE;
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_iio_sw_rb_free;;
}
indio_dev->pollfunc->poll_func_main = &adis16209_poll_func_th;
indio_dev->pollfunc->private_data = indio_dev;
ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16209_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
......
......@@ -229,13 +229,10 @@ int adis16240_configure_ring(struct iio_dev *indio_dev)
ring->predisable = &adis16240_data_rdy_ring_predisable;
ring->owner = THIS_MODULE;
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_iio_sw_rb_free;;
}
indio_dev->pollfunc->poll_func_main = &adis16240_poll_func_th;
indio_dev->pollfunc->private_data = indio_dev;
ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16240_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
......
......@@ -566,13 +566,9 @@ int lis3l02dq_configure_ring(struct iio_dev *indio_dev)
ring->predisable = &lis3l02dq_data_rdy_ring_predisable;
ring->owner = THIS_MODULE;
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
ret = iio_alloc_pollfunc(indio_dev, NULL, &lis3l02dq_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;;
}
indio_dev->pollfunc->poll_func_main = &lis3l02dq_poll_func_th;
indio_dev->pollfunc->private_data = indio_dev;
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
......@@ -592,3 +588,4 @@ void lis3l02dq_uninitialize_ring(struct iio_ring_buffer *ring)
}
......@@ -223,14 +223,9 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev)
}
/* Effectively select the ring buffer implementation */
iio_ring_sw_register_funcs(&st->indio_dev->ring->access);
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
ret = iio_alloc_pollfunc(indio_dev, NULL, &max1363_poll_func_th);
if (ret)
goto error_deallocate_sw_rb;
}
/* Configure the polling function called on trigger interrupts */
indio_dev->pollfunc->poll_func_main = &max1363_poll_func_th;
indio_dev->pollfunc->private_data = indio_dev;
/* Ring buffer functions - here trigger setup related */
indio_dev->ring->postenable = &max1363_ring_postenable;
......
......@@ -231,13 +231,10 @@ int adis16260_configure_ring(struct iio_dev *indio_dev)
ring->predisable = &adis16260_data_rdy_ring_predisable;
ring->owner = THIS_MODULE;
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_iio_sw_rb_free;;
}
indio_dev->pollfunc->poll_func_main = &adis16260_poll_func_th;
indio_dev->pollfunc->private_data = indio_dev;
ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16260_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
......
......@@ -256,13 +256,10 @@ int adis16300_configure_ring(struct iio_dev *indio_dev)
ring->predisable = &adis16300_data_rdy_ring_predisable;
ring->owner = THIS_MODULE;
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_iio_sw_rb_free;;
}
indio_dev->pollfunc->poll_func_main = &adis16300_poll_func_th;
indio_dev->pollfunc->private_data = indio_dev;
ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16300_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
......
......@@ -261,13 +261,10 @@ int adis16350_configure_ring(struct iio_dev *indio_dev)
ring->predisable = &adis16350_data_rdy_ring_predisable;
ring->owner = THIS_MODULE;
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_iio_sw_rb_free;;
}
indio_dev->pollfunc->poll_func_main = &adis16350_poll_func_th;
indio_dev->pollfunc->private_data = indio_dev;
ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16350_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
......
......@@ -268,13 +268,10 @@ int adis16400_configure_ring(struct iio_dev *indio_dev)
ring->predisable = &adis16400_data_rdy_ring_predisable;
ring->owner = THIS_MODULE;
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_iio_sw_rb_free;;
}
indio_dev->pollfunc->poll_func_main = &adis16400_poll_func_th;
indio_dev->pollfunc->private_data = indio_dev;
ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16400_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
......
......@@ -398,3 +398,16 @@ int iio_device_unregister_trigger_consumer(struct iio_dev *dev_info)
}
EXPORT_SYMBOL(iio_device_unregister_trigger_consumer);
int iio_alloc_pollfunc(struct iio_dev *indio_dev,
void (*immediate)(struct iio_dev *indio_dev),
void (*main)(struct iio_dev *private_data))
{
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
if (indio_dev->pollfunc == NULL)
return -ENOMEM;
indio_dev->pollfunc->poll_func_immediate = immediate;
indio_dev->pollfunc->poll_func_main = main;
indio_dev->pollfunc->private_data = indio_dev;
return 0;
}
EXPORT_SYMBOL(iio_alloc_pollfunc);
......@@ -148,9 +148,12 @@ struct iio_poll_func {
};
int iio_alloc_pollfunc(struct iio_dev *indio_dev,
void (*immediate)(struct iio_dev *indio_dev),
void (*main)(struct iio_dev *private_data));
struct iio_trigger *iio_allocate_trigger(void);
void iio_free_trigger(struct iio_trigger *trig);
#endif /* _IIO_TRIGGER_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment