public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Amit Sunil Dhamne <amitsd@google.com>
Cc: "Sebastian Reichel" <sre@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"André Draszik" <andre.draszik@linaro.org>,
	"Lee Jones" <lee@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Badhri Jagan Sridharan" <badhri@google.com>,
	"Peter Griffin" <peter.griffin@linaro.org>,
	"Tudor Ambarus" <tudor.ambarus@linaro.org>,
	"Alim Akhtar" <alim.akhtar@samsung.com>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	devicetree@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org,
	"RD Babiera" <rdbabiera@google.com>,
	"Kyle Tso" <kyletso@google.com>
Subject: Re: [PATCH v3 5/5] usb: typec: tcpm/tcpci_maxim: deprecate WAR for setting charger mode
Date: Mon, 12 Jan 2026 15:20:54 +0200	[thread overview]
Message-ID: <aWT1NgxDSaU7LL2g@kuha> (raw)
In-Reply-To: <9f94993e-dd69-4c9e-b467-aad6031c83d4@google.com>

Fri, Jan 09, 2026 at 06:16:57PM -0800, Amit Sunil Dhamne kirjoitti:
> Hi Heikki,
> 
> Thanks for the review!
> 
> On 1/9/26 5:14 AM, Heikki Krogerus wrote:
> > Hi,
> >
> >> +	if (source) {
> >> +		if (!regulator_is_enabled(chip->vbus_reg))
> >> +			ret = regulator_enable(chip->vbus_reg);
> >> +	} else {
> >> +		if (regulator_is_enabled(chip->vbus_reg))
> >> +			ret = regulator_disable(chip->vbus_reg);
> >> +	}
> > It looks like you have to do one more round, so can drop the
> > regulator_is_enabled() checks and just always enable/disable it
> > unconditionally.
> >
> >         if (source)
> > 		ret = regulator_enable(chip->vbus_reg);
> > 	else
> > 		ret = regulator_disable(chip->vbus_reg);
> 
> The regulator framework uses refcounting on the number of enables. If
> the number of times regulator is disabled > enabled, a warning will be
> thrown. Also, I don't want to call regulator_enable more than once for
> the same refcounting reason (will have to call disable those many number
> of times to actually disable).
> 
> > I don't think you need the check in any case, but if I've understood
> > this correctly, you should not use that check when the regulator does
> > not support that check because then the API claims it's always
> > enabled. So I guess in that case "if (!regulator_is_enabled())" may
> > not work as expected, and you may actually be left with a disabled
> > regulator. This may not be a problem on current platforms, but who
> > knows what happens in the future.
> 
> I don't think this should be an issue in the future as this driver is
> specifically meant for max77759_tcpci device and should only be used
> with max77759 charger (they both exist only in the same package). And
> that the max77759_charger driver does implement the callback. However,
> if you think that regulator_is_enabled() is unreliable, I could track
> the state within the tcpci driver instead of calling
> regulator_is_enabled() and call enable/disable regulator accordingly.
> 
> Let me know wdyt and I'll update the next revision accordingly.

Let's go with this then as is.

thanks,

-- 
heikki

  reply	other threads:[~2026-01-12 13:21 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-27  0:04 [PATCH v3 0/5] Introduce MAX77759 charger driver Amit Sunil Dhamne via B4 Relay
2025-12-27  0:04 ` [PATCH v3 1/5] dt-bindings: mfd: maxim,max77759: reference power-supply schema and add regulator property Amit Sunil Dhamne via B4 Relay
2025-12-29  8:50   ` Krzysztof Kozlowski
2026-01-05 16:35   ` André Draszik
2025-12-27  0:04 ` [PATCH v3 2/5] dt-bindings: usb: maxim,max33359: Add supply property for vbus Amit Sunil Dhamne via B4 Relay
2025-12-27  0:04 ` [PATCH v3 3/5] mfd: max77759: add register bitmasks and modify irq configs for charger Amit Sunil Dhamne via B4 Relay
2026-01-05 16:45   ` André Draszik
2026-01-05 19:58     ` Amit Sunil Dhamne
2025-12-27  0:04 ` [PATCH v3 4/5] power: supply: max77759: add charger driver Amit Sunil Dhamne via B4 Relay
2026-01-05 17:32   ` André Draszik
2026-01-06 23:41     ` Amit Sunil Dhamne
2026-01-07  1:14       ` Amit Sunil Dhamne
2026-01-12 13:47         ` André Draszik
2026-01-12 19:37           ` Amit Sunil Dhamne
2026-01-13 10:02             ` André Draszik
2026-01-14  0:47               ` Amit Sunil Dhamne
2026-01-14 10:20                 ` André Draszik
2026-01-15  2:52                   ` Amit Sunil Dhamne
2025-12-27  0:04 ` [PATCH v3 5/5] usb: typec: tcpm/tcpci_maxim: deprecate WAR for setting charger mode Amit Sunil Dhamne via B4 Relay
2026-01-05 16:10   ` Heikki Krogerus
2026-01-05 16:47   ` André Draszik
2026-01-09 13:14   ` Heikki Krogerus
2026-01-10  2:16     ` Amit Sunil Dhamne
2026-01-12 13:20       ` Heikki Krogerus [this message]
2026-01-15  2:58         ` Amit Sunil Dhamne

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=aWT1NgxDSaU7LL2g@kuha \
    --to=heikki.krogerus@linux.intel.com \
    --cc=alim.akhtar@samsung.com \
    --cc=amitsd@google.com \
    --cc=andre.draszik@linaro.org \
    --cc=badhri@google.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzk+dt@kernel.org \
    --cc=kyletso@google.com \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.griffin@linaro.org \
    --cc=rdbabiera@google.com \
    --cc=robh@kernel.org \
    --cc=sre@kernel.org \
    --cc=tudor.ambarus@linaro.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