Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / iio / pressure / st_pressure_buffer.c
blob7cf6f06797e1e7d2a192dd44b5a207f904250f24
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * STMicroelectronics pressures driver
5 * Copyright 2013 STMicroelectronics Inc.
7 * Denis Ciocca <denis.ciocca@st.com>
8 */
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>
22 #include <linux/iio/common/st_sensors.h>
23 #include "st_pressure.h"
25 int st_press_trig_set_state(struct iio_trigger *trig, bool state)
27 struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
29 return st_sensors_set_dataready_irq(indio_dev, state);
32 static int st_press_buffer_postenable(struct iio_dev *indio_dev)
34 return st_sensors_set_enable(indio_dev, true);
37 static int st_press_buffer_predisable(struct iio_dev *indio_dev)
39 return st_sensors_set_enable(indio_dev, false);
42 static const struct iio_buffer_setup_ops st_press_buffer_setup_ops = {
43 .postenable = &st_press_buffer_postenable,
44 .predisable = &st_press_buffer_predisable,
47 int st_press_allocate_ring(struct iio_dev *indio_dev)
49 return iio_triggered_buffer_setup(indio_dev, NULL,
50 &st_sensors_trigger_handler, &st_press_buffer_setup_ops);
53 void st_press_deallocate_ring(struct iio_dev *indio_dev)
55 iio_triggered_buffer_cleanup(indio_dev);
58 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
59 MODULE_DESCRIPTION("STMicroelectronics pressures buffer");
60 MODULE_LICENSE("GPL v2");