#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/jiffies.h>
#define NUMBER_OF_VIN …
#define NUMBER_OF_FANIN …
#define NUMBER_OF_TEMPIN …
#define NUMBER_OF_PWM …
static const unsigned short normal_i2c[] = …;
static unsigned short force_subclients[4];
module_param_array(…);
MODULE_PARM_DESC(…) …;
static bool reset;
module_param(reset, bool, 0);
MODULE_PARM_DESC(…) …;
static bool init;
module_param(init, bool, 0);
MODULE_PARM_DESC(…) …;
static const u8 W83791D_REG_IN[NUMBER_OF_VIN] = …;
static const u8 W83791D_REG_IN_MAX[NUMBER_OF_VIN] = …;
static const u8 W83791D_REG_IN_MIN[NUMBER_OF_VIN] = …;
static const u8 W83791D_REG_FAN[NUMBER_OF_FANIN] = …;
static const u8 W83791D_REG_FAN_MIN[NUMBER_OF_FANIN] = …;
static const u8 W83791D_REG_PWM[NUMBER_OF_PWM] = …;
static const u8 W83791D_REG_TEMP_TARGET[3] = …;
static const u8 W83791D_REG_TEMP_TOL[2] = …;
static const u8 W83791D_REG_FAN_CFG[2] = …;
static const u8 W83791D_REG_FAN_DIV[3] = …;
#define W83791D_REG_BANK …
#define W83791D_REG_TEMP2_CONFIG …
#define W83791D_REG_TEMP3_CONFIG …
static const u8 W83791D_REG_TEMP1[3] = …;
static const u8 W83791D_REG_TEMP_ADD[2][6] = …;
#define W83791D_REG_BEEP_CONFIG …
static const u8 W83791D_REG_BEEP_CTRL[3] = …;
#define W83791D_REG_GPIO …
#define W83791D_REG_CONFIG …
#define W83791D_REG_VID_FANDIV …
#define W83791D_REG_DID_VID4 …
#define W83791D_REG_WCHIPID …
#define W83791D_REG_CHIPMAN …
#define W83791D_REG_PIN …
#define W83791D_REG_I2C_SUBADDR …
#define W83791D_REG_ALARM1 …
#define W83791D_REG_ALARM2 …
#define W83791D_REG_ALARM3 …
#define W83791D_REG_VBAT …
#define W83791D_REG_I2C_ADDR …
static inline int w83791d_read(struct i2c_client *client, u8 reg)
{ … }
static inline int w83791d_write(struct i2c_client *client, u8 reg, u8 value)
{ … }
#define IN_TO_REG(val) …
#define IN_FROM_REG(val) …
static u8 fan_to_reg(long rpm, int div)
{ … }
#define FAN_FROM_REG(val, div) …
#define TEMP1_FROM_REG(val) …
#define TEMP1_TO_REG(val) …
#define TEMP23_FROM_REG(val) …
#define TEMP23_TO_REG(val) …
#define TARGET_TEMP_TO_REG(val) …
#define TOL_TEMP_TO_REG(val) …
#define BEEP_MASK_TO_REG(val) …
#define BEEP_MASK_FROM_REG(val) …
#define DIV_FROM_REG(val) …
static u8 div_to_reg(int nr, long val)
{ … }
struct w83791d_data { … };
static int w83791d_probe(struct i2c_client *client);
static int w83791d_detect(struct i2c_client *client,
struct i2c_board_info *info);
static void w83791d_remove(struct i2c_client *client);
static int w83791d_read(struct i2c_client *client, u8 reg);
static int w83791d_write(struct i2c_client *client, u8 reg, u8 value);
static struct w83791d_data *w83791d_update_device(struct device *dev);
#ifdef DEBUG
static void w83791d_print_debug(struct w83791d_data *data, struct device *dev);
#endif
static void w83791d_init_client(struct i2c_client *client);
static const struct i2c_device_id w83791d_id[] = …;
MODULE_DEVICE_TABLE(i2c, w83791d_id);
static struct i2c_driver w83791d_driver = …;
#define show_in_reg(reg) …
show_in_reg(in);
show_in_reg(in_min);
show_in_reg(in_max);
#define store_in_reg(REG, reg) …
store_in_reg(MIN, min);
store_in_reg(MAX, max);
static struct sensor_device_attribute sda_in_input[] = …;
static struct sensor_device_attribute sda_in_min[] = …;
static struct sensor_device_attribute sda_in_max[] = …;
static ssize_t show_beep(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t store_beep(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static struct sensor_device_attribute sda_in_beep[] = …;
static struct sensor_device_attribute sda_in_alarm[] = …;
#define show_fan_reg(reg) …
show_fan_reg(fan);
show_fan_reg(fan_min);
static ssize_t store_fan_min(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t store_fan_div(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static struct sensor_device_attribute sda_fan_input[] = …;
static struct sensor_device_attribute sda_fan_min[] = …;
static struct sensor_device_attribute sda_fan_div[] = …;
static struct sensor_device_attribute sda_fan_beep[] = …;
static struct sensor_device_attribute sda_fan_alarm[] = …;
static ssize_t show_pwm(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t store_pwm(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static struct sensor_device_attribute sda_pwm[] = …;
static ssize_t show_pwmenable(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t store_pwmenable(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{ … }
static struct sensor_device_attribute sda_pwmenable[] = …;
static ssize_t show_temp_target(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t store_temp_target(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{ … }
static struct sensor_device_attribute sda_temp_target[] = …;
static ssize_t show_temp_tolerance(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t store_temp_tolerance(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{ … }
static struct sensor_device_attribute sda_temp_tolerance[] = …;
static ssize_t show_temp1(struct device *dev, struct device_attribute *devattr,
char *buf)
{ … }
static ssize_t store_temp1(struct device *dev, struct device_attribute *devattr,
const char *buf, size_t count)
{ … }
static ssize_t show_temp23(struct device *dev, struct device_attribute *devattr,
char *buf)
{ … }
static ssize_t store_temp23(struct device *dev,
struct device_attribute *devattr,
const char *buf, size_t count)
{ … }
static struct sensor_device_attribute_2 sda_temp_input[] = …;
static struct sensor_device_attribute_2 sda_temp_max[] = …;
static struct sensor_device_attribute_2 sda_temp_max_hyst[] = …;
static struct sensor_device_attribute sda_temp_beep[] = …;
static struct sensor_device_attribute sda_temp_alarm[] = …;
static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(alarms);
#define GLOBAL_BEEP_ENABLE_SHIFT …
#define GLOBAL_BEEP_ENABLE_MASK …
static ssize_t show_beep_enable(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t show_beep_mask(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t store_beep_mask(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t store_beep_enable(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static struct sensor_device_attribute sda_beep_ctrl[] = …;
static ssize_t cpu0_vid_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(cpu0_vid);
static ssize_t vrm_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t vrm_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(vrm);
#define IN_UNIT_ATTRS(X) …
#define FAN_UNIT_ATTRS(X) …
#define TEMP_UNIT_ATTRS(X) …
static struct attribute *w83791d_attributes[] = …;
static const struct attribute_group w83791d_group = …;
static struct attribute *w83791d_attributes_fanpwm45[] = …;
static const struct attribute_group w83791d_group_fanpwm45 = …;
static int w83791d_detect_subclients(struct i2c_client *client)
{ … }
static int w83791d_detect(struct i2c_client *client,
struct i2c_board_info *info)
{ … }
static int w83791d_probe(struct i2c_client *client)
{ … }
static void w83791d_remove(struct i2c_client *client)
{ … }
static void w83791d_init_client(struct i2c_client *client)
{ … }
static struct w83791d_data *w83791d_update_device(struct device *dev)
{ … }
#ifdef DEBUG
static void w83791d_print_debug(struct w83791d_data *data, struct device *dev)
{ … }
#endif
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;