Re: [PATCH 11/11] hwmon: (ina2xx) Convert to use with_info hwmon API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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, &regval);
> +		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.

[1]: https://elixir.bootlin.com/linux/v6.10/source/drivers/hwmon/ina2xx.c#L542
[2]: https://elixir.bootlin.com/linux/v6.10/source/drivers/hwmon/ina2xx.c#L554




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux