Skip to content

Commit 4698e88

Browse files
aasinclaircvinayak
authored andcommitted
[nrf fromtree] drivers: regulator: fake: Added is_enabled property
Added is_enabled devicetree property to fake regulator. Allows testing of init behaviour when regulator is enabled in hardware. Signed-off-by: Andy Sinclair <[email protected]> (cherry picked from commit 16fdc4b)
1 parent f71ddc7 commit 4698e88

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

drivers/regulator/regulator_fake.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
struct regulator_fake_config {
1717
struct regulator_common_config common;
18+
bool is_enabled;
1819
};
1920

2021
struct regulator_fake_data {
@@ -64,9 +65,11 @@ static struct regulator_driver_api api = {
6465

6566
static int regulator_fake_init(const struct device *dev)
6667
{
68+
const struct regulator_fake_config *config = dev->config;
69+
6770
regulator_common_data_init(dev);
6871

69-
return regulator_common_init(dev, false);
72+
return regulator_common_init(dev, config->is_enabled);
7073
}
7174

7275
/* parent regulator */
@@ -90,6 +93,7 @@ static struct regulator_parent_driver_api parent_api = {
9093
\
9194
static const struct regulator_fake_config FAKE_CONF_NAME(node_id) = { \
9295
.common = REGULATOR_DT_COMMON_CONFIG_INIT(node_id), \
96+
.is_enabled = DT_PROP(node_id, fake_is_enabled_in_hardware), \
9397
}; \
9498
\
9599
DEVICE_DT_DEFINE(node_id, regulator_fake_init, NULL, \

dts/bindings/regulator/zephyr,fake-regulator.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ compatible: "zephyr,fake-regulator"
1010

1111
child-binding:
1212
include: regulator.yaml
13+
14+
properties:
15+
fake-is-enabled-in-hardware:
16+
type: boolean
17+
description: |
18+
Sets the is_enabled flag passed to regulator_common_init.
19+
Allows test cases where the regulator is enabled in hardware.

0 commit comments

Comments
 (0)