#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/buffer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/delay.h>
#include <linux/regulator/consumer.h>
#define MAG3110_STATUS …
#define MAG3110_OUT_X …
#define MAG3110_OUT_Y …
#define MAG3110_OUT_Z …
#define MAG3110_WHO_AM_I …
#define MAG3110_SYSMOD …
#define MAG3110_OFF_X …
#define MAG3110_OFF_Y …
#define MAG3110_OFF_Z …
#define MAG3110_DIE_TEMP …
#define MAG3110_CTRL_REG1 …
#define MAG3110_CTRL_REG2 …
#define MAG3110_STATUS_DRDY …
#define MAG3110_CTRL_DR_MASK …
#define MAG3110_CTRL_DR_SHIFT …
#define MAG3110_CTRL_DR_DEFAULT …
#define MAG3110_SYSMOD_MODE_MASK …
#define MAG3110_CTRL_TM …
#define MAG3110_CTRL_AC …
#define MAG3110_CTRL_AUTO_MRST_EN …
#define MAG3110_CTRL_RAW …
#define MAG3110_DEVICE_ID …
struct mag3110_data { … };
static int mag3110_request(struct mag3110_data *data)
{ … }
static int mag3110_read(struct mag3110_data *data, __be16 buf[3])
{ … }
static ssize_t mag3110_show_int_plus_micros(char *buf,
const int (*vals)[2], int n)
{ … }
static int mag3110_get_int_plus_micros_index(const int (*vals)[2], int n,
int val, int val2)
{ … }
static const int mag3110_samp_freq[8][2] = …;
static ssize_t mag3110_show_samp_freq_avail(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(mag3110_show_samp_freq_avail);
static int mag3110_get_samp_freq_index(struct mag3110_data *data,
int val, int val2)
{ … }
static int mag3110_calculate_sleep(struct mag3110_data *data)
{ … }
static int mag3110_standby(struct mag3110_data *data)
{ … }
static int mag3110_wait_standby(struct mag3110_data *data)
{ … }
static int mag3110_active(struct mag3110_data *data)
{ … }
static int mag3110_is_active(struct mag3110_data *data)
{ … }
static int mag3110_change_config(struct mag3110_data *data, u8 reg, u8 val)
{ … }
static int mag3110_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{ … }
static int mag3110_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val, int val2, long mask)
{ … }
static irqreturn_t mag3110_trigger_handler(int irq, void *p)
{ … }
#define MAG3110_CHANNEL(axis, idx) …
static const struct iio_chan_spec mag3110_channels[] = …;
static struct attribute *mag3110_attributes[] = …;
static const struct attribute_group mag3110_group = …;
static const struct iio_info mag3110_info = …;
static const unsigned long mag3110_scan_masks[] = …;
static int mag3110_probe(struct i2c_client *client)
{ … }
static void mag3110_remove(struct i2c_client *client)
{ … }
static int mag3110_suspend(struct device *dev)
{ … }
static int mag3110_resume(struct device *dev)
{ … }
static DEFINE_SIMPLE_DEV_PM_OPS(mag3110_pm_ops, mag3110_suspend,
mag3110_resume);
static const struct i2c_device_id mag3110_id[] = …;
MODULE_DEVICE_TABLE(i2c, mag3110_id);
static const struct of_device_id mag3110_of_match[] = …;
MODULE_DEVICE_TABLE(of, mag3110_of_match);
static struct i2c_driver mag3110_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;