#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/jiffies.h>
#include <linux/regmap.h>
#define LTC2945_CONTROL …
#define LTC2945_ALERT …
#define LTC2945_STATUS …
#define LTC2945_FAULT …
#define LTC2945_POWER_H …
#define LTC2945_MAX_POWER_H …
#define LTC2945_MIN_POWER_H …
#define LTC2945_MAX_POWER_THRES_H …
#define LTC2945_MIN_POWER_THRES_H …
#define LTC2945_SENSE_H …
#define LTC2945_MAX_SENSE_H …
#define LTC2945_MIN_SENSE_H …
#define LTC2945_MAX_SENSE_THRES_H …
#define LTC2945_MIN_SENSE_THRES_H …
#define LTC2945_VIN_H …
#define LTC2945_MAX_VIN_H …
#define LTC2945_MIN_VIN_H …
#define LTC2945_MAX_VIN_THRES_H …
#define LTC2945_MIN_VIN_THRES_H …
#define LTC2945_ADIN_H …
#define LTC2945_MAX_ADIN_H …
#define LTC2945_MIN_ADIN_H …
#define LTC2945_MAX_ADIN_THRES_H …
#define LTC2945_MIN_ADIN_THRES_H …
#define LTC2945_MIN_ADIN_THRES_L …
#define FAULT_ADIN_UV …
#define FAULT_ADIN_OV …
#define FAULT_VIN_UV …
#define FAULT_VIN_OV …
#define FAULT_SENSE_UV …
#define FAULT_SENSE_OV …
#define FAULT_POWER_UV …
#define FAULT_POWER_OV …
#define CONTROL_MULT_SELECT …
#define CONTROL_TEST_MODE …
static const struct of_device_id __maybe_unused ltc2945_of_match[] = …;
MODULE_DEVICE_TABLE(of, ltc2945_of_match);
struct ltc2945_data { … };
static inline bool is_power_reg(u8 reg)
{ … }
static long long ltc2945_reg_to_val(struct device *dev, u8 reg)
{ … }
static long long ltc2945_val_to_reg(struct device *dev, u8 reg,
unsigned long long val)
{ … }
static ssize_t ltc2945_value_show(struct device *dev,
struct device_attribute *da, char *buf)
{ … }
static ssize_t ltc2945_value_store(struct device *dev,
struct device_attribute *da,
const char *buf, size_t count)
{ … }
static ssize_t ltc2945_history_store(struct device *dev,
struct device_attribute *da,
const char *buf, size_t count)
{ … }
static ssize_t ltc2945_bool_show(struct device *dev,
struct device_attribute *da, char *buf)
{ … }
static SENSOR_DEVICE_ATTR_RO(in1_input, ltc2945_value, LTC2945_VIN_H);
static SENSOR_DEVICE_ATTR_RW(in1_min, ltc2945_value, LTC2945_MIN_VIN_THRES_H);
static SENSOR_DEVICE_ATTR_RW(in1_max, ltc2945_value, LTC2945_MAX_VIN_THRES_H);
static SENSOR_DEVICE_ATTR_RO(in1_lowest, ltc2945_value, LTC2945_MIN_VIN_H);
static SENSOR_DEVICE_ATTR_RO(in1_highest, ltc2945_value, LTC2945_MAX_VIN_H);
static SENSOR_DEVICE_ATTR_WO(in1_reset_history, ltc2945_history,
LTC2945_MIN_VIN_H);
static SENSOR_DEVICE_ATTR_RO(in2_input, ltc2945_value, LTC2945_ADIN_H);
static SENSOR_DEVICE_ATTR_RW(in2_min, ltc2945_value, LTC2945_MIN_ADIN_THRES_H);
static SENSOR_DEVICE_ATTR_RW(in2_max, ltc2945_value, LTC2945_MAX_ADIN_THRES_H);
static SENSOR_DEVICE_ATTR_RO(in2_lowest, ltc2945_value, LTC2945_MIN_ADIN_H);
static SENSOR_DEVICE_ATTR_RO(in2_highest, ltc2945_value, LTC2945_MAX_ADIN_H);
static SENSOR_DEVICE_ATTR_WO(in2_reset_history, ltc2945_history,
LTC2945_MIN_ADIN_H);
static SENSOR_DEVICE_ATTR_RO(in1_min_alarm, ltc2945_bool, FAULT_VIN_UV);
static SENSOR_DEVICE_ATTR_RO(in1_max_alarm, ltc2945_bool, FAULT_VIN_OV);
static SENSOR_DEVICE_ATTR_RO(in2_min_alarm, ltc2945_bool, FAULT_ADIN_UV);
static SENSOR_DEVICE_ATTR_RO(in2_max_alarm, ltc2945_bool, FAULT_ADIN_OV);
static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc2945_value, LTC2945_SENSE_H);
static SENSOR_DEVICE_ATTR_RW(curr1_min, ltc2945_value,
LTC2945_MIN_SENSE_THRES_H);
static SENSOR_DEVICE_ATTR_RW(curr1_max, ltc2945_value,
LTC2945_MAX_SENSE_THRES_H);
static SENSOR_DEVICE_ATTR_RO(curr1_lowest, ltc2945_value, LTC2945_MIN_SENSE_H);
static SENSOR_DEVICE_ATTR_RO(curr1_highest, ltc2945_value,
LTC2945_MAX_SENSE_H);
static SENSOR_DEVICE_ATTR_WO(curr1_reset_history, ltc2945_history,
LTC2945_MIN_SENSE_H);
static SENSOR_DEVICE_ATTR_RO(curr1_min_alarm, ltc2945_bool, FAULT_SENSE_UV);
static SENSOR_DEVICE_ATTR_RO(curr1_max_alarm, ltc2945_bool, FAULT_SENSE_OV);
static SENSOR_DEVICE_ATTR_RO(power1_input, ltc2945_value, LTC2945_POWER_H);
static SENSOR_DEVICE_ATTR_RW(power1_min, ltc2945_value,
LTC2945_MIN_POWER_THRES_H);
static SENSOR_DEVICE_ATTR_RW(power1_max, ltc2945_value,
LTC2945_MAX_POWER_THRES_H);
static SENSOR_DEVICE_ATTR_RO(power1_input_lowest, ltc2945_value,
LTC2945_MIN_POWER_H);
static SENSOR_DEVICE_ATTR_RO(power1_input_highest, ltc2945_value,
LTC2945_MAX_POWER_H);
static SENSOR_DEVICE_ATTR_WO(power1_reset_history, ltc2945_history,
LTC2945_MIN_POWER_H);
static SENSOR_DEVICE_ATTR_RO(power1_min_alarm, ltc2945_bool, FAULT_POWER_UV);
static SENSOR_DEVICE_ATTR_RO(power1_max_alarm, ltc2945_bool, FAULT_POWER_OV);
static struct attribute *ltc2945_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static const struct regmap_config ltc2945_regmap_config = …;
static int ltc2945_probe(struct i2c_client *client)
{ … }
static const struct i2c_device_id ltc2945_id[] = …;
MODULE_DEVICE_TABLE(i2c, ltc2945_id);
static struct i2c_driver ltc2945_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;