Skip to content

Commit

Permalink
mfd: twl4030-power: Simplify probing of power scripts and resources
Browse files Browse the repository at this point in the history
Increase lisibility when probing power scripts and resources by
creating dedicated functions.

Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Florian Vaussard authored and Samuel Ortiz committed Jun 19, 2013
1 parent 637d689 commit f58cb40
Showing 1 changed file with 40 additions and 20 deletions.
60 changes: 40 additions & 20 deletions drivers/mfd/twl4030-power.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,39 @@ int twl4030_remove_script(u8 flags)
return err;
}

int twl4030_power_configure_scripts(struct twl4030_power_data *pdata)
{
int err;
int i;
u8 address = twl4030_start_script_address;

for (i = 0; i < pdata->num; i++) {
err = load_twl4030_script(pdata->scripts[i], address);
if (err)
return err;
address += pdata->scripts[i]->size;
}

return 0;
}

int twl4030_power_configure_resources(struct twl4030_power_data *pdata)
{
struct twl4030_resconfig *resconfig = pdata->resource_config;
int err;

if (resconfig) {
while (resconfig->resource) {
err = twl4030_configure_resource(resconfig);
if (err)
return err;
resconfig++;
}
}

return 0;
}

/*
* In master mode, start the power off sequence.
* After a successful execution, TWL shuts down the power to the SoC
Expand All @@ -511,9 +544,7 @@ int twl4030_power_probe(struct platform_device *pdev)
{
struct twl4030_power_data *pdata = pdev->dev.platform_data;
int err = 0;
int i;
struct twl4030_resconfig *resconfig;
u8 val, address = twl4030_start_script_address;
u8 val;

err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
TWL4030_PM_MASTER_PROTECT_KEY);
Expand All @@ -525,23 +556,12 @@ int twl4030_power_probe(struct platform_device *pdev)
if (err)
goto unlock;

for (i = 0; i < pdata->num; i++) {
err = load_twl4030_script(pdata->scripts[i], address);
if (err)
goto load;
address += pdata->scripts[i]->size;
}

resconfig = pdata->resource_config;
if (resconfig) {
while (resconfig->resource) {
err = twl4030_configure_resource(resconfig);
if (err)
goto resource;
resconfig++;

}
}
err = twl4030_power_configure_scripts(pdata);
if (err)
goto load;
err = twl4030_power_configure_resources(pdata);
if (err)
goto resource;

/* Board has to be wired properly to use this feature */
if (pdata->use_poweroff && !pm_power_off) {
Expand Down

0 comments on commit f58cb40

Please sign in to comment.