1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * STMicroelectronics pressures driver 4 * 5 * Copyright 2013 STMicroelectronics Inc. 6 * 7 * Denis Ciocca <denis.ciocca@st.com> 8 */ 9 10 #include <linux/kernel.h> 11 #include <linux/iio/iio.h> 12 #include <linux/iio/buffer.h> 13 #include <linux/iio/trigger.h> 14 #include <linux/iio/triggered_buffer.h> 15 16 #include <linux/iio/common/st_sensors.h> 17 #include "st_pressure.h" 18 19 int st_press_trig_set_state(struct iio_trigger *trig, bool state) 20 { 21 struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); 22 23 return st_sensors_set_dataready_irq(indio_dev, state); 24 } 25 26 static int st_press_buffer_postenable(struct iio_dev *indio_dev) 27 { 28 return st_sensors_set_enable(indio_dev, true); 29 } 30 31 static int st_press_buffer_predisable(struct iio_dev *indio_dev) 32 { 33 return st_sensors_set_enable(indio_dev, false); 34 } 35 36 static const struct iio_buffer_setup_ops st_press_buffer_setup_ops = { 37 .postenable = &st_press_buffer_postenable, 38 .predisable = &st_press_buffer_predisable, 39 }; 40 41 int st_press_allocate_ring(struct iio_dev *indio_dev) 42 { 43 return devm_iio_triggered_buffer_setup(indio_dev->dev.parent, indio_dev, 44 NULL, &st_sensors_trigger_handler, &st_press_buffer_setup_ops); 45 } 46