#include <linux/debugfs.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/util_macros.h>
#define INA3221_DRIVER_NAME …
#define INA3221_CONFIG …
#define INA3221_SHUNT1 …
#define INA3221_BUS1 …
#define INA3221_SHUNT2 …
#define INA3221_BUS2 …
#define INA3221_SHUNT3 …
#define INA3221_BUS3 …
#define INA3221_CRIT1 …
#define INA3221_WARN1 …
#define INA3221_CRIT2 …
#define INA3221_WARN2 …
#define INA3221_CRIT3 …
#define INA3221_WARN3 …
#define INA3221_SHUNT_SUM …
#define INA3221_CRIT_SUM …
#define INA3221_MASK_ENABLE …
#define INA3221_CONFIG_MODE_MASK …
#define INA3221_CONFIG_MODE_POWERDOWN …
#define INA3221_CONFIG_MODE_SHUNT …
#define INA3221_CONFIG_MODE_BUS …
#define INA3221_CONFIG_MODE_CONTINUOUS …
#define INA3221_CONFIG_VSH_CT_SHIFT …
#define INA3221_CONFIG_VSH_CT_MASK …
#define INA3221_CONFIG_VSH_CT(x) …
#define INA3221_CONFIG_VBUS_CT_SHIFT …
#define INA3221_CONFIG_VBUS_CT_MASK …
#define INA3221_CONFIG_VBUS_CT(x) …
#define INA3221_CONFIG_AVG_SHIFT …
#define INA3221_CONFIG_AVG_MASK …
#define INA3221_CONFIG_AVG(x) …
#define INA3221_CONFIG_CHs_EN_MASK …
#define INA3221_CONFIG_CHx_EN(x) …
#define INA3221_MASK_ENABLE_SCC_MASK …
#define INA3221_CONFIG_DEFAULT …
#define INA3221_RSHUNT_DEFAULT …
enum ina3221_fields { … };
static const struct reg_field ina3221_reg_fields[] = …;
enum ina3221_channels { … };
struct ina3221_input { … };
struct ina3221_data { … };
static inline bool ina3221_is_enabled(struct ina3221_data *ina, int channel)
{ … }
static inline int ina3221_summation_shunt_resistor(struct ina3221_data *ina)
{ … }
static const u16 ina3221_conv_time[] = …;
static const int ina3221_avg_samples[] = …;
static inline u32 ina3221_interval_ms_to_conv_time(u16 config, int interval)
{ … }
static inline u32 ina3221_reg_to_interval_us(u16 config)
{ … }
static inline int ina3221_wait_for_data(struct ina3221_data *ina)
{ … }
static int ina3221_read_value(struct ina3221_data *ina, unsigned int reg,
int *val)
{ … }
static const u8 ina3221_in_reg[] = …;
static int ina3221_read_chip(struct device *dev, u32 attr, long *val)
{ … }
static int ina3221_read_in(struct device *dev, u32 attr, int channel, long *val)
{ … }
static const u8 ina3221_curr_reg[][INA3221_NUM_CHANNELS + 1] = …;
static int ina3221_read_curr(struct device *dev, u32 attr,
int channel, long *val)
{ … }
static int ina3221_write_chip(struct device *dev, u32 attr, long val)
{ … }
static int ina3221_write_curr(struct device *dev, u32 attr,
int channel, long val)
{ … }
static int ina3221_write_enable(struct device *dev, int channel, bool enable)
{ … }
static int ina3221_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{ … }
static int ina3221_write(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long val)
{ … }
static int ina3221_read_string(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, const char **str)
{ … }
static umode_t ina3221_is_visible(const void *drvdata,
enum hwmon_sensor_types type,
u32 attr, int channel)
{ … }
#define INA3221_HWMON_CURR_CONFIG …
static const struct hwmon_channel_info * const ina3221_info[] = …;
static const struct hwmon_ops ina3221_hwmon_ops = …;
static const struct hwmon_chip_info ina3221_chip_info = …;
static ssize_t ina3221_shunt_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t ina3221_shunt_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static SENSOR_DEVICE_ATTR_RW(shunt1_resistor, ina3221_shunt, INA3221_CHANNEL1);
static SENSOR_DEVICE_ATTR_RW(shunt2_resistor, ina3221_shunt, INA3221_CHANNEL2);
static SENSOR_DEVICE_ATTR_RW(shunt3_resistor, ina3221_shunt, INA3221_CHANNEL3);
static struct attribute *ina3221_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static const struct regmap_range ina3221_yes_ranges[] = …;
static const struct regmap_access_table ina3221_volatile_table = …;
static const struct regmap_config ina3221_regmap_config = …;
static int ina3221_probe_child_from_dt(struct device *dev,
struct device_node *child,
struct ina3221_data *ina)
{ … }
static int ina3221_probe_from_dt(struct device *dev, struct ina3221_data *ina)
{ … }
static int ina3221_probe(struct i2c_client *client)
{ … }
static void ina3221_remove(struct i2c_client *client)
{ … }
static int ina3221_suspend(struct device *dev)
{ … }
static int ina3221_resume(struct device *dev)
{ … }
static DEFINE_RUNTIME_DEV_PM_OPS(ina3221_pm, ina3221_suspend, ina3221_resume,
NULL);
static const struct of_device_id ina3221_of_match_table[] = …;
MODULE_DEVICE_TABLE(of, ina3221_of_match_table);
static const struct i2c_device_id ina3221_ids[] = …;
MODULE_DEVICE_TABLE(i2c, ina3221_ids);
static struct i2c_driver ina3221_i2c_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;