aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/iio/industrialio-trigger.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index ae2806aafb72..672911293987 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -68,6 +68,10 @@ int iio_trigger_register(struct iio_trigger *trig_info)
68{ 68{
69 int ret; 69 int ret;
70 70
71 /* trig_info->ops is required for the module member */
72 if (!trig_info->ops)
73 return -EINVAL;
74
71 trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL); 75 trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL);
72 if (trig_info->id < 0) 76 if (trig_info->id < 0)
73 return trig_info->id; 77 return trig_info->id;
@@ -164,8 +168,7 @@ EXPORT_SYMBOL(iio_trigger_poll_chained);
164 168
165void iio_trigger_notify_done(struct iio_trigger *trig) 169void iio_trigger_notify_done(struct iio_trigger *trig)
166{ 170{
167 if (atomic_dec_and_test(&trig->use_count) && trig->ops && 171 if (atomic_dec_and_test(&trig->use_count) && trig->ops->try_reenable)
168 trig->ops->try_reenable)
169 if (trig->ops->try_reenable(trig)) 172 if (trig->ops->try_reenable(trig))
170 /* Missed an interrupt so launch new poll now */ 173 /* Missed an interrupt so launch new poll now */
171 iio_trigger_poll(trig); 174 iio_trigger_poll(trig);
@@ -219,7 +222,7 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig,
219 return ret; 222 return ret;
220 } 223 }
221 224
222 if (trig->ops && trig->ops->set_trigger_state && notinuse) { 225 if (trig->ops->set_trigger_state && notinuse) {
223 ret = trig->ops->set_trigger_state(trig, true); 226 ret = trig->ops->set_trigger_state(trig, true);
224 if (ret < 0) 227 if (ret < 0)
225 module_put(pf->indio_dev->info->driver_module); 228 module_put(pf->indio_dev->info->driver_module);
@@ -236,7 +239,7 @@ static int iio_trigger_detach_poll_func(struct iio_trigger *trig,
236 = (bitmap_weight(trig->pool, 239 = (bitmap_weight(trig->pool,
237 CONFIG_IIO_CONSUMERS_PER_TRIGGER) 240 CONFIG_IIO_CONSUMERS_PER_TRIGGER)
238 == 1); 241 == 1);
239 if (trig->ops && trig->ops->set_trigger_state && no_other_users) { 242 if (trig->ops->set_trigger_state && no_other_users) {
240 ret = trig->ops->set_trigger_state(trig, false); 243 ret = trig->ops->set_trigger_state(trig, false);
241 if (ret) 244 if (ret)
242 return ret; 245 return ret;
@@ -358,7 +361,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
358 return ret; 361 return ret;
359 } 362 }
360 363
361 if (trig && trig->ops && trig->ops->validate_device) { 364 if (trig && trig->ops->validate_device) {
362 ret = trig->ops->validate_device(trig, indio_dev); 365 ret = trig->ops->validate_device(trig, indio_dev);
363 if (ret) 366 if (ret)
364 return ret; 367 return ret;