summaryrefslogtreecommitdiffstats
path: root/drivers/iio/industrialio-trigger.c
diff options
context:
space:
mode:
authorJonathan Cameron <jic23@kernel.org>2017-07-23 18:25:45 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2017-08-22 22:20:28 +0200
commit04581681df3048b7819c25419de1ea73a2832808 (patch)
treef8ecbf9c8bdd7d87e99a269ae9610cdf71e6e250 /drivers/iio/industrialio-trigger.c
parentiio: triggers: Use macros to avoid boilerplate assignment of owner. (diff)
downloadlinux-04581681df3048b7819c25419de1ea73a2832808.tar.xz
linux-04581681df3048b7819c25419de1ea73a2832808.zip
iio:trigger: Remove necessity to have a trig->ops structure.
There are a few cases where none of the callbacks are supplied and the ops structure purely existed to provide the driver module. Given that is done differently now, we don't need to have a trig_ops structure. Allow for it not being there required a few additional sanity checks when trying check if particular callbacks are set. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Diffstat (limited to 'drivers/iio/industrialio-trigger.c')
-rw-r--r--drivers/iio/industrialio-trigger.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index faf00202915a..ce66699c7fcc 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -73,10 +73,6 @@ int __iio_trigger_register(struct iio_trigger *trig_info,
trig_info->owner = this_mod;
- /* trig_info->ops is required for the module member */
- if (!trig_info->ops)
- return -EINVAL;
-
trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL);
if (trig_info->id < 0)
return trig_info->id;
@@ -209,7 +205,8 @@ EXPORT_SYMBOL(iio_trigger_poll_chained);
void iio_trigger_notify_done(struct iio_trigger *trig)
{
- if (atomic_dec_and_test(&trig->use_count) && trig->ops->try_reenable)
+ if (atomic_dec_and_test(&trig->use_count) && trig->ops &&
+ trig->ops->try_reenable)
if (trig->ops->try_reenable(trig))
/* Missed an interrupt so launch new poll now */
iio_trigger_poll(trig);
@@ -268,7 +265,7 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig,
goto out_put_irq;
/* Enable trigger in driver */
- if (trig->ops->set_trigger_state && notinuse) {
+ if (trig->ops && trig->ops->set_trigger_state && notinuse) {
ret = trig->ops->set_trigger_state(trig, true);
if (ret < 0)
goto out_free_irq;
@@ -301,7 +298,7 @@ static int iio_trigger_detach_poll_func(struct iio_trigger *trig,
= (bitmap_weight(trig->pool,
CONFIG_IIO_CONSUMERS_PER_TRIGGER)
== 1);
- if (trig->ops->set_trigger_state && no_other_users) {
+ if (trig->ops && trig->ops->set_trigger_state && no_other_users) {
ret = trig->ops->set_trigger_state(trig, false);
if (ret)
return ret;
@@ -431,7 +428,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
goto out_trigger_put;
}
- if (trig && trig->ops->validate_device) {
+ if (trig && trig->ops && trig->ops->validate_device) {
ret = trig->ops->validate_device(trig, indio_dev);
if (ret)
goto out_trigger_put;