Re: [PATCH v4 2/2] power: supply: add support for MAX1720x standalone fuel gauge
From: Sebastian Reichel
Date: Tue Jun 18 2024 - 19:19:46 EST
Hi,
On Mon, Jun 17, 2024 at 08:45:04PM GMT, Dimitri Fedrau wrote:
> The MAX17201 monitors a single cell pack. The MAX17205 monitors and
> balances a 2S or 3S pack or monitors a multiple-series cell pack. Both
> devices use a I2C interface.
>
> Signed-off-by: Dimitri Fedrau <dima.fedrau@xxxxxxxxx>
> ---
[...]
> +static int max1720x_read_word_data_nvmem(struct i2c_client *ancillary, u8 addr)
> +{
> + u8 rx[2];
> + struct i2c_msg msgs[] = {
> + {
> + .addr = ancillary->addr,
> + .flags = 0,
> + .len = 1,
> + .buf = &addr,
> + },
> + {
> + .addr = ancillary->addr,
> + .flags = I2C_M_RD,
> + .len = 2,
> + .buf = &rx[0],
> + },
> + };
> + int ret;
> +
> + ret = i2c_transfer(ancillary->adapter, msgs, ARRAY_SIZE(msgs));
> + if (ret != ARRAY_SIZE(msgs))
> + return ret < 0 ? ret : -EIO;
> +
> + return get_unaligned_le16(&rx[0]);
> +}
Have you tried using i2c_smbus_read_word_data(ancillary, addr)
instead of the above?
[...]
> +static int max1720x_probe(struct i2c_client *client)
> +{
> + struct power_supply_config psy_cfg = {};
> + struct device *dev = &client->dev;
> + struct max1720x_device_info *info;
> + struct power_supply *bat;
> + int ret;
> +
> + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
> + if (!info)
> + return -ENOMEM;
> +
> + psy_cfg.drv_data = info;
psy_cfg.fwnode = dev_fwnode(dev);
Otherwise LGTM.
Thanks for your patch,
-- Sebastian
Attachment:
signature.asc
Description: PGP signature