Skip to content

Commit

Permalink
staging:iio: use pollfunc allocation helpers in remaining drivers.
Browse files Browse the repository at this point in the history
Some didn't get converted the first time around.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed May 19, 2011
1 parent 58f0a25 commit 0ed731d
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 129 deletions.
16 changes: 7 additions & 9 deletions drivers/staging/iio/accel/lis3l02dq_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ void lis3l02dq_remove_trigger(struct iio_dev *indio_dev)

void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev)
{
kfree(indio_dev->pollfunc->name);
kfree(indio_dev->pollfunc);
iio_dealloc_pollfunc(indio_dev->pollfunc);
lis3l02dq_free_buf(indio_dev->ring);
}

Expand Down Expand Up @@ -448,18 +447,17 @@ int lis3l02dq_configure_ring(struct iio_dev *indio_dev)
iio_scan_mask_set(ring, 2);

/* Functions are NULL as we set handler below */
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
&lis3l02dq_trigger_handler,
0,
indio_dev,
"lis3l02dq_consumer%d",
indio_dev->id);

if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_iio_sw_rb_free;
}
indio_dev->pollfunc->private_data = indio_dev;
indio_dev->pollfunc->thread = &lis3l02dq_trigger_handler;
indio_dev->pollfunc->h = &iio_pollfunc_store_time;
indio_dev->pollfunc->type = 0;
indio_dev->pollfunc->name
= kasprintf(GFP_KERNEL, "lis3l02dq_consumer%d", indio_dev->id);

indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
Expand Down
24 changes: 10 additions & 14 deletions drivers/staging/iio/adc/ad7298_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,29 +164,26 @@ int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev)
/* Effectively select the ring buffer implementation */
indio_dev->ring->access = &ring_sw_access_funcs;

indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
indio_dev->pollfunc = iio_alloc_pollfunc(NULL,
&ad7298_trigger_handler,
IRQF_ONESHOT,
indio_dev,
"ad7298_consumer%d",
indio_dev->id);

if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_deallocate_sw_rb;
}
indio_dev->pollfunc->private_data = indio_dev;
indio_dev->pollfunc->thread = &ad7298_trigger_handler;
indio_dev->pollfunc->type = IRQF_ONESHOT;
indio_dev->pollfunc->name =
kasprintf(GFP_KERNEL, "ad7298_consumer%d", indio_dev->id);
if (indio_dev->pollfunc->name == NULL) {
ret = -ENOMEM;
goto error_free_poll_func;
}

/* Ring buffer functions - here trigger setup related */
indio_dev->ring->setup_ops = &ad7298_ring_setup_ops;
indio_dev->ring->scan_timestamp = true;

/* Flag that polled ring buffering is possible */
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
error_free_poll_func:
kfree(indio_dev->pollfunc);

error_deallocate_sw_rb:
iio_sw_rb_free(indio_dev->ring);
error_ret:
Expand All @@ -200,7 +197,6 @@ void ad7298_ring_cleanup(struct iio_dev *indio_dev)
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
kfree(indio_dev->pollfunc->name);
kfree(indio_dev->pollfunc);
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
26 changes: 10 additions & 16 deletions drivers/staging/iio/adc/ad7476_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,18 @@ int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
}
/* Effectively select the ring buffer implementation */
indio_dev->ring->access = &ring_sw_access_funcs;
indio_dev->pollfunc = kzalloc(sizeof(indio_dev->pollfunc), GFP_KERNEL);
indio_dev->pollfunc
= iio_alloc_pollfunc(NULL,
&ad7476_trigger_handler,
IRQF_ONESHOT,
indio_dev,
"%s_consumer%d",
spi_get_device_id(st->spi)->name,
indio_dev->id);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_deallocate_sw_rb;
}
indio_dev->pollfunc->private_data = indio_dev;
indio_dev->pollfunc->thread = &ad7476_trigger_handler;
indio_dev->pollfunc->type = IRQF_ONESHOT;
indio_dev->pollfunc->name
= kasprintf(GFP_KERNEL, "%s_consumer%d",
spi_get_device_id(st->spi)->name,
indio_dev->id);
if (indio_dev->pollfunc->name == NULL) {
ret = -ENOMEM;
goto error_free_pollfunc;
}

