linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hansg@kernel.org>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>, linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: adc: Add Intel Dollar Cove TI PMIC ADC driver
Date: Fri, 18 Jul 2025 13:05:09 +0200	[thread overview]
Message-ID: <f66d26d4-64ff-48a0-a276-060aad3b4d04@kernel.org> (raw)
In-Reply-To: <a0d1bcf9-74e1-43cb-9f4f-1fb6f5b20724@kernel.org>

Hi,

On 18-Jul-25 12:56 PM, Hans de Goede wrote:
> Hi Jonathan,
> 
> Thank you for the review and sorry for being quite slow in
> working on the next revision.
> 
> Note this is really part of a fuel-gauge setup series,
> so for the next revision I'll include this driver in
> the upcoming v3 posting of that series (it can still be
> merged independently from the rest of the series).

<snip>

>>> +static int dc_ti_adc_read_raw(struct iio_dev *indio_dev,
>>> +			      struct iio_chan_spec const *chan,
>>> +			      int *val, int *val2, long mask)
>>> +{
>>> +	struct dc_ti_adc_info *info = iio_priv(indio_dev);
>>> +	int ret, ch = chan->channel;
>>> +	unsigned int lsb, msb;
>>> +
>>> +	if (mask != IIO_CHAN_INFO_RAW)
>>> +		return -EINVAL;
>>> +
>>> +	guard(mutex)(&info->lock);
>>> +
>>> +	info->conversion_done = false;
>>> +
>>> +	/*
>>> +	 * If channel BPTHERM has been selected, first enable the BPTHERM BIAS
>>> +	 * which provides the VREFT Voltage reference to convert BPTHERM Input
>>> +	 * voltage to temperature.
>>> +	 * As per PMIC Vendor specifications, BPTHERM BIAS should be enabled
>>> +	 * 35 ms before ADC_EN command.
>>> +	 */
>>> +	if (ch == DC_TI_ADC_BATTEMP) {
>>> +		ret = regmap_update_bits(info->regmap, DC_TI_ADC_CNTL_REG,
>>> +					 DC_TI_ADC_EN_EXT_BPTH_BIAS,
>>> +					 DC_TI_ADC_EN_EXT_BPTH_BIAS);
>>> +		if (ret < 0)
>>> +			return ret;
>>> +		msleep(35);
>>> +	}
>>> +
>>> +	/*
>>> +	 * As per TI (PMIC Vendor), the ADC enable and ADC start commands should
>>> +	 * not be sent together. Hence send the commands separately
>>> +	 */
>>> +	ret = regmap_update_bits(info->regmap, DC_TI_ADC_CNTL_REG,
>>> +				 DC_TI_ADC_EN, DC_TI_ADC_EN);
>>> +	if (ret < 0)
>>> +		goto disable_adc;
>> Always a corner case of what to do about disabling when an enable fail.
>> We'd hope it never happens but in general I'd assume no side effects occured
>> and return here rather than the goto.
> 
> Ok.

Correction, the goto is needed to undo the setting of
DC_TI_ADC_EN_EXT_BPTH_BIAS done above, so I'm keeping this as is.

(although it is ikely that once we start getting register update
errors doing more register updates will likely also fail...)

Regards,

Hans



  reply	other threads:[~2025-07-18 11:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-19 23:00 [PATCH] iio: adc: Add Intel Dollar Cove TI PMIC ADC driver Hans de Goede
2024-12-20 19:42 ` Jonathan Cameron
2025-07-18 10:56   ` Hans de Goede
2025-07-18 11:05     ` Hans de Goede [this message]
2025-07-19 11:04     ` Jonathan Cameron
2025-07-19 16:17       ` Hans de Goede
2025-07-24 13:23         ` 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=f66d26d4-64ff-48a0-a276-060aad3b4d04@kernel.org \
    --to=hansg@kernel.org \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.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;
as well as URLs for NNTP newsgroup(s).