On 8/29/24 07:55, Tzung-Bi Shih wrote:
On Tue, Aug 27, 2024 at 08:34:55AM -0700, Guenter Roeck wrote:
+static int ina2xx_in_read(struct device *dev, u32 attr, int channel, long *val)
+{
+ int voltage_reg = channel ? INA2XX_BUS_VOLTAGE : INA2XX_SHUNT_VOLTAGE;
+ u32 under_voltage_mask = channel ? INA226_BUS_UNDER_VOLTAGE_MASK
+ : INA226_SHUNT_UNDER_VOLTAGE_MASK;
+ u32 over_voltage_mask = channel ? INA226_BUS_OVER_VOLTAGE_MASK
+ : INA226_SHUNT_OVER_VOLTAGE_MASK;
+ struct ina2xx_data *data = dev_get_drvdata(dev);
+ struct regmap *regmap = data->regmap;
+ unsigned int regval;
+ int ret;
+
+ switch (attr) {
+ case hwmon_in_input:
+ ret = regmap_read(regmap, voltage_reg, ®val);
+ if (ret)
+ return ret;
+ *val = ina2xx_get_value(data, voltage_reg, regval);
Doesn't it need to call ina2xx_read_init() too? Originally, [1][2] call
ina2xx_value_show() and then ina2xx_read_reg() and detect if the chip has
been reset.
No, because reading the voltage does not require calibration. If a voltage
happens to report 0V, it is just 0V, and does not indicate that the chip
has been reset. That applies to both shunt and bus voltage.
Thanks,
Guenter