regulator: tps62360: dt: initialize of_node param for regulator register.
Subsystems (2)
PATCH 1/1 regulator: tps62360: dt: initialize of_node param for regulator register.
Initialize config.of_node for regulator before registering. This is needed for DT based regulator support. Regulator stores this of_node value in rdev->dev.of_node and used for lookup when client ask for regulator_get().
--- drivers/regulator/tps62360-regulator.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/regulator/tps62360-regulator.c +1 -0
@@ -490,6 +490,7 @@ static int __devinit tps62360_probe(struct i2c_client *client, config.dev = &client->dev; config.init_data = pdata->reg_init_data; config.driver_data = tps; + config.of_node = client->dev.of_node;/* Register the regulators */ rdev =regulator_register (&tps->desc, &config);
Signature · 1 line
1.7.1.1
PATCH 1/3 regulator: tps65910: add error message in case of failure
Prints error message whenever there is failure on resource allocation.
Also used dev_* to print messages instead of pr_*
---
Resend: This was sent earlier on other series as 5/5 and it was ok but due to discussion on other patches it did not apply. Making the changes as first of this series.
drivers/regulator/tps65910-regulator.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)
drivers/regulator/tps65910-regulator.c +8 -4
@@ -1101,7 +1101,7 @@ static struct tps65910_board *tps65910_parse_dt_reg_data( matches = tps65911_matches;break ;default : -pr_err ("Invalid tps chip version\n" ); +dev_err (&pdev->dev,"Invalid tps chip version\n" );return NULL ; }
@@ -1150,12 +1150,16 @@ static __devinit int tps65910_probe(struct platform_device *pdev)if (!pmic_plat_data && tps65910->dev->of_node) pmic_plat_data =tps65910_parse_dt_reg_data (pdev); -if (!pmic_plat_data) +if (!pmic_plat_data) { +dev_err (&pdev->dev,"Platform data not found\n" );return -EINVAL ; + } pmic =devm_kzalloc (&pdev->dev,sizeof (*pmic),GFP_KERNEL ); -if (!pmic) +if (!pmic) { +dev_err (&pdev->dev,"Memory allocation failed for pmic\n" );return -ENOMEM ; + }mutex_init (&pmic->mutex); pmic->mfd = tps65910;
@@ -1179,7 +1183,7 @@ static __devinit int tps65910_probe(struct platform_device *pdev) info = tps65911_regs;break ;default : -pr_err ("Invalid tps chip version\n" ); +dev_err (&pdev->dev,"Invalid tps chip version\n" );return -ENODEV ; }
Signature · 1 line
1.7.1.1
PATCH 2/3 regulator: tps65910: dt: support when "regulators" node found
In reply to Laxman DewanganThe device tree binding for the tps65910 is described as:
tps65911 {
reg = <0x2d>
:::::::::
regulators {
compatible = "ti,tps65911";
ldo1_reg: ldo1 {
/** regulator entry */
};
ldo2_reg: ldo2 {
/** regulator entry */
};
::::::::::
};
};Support the regulators functionality only when there is "regulators" child node available for tps65910.
--- drivers/regulator/tps65910-regulator.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/regulator/tps65910-regulator.c +4 -0
@@ -1090,6 +1090,10 @@ static struct tps65910_board *tps65910_parse_dt_reg_data( } regulators =of_find_node_by_name (np,"regulators" ); +if (!regulators) { +dev_err (&pdev->dev,"regulator node not found\n" ); +return NULL ; + }switch (tps65910_chip_id (tps65910)) {case TPS65910 :
Signature · 1 line
1.7.1.1
PATCH v2 3/3 regulator: tps65910: use of_node of matched regulator being register
In reply to Laxman DewanganAfter getting matched regulators by using of_regulator_match(), initialize the config.of_node of regulator being register with of_regulator_match.of_node of that regulator.
This is require for supporting regulator consumers in dt.
---
Changes from V1:
This is discussed in details on patch
regulator: core: use correct device for device supply lookup
with other issue of input_supply and decided to have the implementation similar to the mc13892-regulator.c.
In this patch making the implementation very similar to mc13892-regulator.c. config.of_node for regulator being register is initialize with of_regulator_match.of_node
which get initialized by calling of_regulator_match.
drivers/regulator/tps65910-regulator.c | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-)
drivers/regulator/tps65910-regulator.c +12 -7
@@ -1071,7 +1071,8 @@ static struct of_regulator_match tps65911_matches[] = { };static struct tps65910_board *tps65910_parse_dt_reg_data ( -struct platform_device *pdev) +struct platform_device *pdev, +struct of_regulator_match **tps65910_reg_matches) {struct tps65910_board *pmic_plat_data;struct tps65910 *tps65910 =dev_get_drvdata (pdev->dev.parent);
@@ -1116,6 +1117,8 @@ static struct tps65910_board *tps65910_parse_dt_reg_data(return NULL ; } + *tps65910_reg_matches = matches; +for (idx =0 ; idx < count; idx++) {if (!matches[idx].init_data || !matches[idx].of_node)continue ;
@@ -1133,8 +1136,10 @@ static struct tps65910_board *tps65910_parse_dt_reg_data( }#else static inline struct tps65910_board *tps65910_parse_dt_reg_data ( -struct platform_device *pdev) +struct platform_device *pdev, +struct of_regulator_match **tps65910_reg_matches) { + *tps65910_reg_matches =NULL ;return 0 ; }#endif
@@ -1148,11 +1153,13 @@ static __devinit int tps65910_probe(struct platform_device *pdev)struct regulator_dev *rdev;struct tps65910_reg *pmic;struct tps65910_board *pmic_plat_data; +struct of_regulator_match *tps65910_reg_matches =NULL ;int i, err; pmic_plat_data =dev_get_platdata (tps65910->dev);if (!pmic_plat_data && tps65910->dev->of_node) - pmic_plat_data =tps65910_parse_dt_reg_data (pdev); + pmic_plat_data =tps65910_parse_dt_reg_data (pdev, + &tps65910_reg_matches);if (!pmic_plat_data) {dev_err (&pdev->dev,"Platform data not found\n" );
@@ -1265,10 +1272,8 @@ static __devinit int tps65910_probe(struct platform_device *pdev) config.driver_data = pmic; config.regmap = tps65910->regmap; -#ifdef CONFIG_OF - config.of_node =of_find_node_by_name (tps65910->dev->of_node, - info->name); -#endif +if (tps65910_reg_matches) + config.of_node = tps65910_reg_matches[i].of_node; rdev =regulator_register (&pmic->desc[i], &config);if (IS_ERR (rdev)) {
Signature · 1 line
1.7.1.1
Mark Brown
AppliedQuoted 4 lines · Laxman Dewangan
Initialize config.of_node for regulator before registering. This is needed for DT based regulator support. Regulator stores this
of_nodevalue inrdev->dev.of_nodeand used for lookup when client ask forregulator_get().
Applied, thanks.
Mark Brown
AppliedRe: [PATCH 1/3] regulator: tps65910: add error message in case of failure
In reply to Laxman DewanganQuoted 3 lines · Laxman Dewangan
Prints error message whenever there is failure on resource allocation.
Also used dev_* to print messages instead of pr_*
Applied all, thanks.