From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mark Brown <broonie@kernel.org>, Lee Jones <lee.jones@linaro.org>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Mayulong <mayulong1@huawei.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH v6 2/7] staging: hikey9xx: hi6421v600-regulator: use some regmap helpers
Date: Wed, 27 Jan 2021 20:08:17 +0100 [thread overview]
Message-ID: <a4b76eebb5872df8c7114dd84099e34ee61cbd76.1611773727.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1611773727.git.mchehab+huawei@kernel.org>
Now that the driver was ported to use regmap, let's use
some help functions in order to simplify the code a little
bit.
Suggested-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
.../staging/hikey9xx/hi6421v600-regulator.c | 45 ++-----------------
1 file changed, 3 insertions(+), 42 deletions(-)
diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c
index 9e319fa11137..7090107b9ec2 100644
--- a/drivers/staging/hikey9xx/hi6421v600-regulator.c
+++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c
@@ -95,17 +95,6 @@ static const unsigned int ldo34_voltages[] = {
.eco_uA = ecoamp, \
}
-static int hi6421_spmi_regulator_is_enabled(struct regulator_dev *rdev)
-{
- struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
- struct hi6421_spmi_pmic *pmic = sreg->pmic;
- u32 reg_val;
-
- regmap_read(pmic->map, rdev->desc->enable_reg, ®_val);
-
- return ((reg_val & rdev->desc->enable_mask) != 0);
-}
-
static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
{
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
@@ -136,34 +125,6 @@ static int hi6421_spmi_regulator_disable(struct regulator_dev *rdev)
rdev->desc->enable_mask, 0);
}
-static int hi6421_spmi_regulator_get_voltage_sel(struct regulator_dev *rdev)
-{
- struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
- struct hi6421_spmi_pmic *pmic = sreg->pmic;
- u32 reg_val;
-
- regmap_read(pmic->map, rdev->desc->vsel_reg, ®_val);
-
- return (reg_val & rdev->desc->vsel_mask) >> (ffs(rdev->desc->vsel_mask) - 1);
-}
-
-static int hi6421_spmi_regulator_set_voltage_sel(struct regulator_dev *rdev,
- unsigned int selector)
-{
- struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
- struct hi6421_spmi_pmic *pmic = sreg->pmic;
- u32 reg_val;
-
- if (selector >= rdev->desc->n_voltages)
- return -EINVAL;
-
- reg_val = selector << (ffs(rdev->desc->vsel_mask) - 1);
-
- /* set voltage selector */
- return regmap_update_bits(pmic->map, rdev->desc->vsel_reg,
- rdev->desc->vsel_mask, reg_val);
-}
-
static unsigned int hi6421_spmi_regulator_get_mode(struct regulator_dev *rdev)
{
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
@@ -214,13 +175,13 @@ hi6421_spmi_regulator_get_optimum_mode(struct regulator_dev *rdev,
}
static const struct regulator_ops hi6421_spmi_ldo_rops = {
- .is_enabled = hi6421_spmi_regulator_is_enabled,
+ .is_enabled = regulator_is_enabled_regmap,
.enable = hi6421_spmi_regulator_enable,
.disable = hi6421_spmi_regulator_disable,
.list_voltage = regulator_list_voltage_table,
.map_voltage = regulator_map_voltage_iterate,
- .get_voltage_sel = hi6421_spmi_regulator_get_voltage_sel,
- .set_voltage_sel = hi6421_spmi_regulator_set_voltage_sel,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_mode = hi6421_spmi_regulator_get_mode,
.set_mode = hi6421_spmi_regulator_set_mode,
.get_optimum_mode = hi6421_spmi_regulator_get_optimum_mode,
--
2.29.2
next prev parent reply other threads:[~2021-01-27 19:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-27 19:08 [PATCH v6 0/7] Move Hisilicon 6421v600 SPMI and USB drivers out of staging Mauro Carvalho Chehab
2021-01-27 19:08 ` [PATCH v6 1/7] staging: hikey9xx: spmi driver: convert to regmap Mauro Carvalho Chehab
2021-01-27 19:08 ` Mauro Carvalho Chehab [this message]
2021-01-27 19:08 ` [PATCH v6 3/7] phy: phy-hi3670-usb3: move driver from staging into phy Mauro Carvalho Chehab
2021-02-04 7:54 ` Vinod Koul
2021-01-27 19:08 ` [PATCH v6 4/7] spmi: hisi-spmi-controller: move driver from staging Mauro Carvalho Chehab
2021-01-27 19:08 ` [PATCH v6 5/7] mfd: hi6421-spmi-pmic: " Mauro Carvalho Chehab
2021-01-28 8:16 ` Lee Jones
2021-01-27 19:08 ` [PATCH v6 6/7] regulator: hi6421v600-regulator: move it " Mauro Carvalho Chehab
2021-01-27 19:08 ` [PATCH v6 7/7] dts: hisilicon: add support for the PMIC found on Hikey 970 Mauro Carvalho Chehab
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=a4b76eebb5872df8c7114dd84099e34ee61cbd76.1611773727.git.mchehab+huawei@kernel.org \
--to=mchehab+huawei@kernel.org \
--cc=broonie@kernel.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mayulong1@huawei.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).