All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Duje Mihanović" <duje@dujemihanovic.xyz>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Karel Balej" <balejk@matfyz.cz>, "Lee Jones" <lee@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"David Wronek" <david@mainlining.org>,
	phone-devel@vger.kernel.org,
	~postmarketos/upstreaming@lists.sr.ht,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v2 2/3] iio: adc: Add driver for Marvell 88PM886 PMIC ADC
Date: Mon, 01 Sep 2025 18:51:19 +0200	[thread overview]
Message-ID: <3031049.e9J7NaK4W3@radijator> (raw)
In-Reply-To: <aLW9O1rnhUqqh02r@smile.fi.intel.com>

On Monday, 1 September 2025 17:35:23 Central European Summer Time Andy Shevchenko wrote:
> On Sun, Aug 31, 2025 at 12:33:05PM +0200, Duje Mihanović wrote:
> > +static const struct regmap_config pm886_gpadc_regmap_config = {
> > +	.reg_bits = 8,
> > +	.val_bits = 8,
> > +	.max_register = PM886_REG_GPADC_VBAT_SLP + 1,
> 
> What is this + 1 register? Why is it not defined / documented?

It is the second field of the vbat_slp channel.

> > +static int
> > +gpadc_get_resistance_ohm(struct iio_dev *iio, struct iio_chan_spec const
> > *chan) +{
> > +	struct pm886_gpadc *gpadc = iio_priv(iio);
> > +	unsigned int raw_uv, raw_ua;
> > +	int ret;
> > +
> > +	ret = gpadc_set_bias(gpadc, chan->channel, true);
> > +	if (ret)
> > +		goto err;
> > +
> > +	ret = gpadc_find_bias_current(iio, chan, &raw_uv, &raw_ua);
> > +	if (ret)
> > +		goto err;
> > +
> > +	ret = gpadc_set_bias(gpadc, chan->channel, false);
> > +	if (ret)
> > +		return ret;
> > +
> > +	return DIV_ROUND_CLOSEST(raw_uv, raw_ua);
> > +err:
> > +	gpadc_set_bias(gpadc, chan->channel, false);
> 
> You do the same in the other branch and checking there for an error. Why this
> one is so special?

My rationale here was to not override the error from either the first
gpadc_set_bias() call or the subsequent gpadc_find_bias_current() call.

> > +		dev_dbg(&iio->dev, "chan: %d, raw: %d\n", chan->channel, *val);
> 
> How is this useful? The userspace gets the same value. Do you expect problems
> on its way to the user space?

That's a leftover from debugging v1, will drop.

> > +	iio->dev.of_node = dev->parent->of_node;
> 
> No, use device_set_node() with the respective parameters.
> 
> But rather debug why firmware node (or OF in your case) is not propagated from
> the parent device.

I guess it is because the IIO device is registered as a child of the
GPADC platform device, which does not have a node unlike the PMIC
device (GPADC pdev's parent). It seems that the regulator cell
registers its regulators directly under the PMIC dev, so maybe I should
do the same here with the IIO dev?

Regards,
--
Duje



  reply	other threads:[~2025-09-01 16:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-31 10:33 [PATCH v2 0/3] Marvell 88PM886 PMIC GPADC driver Duje Mihanović
2025-08-31 10:33 ` [PATCH v2 1/3] dt-bindings: mfd: 88pm886: Add #io-channel-cells Duje Mihanović
2025-08-31 16:49   ` Krzysztof Kozlowski
2025-08-31 18:40   ` Karel Balej
2025-08-31 10:33 ` [PATCH v2 2/3] iio: adc: Add driver for Marvell 88PM886 PMIC ADC Duje Mihanović
2025-08-31 19:24   ` Karel Balej
2025-08-31 20:19     ` Duje Mihanović
2025-09-01 12:43       ` Andy Shevchenko
2025-09-01 18:04         ` Jonathan Cameron
2025-09-01 15:35   ` Andy Shevchenko
2025-09-01 16:51     ` Duje Mihanović [this message]
2025-09-02  9:50       ` Andy Shevchenko
2025-09-01 18:18   ` Jonathan Cameron
2025-08-31 10:33 ` [PATCH v2 3/3] mfd: 88pm886: Add GPADC cell Duje Mihanović

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=3031049.e9J7NaK4W3@radijator \
    --to=duje@dujemihanovic.xyz \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=balejk@matfyz.cz \
    --cc=conor+dt@kernel.org \
    --cc=david@mainlining.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=phone-devel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.