#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/bitops.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/jiffies.h>
#include <linux/regmap.h>
#define LTC4222_CONTROL1 …
#define LTC4222_ALERT1 …
#define LTC4222_STATUS1 …
#define LTC4222_FAULT1 …
#define LTC4222_CONTROL2 …
#define LTC4222_ALERT2 …
#define LTC4222_STATUS2 …
#define LTC4222_FAULT2 …
#define LTC4222_SOURCE1 …
#define LTC4222_SOURCE2 …
#define LTC4222_ADIN1 …
#define LTC4222_ADIN2 …
#define LTC4222_SENSE1 …
#define LTC4222_SENSE2 …
#define LTC4222_ADC_CONTROL …
#define FAULT_OV …
#define FAULT_UV …
#define FAULT_OC …
#define FAULT_POWER_BAD …
#define FAULT_FET_BAD …
static int ltc4222_get_value(struct device *dev, u8 reg)
{ … }
static ssize_t ltc4222_value_show(struct device *dev,
struct device_attribute *da, char *buf)
{ … }
static ssize_t ltc4222_bool_show(struct device *dev,
struct device_attribute *da, char *buf)
{ … }
static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4222_value, LTC4222_SOURCE1);
static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4222_value, LTC4222_ADIN1);
static SENSOR_DEVICE_ATTR_RO(in3_input, ltc4222_value, LTC4222_SOURCE2);
static SENSOR_DEVICE_ATTR_RO(in4_input, ltc4222_value, LTC4222_ADIN2);
static SENSOR_DEVICE_ATTR_2_RO(in1_min_alarm, ltc4222_bool, LTC4222_FAULT1,
FAULT_UV);
static SENSOR_DEVICE_ATTR_2_RO(in1_max_alarm, ltc4222_bool, LTC4222_FAULT1,
FAULT_OV);
static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, ltc4222_bool, LTC4222_FAULT1,
FAULT_POWER_BAD | FAULT_FET_BAD);
static SENSOR_DEVICE_ATTR_2_RO(in3_min_alarm, ltc4222_bool, LTC4222_FAULT2,
FAULT_UV);
static SENSOR_DEVICE_ATTR_2_RO(in3_max_alarm, ltc4222_bool, LTC4222_FAULT2,
FAULT_OV);
static SENSOR_DEVICE_ATTR_2_RO(in4_alarm, ltc4222_bool, LTC4222_FAULT2,
FAULT_POWER_BAD | FAULT_FET_BAD);
static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4222_value, LTC4222_SENSE1);
static SENSOR_DEVICE_ATTR_RO(curr2_input, ltc4222_value, LTC4222_SENSE2);
static SENSOR_DEVICE_ATTR_2_RO(curr1_max_alarm, ltc4222_bool, LTC4222_FAULT1,
FAULT_OC);
static SENSOR_DEVICE_ATTR_2_RO(curr2_max_alarm, ltc4222_bool, LTC4222_FAULT2,
FAULT_OC);
static struct attribute *ltc4222_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static const struct regmap_config ltc4222_regmap_config = …;
static int ltc4222_probe(struct i2c_client *client)
{ … }
static const struct i2c_device_id ltc4222_id[] = …;
MODULE_DEVICE_TABLE(i2c, ltc4222_id);
static struct i2c_driver ltc4222_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;