lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <74d0deb30908021049u191b3f9fj5230193535965ff7@mail.gmail.com>
Date:	Sun, 2 Aug 2009 19:49:52 +0200
From:	pHilipp Zabel <philipp.zabel@...il.com>
To:	Roger Quadros <quadros.roger@...il.com>
Cc:	broonie@...ena.org.uk, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] regulator: Add GPIO enable control to fixed voltage 
	regulator driver

On Sun, Aug 2, 2009 at 6:56 PM, Roger Quadros<quadros.roger@...il.com> wrote:
> From: Roger Quadros <ext-roger.quadros@...ia.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@...ia.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