Skip to content

Commit

Permalink
mfd: arizona: Defer patch initialistation until after first device boot
Browse files Browse the repository at this point in the history
Make sure that we don't race with the initial device boot by only doing
the initialisation after we've waited for the boot to complete.

The runtime PM code already waits for the boot to complete before it
syncs the register patches so in most systems if a race does occur we will
power down very soon afterwards and recover anyway.

Reported-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Mark Brown authored and Samuel Ortiz committed Dec 2, 2012
1 parent 0582c0f commit 62d62b5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions drivers/mfd/arizona-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ int __devinit arizona_dev_init(struct arizona *arizona)
struct device *dev = arizona->dev;
const char *type_name;
unsigned int reg, val;
int (*apply_patch)(struct arizona *) = NULL;
int ret, i;

dev_set_drvdata(arizona->dev, arizona);
Expand Down Expand Up @@ -391,7 +392,7 @@ int __devinit arizona_dev_init(struct arizona *arizona)
arizona->type);
arizona->type = WM5102;
}
ret = wm5102_patch(arizona);
apply_patch = wm5102_patch;
break;
#endif
#ifdef CONFIG_MFD_WM5110
Expand All @@ -402,7 +403,7 @@ int __devinit arizona_dev_init(struct arizona *arizona)
arizona->type);
arizona->type = WM5110;
}
ret = wm5110_patch(arizona);
apply_patch = wm5110_patch;
break;
#endif
default:
Expand All @@ -412,9 +413,6 @@ int __devinit arizona_dev_init(struct arizona *arizona)

dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A');

if (ret != 0)
dev_err(arizona->dev, "Failed to apply patch: %d\n", ret);

/* If we have a /RESET GPIO we'll already be reset */
if (!arizona->pdata.reset) {
ret = regmap_write(arizona->regmap, ARIZONA_SOFTWARE_RESET, 0);
Expand All @@ -430,6 +428,15 @@ int __devinit arizona_dev_init(struct arizona *arizona)
goto err_reset;
}

if (apply_patch) {
ret = apply_patch(arizona);
if (ret != 0) {
dev_err(arizona->dev, "Failed to apply patch: %d\n",
ret);
goto err_reset;
}
}

for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) {
if (!arizona->pdata.gpio_defaults[i])
continue;
Expand Down

0 comments on commit 62d62b5

Please sign in to comment.