mirror of
https://gitlab.com/manzerbredes/ina260-sysfs-driver.git
synced 2025-04-19 04:09:45 +00:00
Minor changes
This commit is contained in:
parent
c3df82853b
commit
bbdef98fc2
1 changed files with 14 additions and 15 deletions
29
ina260.c
29
ina260.c
|
@ -17,10 +17,9 @@
|
|||
#define INA260_REG_ALERTLIMIT 0x07
|
||||
#define INA260_REG_MANUFACTURER 0xFE
|
||||
#define INA260_REG_DIE 0xFF
|
||||
#undef current
|
||||
|
||||
static struct regmap_config ina260_regmap_config = {
|
||||
.max_register = 0xFF,
|
||||
.max_register = INA260_REG_DIE,
|
||||
.reg_bits = 8,
|
||||
.val_bits = 16,
|
||||
};
|
||||
|
@ -58,19 +57,14 @@ static ssize_t _attr##_store(struct device *dev, struct device_attribute *attr,
|
|||
} \
|
||||
})
|
||||
|
||||
// Data attached to i2c clients
|
||||
/**
|
||||
* @brief Embedded user data
|
||||
*/
|
||||
struct client_data {
|
||||
struct i2c_client *client;
|
||||
struct regmap *regmap;
|
||||
};
|
||||
|
||||
static const struct i2c_device_id ina260_ids[] = {
|
||||
{ "ina260", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c,ina260_ids);
|
||||
|
||||
|
||||
static int ina260_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
|
||||
u32 attr, int channel, long *val)
|
||||
{
|
||||
|
@ -107,7 +101,7 @@ static int ina260_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
|
|||
}
|
||||
|
||||
INA260_REG_SHOW(configuration,INA260_REG_CONFIGURATION)
|
||||
INA260_REG_SHOW(current,INA260_REG_CURRENT)
|
||||
INA260_REG_SHOW(curr,INA260_REG_CURRENT)
|
||||
INA260_REG_SHOW(bus_voltage,INA260_REG_VOLTAGE)
|
||||
INA260_REG_SHOW(power,INA260_REG_POWER)
|
||||
INA260_REG_SHOW(mask_enable,INA260_REG_MASKENABLE)
|
||||
|
@ -116,13 +110,12 @@ INA260_REG_SHOW(manufacturer_id,INA260_REG_MANUFACTURER)
|
|||
INA260_REG_SHOW(die_id,INA260_REG_DIE)
|
||||
|
||||
INA260_REG_STORE(configuration,INA260_REG_CONFIGURATION)
|
||||
INA260_REG_STORE(current,INA260_REG_CURRENT)
|
||||
INA260_REG_STORE(curr,INA260_REG_CURRENT)
|
||||
INA260_REG_STORE(bus_voltage,INA260_REG_VOLTAGE)
|
||||
INA260_REG_STORE(power,INA260_REG_POWER)
|
||||
INA260_REG_STORE(mask_enable,INA260_REG_MASKENABLE)
|
||||
INA260_REG_STORE(alert_limit,INA260_REG_ALERTLIMIT)
|
||||
|
||||
|
||||
static umode_t ina260_hwmon_is_visible(const void *drvdata,
|
||||
enum hwmon_sensor_types type,
|
||||
u32 attr, int channel){
|
||||
|
@ -146,7 +139,7 @@ static const struct hwmon_chip_info ina260_chip_info = {
|
|||
};
|
||||
// ----- Registers -----
|
||||
static DEVICE_ATTR_RW(configuration);
|
||||
static DEVICE_ATTR_RW(current);
|
||||
static DEVICE_ATTR_RW(curr);
|
||||
static DEVICE_ATTR_RW(bus_voltage);
|
||||
static DEVICE_ATTR_RW(power);
|
||||
static DEVICE_ATTR_RW(mask_enable);
|
||||
|
@ -155,7 +148,7 @@ static DEVICE_ATTR_RO(manufacturer_id);
|
|||
static DEVICE_ATTR_RO(die_id);
|
||||
static struct attribute *registers_attrs[] = {
|
||||
&dev_attr_configuration.attr,
|
||||
&dev_attr_current.attr,
|
||||
&dev_attr_curr.attr,
|
||||
&dev_attr_bus_voltage.attr,
|
||||
&dev_attr_power.attr,
|
||||
&dev_attr_mask_enable.attr,
|
||||
|
@ -199,6 +192,12 @@ static int ina260_remove(struct i2c_client *client){
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id ina260_ids[] = {
|
||||
{ "ina260", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c,ina260_ids);
|
||||
|
||||
static struct i2c_driver ina260_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue