#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/iio/buffer.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>
#define STK8312_REG_XOUT …
#define STK8312_REG_YOUT …
#define STK8312_REG_ZOUT …
#define STK8312_REG_INTSU …
#define STK8312_REG_MODE …
#define STK8312_REG_SR …
#define STK8312_REG_STH …
#define STK8312_REG_RESET …
#define STK8312_REG_AFECTRL …
#define STK8312_REG_OTPADDR …
#define STK8312_REG_OTPDATA …
#define STK8312_REG_OTPCTRL …
#define STK8312_MODE_ACTIVE …
#define STK8312_MODE_STANDBY …
#define STK8312_MODE_INT_AH_PP …
#define STK8312_DREADY_BIT …
#define STK8312_RNG_6G …
#define STK8312_RNG_SHIFT …
#define STK8312_RNG_MASK …
#define STK8312_SR_MASK …
#define STK8312_SR_400HZ_IDX …
#define STK8312_ALL_CHANNEL_MASK …
#define STK8312_ALL_CHANNEL_SIZE …
#define STK8312_DRIVER_NAME …
#define STK8312_IRQ_NAME …
#define STK8312_SCALE_AVAIL …
static const int stk8312_scale_table[][2] = …;
static const struct { … } stk8312_samp_freq_table[] = …;
#define STK8312_ACCEL_CHANNEL(index, reg, axis) …
static const struct iio_chan_spec stk8312_channels[] = …;
struct stk8312_data { … };
static IIO_CONST_ATTR(in_accel_scale_available, STK8312_SCALE_AVAIL);
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("3.125 6.25 12.5 25 50 100 200 400");
static struct attribute *stk8312_attributes[] = …;
static const struct attribute_group stk8312_attribute_group = …;
static int stk8312_otp_init(struct stk8312_data *data)
{ … }
static int stk8312_set_mode(struct stk8312_data *data, u8 mode)
{ … }
static int stk8312_set_interrupts(struct stk8312_data *data, u8 int_mask)
{ … }
static int stk8312_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool state)
{ … }
static const struct iio_trigger_ops stk8312_trigger_ops = …;
static int stk8312_set_sample_rate(struct stk8312_data *data, u8 rate)
{ … }
static int stk8312_set_range(struct stk8312_data *data, u8 range)
{ … }
static int stk8312_read_accel(struct stk8312_data *data, u8 address)
{ … }
static int stk8312_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{ … }
static int stk8312_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val, int val2, long mask)
{ … }
static const struct iio_info stk8312_info = …;
static irqreturn_t stk8312_trigger_handler(int irq, void *p)
{ … }
static irqreturn_t stk8312_data_rdy_trig_poll(int irq, void *private)
{ … }
static int stk8312_buffer_preenable(struct iio_dev *indio_dev)
{ … }
static int stk8312_buffer_postdisable(struct iio_dev *indio_dev)
{ … }
static const struct iio_buffer_setup_ops stk8312_buffer_setup_ops = …;
static int stk8312_probe(struct i2c_client *client)
{ … }
static void stk8312_remove(struct i2c_client *client)
{ … }
static int stk8312_suspend(struct device *dev)
{ … }
static int stk8312_resume(struct device *dev)
{ … }
static DEFINE_SIMPLE_DEV_PM_OPS(stk8312_pm_ops, stk8312_suspend,
stk8312_resume);
static const struct i2c_device_id stk8312_i2c_id[] = …;
MODULE_DEVICE_TABLE(i2c, stk8312_i2c_id);
static struct i2c_driver stk8312_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;