From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Svyatoslav Ryhel <clamor95@gmail.com>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: [PATCH v1 4/7] regulator: lp872x: Remove redundant regmap wrappers
Date: Tue, 6 Oct 2026 18:44:28 +0300 [thread overview]
Message-ID: <20261006154431.318936-5-clamor95@gmail.com> (raw)
In-Reply-To: <20261006154431.318936-1-clamor95@gmail.com>
Remove lp872x_read_byte(), lp872x_write_byte(), and lp872x_update_bits()
helpers which are just wrappers around the same regmap helpers.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/regulator/lp872x.c | 66 ++++++++++++--------------------------
1 file changed, 20 insertions(+), 46 deletions(-)
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index 13dce4dcdbe14..1e16d7e8361a0 100644
--- a/drivers/regulator/lp872x.c
+++ b/drivers/regulator/lp872x.c
@@ -204,36 +204,10 @@ static const unsigned int lp8725_buck_uA[] = {
460000, 780000, 1050000, 1370000,
};
-static int lp872x_read_byte(struct lp872x *lp, u8 addr, u8 *data)
-{
- int ret;
- unsigned int val;
-
- ret = regmap_read(lp->regmap, addr, &val);
- if (ret < 0) {
- dev_err(lp->dev, "failed to read 0x%.2x\n", addr);
- return ret;
- }
-
- *data = (u8)val;
- return 0;
-}
-
-static inline int lp872x_write_byte(struct lp872x *lp, u8 addr, u8 data)
-{
- return regmap_write(lp->regmap, addr, data);
-}
-
-static inline int lp872x_update_bits(struct lp872x *lp, u8 addr,
- unsigned int mask, u8 data)
-{
- return regmap_update_bits(lp->regmap, addr, mask, data);
-}
-
static int lp872x_get_timestep_usec(struct lp872x *lp)
{
enum lp872x_id chip = lp->chipid;
- u8 val, mask, shift;
+ u32 val, mask, shift;
int *time_usec, size, ret;
int lp8720_time_usec[] = { 25, 50 };
int lp8725_time_usec[] = { 32, 64, 128, 256 };
@@ -255,7 +229,7 @@ static int lp872x_get_timestep_usec(struct lp872x *lp)
return -EINVAL;
}
- ret = lp872x_read_byte(lp, LP872X_GENERAL_CFG, &val);
+ ret = regmap_read(lp->regmap, LP872X_GENERAL_CFG, &val);
if (ret)
return ret;
@@ -272,7 +246,7 @@ static int lp872x_regulator_enable_time(struct regulator_dev *rdev)
enum lp872x_regulator_id rid = rdev_get_id(rdev);
int time_step_us = lp872x_get_timestep_usec(lp);
int ret;
- u8 addr, val;
+ u32 addr, val;
if (time_step_us < 0)
return time_step_us;
@@ -291,7 +265,7 @@ static int lp872x_regulator_enable_time(struct regulator_dev *rdev)
return -EINVAL;
}
- ret = lp872x_read_byte(lp, addr, &val);
+ ret = regmap_read(lp->regmap, addr, &val);
if (ret)
return ret;
@@ -313,9 +287,9 @@ static void lp872x_set_dvs(struct lp872x *lp, enum lp872x_dvs_sel dvs_sel,
static u8 lp872x_select_buck_vout_addr(struct lp872x *lp,
enum lp872x_regulator_id buck)
{
- u8 val, addr;
+ u32 val, addr;
- if (lp872x_read_byte(lp, LP872X_GENERAL_CFG, &val))
+ if (regmap_read(lp->regmap, LP872X_GENERAL_CFG, &val))
return 0;
switch (buck) {
@@ -324,7 +298,7 @@ static u8 lp872x_select_buck_vout_addr(struct lp872x *lp,
addr = (lp->dvs_pin == GPIOD_OUT_HIGH) ?
LP8720_BUCK_VOUT1 : LP8720_BUCK_VOUT2;
} else {
- if (lp872x_read_byte(lp, LP8720_ENABLE, &val))
+ if (regmap_read(lp->regmap, LP8720_ENABLE, &val))
return 0;
addr = val & LP8720_DVS_SEL_M ?
@@ -369,7 +343,7 @@ static int lp872x_buck_set_voltage_sel(struct regulator_dev *rdev,
{
struct lp872x *lp = rdev_get_drvdata(rdev);
enum lp872x_regulator_id buck = rdev_get_id(rdev);
- u8 addr, mask = LP872X_VOUT_M;
+ u32 addr, mask = LP872X_VOUT_M;
struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL;
if (dvs && dvs->gpio)
@@ -379,21 +353,21 @@ static int lp872x_buck_set_voltage_sel(struct regulator_dev *rdev,
if (!lp872x_is_valid_buck_addr(addr))
return -EINVAL;
- return lp872x_update_bits(lp, addr, mask, selector);
+ return regmap_update_bits(lp->regmap, addr, mask, selector);
}
static int lp872x_buck_get_voltage_sel(struct regulator_dev *rdev)
{
struct lp872x *lp = rdev_get_drvdata(rdev);
enum lp872x_regulator_id buck = rdev_get_id(rdev);
- u8 addr, val;
+ u32 addr, val;
int ret;
addr = lp872x_select_buck_vout_addr(lp, buck);
if (!lp872x_is_valid_buck_addr(addr))
return -EINVAL;
- ret = lp872x_read_byte(lp, addr, &val);
+ ret = regmap_read(lp->regmap, addr, &val);
if (ret)
return ret;
@@ -404,7 +378,7 @@ static int lp872x_buck_set_mode(struct regulator_dev *rdev, unsigned int mode)
{
struct lp872x *lp = rdev_get_drvdata(rdev);
enum lp872x_regulator_id buck = rdev_get_id(rdev);
- u8 addr, mask, shift, val;
+ u32 addr, mask, shift, val;
switch (buck) {
case LP8720_ID_BUCK:
@@ -433,14 +407,14 @@ static int lp872x_buck_set_mode(struct regulator_dev *rdev, unsigned int mode)
else
return -EINVAL;
- return lp872x_update_bits(lp, addr, mask, val);
+ return regmap_update_bits(lp->regmap, addr, mask, val);
}
static unsigned int lp872x_buck_get_mode(struct regulator_dev *rdev)
{
struct lp872x *lp = rdev_get_drvdata(rdev);
enum lp872x_regulator_id buck = rdev_get_id(rdev);
- u8 addr, mask, val;
+ u32 addr, mask, val;
int ret;
switch (buck) {
@@ -460,7 +434,7 @@ static unsigned int lp872x_buck_get_mode(struct regulator_dev *rdev)
return -EINVAL;
}
- ret = lp872x_read_byte(lp, addr, &val);
+ ret = regmap_read(lp->regmap, addr, &val);
if (ret)
return ret;
@@ -728,8 +702,8 @@ static int lp872x_init_dvs(struct lp872x *lp)
{
struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL;
enum gpiod_flags pinstate;
- u8 mask[] = { LP8720_EXT_DVS_M, LP8725_DVS1_M | LP8725_DVS2_M };
- u8 default_dvs_mode[] = { LP8720_DEFAULT_DVS, LP8725_DEFAULT_DVS };
+ u32 mask[] = { LP8720_EXT_DVS_M, LP8725_DVS1_M | LP8725_DVS2_M };
+ u32 default_dvs_mode[] = { LP8720_DEFAULT_DVS, LP8725_DEFAULT_DVS };
if (!dvs)
goto set_default_dvs_mode;
@@ -750,8 +724,8 @@ static int lp872x_init_dvs(struct lp872x *lp)
return 0;
set_default_dvs_mode:
- return lp872x_update_bits(lp, LP872X_GENERAL_CFG, mask[lp->chipid],
- default_dvs_mode[lp->chipid]);
+ return regmap_update_bits(lp->regmap, LP872X_GENERAL_CFG, mask[lp->chipid],
+ default_dvs_mode[lp->chipid]);
}
static int lp872x_hw_enable(struct lp872x *lp)
@@ -786,7 +760,7 @@ static int lp872x_config(struct lp872x *lp)
if (!pdata || !pdata->update_config)
goto init_dvs;
- ret = lp872x_write_byte(lp, LP872X_GENERAL_CFG, pdata->general_config);
+ ret = regmap_write(lp->regmap, LP872X_GENERAL_CFG, pdata->general_config);
if (ret)
return ret;
--
2.53.0
next prev parent reply other threads:[~2026-10-06 15:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 15:44 [PATCH v1 0/7] lp872x: remove platform_data based probing and adjustments Svyatoslav Ryhel
2026-10-06 15:44 ` [PATCH v1 1/7] regulator: dt-bindings: ti,lp872x: Convert to DT schema Svyatoslav Ryhel
2026-10-06 15:44 ` [PATCH v1 2/7] regulator: dt-bindings: ti,lp872x: Document input supplies Svyatoslav Ryhel
2026-10-06 15:44 ` [PATCH v1 3/7] regulator: lp872x: Fold driver header into driver file Svyatoslav Ryhel
2026-10-06 15:44 ` Svyatoslav Ryhel [this message]
2026-10-06 15:44 ` [PATCH v1 5/7] regulator: lp872x: Remove platform_data based probing Svyatoslav Ryhel
2026-10-07 8:39 ` Mark Brown
2026-10-07 8:59 ` Svyatoslav Ryhel
2026-10-06 15:44 ` [PATCH v1 6/7] regulator: lp872x: Add support for input and regulator power supplies Svyatoslav Ryhel
2026-10-06 15:44 ` [PATCH v1 7/7] regulator: lp872x: Use macro to fill regulator descriptor Svyatoslav Ryhel
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=20261006154431.318936-5-clamor95@gmail.com \
--to=clamor95@gmail.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
/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®