Skip to content

Commit

Permalink
staging:iio: prevent removal of module connected to trigger.
Browse files Browse the repository at this point in the history
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 Aug 24, 2011
1 parent e65bc6a commit f60c4a0
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 51 deletions.
6 changes: 0 additions & 6 deletions drivers/staging/iio/adc/ad7192.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,6 @@ static int ad7192_register_ring_funcs_and_init(struct iio_dev *indio_dev)

static void ad7192_ring_cleanup(struct iio_dev *indio_dev)
{
/* ensure that the trigger has been detached */
if (indio_dev->trig) {
iio_put_trigger(indio_dev->trig);
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
Expand Down
5 changes: 0 additions & 5 deletions drivers/staging/iio/adc/ad7298_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,6 @@ int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev)

void ad7298_ring_cleanup(struct iio_dev *indio_dev)
{
if (indio_dev->trig) {
iio_put_trigger(indio_dev->trig);
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
6 changes: 0 additions & 6 deletions drivers/staging/iio/adc/ad7476_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@ int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)

void ad7476_ring_cleanup(struct iio_dev *indio_dev)
{
/* ensure that the trigger has been detached */
if (indio_dev->trig) {
iio_put_trigger(indio_dev->trig);
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
5 changes: 0 additions & 5 deletions drivers/staging/iio/adc/ad7606_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,6 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev)

void ad7606_ring_cleanup(struct iio_dev *indio_dev)
{
if (indio_dev->trig) {
iio_put_trigger(indio_dev->trig);
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
6 changes: 0 additions & 6 deletions drivers/staging/iio/adc/ad7793.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,6 @@ static int ad7793_register_ring_funcs_and_init(struct iio_dev *indio_dev)

static void ad7793_ring_cleanup(struct iio_dev *indio_dev)
{
/* ensure that the trigger has been detached */
if (indio_dev->trig) {
iio_put_trigger(indio_dev->trig);
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
Expand Down
6 changes: 0 additions & 6 deletions drivers/staging/iio/adc/ad7887_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,6 @@ int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev)

void ad7887_ring_cleanup(struct iio_dev *indio_dev)
{
/* ensure that the trigger has been detached */
if (indio_dev->trig) {
iio_put_trigger(indio_dev->trig);
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
6 changes: 0 additions & 6 deletions drivers/staging/iio/adc/ad799x_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,6 @@ int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev)

void ad799x_ring_cleanup(struct iio_dev *indio_dev)
{
/* ensure that the trigger has been detached */
if (indio_dev->trig) {
iio_put_trigger(indio_dev->trig);
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
5 changes: 0 additions & 5 deletions drivers/staging/iio/adc/max1363_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,6 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev)
void max1363_ring_cleanup(struct iio_dev *indio_dev)
{
/* ensure that the trigger has been detached */
if (indio_dev->trig) {
iio_put_trigger(indio_dev->trig);
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
3 changes: 3 additions & 0 deletions drivers/staging/iio/industrialio-trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig,
bool notinuse
= bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER);

/* Prevent the module being removed whilst attached to a trigger */
__module_get(pf->indio_dev->info->driver_module);
pf->irq = iio_trigger_get_irq(trig);
ret = request_threaded_irq(pf->irq, pf->h, pf->thread,
pf->type, pf->name,
Expand All @@ -256,6 +258,7 @@ int iio_trigger_dettach_poll_func(struct iio_trigger *trig,
}
iio_trigger_put_irq(trig, pf->irq);
free_irq(pf->irq, pf);
module_put(pf->indio_dev->info->driver_module);

error_ret:
return ret;
Expand Down
6 changes: 0 additions & 6 deletions drivers/staging/iio/meter/ade7758_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ static const struct iio_ring_setup_ops ade7758_ring_setup_ops = {

void ade7758_unconfigure_ring(struct iio_dev *indio_dev)
{
/* ensure that the trigger has been detached */
if (indio_dev->trig) {
iio_put_trigger(indio_dev->trig);
iio_trigger_dettach_poll_func(indio_dev->trig,
indio_dev->pollfunc);
}
iio_dealloc_pollfunc(indio_dev->pollfunc);
iio_sw_rb_free(indio_dev->ring);
}
Expand Down

0 comments on commit f60c4a0

Please sign in to comment.