/* Ring buffer functions - here trigger setup related */
indio_dev->ring->setup_ops = &ad7476_ring_setup_ops;
Expand All @@ -149,8 +145,7 @@ int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
/* Flag that polled ring buffering is possible */
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
error_free_pollfunc:
kfree(indio_dev->pollfunc);

error_deallocate_sw_rb:
iio_sw_rb_free(indio_dev->ring);
error_ret:
Expand All @@ -165,7 +160,6 @@ void ad7476_ring_cleanup(struct iio_dev *indio_dev)
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
kfree(indio_dev->pollfunc->name);
kfree(indio_dev->pollfunc);
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
24 changes: 9 additions & 15 deletions drivers/staging/iio/adc/ad7606_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,18 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev)

/* Effectively select the ring buffer implementation */
indio_dev->ring->access = &ring_sw_access_funcs;
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
indio_dev->pollfunc = iio_alloc_pollfunc(&ad7606_trigger_handler_th_bh,
&ad7606_trigger_handler_th_bh,
0,
indio_dev,
"%s_consumer%d",
indio_dev->name,
indio_dev->id);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_deallocate_sw_rb;
}

indio_dev->pollfunc->private_data = indio_dev;
indio_dev->pollfunc->h = &ad7606_trigger_handler_th_bh;
indio_dev->pollfunc->thread = &ad7606_trigger_handler_th_bh;
indio_dev->pollfunc->name =
kasprintf(GFP_KERNEL, "%s_consumer%d", indio_dev->name,
indio_dev->id);
if (indio_dev->pollfunc->name == NULL) {
ret = -ENOMEM;
goto error_free_poll_func;
}
/* Ring buffer functions - here trigger setup related */

indio_dev->ring->setup_ops = &ad7606_ring_setup_ops;
Expand All @@ -195,8 +191,7 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev)
/* Flag that polled ring buffering is possible */
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
error_free_poll_func:
kfree(indio_dev->pollfunc);

error_deallocate_sw_rb:
iio_sw_rb_free(indio_dev->ring);
error_ret:
Expand All @@ -210,7 +205,6 @@ void ad7606_ring_cleanup(struct iio_dev *indio_dev)
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
kfree(indio_dev->pollfunc->name);
kfree(indio_dev->pollfunc);
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
24 changes: 8 additions & 16 deletions drivers/staging/iio/adc/ad7887_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,30 +166,23 @@ int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev)
}
/* Effectively select the ring buffer implementation */
indio_dev->ring->access = &ring_sw_access_funcs;
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
&ad7887_trigger_handler,
IRQF_ONESHOT,
indio_dev,
"ad7887_consumer%d",
indio_dev->id);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_deallocate_sw_rb;
}

indio_dev->pollfunc->private_data = indio_dev;
indio_dev->pollfunc->h = &iio_pollfunc_store_time;
indio_dev->pollfunc->thread = &ad7887_trigger_handler;
indio_dev->pollfunc->type = IRQF_ONESHOT;
indio_dev->pollfunc->name =
kasprintf(GFP_KERNEL, "ad7887_consumer%d", indio_dev->id);
if (indio_dev->pollfunc->name == NULL) {
ret = -ENOMEM;
goto error_free_pollfunc;
}
/* Ring buffer functions - here trigger setup related */
indio_dev->ring->setup_ops = &ad7887_ring_setup_ops;

/* Flag that polled ring buffering is possible */
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
error_free_pollfunc:
kfree(indio_dev->pollfunc);

error_deallocate_sw_rb:
iio_sw_rb_free(indio_dev->ring);
error_ret:
Expand All @@ -204,7 +197,6 @@ void ad7887_ring_cleanup(struct iio_dev *indio_dev)
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
kfree(indio_dev->pollfunc->name);
kfree(indio_dev->pollfunc);
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
25 changes: 10 additions & 15 deletions drivers/staging/iio/adc/ad799x_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,30 +179,26 @@ int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev)
}
/* Effectively select the ring buffer implementation */
indio_dev->ring->access = &ring_sw_access_funcs;
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
indio_dev->pollfunc = iio_alloc_pollfunc(NULL,
&ad799x_trigger_handler,
IRQF_ONESHOT,
indio_dev,
"%s_consumer%d",
indio_dev->name,
indio_dev->id);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_deallocate_sw_rb;
}
indio_dev->pollfunc->private_data = indio_dev;
indio_dev->pollfunc->thread = &ad799x_trigger_handler;
indio_dev->pollfunc->type = IRQF_ONESHOT;
indio_dev->pollfunc->name =
kasprintf(GFP_KERNEL, "%s_consumer%d", indio_dev->name,
indio_dev->id);
if (indio_dev->pollfunc->name == NULL) {
ret = -ENOMEM;
goto error_free_poll_func;
}

