mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <Ariana.Lazar@microchip.com>
To: <jic23@kernel.org>
Cc: <dlechner@baylibre.com>, <linux@roeck-us.net>,
	<linux-hwmon@vger.kernel.org>, <nuno.sa@analog.com>,
	<linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<robh@kernel.org>, <linux-kernel@vger.kernel.org>,
	<andy@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
	<neil.armstrong@linaro.org>
Subject: Re: [PATCH v4 3/3] iio: adc: add support for PAC1711
Date: Mon, 19 Oct 2026 13:35:29 +0000	[thread overview]
Message-ID: <514e3ba1e9dd5f49afddf5c81ed6b9c38329102c.camel@microchip.com> (raw)
In-Reply-To: <20261018202704.4ac77274@jic23-hlaptop>

Hi Jonathan,

Thank you for the review.

> > +static inline u64 pac1711_get_unaligned_be56(u8 *p)
> > +{
> > +     return (u64)p[0] << 48 | (u64)p[1] << 40 | (u64)p[2] << 32 |
> > +             (u64)p[3] << 24 | p[4] << 16 | p[5] << 8 | p[6];
> > +}
> Neil Amstrong has a patch on list adding a generic version of this.
> https://lore.kernel.org/all/20261013-topic-sm8x50-iio-max34417-adc-v3-2-d3604ae4a229@linaro.org/
> 
> If you can add that to start of your series, then I'll deal with
> picking it up with whoever's series lands first.
> +CC Neil for info on this.


Sure, I will include be56 helper patch in the series and add Neil to
CC.


> > +
> > +static int pac1711_read_raw(struct iio_dev *indio_dev, struct
> > iio_chan_spec const *chan,
> > +                         int *val, int *val2, long mask)
> > +{
> > +     struct pac1711_chip_info *info = iio_priv(indio_dev);
> > +     u64 tmp = 0;
> > +     int ret;
> > +
> > +     switch (mask) {
> > +     case IIO_CHAN_INFO_RAW:
> > +             ret = pac1711_retrieve_data(info,
> > PAC1711_MIN_UPDATE_WAIT_TIME_US);
> > +             if (ret)
> > +                     return ret;
> > +
> > +             switch (chan->type) {
> > +             case IIO_VOLTAGE:
> > +                     *val = info->chip_reg_data.vbus;
> > +                     return IIO_VAL_INT;
> > +             case IIO_CURRENT:
> > +                     *val = info->chip_reg_data.vsense;
> > +                     return IIO_VAL_INT;
> > +             case IIO_POWER:
> > +                     scoped_guard(mutex, &info->lock) {
> > +                             *val = (u32)info-
> > >chip_reg_data.vpower;
> > +                             *val2 = (u32)(info-
> > >chip_reg_data.vpower >> 32);
> > +                     }
> > +                     return IIO_VAL_INT_64;
> > +             case IIO_ENERGY:
> > +             case IIO_CHARGE:
> > +                     scoped_guard(mutex, &info->lock) {
> > +                             *val = (u32)info-
> > >chip_reg_data.acc_val;
> 
> Could use lower_32_bits / upper_32_bits.
> Maybe we should just have a helper for this given it is
> becoming rather more common.
>                                 iio_fill_val_int_64(info-
> >chip_reg_data.acc_val, val, val2);
> 
> I don't mind if you want to leave that a follow up for someone else
> to do though.


About this, would you prefer me to add iio_fill_val_int_64() as a
precursor patch in this series, with PAC1711 as its first user? Or
should I use lower_32_bits() and upper_32_bits() in the driver
implementation and leave the generic helper for a separate follow-up
series?

> > 
> > 
> > +
> > +static int pac1711_parse_fw(struct i2c_client *client, struct
> > pac1711_chip_info *info)
> > +{
> > +     struct device *dev = &client->dev;
> > +     const char *acc_mode;
> > +     int ret;
> > +
> > +     ret = device_property_read_u32(dev, "shunt-resistor-micro-
> > ohms", &info->shunt);
> > +     if (ret)
> > +             return dev_err_probe(dev, ret, "Shunt resistor
> > property error\n");
> > +
> > +     if (!info->shunt)
> > +             return dev_err_probe(dev, -EINVAL, "Invalid value for
> > shunt resistor\n");
> > +
> > +     ret = pac1711_init_vbus_vsense_ranges(info, true);
> > +     if (ret)
> > +             return ret;
> > +
> > +     ret = pac1711_init_vbus_vsense_ranges(info, false);
> > +     if (ret)
> > +             return ret;
> > +
> > +     if (device_property_present(dev, "microchip,accumulation-
> > source")) {
> > +             ret = device_property_read_string(dev,
> > "microchip,accumulation-source", &acc_mode);
> > +             if (ret)
> > +                     return dev_err_probe(dev, ret, "Cannot read
> > accumulation-source\n");
> > +
> > +             if (!strcmp(acc_mode, PAC1711_ACC_ENERGY_STR))
> > +                     info->accumulation_mode =
> > PAC1711_ACCMODE_VPOWER;
> > +             else if (!strcmp(acc_mode, PAC1711_ACC_CHARGE_STR))
> > +                     info->accumulation_mode =
> > PAC1711_ACCMODE_VSENSE;
> 
> Can we use fwnode_property_match_property_string() for this?
> Could add a device variant for that to make it simpler still.
> 
> 

Regarding this comment, I was wondering if
device_property_match_property_string() is the function you want me to
use in the driver implementation instead of strcmp():

https://elixir.bootlin.com/linux/v7.3-rc7/C/ident/device_property_match_property_string




Best regards,
Ariana


  reply	other threads:[~2026-10-19 13:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 14:41 [PATCH v4 0/3] Add support for Microchip PAC1711 Power Monitor Ariana Lazar
2026-10-07 14:41 ` [PATCH v4 1/3] iio: core: add IIO_CHARGE channel type Ariana Lazar
2026-10-07 14:41 ` [PATCH v4 2/3] dt-bindings: iio: adc: add support for PAC1711 Ariana Lazar
2026-10-07 20:47   ` Rob Herring (Arm)
2026-10-07 14:41 ` [PATCH v4 3/3] " Ariana Lazar
2026-10-08 16:46   ` kernel test robot
2026-10-18 19:27   ` Jonathan Cameron
2026-10-19 13:35     ` Ariana.Lazar [this message]
2026-10-18 18:43 ` [PATCH v4 0/3] Add support for Microchip PAC1711 Power Monitor Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=514e3ba1e9dd5f49afddf5c81ed6b9c38329102c.camel@microchip.com \
    --to=ariana.lazar@microchip.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=neil.armstrong@linaro.org \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®