Skip to content

Commit

Permalink
iio: fix suspend/resume bug where trigger is not resumed
Browse files Browse the repository at this point in the history
  • Loading branch information
NeroReflex committed Jul 24, 2024
1 parent 899d3c5 commit f843e10
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
42 changes: 42 additions & 0 deletions drivers/iio/industrialio-trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,3 +781,45 @@ void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev)
if (indio_dev->trig)
iio_trigger_put(indio_dev->trig);
}

int iio_suspend_triggering(struct iio_dev *indio_dev) {
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);

int err = 0;

mutex_lock(&iio_dev_opaque->mlock);

if (!indio_dev->pollfunc)
goto iio_suspend_triggering_exit;

if (indio_dev->pollfunc->irq <= 0)
goto iio_suspend_triggering_exit;

disable_irq(indio_dev->pollfunc->irq);

iio_suspend_triggering_exit:
mutex_unlock(&iio_dev_opaque->mlock);
return err;
}
EXPORT_SYMBOL(iio_suspend_triggering);

int iio_resume_triggering(struct iio_dev *indio_dev) {
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);

int err = 0;

mutex_lock(&iio_dev_opaque->mlock);

if (!indio_dev->pollfunc)
goto iio_resume_triggering_exit;

if (indio_dev->pollfunc->irq <= 0)
goto iio_resume_triggering_exit;

enable_irq(indio_dev->pollfunc->irq);

iio_resume_triggering_exit:
mutex_unlock(&iio_dev_opaque->mlock);
return 0;
}
EXPORT_SYMBOL(iio_resume_triggering);
18 changes: 18 additions & 0 deletions include/linux/iio/trigger_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,22 @@ irqreturn_t iio_pollfunc_store_time(int irq, void *p);

void iio_trigger_notify_done(struct iio_trigger *trig);

/**
* iio_suspend_triggering() - suspend triggers attached to an iio_dev
* @indio_dev: iio_dev associated with the device that will have triggers suspended
*
* Return 0 if successful, negative otherwise
**/
int iio_suspend_triggering(struct iio_dev *indio_dev);

/**
* iio_resume_triggering() - resume triggers attached to an iio_dev that were previously suspended
* @indio_dev: iio_dev associated with the device that will have triggers resumed
*
* Return 0 if successful, negative otherwise
**/
int iio_resume_triggering(struct iio_dev *indio_dev);



#endif

0 comments on commit f843e10

Please sign in to comment.