#include <linux/unaligned.h>
#include <linux/crc8.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/iio/buffer.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/types.h>
#include <linux/kernel.h>
#include <linux/mutex.h>
#include <linux/string.h>
#include <linux/sysfs.h>
#include <linux/types.h>
#define SCD4X_CRC8_POLYNOMIAL …
#define SCD4X_TIMEOUT_ERR …
#define SCD4X_READ_BUF_SIZE …
#define SCD4X_COMMAND_BUF_SIZE …
#define SCD4X_WRITE_BUF_SIZE …
#define SCD4X_FRC_MIN_PPM …
#define SCD4X_FRC_MAX_PPM …
#define SCD4X_PRESSURE_COMP_MIN_MBAR …
#define SCD4X_PRESSURE_COMP_MAX_MBAR …
#define SCD4X_READY_MASK …
enum scd4x_cmd { … };
enum scd4x_channel_idx { … };
struct scd4x_state { … };
DECLARE_CRC8_TABLE(scd4x_crc8_table);
static int scd4x_i2c_xfer(struct scd4x_state *state, char *txbuf, int txsize,
char *rxbuf, int rxsize)
{ … }
static int scd4x_send_command(struct scd4x_state *state, enum scd4x_cmd cmd)
{ … }
static int scd4x_read(struct scd4x_state *state, enum scd4x_cmd cmd,
void *response, int response_sz)
{ … }
static int scd4x_write(struct scd4x_state *state, enum scd4x_cmd cmd, uint16_t arg)
{ … }
static int scd4x_write_and_fetch(struct scd4x_state *state, enum scd4x_cmd cmd,
uint16_t arg, void *response, int response_sz)
{ … }
static int scd4x_read_meas(struct scd4x_state *state, uint16_t *meas)
{ … }
static int scd4x_wait_meas_poll(struct scd4x_state *state)
{ … }
static int scd4x_read_poll(struct scd4x_state *state, uint16_t *buf)
{ … }
static int scd4x_read_channel(struct scd4x_state *state, int chan)
{ … }
static int scd4x_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int *val,
int *val2, long mask)
{ … }
static const int scd4x_pressure_calibbias_available[] = …;
static int scd4x_read_avail(struct iio_dev *indio_dev, struct iio_chan_spec const *chan,
const int **vals, int *type, int *length, long mask)
{ … }
static int scd4x_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan,
int val, int val2, long mask)
{ … }
static ssize_t calibration_auto_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t calibration_auto_enable_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static ssize_t calibration_forced_value_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static IIO_DEVICE_ATTR_RW(calibration_auto_enable, 0);
static IIO_DEVICE_ATTR_WO(calibration_forced_value, 0);
static IIO_CONST_ATTR(calibration_forced_value_available,
__stringify([SCD4X_FRC_MIN_PPM 1 SCD4X_FRC_MAX_PPM]));
static struct attribute *scd4x_attrs[] = …;
static const struct attribute_group scd4x_attr_group = …;
static const struct iio_info scd4x_info = …;
static const struct iio_chan_spec scd4x_channels[] = …;
static int scd4x_suspend(struct device *dev)
{ … }
static int scd4x_resume(struct device *dev)
{ … }
static DEFINE_SIMPLE_DEV_PM_OPS(scd4x_pm_ops, scd4x_suspend, scd4x_resume);
static void scd4x_stop_meas(void *state)
{ … }
static void scd4x_disable_regulator(void *data)
{ … }
static irqreturn_t scd4x_trigger_handler(int irq, void *p)
{ … }
static int scd4x_probe(struct i2c_client *client)
{ … }
static const struct of_device_id scd4x_dt_ids[] = …;
MODULE_DEVICE_TABLE(of, scd4x_dt_ids);
static struct i2c_driver scd4x_i2c_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;