Skip to content

Commit 19d022d

Browse files
ijgscottbroonie
authored andcommitted
regulator: ad5398: change enable bit name to improve readibility
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> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Link: https://patch.msgid.link/20250128173143.959600-2-isaac.scott@ideasonboard.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 2014c95 commit 19d022d

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

drivers/regulator/ad5398.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <linux/regulator/driver.h>
1616
#include <linux/regulator/machine.h>
1717

18-
#define AD5398_CURRENT_EN_MASK 0x8000
18+
#define AD5398_SW_POWER_DOWN BIT(16)
1919

2020
struct ad5398_chip_info {
2121
struct i2c_client *client;
@@ -113,7 +113,7 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, int
113113

114114
/* prepare register data */
115115
selector = (selector << chip->current_offset) & chip->current_mask;
116-
data = (unsigned short)selector | (data & AD5398_CURRENT_EN_MASK);
116+
data = (unsigned short)selector | (data & AD5398_SW_POWER_DOWN);
117117

118118
/* write the new current value back as well as enable bit */
119119
ret = ad5398_write_reg(client, data);
@@ -132,10 +132,10 @@ static int ad5398_is_enabled(struct regulator_dev *rdev)
132132
if (ret < 0)
133133
return ret;
134134

135-
if (data & AD5398_CURRENT_EN_MASK)
136-
return 1;
137-
else
135+
if (data & AD5398_SW_POWER_DOWN)
138136
return 0;
137+
else
138+
return 1;
139139
}
140140

141141
static int ad5398_enable(struct regulator_dev *rdev)
@@ -149,10 +149,10 @@ static int ad5398_enable(struct regulator_dev *rdev)
149149
if (ret < 0)
150150
return ret;
151151

152-
if (data & AD5398_CURRENT_EN_MASK)
152+
if (!(data & AD5398_SW_POWER_DOWN))
153153
return 0;
154154

155-
data |= AD5398_CURRENT_EN_MASK;
155+
data &= ~AD5398_SW_POWER_DOWN;
156156

157157
ret = ad5398_write_reg(client, data);
158158

@@ -170,10 +170,10 @@ static int ad5398_disable(struct regulator_dev *rdev)
170170
if (ret < 0)
171171
return ret;
172172

173-
if (!(data & AD5398_CURRENT_EN_MASK))
173+
if (data & AD5398_SW_POWER_DOWN)
174174
return 0;
175175

176-
data &= ~AD5398_CURRENT_EN_MASK;
176+
data |= AD5398_SW_POWER_DOWN;
177177

178178
ret = ad5398_write_reg(client, data);
179179

0 commit comments

Comments
 (0)