Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: twl4030-power: Fix relocking on error

If an error occurs when loading power scripts or resources, the
registers are not correctly relocked. Fix it.

Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Florian Vaussard and committed by
Samuel Ortiz
cb3cabd6 e77a4c2f

+8 -4
+8 -4
drivers/mfd/twl4030-power.c
··· 558 558 struct twl4030_power_data *pdata = pdev->dev.platform_data; 559 559 struct device_node *node = pdev->dev.of_node; 560 560 int err = 0; 561 + int err2 = 0; 561 562 u8 val; 562 563 563 564 if (!pdata && !node) { ··· 582 581 err = twl4030_power_configure_scripts(pdata); 583 582 if (err) { 584 583 pr_err("TWL4030 failed to load scripts\n"); 585 - return err; 584 + goto relock; 586 585 } 587 586 err = twl4030_power_configure_resources(pdata); 588 587 if (err) { 589 588 pr_err("TWL4030 failed to configure resource\n"); 590 - return err; 589 + goto relock; 591 590 } 592 591 } 593 592 ··· 613 612 } 614 613 615 614 relock: 616 - err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0, 615 + err2 = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0, 617 616 TWL4030_PM_MASTER_PROTECT_KEY); 618 - if (err) 617 + if (err2) { 619 618 pr_err("TWL4030 Unable to relock registers\n"); 619 + return err2; 620 + } 621 + 620 622 return err; 621 623 } 622 624