• Home
  • Raw
  • Download

Lines Matching refs:trig

52 	struct iio_trigger *trig = to_iio_trigger(dev);  in iio_trigger_read_name()  local
53 return sprintf(buf, "%s\n", trig->name); in iio_trigger_read_name()
118 int iio_trigger_set_immutable(struct iio_dev *indio_dev, struct iio_trigger *trig) in iio_trigger_set_immutable() argument
120 if (!indio_dev || !trig) in iio_trigger_set_immutable()
126 indio_dev->trig = iio_trigger_get(trig); in iio_trigger_set_immutable()
148 struct iio_trigger *trig = NULL, *iter; in iio_trigger_acquire_by_name() local
153 trig = iter; in iio_trigger_acquire_by_name()
154 iio_trigger_get(trig); in iio_trigger_acquire_by_name()
159 return trig; in iio_trigger_acquire_by_name()
162 void iio_trigger_poll(struct iio_trigger *trig) in iio_trigger_poll() argument
166 if (!atomic_read(&trig->use_count)) { in iio_trigger_poll()
167 atomic_set(&trig->use_count, CONFIG_IIO_CONSUMERS_PER_TRIGGER); in iio_trigger_poll()
170 if (trig->subirqs[i].enabled) in iio_trigger_poll()
171 generic_handle_irq(trig->subirq_base + i); in iio_trigger_poll()
173 iio_trigger_notify_done(trig); in iio_trigger_poll()
186 void iio_trigger_poll_chained(struct iio_trigger *trig) in iio_trigger_poll_chained() argument
190 if (!atomic_read(&trig->use_count)) { in iio_trigger_poll_chained()
191 atomic_set(&trig->use_count, CONFIG_IIO_CONSUMERS_PER_TRIGGER); in iio_trigger_poll_chained()
194 if (trig->subirqs[i].enabled) in iio_trigger_poll_chained()
195 handle_nested_irq(trig->subirq_base + i); in iio_trigger_poll_chained()
197 iio_trigger_notify_done(trig); in iio_trigger_poll_chained()
203 void iio_trigger_notify_done(struct iio_trigger *trig) in iio_trigger_notify_done() argument
205 if (atomic_dec_and_test(&trig->use_count) && trig->ops && in iio_trigger_notify_done()
206 trig->ops->try_reenable) in iio_trigger_notify_done()
207 if (trig->ops->try_reenable(trig)) in iio_trigger_notify_done()
209 iio_trigger_poll(trig); in iio_trigger_notify_done()
214 static int iio_trigger_get_irq(struct iio_trigger *trig) in iio_trigger_get_irq() argument
217 mutex_lock(&trig->pool_lock); in iio_trigger_get_irq()
218 ret = bitmap_find_free_region(trig->pool, in iio_trigger_get_irq()
221 mutex_unlock(&trig->pool_lock); in iio_trigger_get_irq()
223 ret += trig->subirq_base; in iio_trigger_get_irq()
228 static void iio_trigger_put_irq(struct iio_trigger *trig, int irq) in iio_trigger_put_irq() argument
230 mutex_lock(&trig->pool_lock); in iio_trigger_put_irq()
231 clear_bit(irq - trig->subirq_base, trig->pool); in iio_trigger_put_irq()
232 mutex_unlock(&trig->pool_lock); in iio_trigger_put_irq()
242 int iio_trigger_attach_poll_func(struct iio_trigger *trig, in iio_trigger_attach_poll_func() argument
247 = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER); in iio_trigger_attach_poll_func()
253 pf->irq = iio_trigger_get_irq(trig); in iio_trigger_attach_poll_func()
256 trig->name, CONFIG_IIO_CONSUMERS_PER_TRIGGER); in iio_trigger_attach_poll_func()
268 if (trig->ops && trig->ops->set_trigger_state && notinuse) { in iio_trigger_attach_poll_func()
269 ret = trig->ops->set_trigger_state(trig, true); in iio_trigger_attach_poll_func()
279 if (pf->indio_dev->dev.parent == trig->dev.parent) in iio_trigger_attach_poll_func()
280 trig->attached_own_device = true; in iio_trigger_attach_poll_func()
287 iio_trigger_put_irq(trig, pf->irq); in iio_trigger_attach_poll_func()
293 int iio_trigger_detach_poll_func(struct iio_trigger *trig, in iio_trigger_detach_poll_func() argument
298 = (bitmap_weight(trig->pool, in iio_trigger_detach_poll_func()
301 if (trig->ops && trig->ops->set_trigger_state && no_other_users) { in iio_trigger_detach_poll_func()
302 ret = trig->ops->set_trigger_state(trig, false); in iio_trigger_detach_poll_func()
306 if (pf->indio_dev->dev.parent == trig->dev.parent) in iio_trigger_detach_poll_func()
307 trig->attached_own_device = false; in iio_trigger_detach_poll_func()
308 iio_trigger_put_irq(trig, pf->irq); in iio_trigger_detach_poll_func()
379 if (indio_dev->trig) in iio_trigger_read_current()
380 return sprintf(buf, "%s\n", indio_dev->trig->name); in iio_trigger_read_current()
404 struct iio_trigger *oldtrig = indio_dev->trig; in iio_trigger_write_current()
405 struct iio_trigger *trig; in iio_trigger_write_current() local
419 trig = iio_trigger_acquire_by_name(buf); in iio_trigger_write_current()
420 if (oldtrig == trig) { in iio_trigger_write_current()
425 if (trig && indio_dev->info->validate_trigger) { in iio_trigger_write_current()
426 ret = indio_dev->info->validate_trigger(indio_dev, trig); in iio_trigger_write_current()
431 if (trig && trig->ops && trig->ops->validate_device) { in iio_trigger_write_current()
432 ret = trig->ops->validate_device(trig, indio_dev); in iio_trigger_write_current()
437 indio_dev->trig = trig; in iio_trigger_write_current()
445 if (indio_dev->trig) { in iio_trigger_write_current()
447 iio_trigger_attach_poll_func(indio_dev->trig, in iio_trigger_write_current()
454 if (trig) in iio_trigger_write_current()
455 iio_trigger_put(trig); in iio_trigger_write_current()
475 struct iio_trigger *trig = to_iio_trigger(device); in iio_trig_release() local
478 if (trig->subirq_base) { in iio_trig_release()
480 irq_modify_status(trig->subirq_base + i, in iio_trig_release()
483 irq_set_chip(trig->subirq_base + i, in iio_trig_release()
485 irq_set_handler(trig->subirq_base + i, in iio_trig_release()
489 irq_free_descs(trig->subirq_base, in iio_trig_release()
492 kfree(trig->name); in iio_trig_release()
493 kfree(trig); in iio_trig_release()
504 struct iio_trigger *trig in iio_trig_subirqmask() local
507 trig->subirqs[d->irq - trig->subirq_base].enabled = false; in iio_trig_subirqmask()
513 struct iio_trigger *trig in iio_trig_subirqunmask() local
516 trig->subirqs[d->irq - trig->subirq_base].enabled = true; in iio_trig_subirqunmask()
522 struct iio_trigger *trig; in viio_trigger_alloc() local
525 trig = kzalloc(sizeof *trig, GFP_KERNEL); in viio_trigger_alloc()
526 if (!trig) in viio_trigger_alloc()
529 trig->dev.type = &iio_trig_type; in viio_trigger_alloc()
530 trig->dev.bus = &iio_bus_type; in viio_trigger_alloc()
531 device_initialize(&trig->dev); in viio_trigger_alloc()
533 mutex_init(&trig->pool_lock); in viio_trigger_alloc()
534 trig->subirq_base = irq_alloc_descs(-1, 0, in viio_trigger_alloc()
537 if (trig->subirq_base < 0) in viio_trigger_alloc()
540 trig->name = kvasprintf(GFP_KERNEL, fmt, vargs); in viio_trigger_alloc()
541 if (trig->name == NULL) in viio_trigger_alloc()
544 trig->subirq_chip.name = trig->name; in viio_trigger_alloc()
545 trig->subirq_chip.irq_mask = &iio_trig_subirqmask; in viio_trigger_alloc()
546 trig->subirq_chip.irq_unmask = &iio_trig_subirqunmask; in viio_trigger_alloc()
548 irq_set_chip(trig->subirq_base + i, &trig->subirq_chip); in viio_trigger_alloc()
549 irq_set_handler(trig->subirq_base + i, &handle_simple_irq); in viio_trigger_alloc()
550 irq_modify_status(trig->subirq_base + i, in viio_trigger_alloc()
554 return trig; in viio_trigger_alloc()
557 irq_free_descs(trig->subirq_base, CONFIG_IIO_CONSUMERS_PER_TRIGGER); in viio_trigger_alloc()
559 kfree(trig); in viio_trigger_alloc()
565 struct iio_trigger *trig; in iio_trigger_alloc() local
569 trig = viio_trigger_alloc(fmt, vargs); in iio_trigger_alloc()
572 return trig; in iio_trigger_alloc()
576 void iio_trigger_free(struct iio_trigger *trig) in iio_trigger_free() argument
578 if (trig) in iio_trigger_free()
579 put_device(&trig->dev); in iio_trigger_free()
605 struct iio_trigger **ptr, *trig; in devm_iio_trigger_alloc() local
615 trig = viio_trigger_alloc(fmt, vargs); in devm_iio_trigger_alloc()
617 if (trig) { in devm_iio_trigger_alloc()
618 *ptr = trig; in devm_iio_trigger_alloc()
624 return trig; in devm_iio_trigger_alloc()
671 return indio_dev->trig->attached_own_device; in iio_trigger_using_own()
687 int iio_trigger_validate_own_device(struct iio_trigger *trig, in iio_trigger_validate_own_device() argument
690 if (indio_dev->dev.parent != trig->dev.parent) in iio_trigger_validate_own_device()
705 if (indio_dev->trig) in iio_device_unregister_trigger_consumer()
706 iio_trigger_put(indio_dev->trig); in iio_device_unregister_trigger_consumer()