/* Ring buffer functions - here trigger setup related */
indio_dev->ring->setup_ops = &ad799x_buf_setup_ops;
indio_dev->ring->scan_timestamp = true;

/* Flag that polled ring buffering is possible */
indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
error_free_poll_func:
kfree(indio_dev->pollfunc);

error_deallocate_sw_rb:
iio_sw_rb_free(indio_dev->ring);
error_ret:
Expand All @@ -217,7 +213,6 @@ void ad799x_ring_cleanup(struct iio_dev *indio_dev)
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
kfree(indio_dev->pollfunc->name);
kfree(indio_dev->pollfunc);
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
24 changes: 9 additions & 15 deletions drivers/staging/iio/adc/max1363_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,17 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev)
ret = -ENOMEM;
goto error_ret;
}
indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
indio_dev->pollfunc = iio_alloc_pollfunc(NULL,
&max1363_trigger_handler,
IRQF_ONESHOT,
indio_dev,
"%s_consumer%d",
st->client->name,
indio_dev->id);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_deallocate_sw_rb;
}
indio_dev->pollfunc->private_data = indio_dev;
indio_dev->pollfunc->thread = &max1363_trigger_handler;
indio_dev->pollfunc->type = IRQF_ONESHOT;
indio_dev->pollfunc->name =
kasprintf(GFP_KERNEL, "%s_consumer%d",
st->client->name, indio_dev->id);
if (indio_dev->pollfunc->name == NULL) {
ret = -ENOMEM;
goto error_free_pollfunc;
}
/* Effectively select the ring buffer implementation */
indio_dev->ring->access = &ring_sw_access_funcs;
/* Ring buffer functions - here trigger setup related */
Expand All @@ -193,8 +189,7 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev)
indio_dev->modes |= INDIO_RING_TRIGGERED;

return 0;
error_free_pollfunc:
kfree(indio_dev->pollfunc);

error_deallocate_sw_rb:
iio_sw_rb_free(indio_dev->ring);
error_ret:
Expand All @@ -209,7 +204,6 @@ void max1363_ring_cleanup(struct iio_dev *indio_dev)
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
kfree(indio_dev->pollfunc->name);
kfree(indio_dev->pollfunc);
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
23 changes: 8 additions & 15 deletions drivers/staging/iio/gyro/adis16260_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ static irqreturn_t adis16260_trigger_handler(int irq, void *p)

void adis16260_unconfigure_ring(struct iio_dev *indio_dev)
{
kfree(indio_dev->pollfunc->name);
kfree(indio_dev->pollfunc);
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}

Expand Down Expand Up @@ -137,26 +136,20 @@ int adis16260_configure_ring(struct iio_dev *indio_dev)
iio_scan_mask_set(ring, ADIS16260_SCAN_TEMP);
iio_scan_mask_set(ring, ADIS16260_SCAN_ANGL);

indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
&adis16260_trigger_handler,
IRQF_ONESHOT,
indio_dev,
"adis16260_consumer%d",
indio_dev->id);
if (indio_dev->pollfunc == NULL) {
ret = -ENOMEM;
goto error_iio_sw_rb_free;
}
indio_dev->pollfunc->private_data = indio_dev;
indio_dev->pollfunc->h = &iio_pollfunc_store_time;
indio_dev->pollfunc->thread = &adis16260_trigger_handler;
indio_dev->pollfunc->type = IRQF_ONESHOT;
indio_dev->pollfunc->name =
kasprintf(GFP_KERNEL, "adis16260_consumer%d", indio_dev->id);
if (indio_dev->pollfunc->name == NULL) {
ret = -ENOMEM;
goto error_free_pollfunc;
}

indio_dev->modes |= INDIO_RING_TRIGGERED;
return 0;
error_free_pollfunc:
kfree(indio_dev->pollfunc);

error_iio_sw_rb_free:
iio_sw_rb_free(indio_dev->ring);
return ret;
Expand Down
Loading

0 comments on commit 0ed731d

Please sign in to comment.