aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorFlorian Vaussard <florian.vaussard@epfl.ch>2013-06-18 09:17:57 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-06-19 04:19:40 -0400
commitf58cb407632ecf0ec01627b8a61852d5585b573d (patch)
treec1bc31a70746c40e53928a5842f12a2a51a1947a /drivers/mfd
parent637d6895f8f5ecc041ca6f521f544bb3d5699416 (diff)
mfd: twl4030-power: Simplify probing of power scripts and resources
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>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/twl4030-power.c60
1 files changed, 40 insertions, 20 deletions
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 94bcbeed1d62..d36622d0f98a 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -492,6 +492,39 @@ int twl4030_remove_script(u8 flags)
492 return err; 492 return err;
493} 493}
494 494
495int twl4030_power_configure_scripts(struct twl4030_power_data *pdata)
496{
497 int err;
498 int i;
499 u8 address = twl4030_start_script_address;
500
501 for (i = 0; i < pdata->num; i++) {
502 err = load_twl4030_script(pdata->scripts[i], address);
503 if (err)
504 return err;
505 address += pdata->scripts[i]->size;
506 }
507
508 return 0;
509}
510
511int twl4030_power_configure_resources(struct twl4030_power_data *pdata)
512{
513 struct twl4030_resconfig *resconfig = pdata->resource_config;
514 int err;
515
516 if (resconfig) {
517 while (resconfig->resource) {
518 err = twl4030_configure_resource(resconfig);
519 if (err)
520 return err;
521 resconfig++;
522 }
523 }
524
525 return 0;
526}
527
495/* 528/*
496 * In master mode, start the power off sequence. 529 * In master mode, start the power off sequence.
497 * After a successful execution, TWL shuts down the power to the SoC 530 * After a successful execution, TWL shuts down the power to the SoC
@@ -511,9 +544,7 @@ int twl4030_power_probe(struct platform_device *pdev)
511{ 544{
512 struct twl4030_power_data *pdata = pdev->dev.platform_data; 545 struct twl4030_power_data *pdata = pdev->dev.platform_data;
513 int err = 0; 546 int err = 0;
514 int i; 547 u8 val;
515 struct twl4030_resconfig *resconfig;
516 u8 val, address = twl4030_start_script_address;
517 548
518 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1, 549 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
519 TWL4030_PM_MASTER_PROTECT_KEY); 550 TWL4030_PM_MASTER_PROTECT_KEY);
@@ -525,23 +556,12 @@ int twl4030_power_probe(struct platform_device *pdev)
525 if (err) 556 if (err)
526 goto unlock; 557 goto unlock;
527 558
528 for (i = 0; i < pdata->num; i++) { 559 err = twl4030_power_configure_scripts(pdata);
529 err = load_twl4030_script(pdata->scripts[i], address); 560 if (err)
530 if (err) 561 goto load;
531 goto load; 562 err = twl4030_power_configure_resources(pdata);
532 address += pdata->scripts[i]->size; 563 if (err)
533 } 564 goto resource;
534
535 resconfig = pdata->resource_config;
536 if (resconfig) {
537 while (resconfig->resource) {
538 err = twl4030_configure_resource(resconfig);
539 if (err)
540 goto resource;
541 resconfig++;
542
543 }
544 }
545 565
546 /* Board has to be wired properly to use this feature */ 566 /* Board has to be wired properly to use this feature */
547 if (pdata->use_poweroff && !pm_power_off) { 567 if (pdata->use_poweroff && !pm_power_off) {