mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: pHilipp Zabel <philipp.zabel@gmail.com>
To: Roger Quadros <quadros.roger@gmail.com>
Cc: broonie@sirena.org.uk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] regulator: Add GPIO enable control to fixed voltage  regulator driver
Date: Sun, 2 Aug 2009 19:49:52 +0200	[thread overview]
Message-ID: <74d0deb30908021049u191b3f9fj5230193535965ff7@mail.gmail.com> (raw)
In-Reply-To: <1249232208-22274-1-git-send-email-quadros.roger@gmail.com>

On Sun, Aug 2, 2009 at 6:56 PM, Roger Quadros<quadros.roger@gmail.com> wrote:
> From: Roger Quadros <ext-roger.quadros@nokia.com>
>
> Now fixed regulators that have their enable pin connected to a GPIO line
> can use the fixed regulator driver for regulator enable/disable control.
> The GPIO number and polarity information is passed through platform data.
> GPIO enable control is achieved using gpiolib.
>
> Signed-off-by: Roger Quadros <ext-roger.quadros@nokia.com>
> ---
>  drivers/regulator/fixed.c       |   75 +++++++++++++++++++++++++++++++++++++-
>  include/linux/regulator/fixed.h |   21 +++++++++++
>  2 files changed, 94 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
> index cdc674f..0888cb7 100644
> --- a/drivers/regulator/fixed.c
> +++ b/drivers/regulator/fixed.c
[...]
> @@ -85,12 +111,51 @@ static int regulator_fixed_voltage_probe(struct platform_device *pdev)
>        drvdata->desc.n_voltages = 1;
>
>        drvdata->microvolts = config->microvolts;
> +       drvdata->gpio = config->gpio;
> +
> +       if (gpio_is_valid(config->gpio)) {
> +               drvdata->enable_high = config->enable_high;
> +
> +               /* FIXME: Remove this print warning */
> +               if (!config->gpio)
> +                       dev_warn(&pdev->dev,
> +                               "using GPIO 0 for regulator enable control\n");
> +
> +               ret = gpio_request(config->gpio, config->supply_name);
> +               if (ret) {
> +                       dev_err(&pdev->dev,
> +                          "Could not obtain regulator enable GPIO %d: %d\n",
> +                                                       config->gpio, ret);
> +                       goto err_name;
> +               }
> +
> +               /* set output direction without changing state
> +                * to prevent glitch
> +                */
> +               drvdata->is_enabled = config->enabled_at_boot;
> +               if (!config->enable_high)
> +                       drvdata->is_enabled = !drvdata->is_enabled;

Assume .enabled_at_boot = 1, .enable_high = 0. In this case we end up
with .is_enabled = 0, which does not represent the real state after
the following call:

> +               ret = gpio_direction_output(config->gpio, drvdata->is_enabled);

Maybe use a local variable here or (drvdata->is_enabled ?
config->enable_high : !config->enable_high).

regards
Philipp

  reply	other threads:[~2009-08-02 17:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-02 16:56 Roger Quadros
2009-08-02 17:49 ` pHilipp Zabel [this message]
2009-08-03  9:15   ` Roger Quadros
2009-08-03 11:33 ` 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:
  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=74d0deb30908021049u191b3f9fj5230193535965ff7@mail.gmail.com \
    --to=philipp.zabel@gmail.com \
    --cc=broonie@sirena.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quadros.roger@gmail.com \
    /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®