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: <CAN1soZzezBXyF3QU6mHUUP=MZDbQPB+a-wruPZ0ZbQ0UxjACUQ@mail.gmail.com>
Date:	Sun, 17 Feb 2013 09:38:54 +0800
From:	Haojian Zhuang <haojian.zhuang@...il.com>
To:	Axel Lin <axel.lin@...ics.com>
Cc:	Mark Brown <broonie@...nsource.wolfsonmicro.com>,
	"Jett.Zhou" <jtzhou@...vell.com>,
	Liam Girdwood <lgirdwood@...il.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [RFT][PATCH 1/3] regulator: core: Add enable_is_inverted flag to
 indicate set enable_mask bits to disable

On Sat, Feb 16, 2013 at 2:36 PM, Axel Lin <axel.lin@...ics.com> wrote:
> Add enable_is_inverted flag to indicate set enable_mask bits to disable
> when using regulator_enable_regmap and friends APIs.
>
> Signed-off-by: Axel Lin <axel.lin@...ics.com>
> ---
>  drivers/regulator/core.c         |   24 ++++++++++++++++++++----
>  include/linux/regulator/driver.h |    3 +++
>  2 files changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index da9782b..142205b 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -1794,7 +1794,10 @@ int regulator_is_enabled_regmap(struct regulator_dev *rdev)
>         if (ret != 0)
>                 return ret;
>
> -       return (val & rdev->desc->enable_mask) != 0;
> +       if (rdev->desc->enable_is_inverted)
> +               return (val & rdev->desc->enable_mask) == 0;
> +       else
> +               return (val & rdev->desc->enable_mask) != 0;
>  }
>  EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap);
>
> @@ -1809,9 +1812,15 @@ EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap);
>   */
>  int regulator_enable_regmap(struct regulator_dev *rdev)
>  {
> +       unsigned int val;
> +
> +       if (rdev->desc->enable_is_inverted)
> +               val = 0;
> +       else
> +               val = rdev->desc->enable_mask;
> +
>         return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
> -                                 rdev->desc->enable_mask,
> -                                 rdev->desc->enable_mask);
> +                                 rdev->desc->enable_mask, val);
>  }
>  EXPORT_SYMBOL_GPL(regulator_enable_regmap);
>
> @@ -1826,8 +1835,15 @@ EXPORT_SYMBOL_GPL(regulator_enable_regmap);
>   */
>  int regulator_disable_regmap(struct regulator_dev *rdev)
>  {
> +       unsigned int val;
> +
> +       if (rdev->desc->enable_is_inverted)
> +               val = rdev->desc->enable_mask;
> +       else
> +               val = 0;
> +
>         return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
> -                                 rdev->desc->enable_mask, 0);
> +                                 rdev->desc->enable_mask, val);
>  }
>  EXPORT_SYMBOL_GPL(regulator_disable_regmap);
>
> diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
> index 23070fd..074b57e 100644
> --- a/include/linux/regulator/driver.h
> +++ b/include/linux/regulator/driver.h
> @@ -199,6 +199,8 @@ enum regulator_type {
>   *                output when using regulator_set_voltage_sel_regmap
>   * @enable_reg: Register for control when using regmap enable/disable ops
>   * @enable_mask: Mask for control when using regmap enable/disable ops
> + * @enable_is_inverted: A flag to indicate set enable_mask bits to disable
> + *                      when using regulator_enable_regmap and friends APIs.
>   *
>   * @enable_time: Time taken for initial enable of regulator (in uS).
>   */
> @@ -226,6 +228,7 @@ struct regulator_desc {
>         unsigned int apply_bit;
>         unsigned int enable_reg;
>         unsigned int enable_mask;
> +       bool enable_is_inverted;
>         unsigned int bypass_reg;
>         unsigned int bypass_mask;
>
> --
> 1.7.9.5
>
>
>

Reviewed-by: Haojian Zhuang <haojian.zhuang@...il.com>
--
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