drm/modes: Fix drm_mode_vrefres() docs
[drm/drm-misc.git] / drivers / iio / magnetometer / st_magn_buffer.c
blob79987f42e8d9e796c3bd426a9258b46246fa653f
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * STMicroelectronics magnetometers driver
5 * Copyright 2012-2013 STMicroelectronics Inc.
7 * Denis Ciocca <denis.ciocca@st.com>
8 */
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>
16 #include <linux/iio/common/st_sensors.h>
17 #include "st_magn.h"
19 int st_magn_trig_set_state(struct iio_trigger *trig, bool state)
21 struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
23 return st_sensors_set_dataready_irq(indio_dev, state);
26 static int st_magn_buffer_postenable(struct iio_dev *indio_dev)
28 return st_sensors_set_enable(indio_dev, true);
31 static int st_magn_buffer_predisable(struct iio_dev *indio_dev)
33 return st_sensors_set_enable(indio_dev, false);
36 static const struct iio_buffer_setup_ops st_magn_buffer_setup_ops = {
37 .postenable = &st_magn_buffer_postenable,
38 .predisable = &st_magn_buffer_predisable,
41 int st_magn_allocate_ring(struct iio_dev *indio_dev)
43 return devm_iio_triggered_buffer_setup(indio_dev->dev.parent, indio_dev,
44 NULL, &st_sensors_trigger_handler, &st_magn_buffer_setup_ops);