From: Isaac Scott <isaac.scott@ideasonboard.com>
To: michael.hennerich@analog.com
Cc: lgirdwood@gmail.com, broonie@kernel.org,
linux-kernel@vger.kernel.org,
Isaac Scott <isaac.scott@ideasonboard.com>
Subject: [PATCH v2 1/3] regulator: ad5398: change enable bit name to improve readibility
Date: Tue, 28 Jan 2025 17:31:41 +0000 [thread overview]
Message-ID: <20250128173143.959600-2-isaac.scott@ideasonboard.com> (raw)
In-Reply-To: <20250128173143.959600-1-isaac.scott@ideasonboard.com>
The mask name AD5398_CURRENT_EN_MASK is misleading, as it implies that
setting bit 16 of the AD5398 enables current flow. In fact, setting this
bit prevents current flow, due to this bit being a software power down
control. This bit is referred to as "soft power down" in the datasheet.
As such, change the name of the bit and modify its use in the driver to
make the regulator more intuitively usable.
(When calling ad5398_enable, current will start flowing, and vice
versa).
Signed-off-by: Isaac Scott <isaac.scott@ideasonboard.com>
---
drivers/regulator/ad5398.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c
index 40f7dba42b5a..e6f45c6e750c 100644
--- a/drivers/regulator/ad5398.c
+++ b/drivers/regulator/ad5398.c
@@ -15,7 +15,7 @@
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
-#define AD5398_CURRENT_EN_MASK 0x8000
+#define AD5398_SW_POWER_DOWN BIT(16)
struct ad5398_chip_info {
struct i2c_client *client;
@@ -113,7 +113,7 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, int
/* prepare register data */
selector = (selector << chip->current_offset) & chip->current_mask;
- data = (unsigned short)selector | (data & AD5398_CURRENT_EN_MASK);
+ data = (unsigned short)selector | (data & AD5398_SW_POWER_DOWN);
/* write the new current value back as well as enable bit */
ret = ad5398_write_reg(client, data);
@@ -132,10 +132,10 @@ static int ad5398_is_enabled(struct regulator_dev *rdev)
if (ret < 0)
return ret;
- if (data & AD5398_CURRENT_EN_MASK)
- return 1;
- else
+ if (data & AD5398_SW_POWER_DOWN)
return 0;
+ else
+ return 1;
}
static int ad5398_enable(struct regulator_dev *rdev)
@@ -149,10 +149,10 @@ static int ad5398_enable(struct regulator_dev *rdev)
if (ret < 0)
return ret;
- if (data & AD5398_CURRENT_EN_MASK)
+ if (!(data & AD5398_SW_POWER_DOWN))
return 0;
- data |= AD5398_CURRENT_EN_MASK;
+ data &= ~AD5398_SW_POWER_DOWN;
ret = ad5398_write_reg(client, data);
@@ -170,10 +170,10 @@ static int ad5398_disable(struct regulator_dev *rdev)
if (ret < 0)
return ret;
- if (!(data & AD5398_CURRENT_EN_MASK))
+ if (data & AD5398_SW_POWER_DOWN)
return 0;
- data &= ~AD5398_CURRENT_EN_MASK;
+ data |= AD5398_SW_POWER_DOWN;
ret = ad5398_write_reg(client, data);
--
2.43.0
next prev parent reply other threads:[~2025-01-28 17:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-28 17:31 [PATCH v2 0/3] regulator: Add device tree support to AD5398 Isaac Scott
2025-01-28 17:31 ` Isaac Scott [this message]
2025-01-29 8:31 ` [PATCH v2 1/3] regulator: ad5398: change enable bit name to improve readibility Hennerich, Michael
2025-02-05 18:45 ` Guenter Roeck
2025-02-06 9:59 ` Isaac Scott
2025-02-06 11:30 ` Mark Brown
2025-01-28 17:31 ` [PATCH v2 2/3] RFC: regulator: ad5398: Change selector division calculation Isaac Scott
2025-01-29 8:34 ` Hennerich, Michael
2025-01-29 18:21 ` Isaac Scott
2025-02-06 13:38 ` Isaac Scott
2025-01-28 17:31 ` [PATCH v2 3/3] regulator: ad5398: Add device tree support Isaac Scott
2025-01-29 8:32 ` Hennerich, Michael
2025-02-03 19:57 ` (subset) [PATCH v2 0/3] regulator: Add device tree support to AD5398 Mark Brown
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=20250128173143.959600-2-isaac.scott@ideasonboard.com \
--to=isaac.scott@ideasonboard.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.hennerich@analog.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
all inboxes | Powered by JetHome®