linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
To: Axel Lin <axel.lin@ingics.com>
Cc: Mark Brown <broonie@kernel.org>,
	Support Opensource <support.opensource@diasemi.com>,
	patches@opensource.cirrus.com,
	Ashish Jangam <ashish.jangam@kpitcummins.com>,
	Steve Twiss <stwiss.opensource@diasemi.com>,
	Paul Kocialkowski <contact@paulk.fr>, Milo Kim <milo.kim@ti.com>,
	Keerthy <j-keerthy@ti.com>,
	James Ban <James.Ban.opensource@diasemi.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 07/11] regulator: max77650: Convert to use regulator_set/get_current_limit_regmap
Date: Thu, 28 Feb 2019 15:11:22 +0100	[thread overview]
Message-ID: <CAMpxmJVYsvPWuxG-vo1LBQUFkQHfCcyTU19G=JvxYi_S0P6gtw@mail.gmail.com> (raw)
In-Reply-To: <20190228134022.32625-8-axel.lin@ingics.com>

czw., 28 lut 2019 o 14:41 Axel Lin <axel.lin@ingics.com> napisał(a):
>
> Use regulator_set/get_current_limit_regmap helpers to save some code.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/regulator/max77650-regulator.c | 74 +++++++++-----------------
>  1 file changed, 25 insertions(+), 49 deletions(-)
>
> diff --git a/drivers/regulator/max77650-regulator.c b/drivers/regulator/max77650-regulator.c
> index a1af414db751..31ebf34b01ec 100644
> --- a/drivers/regulator/max77650-regulator.c
> +++ b/drivers/regulator/max77650-regulator.c
> @@ -26,9 +26,6 @@
>  #define MAX77650_REGULATOR_AD_ENABLED          BIT(3)
>
>  #define MAX77650_REGULATOR_CURR_LIM_MASK       GENMASK(7, 6)
> -#define MAX77650_REGULATOR_CURR_LIM_BITS(_reg) \
> -               (((_reg) & MAX77650_REGULATOR_CURR_LIM_MASK) >> 6)
> -#define MAX77650_REGULATOR_CURR_LIM_SHIFT(_val)        ((_val) << 6)
>
>  enum {
>         MAX77650_REGULATOR_ID_LDO = 0,
> @@ -82,7 +79,7 @@ static const u32 max77651_sbb1_regulator_volt_table[] = {
>                 _val = MAX77651_REGULATOR_SBB1_SEL_ENC(_val);           \
>         } while (0)
>
> -static const int max77650_current_limit_table[] = {
> +static const unsigned int max77650_current_limit_table[] = {
>         1000000, 866000, 707000, 500000,
>  };
>
> @@ -220,47 +217,6 @@ static int max77651_regulator_sbb1_set_voltage_sel(struct regulator_dev *rdev,
>         return 0;
>  }
>
> -static int max77650_regulator_get_current_limit(struct regulator_dev *rdev)
> -{
> -       struct max77650_regulator_desc *rdesc;
> -       struct regmap *map;
> -       int val, rv, limit;
> -
> -       rdesc = rdev_get_drvdata(rdev);
> -       map = rdev_get_regmap(rdev);
> -
> -       rv = regmap_read(map, rdesc->regA, &val);
> -       if (rv)
> -               return rv;
> -
> -       limit = MAX77650_REGULATOR_CURR_LIM_BITS(val);
> -
> -       return max77650_current_limit_table[limit];
> -}
> -
> -static int max77650_regulator_set_current_limit(struct regulator_dev *rdev,
> -                                               int min_uA, int max_uA)
> -{
> -       struct max77650_regulator_desc *rdesc;
> -       struct regmap *map;
> -       int i, limit;
> -
> -       rdesc = rdev_get_drvdata(rdev);
> -       map = rdev_get_regmap(rdev);
> -
> -       for (i = 0; i < ARRAY_SIZE(max77650_current_limit_table); i++) {
> -               limit = max77650_current_limit_table[i];
> -
> -               if (limit >= min_uA && limit <= max_uA) {
> -                       return regmap_update_bits(map, rdesc->regA,
> -                                       MAX77650_REGULATOR_CURR_LIM_MASK,
> -                                       MAX77650_REGULATOR_CURR_LIM_SHIFT(i));
> -               }
> -       }
> -
> -       return -EINVAL;
> -}
> -
>  static const struct regulator_ops max77650_regulator_LDO_ops = {
>         .is_enabled             = max77650_regulator_is_enabled,
>         .enable                 = max77650_regulator_enable,
> @@ -280,8 +236,8 @@ static const struct regulator_ops max77650_regulator_SBB_ops = {
>         .map_voltage            = regulator_map_voltage_linear,
>         .get_voltage_sel        = regulator_get_voltage_sel_regmap,
>         .set_voltage_sel        = max77650_regulator_set_voltage_sel,
> -       .get_current_limit      = max77650_regulator_get_current_limit,
> -       .set_current_limit      = max77650_regulator_set_current_limit,
> +       .get_current_limit      = regulator_get_current_limit_regmap,
> +       .set_current_limit      = regulator_set_current_limit_regmap,
>         .set_active_discharge   = regulator_set_active_discharge_regmap,
>  };
>
> @@ -293,8 +249,8 @@ static const struct regulator_ops max77651_SBB1_regulator_ops = {
>         .list_voltage           = regulator_list_voltage_table,
>         .get_voltage_sel        = regulator_get_voltage_sel_regmap,
>         .set_voltage_sel        = max77651_regulator_sbb1_set_voltage_sel,
> -       .get_current_limit      = max77650_regulator_get_current_limit,
> -       .set_current_limit      = max77650_regulator_set_current_limit,
> +       .get_current_limit      = regulator_get_current_limit_regmap,
> +       .set_current_limit      = regulator_set_current_limit_regmap,
>         .set_active_discharge   = regulator_set_active_discharge_regmap,
>  };
>
> @@ -343,6 +299,10 @@ static struct max77650_regulator_desc max77650_SBB0_desc = {
>                 .enable_time            = 100,
>                 .type                   = REGULATOR_VOLTAGE,
>                 .owner                  = THIS_MODULE,
> +               .csel_reg               = MAX77650_REG_CNFG_SBB0_A,
> +               .csel_mask              = MAX77650_REGULATOR_CURR_LIM_MASK,
> +               .curr_table             = max77650_current_limit_table,
> +               .n_current_limits = ARRAY_SIZE(max77650_current_limit_table),
>         },
>         .regA           = MAX77650_REG_CNFG_SBB0_A,
>         .regB           = MAX77650_REG_CNFG_SBB0_B,
> @@ -368,6 +328,10 @@ static struct max77650_regulator_desc max77650_SBB1_desc = {
>                 .enable_time            = 100,
>                 .type                   = REGULATOR_VOLTAGE,
>                 .owner                  = THIS_MODULE,
> +               .csel_reg               = MAX77650_REG_CNFG_SBB1_A,
> +               .csel_mask              = MAX77650_REGULATOR_CURR_LIM_MASK,
> +               .curr_table             = max77650_current_limit_table,
> +               .n_current_limits = ARRAY_SIZE(max77650_current_limit_table),
>         },
>         .regA           = MAX77650_REG_CNFG_SBB1_A,
>         .regB           = MAX77650_REG_CNFG_SBB1_B,
> @@ -392,6 +356,10 @@ static struct max77650_regulator_desc max77651_SBB1_desc = {
>                 .enable_time            = 100,
>                 .type                   = REGULATOR_VOLTAGE,
>                 .owner                  = THIS_MODULE,
> +               .csel_reg               = MAX77650_REG_CNFG_SBB1_A,
> +               .csel_mask              = MAX77650_REGULATOR_CURR_LIM_MASK,
> +               .curr_table             = max77650_current_limit_table,
> +               .n_current_limits = ARRAY_SIZE(max77650_current_limit_table),
>         },
>         .regA           = MAX77650_REG_CNFG_SBB1_A,
>         .regB           = MAX77650_REG_CNFG_SBB1_B,
> @@ -417,6 +385,10 @@ static struct max77650_regulator_desc max77650_SBB2_desc = {
>                 .enable_time            = 100,
>                 .type                   = REGULATOR_VOLTAGE,
>                 .owner                  = THIS_MODULE,
> +               .csel_reg               = MAX77650_REG_CNFG_SBB2_A,
> +               .csel_mask              = MAX77650_REGULATOR_CURR_LIM_MASK,
> +               .curr_table             = max77650_current_limit_table,
> +               .n_current_limits = ARRAY_SIZE(max77650_current_limit_table),
>         },
>         .regA           = MAX77650_REG_CNFG_SBB2_A,
>         .regB           = MAX77650_REG_CNFG_SBB2_B,
> @@ -442,6 +414,10 @@ static struct max77650_regulator_desc max77651_SBB2_desc = {
>                 .enable_time            = 100,
>                 .type                   = REGULATOR_VOLTAGE,
>                 .owner                  = THIS_MODULE,
> +               .csel_reg               = MAX77650_REG_CNFG_SBB2_A,
> +               .csel_mask              = MAX77650_REGULATOR_CURR_LIM_MASK,
> +               .curr_table             = max77650_current_limit_table,
> +               .n_current_limits = ARRAY_SIZE(max77650_current_limit_table),
>         },
>         .regA           = MAX77650_REG_CNFG_SBB2_A,
>         .regB           = MAX77650_REG_CNFG_SBB2_B,
> --
> 2.17.1
>

Looks good.

Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

  reply	other threads:[~2019-02-28 14:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28 13:40 [PATCH 00/11] regulator: Add set/get_current_limit helpers and use it Axel Lin
2019-02-28 13:40 ` [PATCH 01/11] regulator: Fix comment for csel_reg and csel_mask Axel Lin
2019-02-28 13:40 ` [PATCH 02/11] regulator: core: Add set/get_current_limit helpers for regmap users Axel Lin
2019-02-28 13:40 ` [PATCH 03/11] regulator: da9055: Convert to use regulator_set/get_current_limit_regmap Axel Lin
2019-02-28 15:18   ` Steve Twiss
2019-02-28 13:40 ` [PATCH 04/11] regulator: da9210: " Axel Lin
2019-02-28 14:01   ` Steve Twiss
2019-02-28 13:40 ` [PATCH 05/11] regulator: lp872x: " Axel Lin
2019-02-28 13:40 ` [PATCH 06/11] regulator: lp873x: " Axel Lin
2019-02-28 13:40 ` [PATCH 07/11] regulator: max77650: " Axel Lin
2019-02-28 14:11   ` Bartosz Golaszewski [this message]
2019-02-28 13:40 ` [PATCH 08/11] regulator: pv88060: " Axel Lin
2019-02-28 15:26   ` Steve Twiss
2019-02-28 13:40 ` [PATCH 09/11] regulator: pv88080: " Axel Lin
2019-02-28 15:41   ` Steve Twiss
2019-02-28 13:40 ` [PATCH 10/11] regulator: pv88090: " Axel Lin
2019-02-28 15:47   ` Steve Twiss
2019-02-28 13:40 ` [PATCH 11/11] regulator: wm831x-dcdc: " Axel Lin
2019-03-01  8:33   ` Charles Keepax

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='CAMpxmJVYsvPWuxG-vo1LBQUFkQHfCcyTU19G=JvxYi_S0P6gtw@mail.gmail.com' \
    --to=bgolaszewski@baylibre.com \
    --cc=James.Ban.opensource@diasemi.com \
    --cc=ashish.jangam@kpitcummins.com \
    --cc=axel.lin@ingics.com \
    --cc=broonie@kernel.org \
    --cc=contact@paulk.fr \
    --cc=j-keerthy@ti.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=milo.kim@ti.com \
    --cc=patches@opensource.cirrus.com \
    --cc=stwiss.opensource@diasemi.com \
    --cc=support.opensource@diasemi.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;
as well as URLs for NNTP newsgroup(s).