#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.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>
enum chips { … };
#define MAX16065_ADC(x) …
#define MAX16065_CURR_SENSE …
#define MAX16065_CSP_ADC …
#define MAX16065_FAULT(x) …
#define MAX16065_SCALE(x) …
#define MAX16065_CURR_CONTROL …
#define MAX16065_LIMIT(l, x) …
#define MAX16065_SW_ENABLE …
#define MAX16065_WARNING_OV …
#define MAX16065_CURR_ENABLE …
#define MAX16065_NUM_LIMIT …
#define MAX16065_NUM_ADC …
static const int max16065_num_adc[] = …;
static const bool max16065_have_secondary[] = …;
static const bool max16065_have_current[] = …;
struct max16065_data { … };
static const int max16065_adc_range[] = …;
static const int max16065_csp_adc_range[] = …;
static inline int ADC_TO_MV(int adc, int range)
{ … }
static inline int LIMIT_TO_MV(int limit, int range)
{ … }
static inline int MV_TO_LIMIT(int mv, int range)
{ … }
static inline int ADC_TO_CURR(int adc, int gain)
{ … }
static int max16065_read_adc(struct i2c_client *client, int reg)
{ … }
static struct max16065_data *max16065_update_device(struct device *dev)
{ … }
static ssize_t max16065_alarm_show(struct device *dev,
struct device_attribute *da, char *buf)
{ … }
static ssize_t max16065_input_show(struct device *dev,
struct device_attribute *da, char *buf)
{ … }
static ssize_t max16065_current_show(struct device *dev,
struct device_attribute *da, char *buf)
{ … }
static ssize_t max16065_limit_store(struct device *dev,
struct device_attribute *da,
const char *buf, size_t count)
{ … }
static ssize_t max16065_limit_show(struct device *dev,
struct device_attribute *da, char *buf)
{ … }
static SENSOR_DEVICE_ATTR_RO(in0_input, max16065_input, 0);
static SENSOR_DEVICE_ATTR_RO(in1_input, max16065_input, 1);
static SENSOR_DEVICE_ATTR_RO(in2_input, max16065_input, 2);
static SENSOR_DEVICE_ATTR_RO(in3_input, max16065_input, 3);
static SENSOR_DEVICE_ATTR_RO(in4_input, max16065_input, 4);
static SENSOR_DEVICE_ATTR_RO(in5_input, max16065_input, 5);
static SENSOR_DEVICE_ATTR_RO(in6_input, max16065_input, 6);
static SENSOR_DEVICE_ATTR_RO(in7_input, max16065_input, 7);
static SENSOR_DEVICE_ATTR_RO(in8_input, max16065_input, 8);
static SENSOR_DEVICE_ATTR_RO(in9_input, max16065_input, 9);
static SENSOR_DEVICE_ATTR_RO(in10_input, max16065_input, 10);
static SENSOR_DEVICE_ATTR_RO(in11_input, max16065_input, 11);
static SENSOR_DEVICE_ATTR_RO(in12_input, max16065_input, 12);
static SENSOR_DEVICE_ATTR_2_RW(in0_lcrit, max16065_limit, 2, 0);
static SENSOR_DEVICE_ATTR_2_RW(in1_lcrit, max16065_limit, 2, 1);
static SENSOR_DEVICE_ATTR_2_RW(in2_lcrit, max16065_limit, 2, 2);
static SENSOR_DEVICE_ATTR_2_RW(in3_lcrit, max16065_limit, 2, 3);
static SENSOR_DEVICE_ATTR_2_RW(in4_lcrit, max16065_limit, 2, 4);
static SENSOR_DEVICE_ATTR_2_RW(in5_lcrit, max16065_limit, 2, 5);
static SENSOR_DEVICE_ATTR_2_RW(in6_lcrit, max16065_limit, 2, 6);
static SENSOR_DEVICE_ATTR_2_RW(in7_lcrit, max16065_limit, 2, 7);
static SENSOR_DEVICE_ATTR_2_RW(in8_lcrit, max16065_limit, 2, 8);
static SENSOR_DEVICE_ATTR_2_RW(in9_lcrit, max16065_limit, 2, 9);
static SENSOR_DEVICE_ATTR_2_RW(in10_lcrit, max16065_limit, 2, 10);
static SENSOR_DEVICE_ATTR_2_RW(in11_lcrit, max16065_limit, 2, 11);
static SENSOR_DEVICE_ATTR_2_RW(in0_crit, max16065_limit, 1, 0);
static SENSOR_DEVICE_ATTR_2_RW(in1_crit, max16065_limit, 1, 1);
static SENSOR_DEVICE_ATTR_2_RW(in2_crit, max16065_limit, 1, 2);
static SENSOR_DEVICE_ATTR_2_RW(in3_crit, max16065_limit, 1, 3);
static SENSOR_DEVICE_ATTR_2_RW(in4_crit, max16065_limit, 1, 4);
static SENSOR_DEVICE_ATTR_2_RW(in5_crit, max16065_limit, 1, 5);
static SENSOR_DEVICE_ATTR_2_RW(in6_crit, max16065_limit, 1, 6);
static SENSOR_DEVICE_ATTR_2_RW(in7_crit, max16065_limit, 1, 7);
static SENSOR_DEVICE_ATTR_2_RW(in8_crit, max16065_limit, 1, 8);
static SENSOR_DEVICE_ATTR_2_RW(in9_crit, max16065_limit, 1, 9);
static SENSOR_DEVICE_ATTR_2_RW(in10_crit, max16065_limit, 1, 10);
static SENSOR_DEVICE_ATTR_2_RW(in11_crit, max16065_limit, 1, 11);
static SENSOR_DEVICE_ATTR_2_RW(in0_min, max16065_limit, 0, 0);
static SENSOR_DEVICE_ATTR_2_RW(in1_min, max16065_limit, 0, 1);
static SENSOR_DEVICE_ATTR_2_RW(in2_min, max16065_limit, 0, 2);
static SENSOR_DEVICE_ATTR_2_RW(in3_min, max16065_limit, 0, 3);
static SENSOR_DEVICE_ATTR_2_RW(in4_min, max16065_limit, 0, 4);
static SENSOR_DEVICE_ATTR_2_RW(in5_min, max16065_limit, 0, 5);
static SENSOR_DEVICE_ATTR_2_RW(in6_min, max16065_limit, 0, 6);
static SENSOR_DEVICE_ATTR_2_RW(in7_min, max16065_limit, 0, 7);
static SENSOR_DEVICE_ATTR_2_RW(in8_min, max16065_limit, 0, 8);
static SENSOR_DEVICE_ATTR_2_RW(in9_min, max16065_limit, 0, 9);
static SENSOR_DEVICE_ATTR_2_RW(in10_min, max16065_limit, 0, 10);
static SENSOR_DEVICE_ATTR_2_RW(in11_min, max16065_limit, 0, 11);
static SENSOR_DEVICE_ATTR_2_RW(in0_max, max16065_limit, 0, 0);
static SENSOR_DEVICE_ATTR_2_RW(in1_max, max16065_limit, 0, 1);
static SENSOR_DEVICE_ATTR_2_RW(in2_max, max16065_limit, 0, 2);
static SENSOR_DEVICE_ATTR_2_RW(in3_max, max16065_limit, 0, 3);
static SENSOR_DEVICE_ATTR_2_RW(in4_max, max16065_limit, 0, 4);
static SENSOR_DEVICE_ATTR_2_RW(in5_max, max16065_limit, 0, 5);
static SENSOR_DEVICE_ATTR_2_RW(in6_max, max16065_limit, 0, 6);
static SENSOR_DEVICE_ATTR_2_RW(in7_max, max16065_limit, 0, 7);
static SENSOR_DEVICE_ATTR_2_RW(in8_max, max16065_limit, 0, 8);
static SENSOR_DEVICE_ATTR_2_RW(in9_max, max16065_limit, 0, 9);
static SENSOR_DEVICE_ATTR_2_RW(in10_max, max16065_limit, 0, 10);
static SENSOR_DEVICE_ATTR_2_RW(in11_max, max16065_limit, 0, 11);
static SENSOR_DEVICE_ATTR_2_RO(in0_alarm, max16065_alarm, 0, 0);
static SENSOR_DEVICE_ATTR_2_RO(in1_alarm, max16065_alarm, 0, 1);
static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, max16065_alarm, 0, 2);
static SENSOR_DEVICE_ATTR_2_RO(in3_alarm, max16065_alarm, 0, 3);
static SENSOR_DEVICE_ATTR_2_RO(in4_alarm, max16065_alarm, 0, 4);
static SENSOR_DEVICE_ATTR_2_RO(in5_alarm, max16065_alarm, 0, 5);
static SENSOR_DEVICE_ATTR_2_RO(in6_alarm, max16065_alarm, 0, 6);
static SENSOR_DEVICE_ATTR_2_RO(in7_alarm, max16065_alarm, 0, 7);
static SENSOR_DEVICE_ATTR_2_RO(in8_alarm, max16065_alarm, 1, 0);
static SENSOR_DEVICE_ATTR_2_RO(in9_alarm, max16065_alarm, 1, 1);
static SENSOR_DEVICE_ATTR_2_RO(in10_alarm, max16065_alarm, 1, 2);
static SENSOR_DEVICE_ATTR_2_RO(in11_alarm, max16065_alarm, 1, 3);
static SENSOR_DEVICE_ATTR_RO(curr1_input, max16065_current, 0);
static SENSOR_DEVICE_ATTR_2_RO(curr1_alarm, max16065_alarm, 1, 4);
static struct attribute *max16065_basic_attributes[] = …;
static struct attribute *max16065_current_attributes[] = …;
static struct attribute *max16065_min_attributes[] = …;
static struct attribute *max16065_max_attributes[] = …;
static umode_t max16065_basic_is_visible(struct kobject *kobj,
struct attribute *a, int n)
{ … }
static umode_t max16065_secondary_is_visible(struct kobject *kobj,
struct attribute *a, int index)
{ … }
static const struct attribute_group max16065_basic_group = …;
static const struct attribute_group max16065_current_group = …;
static const struct attribute_group max16065_min_group = …;
static const struct attribute_group max16065_max_group = …;
static int max16065_probe(struct i2c_client *client)
{ … }
static const struct i2c_device_id max16065_id[] = …;
MODULE_DEVICE_TABLE(i2c, max16065_id);
static struct i2c_driver max16065_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;