LKML Archive on
help / color / mirror / Atom feed
From: "H. Nikolaus Schaller" <>
To: Mark Brown <>
Cc: Andreas Kemnade <>,,,,,,
Subject: Re: [PATCH RFC] regulator: core: fix handling negative voltages e.g. in EPD PMICs
Date: Mon, 24 Feb 2020 13:22:21 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

> Am 24.02.2020 um 13:05 schrieb Mark Brown <>:
> On Sun, Feb 23, 2020 at 04:35:01PM +0100, Andreas Kemnade wrote:
>> An alternative would be to handle voltages as absolute values.
>> There are probably no regulators with support both negative
>> and positive output.
> This is what'd be needed, your approach here is a bit of a hack and
> leaves some values unrepresentable if they overlap with errnos which
> obviously has issues if someone has a need for those values.

Negative ERRNOs have BIT(31) set.

Since voltage integers on a 32 bit architecture represent µV this would
still allow voltages up to (2^31 - 1) µV i.e. 2 kV with BIT(31) not set.

Therefore it seems very unlikely that anyone needs to represent voltages
above 2 kV within a Linux system through a regulator.

So I'd say any negative return value got regulator_get_voltage() can be
treated as an error.

And regulators for negative voltages could be represented by
their absolute value (and maybe a _neg component in the regulator

But then it seems to be a little inconsistent that the voltage
parameters of regulator_set_voltage_unlocked() are signed integers
and not unsigned.

So shouldn't that be protected against attempting to set negative voltages?

Just my 2 cts.


  reply	other threads:[~2020-02-24 12:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-23 15:35 Andreas Kemnade
2020-02-24 12:05 ` Mark Brown
2020-02-24 12:22   ` H. Nikolaus Schaller [this message]
2020-02-24 12:31     ` Mark Brown
2020-02-24 18:46   ` Andreas Kemnade
2020-02-24 15:21 ` Denis 'GNUtoo' Carikli
2020-02-24 17:00   ` Mark Brown

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:

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

  git send-email \ \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH RFC] regulator: core: fix handling negative voltages e.g. in EPD PMICs' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).