hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/iio/industrialio-trigger.c
....@@ -1,10 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* The industrial I/O core, trigger handling functions
23 *
34 * 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.
85 */
96
107 #include <linux/kernel.h>
....@@ -242,8 +239,8 @@
242239 * the relevant function is in there may be the best option.
243240 */
244241 /* 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)
247244 {
248245 int ret = 0;
249246 bool notinuse
....@@ -254,8 +251,11 @@
254251
255252 /* Get irq number */
256253 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);
258257 goto out_put_module;
258
+ }
259259
260260 /* Request irq */
261261 ret = request_threaded_irq(pf->irq, pf->h, pf->thread,
....@@ -290,8 +290,8 @@
290290 return ret;
291291 }
292292
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)
295295 {
296296 int ret = 0;
297297 bool no_other_users
....@@ -516,7 +516,8 @@
516516 trig->subirqs[d->irq - trig->subirq_base].enabled = true;
517517 }
518518
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)
520521 {
521522 struct iio_trigger *trig;
522523 int i;
....@@ -584,18 +585,6 @@
584585 iio_trigger_free(*(struct iio_trigger **)res);
585586 }
586587
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
-
599588 /**
600589 * devm_iio_trigger_alloc - Resource-managed iio_trigger_alloc()
601590 * @dev: Device to allocate iio_trigger for
....@@ -606,9 +595,6 @@
606595 *
607596 * Managed iio_trigger_alloc. iio_trigger allocated with this function is
608597 * 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.
612598 *
613599 * RETURNS:
614600 * Pointer to allocated iio_trigger on success, NULL on failure.
....@@ -639,23 +625,6 @@
639625 }
640626 EXPORT_SYMBOL_GPL(devm_iio_trigger_alloc);
641627
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
-
659628 static void devm_iio_trigger_unreg(struct device *dev, void *res)
660629 {
661630 iio_trigger_unregister(*(struct iio_trigger **)res);
....@@ -671,9 +640,6 @@
671640 * function is automatically unregistered on driver detach. This function
672641 * calls iio_trigger_register() internally. Refer to that function for more
673642 * information.
674
- *
675
- * If an iio_trigger registered with this function needs to be unregistered
676
- * separately, devm_iio_trigger_unregister() must be used.
677643 *
678644 * RETURNS:
679645 * 0 on success, negative error number on failure.
....@@ -699,24 +665,6 @@
699665 return ret;
700666 }
701667 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);
720668
721669 bool iio_trigger_using_own(struct iio_dev *indio_dev)
722670 {
....@@ -757,17 +705,3 @@
757705 if (indio_dev->trig)
758706 iio_trigger_put(indio_dev->trig);
759707 }
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);