.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* The industrial I/O core, trigger handling functions |
---|
2 | 3 | * |
---|
3 | 4 | * Copyright (c) 2008 Jonathan Cameron |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify it |
---|
6 | | - * under the terms of the GNU General Public License version 2 as published by |
---|
7 | | - * the Free Software Foundation. |
---|
8 | 5 | */ |
---|
9 | 6 | |
---|
10 | 7 | #include <linux/kernel.h> |
---|
.. | .. |
---|
242 | 239 | * the relevant function is in there may be the best option. |
---|
243 | 240 | */ |
---|
244 | 241 | /* Worth protecting against double additions? */ |
---|
245 | | -static int iio_trigger_attach_poll_func(struct iio_trigger *trig, |
---|
246 | | - struct iio_poll_func *pf) |
---|
| 242 | +int iio_trigger_attach_poll_func(struct iio_trigger *trig, |
---|
| 243 | + struct iio_poll_func *pf) |
---|
247 | 244 | { |
---|
248 | 245 | int ret = 0; |
---|
249 | 246 | bool notinuse |
---|
.. | .. |
---|
254 | 251 | |
---|
255 | 252 | /* Get irq number */ |
---|
256 | 253 | pf->irq = iio_trigger_get_irq(trig); |
---|
257 | | - if (pf->irq < 0) |
---|
| 254 | + if (pf->irq < 0) { |
---|
| 255 | + pr_err("Could not find an available irq for trigger %s, CONFIG_IIO_CONSUMERS_PER_TRIGGER=%d limit might be exceeded\n", |
---|
| 256 | + trig->name, CONFIG_IIO_CONSUMERS_PER_TRIGGER); |
---|
258 | 257 | goto out_put_module; |
---|
| 258 | + } |
---|
259 | 259 | |
---|
260 | 260 | /* Request irq */ |
---|
261 | 261 | ret = request_threaded_irq(pf->irq, pf->h, pf->thread, |
---|
.. | .. |
---|
290 | 290 | return ret; |
---|
291 | 291 | } |
---|
292 | 292 | |
---|
293 | | -static int iio_trigger_detach_poll_func(struct iio_trigger *trig, |
---|
294 | | - struct iio_poll_func *pf) |
---|
| 293 | +int iio_trigger_detach_poll_func(struct iio_trigger *trig, |
---|
| 294 | + struct iio_poll_func *pf) |
---|
295 | 295 | { |
---|
296 | 296 | int ret = 0; |
---|
297 | 297 | bool no_other_users |
---|
.. | .. |
---|
516 | 516 | trig->subirqs[d->irq - trig->subirq_base].enabled = true; |
---|
517 | 517 | } |
---|
518 | 518 | |
---|
519 | | -static struct iio_trigger *viio_trigger_alloc(const char *fmt, va_list vargs) |
---|
| 519 | +static __printf(1, 0) |
---|
| 520 | +struct iio_trigger *viio_trigger_alloc(const char *fmt, va_list vargs) |
---|
520 | 521 | { |
---|
521 | 522 | struct iio_trigger *trig; |
---|
522 | 523 | int i; |
---|
.. | .. |
---|
584 | 585 | iio_trigger_free(*(struct iio_trigger **)res); |
---|
585 | 586 | } |
---|
586 | 587 | |
---|
587 | | -static int devm_iio_trigger_match(struct device *dev, void *res, void *data) |
---|
588 | | -{ |
---|
589 | | - struct iio_trigger **r = res; |
---|
590 | | - |
---|
591 | | - if (!r || !*r) { |
---|
592 | | - WARN_ON(!r || !*r); |
---|
593 | | - return 0; |
---|
594 | | - } |
---|
595 | | - |
---|
596 | | - return *r == data; |
---|
597 | | -} |
---|
598 | | - |
---|
599 | 588 | /** |
---|
600 | 589 | * devm_iio_trigger_alloc - Resource-managed iio_trigger_alloc() |
---|
601 | 590 | * @dev: Device to allocate iio_trigger for |
---|
.. | .. |
---|
606 | 595 | * |
---|
607 | 596 | * Managed iio_trigger_alloc. iio_trigger allocated with this function is |
---|
608 | 597 | * automatically freed on driver detach. |
---|
609 | | - * |
---|
610 | | - * If an iio_trigger allocated with this function needs to be freed separately, |
---|
611 | | - * devm_iio_trigger_free() must be used. |
---|
612 | 598 | * |
---|
613 | 599 | * RETURNS: |
---|
614 | 600 | * Pointer to allocated iio_trigger on success, NULL on failure. |
---|
.. | .. |
---|
639 | 625 | } |
---|
640 | 626 | EXPORT_SYMBOL_GPL(devm_iio_trigger_alloc); |
---|
641 | 627 | |
---|
642 | | -/** |
---|
643 | | - * devm_iio_trigger_free - Resource-managed iio_trigger_free() |
---|
644 | | - * @dev: Device this iio_dev belongs to |
---|
645 | | - * @iio_trig: the iio_trigger associated with the device |
---|
646 | | - * |
---|
647 | | - * Free iio_trigger allocated with devm_iio_trigger_alloc(). |
---|
648 | | - */ |
---|
649 | | -void devm_iio_trigger_free(struct device *dev, struct iio_trigger *iio_trig) |
---|
650 | | -{ |
---|
651 | | - int rc; |
---|
652 | | - |
---|
653 | | - rc = devres_release(dev, devm_iio_trigger_release, |
---|
654 | | - devm_iio_trigger_match, iio_trig); |
---|
655 | | - WARN_ON(rc); |
---|
656 | | -} |
---|
657 | | -EXPORT_SYMBOL_GPL(devm_iio_trigger_free); |
---|
658 | | - |
---|
659 | 628 | static void devm_iio_trigger_unreg(struct device *dev, void *res) |
---|
660 | 629 | { |
---|
661 | 630 | iio_trigger_unregister(*(struct iio_trigger **)res); |
---|
.. | .. |
---|
671 | 640 | * function is automatically unregistered on driver detach. This function |
---|
672 | 641 | * calls iio_trigger_register() internally. Refer to that function for more |
---|
673 | 642 | * information. |
---|
674 | | - * |
---|
675 | | - * If an iio_trigger registered with this function needs to be unregistered |
---|
676 | | - * separately, devm_iio_trigger_unregister() must be used. |
---|
677 | 643 | * |
---|
678 | 644 | * RETURNS: |
---|
679 | 645 | * 0 on success, negative error number on failure. |
---|
.. | .. |
---|
699 | 665 | return ret; |
---|
700 | 666 | } |
---|
701 | 667 | EXPORT_SYMBOL_GPL(__devm_iio_trigger_register); |
---|
702 | | - |
---|
703 | | -/** |
---|
704 | | - * devm_iio_trigger_unregister - Resource-managed iio_trigger_unregister() |
---|
705 | | - * @dev: device this iio_trigger belongs to |
---|
706 | | - * @trig_info: the trigger associated with the device |
---|
707 | | - * |
---|
708 | | - * Unregister trigger registered with devm_iio_trigger_register(). |
---|
709 | | - */ |
---|
710 | | -void devm_iio_trigger_unregister(struct device *dev, |
---|
711 | | - struct iio_trigger *trig_info) |
---|
712 | | -{ |
---|
713 | | - int rc; |
---|
714 | | - |
---|
715 | | - rc = devres_release(dev, devm_iio_trigger_unreg, devm_iio_trigger_match, |
---|
716 | | - trig_info); |
---|
717 | | - WARN_ON(rc); |
---|
718 | | -} |
---|
719 | | -EXPORT_SYMBOL_GPL(devm_iio_trigger_unregister); |
---|
720 | 668 | |
---|
721 | 669 | bool iio_trigger_using_own(struct iio_dev *indio_dev) |
---|
722 | 670 | { |
---|
.. | .. |
---|
757 | 705 | if (indio_dev->trig) |
---|
758 | 706 | iio_trigger_put(indio_dev->trig); |
---|
759 | 707 | } |
---|
760 | | - |
---|
761 | | -int iio_triggered_buffer_postenable(struct iio_dev *indio_dev) |
---|
762 | | -{ |
---|
763 | | - return iio_trigger_attach_poll_func(indio_dev->trig, |
---|
764 | | - indio_dev->pollfunc); |
---|
765 | | -} |
---|
766 | | -EXPORT_SYMBOL(iio_triggered_buffer_postenable); |
---|
767 | | - |
---|
768 | | -int iio_triggered_buffer_predisable(struct iio_dev *indio_dev) |
---|
769 | | -{ |
---|
770 | | - return iio_trigger_detach_poll_func(indio_dev->trig, |
---|
771 | | - indio_dev->pollfunc); |
---|
772 | | -} |
---|
773 | | -EXPORT_SYMBOL(iio_triggered_buffer_predisable); |
---|