This source file includes following definitions.
- st_press_trig_set_state
- st_press_buffer_postenable
- st_press_buffer_predisable
- st_press_allocate_ring
- st_press_deallocate_ring
1
2
3
4
5
6
7
8
9
10 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/slab.h>
13 #include <linux/stat.h>
14 #include <linux/interrupt.h>
15 #include <linux/i2c.h>
16 #include <linux/delay.h>
17 #include <linux/iio/iio.h>
18 #include <linux/iio/buffer.h>
19 #include <linux/iio/trigger_consumer.h>
20 #include <linux/iio/triggered_buffer.h>
21
22 #include <linux/iio/common/st_sensors.h>
23 #include "st_pressure.h"
24
25 int st_press_trig_set_state(struct iio_trigger *trig, bool state)
26 {
27 struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
28
29 return st_sensors_set_dataready_irq(indio_dev, state);
30 }
31
32 static int st_press_buffer_postenable(struct iio_dev *indio_dev)
33 {
34 int err;
35
36 err = iio_triggered_buffer_postenable(indio_dev);
37 if (err < 0)
38 return err;
39
40 err = st_sensors_set_enable(indio_dev, true);
41 if (err < 0)
42 goto st_press_buffer_predisable;
43
44 return 0;
45
46 st_press_buffer_predisable:
47 iio_triggered_buffer_predisable(indio_dev);
48 return err;
49 }
50
51 static int st_press_buffer_predisable(struct iio_dev *indio_dev)
52 {
53 int err, err2;
54
55 err = st_sensors_set_enable(indio_dev, false);
56
57 err2 = iio_triggered_buffer_predisable(indio_dev);
58 if (!err)
59 err = err2;
60
61 return err;
62 }
63
64 static const struct iio_buffer_setup_ops st_press_buffer_setup_ops = {
65 .postenable = &st_press_buffer_postenable,
66 .predisable = &st_press_buffer_predisable,
67 };
68
69 int st_press_allocate_ring(struct iio_dev *indio_dev)
70 {
71 return iio_triggered_buffer_setup(indio_dev, NULL,
72 &st_sensors_trigger_handler, &st_press_buffer_setup_ops);
73 }
74
75 void st_press_deallocate_ring(struct iio_dev *indio_dev)
76 {
77 iio_triggered_buffer_cleanup(indio_dev);
78 }
79
80 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
81 MODULE_DESCRIPTION("STMicroelectronics pressures buffer");
82 MODULE_LICENSE("GPL v2");