Skip to content

Commit

Permalink
staging: iio: Add and convert drivers to use iio_alloc_pollfunc
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Acked-by: Barry Song <21cnbao@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed Jul 22, 2010
1 parent 3c9bbf5 commit 1574409
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 56 deletions.
11 changes: 4 additions & 7 deletions drivers/staging/iio/accel/adis16209_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 4 additions & 7 deletions drivers/staging/iio/accel/adis16240_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 3 additions & 6 deletions drivers/staging/iio/accel/lis3l02dq_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -592,3 +588,4 @@ void lis3l02dq_uninitialize_ring(struct iio_ring_buffer *ring)
}



9 changes: 2 additions & 7 deletions drivers/staging/iio/adc/max1363_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 4 additions & 7 deletions drivers/staging/iio/gyro/adis16260_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 4 additions & 7 deletions drivers/staging/iio/imu/adis16300_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 4 additions & 7 deletions drivers/staging/iio/imu/adis16350_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 4 additions & 7 deletions drivers/staging/iio/imu/adis16400_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 13 additions & 0 deletions drivers/staging/iio/industrialio-trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 4 additions & 1 deletion drivers/staging/iio/trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */

0 comments on commit 1574409

Please sign in to comment.