Skip to content

Commit 5a6a461

Browse files
ijgs02broonie
authored andcommitted
regulator: ad5398: Add device tree support
Previously, the ad5398 driver used only platform_data, which is deprecated in favour of device tree. This caused the AD5398 to fail to probe as it could not load its init_data. If the AD5398 has a device tree node, pull the init_data from there using of_get_regulator_init_data. Signed-off-by: Isaac Scott <[email protected]> Acked-by: Michael Hennerich <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 19d022d commit 5a6a461

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/regulator/ad5398.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/platform_device.h>
1515
#include <linux/regulator/driver.h>
1616
#include <linux/regulator/machine.h>
17+
#include <linux/regulator/of_regulator.h>
1718

1819
#define AD5398_SW_POWER_DOWN BIT(16)
1920

@@ -221,15 +222,20 @@ static int ad5398_probe(struct i2c_client *client)
221222
const struct ad5398_current_data_format *df =
222223
(struct ad5398_current_data_format *)id->driver_data;
223224

224-
if (!init_data)
225-
return -EINVAL;
226-
227225
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
228226
if (!chip)
229227
return -ENOMEM;
230228

231229
config.dev = &client->dev;
230+
if (client->dev.of_node)
231+
init_data = of_get_regulator_init_data(&client->dev,
232+
client->dev.of_node,
233+
&ad5398_reg);
234+
if (!init_data)
235+
return -EINVAL;
236+
232237
config.init_data = init_data;
238+
config.of_node = client->dev.of_node;
233239
config.driver_data = chip;
234240

235241
chip->client = client;

0 commit comments

Comments
 (0)