regulator: tps6586x: register regulator even if no init data
PATCH 1/1 regulator: tps6586x: register regulator even if no init data
Register all TPS6586x regulators even if there is no regulator init data for platform i.e. without any user-supplied constraints.
---
This patch make sure that all chip regulators get registered even there is no user-supplied.
This is based on discussion on following patch about registering rails without init data.
max8907: fix use of possibly NULL idata
drivers/mfd/tps6586x.c | 16 ++++++++-------- drivers/regulator/tps6586x-regulator.c | 3 +++ 2 files changed, 11 insertions(+), 8 deletions(-)
drivers/mfd/tps6586x.c +8 -8
@@ -396,19 +396,19 @@ static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clienfor (i =0 , j =0 ; i < num && j < count; i++) {struct regulator_init_data *reg_idata; -if (!tps6586x_matches[i].init_data) -continue ; - reg_idata = tps6586x_matches[i].init_data; devs[j].name ="tps6586x-regulator" ; devs[j].platform_data = tps6586x_matches[i].init_data; devs[j].id = (int )tps6586x_matches[i].driver_data; -if (devs[j].id ==TPS6586X_ID_SYS ) - sys_rail_name = reg_idata->constraints.name; -if ((devs[j].id ==TPS6586X_ID_LDO_5 ) || - (devs[j].id ==TPS6586X_ID_LDO_RTC )) - reg_idata->supply_regulator = sys_rail_name; +if (tps6586x_matches[i].init_data) { +if (devs[j].id ==TPS6586X_ID_SYS ) + sys_rail_name = reg_idata->constraints.name; + +if ((devs[j].id ==TPS6586X_ID_LDO_5 ) || + (devs[j].id ==TPS6586X_ID_LDO_RTC )) + reg_idata->supply_regulator = sys_rail_name; + } devs[j].of_node = tps6586x_matches[i].of_node; j++;
drivers/regulator/tps6586x-regulator.c +3 -0
@@ -332,6 +332,9 @@ static int __devinit tps6586x_regulator_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rdev); +if (!pdev->dev.platform_data) +return 0 ; +return tps6586x_regulator_set_slew_rate (pdev); }
Signature · 1 line
1.7.1.1
PATCH 1/1 regulator: tps65910: register regulator even if no init data
Register all TPS65910 regulators even if there is no regulator init data for platform i.e. without any user-supplied constraints.
---
This patch make sure that all chip regulators get registered even there is no user-supplied.
This is based on discussion on following patch about registering rails without init data.
max8907: fix use of possibly NULL idata
drivers/regulator/tps65910-regulator.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/regulator/tps65910-regulator.c +0 -5
@@ -1105,11 +1105,6 @@ static __devinit int tps65910_probe(struct platform_device *pdev) reg_data = pmic_plat_data->tps65910_pmic_init_data[i]; -/* Regulator API handles empty constraints but not NULL -* constraints */ -if (!reg_data) -continue ; -/* Register the regulators */ pmic->info[i] = info;
Signature · 1 line
1.7.1.1
Quoted 13 lines · Laxman Dewangan
Register all TPS6586x regulators even if there is no regulator init data for platform i.e. without any user-supplied constraints.
drivers/mfd/tps6586x.c +0
-3@@ -396,19 +396,19 @@ static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clienfor (i =0 , j =0 ; i < num && j < count; i++) {struct regulator_init_data *reg_idata; -if (!tps6586x_matches[i].init_data) -continue ; - reg_idata = tps6586x_matches[i].init_data;
drivers/mfd/tps6586x.c static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clien · line 404
Quoted 10 lines
drivers/mfd/tps6586x.c +1
-5devs[j].name ="tps6586x-regulator" ; devs[j].platform_data = tps6586x_matches[i].init_data; devs[j].id = (int )tps6586x_matches[i].driver_data; -if (devs[j].id ==TPS6586X_ID_SYS ) - sys_rail_name = reg_idata->constraints.name; -if ((devs[j].id ==TPS6586X_ID_LDO_5 ) || - (devs[j].id ==TPS6586X_ID_LDO_RTC )) - reg_idata->supply_regulator = sys_rail_name; +if (tps6586x_matches[i].init_data) {
The variable that's being used inside this block is reg_idata. Admittedly the value of that variable is tps6586x_matches[i].init_data, but I think it'd be much cleaner if the if statement checked reg_idata directly; that way, someone reading the code wouldn't have to look above to find out that reg_idata and tps6586x_matches[i].init_data are related.
drivers/mfd/tps6586x.c static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clien · line 406
Quoted 2 lines
drivers/mfd/tps6586x.c +2
-0+if (devs[j].id ==TPS6586X_ID_SYS ) + sys_rail_name = reg_idata->constraints.name;
In the MAX8907 patch this attempts to duplicate; if there is no init data where the user gives an explicit name, the name from the descriptor is used:
if (idata && idata->constraints.name)
mbatt_rail_name = idata->constraints.name;
else
mbatt_rail_name = pmic->desc[i].name;Shouldn't that same algorithm be used here?
drivers/regulator/tps6586x-regulator.c static int __devinit tps6586x_regulator_probe(struct platform_device *pdev) · line 339
Quoted 11 lines
drivers/regulator/tps6586x-regulator.c +3
-0@@ -332,6 +332,9 @@ static int __devinit tps6586x_regulator_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rdev); +if (!pdev->dev.platform_data) +return 0 ; +return tps6586x_regulator_set_slew_rate (pdev); }
Sorry, I don't immediately see why that's related?
Quoted 12 lines · Stephen Warren
drivers/mfd/tps6586x.c static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clien · line 404
Quoted 6 lines
drivers/mfd/tps6586x.c +1
-3-if ((devs[j].id ==TPS6586X_ID_LDO_5 ) || - (devs[j].id ==TPS6586X_ID_LDO_RTC )) - reg_idata->supply_regulator = sys_rail_name; +if (tps6586x_matches[i].init_data) {The variable that's being used inside this block is
reg_idata. Admittedly the value of that variable is tps6586x_matches[i].init_data, but I think it'd be much cleaner if the if statement checkedreg_idatadirectly; that way, someone reading the code wouldn't have to look above to find out thatreg_idataand tps6586x_matches[i].init_data are related.
OK, will take care in my next patch.
Quoted 6 lines
drivers/mfd/tps6586x.c static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clien · line 406
Quoted 2 lines
drivers/mfd/tps6586x.c +2
-0+if (devs[j].id ==TPS6586X_ID_SYS ) + sys_rail_name = reg_idata->constraints.name;In the MAX8907 patch this attempts to duplicate; if there is no init data where the user gives an explicit name, the name from the descriptor is used:
Quoted 6 lines
if (idata&&
idata->constraints.name)mbatt_rail_name = idata->constraints.name; else mbatt_rail_name = pmic->desc[i].name;Shouldn't that same algorithm be used here?
the desc is not available here in mfd file and so not possible. Each regulator register as different platform driver and hence does not have the other instance platform data. However, this will be get fixed once my next patch for moving the dt parsing from mfd core to regulator is there. At that time I will take care of this.
Quoted 7 lines
drivers/regulator/tps6586x-regulator.c static int __devinit tps6586x_regulator_probe(struct platform_device *pdev) · line 339
Quoted 6 lines
drivers/regulator/tps6586x-regulator.c +3
-0+if (!pdev->dev.platform_data) +return 0 ; +return tps6586x_regulator_set_slew_rate (pdev); }Sorry, I don't immediately see why that's related?
The function tps6586x_regulator_set_slew_rate() use the platform data which is not available if init_data is not provided by platform.