mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Jonathan Corbet <corbet@lwn.net>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Rob Herring <robh@kernel.org>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH v3 5/5] hwmon: Add support for Amphenol ChipCap 2
Date: Thu, 7 Dec 2023 20:05:21 +0000	[thread overview]
Message-ID: <04475f91-bdce-4677-894c-74c2bb8233d9@sirena.org.uk> (raw)
In-Reply-To: <20231020-topic-chipcap2-v3-5-5b3bb50a5f0b@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1755 bytes --]

On Thu, Dec 07, 2023 at 08:44:55PM +0100, Javier Carrasco wrote:

> +       if (regulator_is_enabled(data->regulator)) {
> +               ret = regulator_disable(data->regulator);
> +               if (ret < 0)
> +                       return ret;
> +
> +               msleep(CC2_POWER_CYCLE_MS); /* ensure a clean power cycle */
> +       }
> +
> +       ret = regulator_enable(data->regulator);
> +       if (ret < 0)
> +               return ret;

This is very buggy.  A consumer should only disable a regulator if it
itself enabled that regulator (or it *requires* an exclusive regulator
which isn't a good fit here), and there's no guarantee that disabling a
regulator will actually result in a power off.  Either the board might
not physically or through constraints permit the state to change or
another user may have enabled the regulator.  The driver needs to keep
track of if it enabled the regulator and only disable it as many times
as it enabled it.

For this usage with trying to bounce the power of the regulator you can
keep track of the actual power state of the supply by listening to
notifications, and should possibly just keep the regulator disabled when
it's not actively in use (if no alarm is active or measurement in
progress?).

> +	data->regulator = devm_regulator_get_optional(dev, "vdd");

Does the device *really* work without power?  The datasheet appears to
suggest that the device has a non-optional supply Vdd

   https://f.hubspotusercontent40.net/hubfs/9035299/Documents/AAS-916-127J-Telaire-ChipCap2-022118-web.pdf

(there's also a Vcore pin but that appears to be for connecting a
decoupling capacitor rather than a supply).

In general _optional() should only be used for supplies which may be
physically absent.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2023-12-07 20:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07 19:44 [PATCH v3 0/5] " Javier Carrasco
2023-12-07 19:44 ` [PATCH v3 1/5] dt-bindings: vendor-prefixes: add Amphenol Javier Carrasco
2023-12-07 19:44 ` [PATCH v3 2/5] hwmon: (core) Add support for humidity min/max alarm Javier Carrasco
2023-12-07 19:44 ` [PATCH v3 3/5] ABI: sysfs-class-hwmon: add descriptions for humidity min/max alarms Javier Carrasco
2023-12-07 19:44 ` [PATCH v3 4/5] dt-bindings: hwmon: Add Amphenol ChipCap 2 Javier Carrasco
2023-12-08 15:06   ` Conor Dooley
2023-12-07 19:44 ` [PATCH v3 5/5] hwmon: Add support for " Javier Carrasco
2023-12-07 20:05   ` Mark Brown [this message]
2023-12-07 20:34     ` Javier Carrasco
2023-12-07 20:44       ` Mark Brown
2023-12-08 15:09         ` Javier Carrasco

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=04475f91-bdce-4677-894c-74c2bb8233d9@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=robh+dt@kernel.org \
    --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®