Input: wm97xx-core - fix race on PHY init

The chip phy_init() function must be called before the dig_enable() function
but dig_enable() is called when the device is opened and we only call
phy_init() after having reigstered the device, meaning the two can race.
Fix this by doing the phy_init() before we register the input device.

Thanks to Rodolfo Giometti <giometti@enneenne.com> for the report.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

authored by Mark Brown and committed by Dmitry Torokhov 5de4cd43 ef9db492

+11 -11
+11 -11
drivers/input/touchscreen/wm97xx-core.c
··· 608 goto alloc_err; 609 } 610 611 wm->input_dev = input_allocate_device(); 612 if (wm->input_dev == NULL) { 613 ret = -ENOMEM; ··· 645 ret = input_register_device(wm->input_dev); 646 if (ret < 0) 647 goto dev_alloc_err; 648 - 649 - /* set up physical characteristics */ 650 - wm->codec->phy_init(wm); 651 - 652 - /* load gpio cache */ 653 - wm->gpio[0] = wm97xx_reg_read(wm, AC97_GPIO_CFG); 654 - wm->gpio[1] = wm97xx_reg_read(wm, AC97_GPIO_POLARITY); 655 - wm->gpio[2] = wm97xx_reg_read(wm, AC97_GPIO_STICKY); 656 - wm->gpio[3] = wm97xx_reg_read(wm, AC97_GPIO_WAKEUP); 657 - wm->gpio[4] = wm97xx_reg_read(wm, AC97_GPIO_STATUS); 658 - wm->gpio[5] = wm97xx_reg_read(wm, AC97_MISC_AFE); 659 660 /* register our battery device */ 661 wm->battery_dev = platform_device_alloc("wm97xx-battery", -1);
··· 608 goto alloc_err; 609 } 610 611 + /* set up physical characteristics */ 612 + wm->codec->phy_init(wm); 613 + 614 + /* load gpio cache */ 615 + wm->gpio[0] = wm97xx_reg_read(wm, AC97_GPIO_CFG); 616 + wm->gpio[1] = wm97xx_reg_read(wm, AC97_GPIO_POLARITY); 617 + wm->gpio[2] = wm97xx_reg_read(wm, AC97_GPIO_STICKY); 618 + wm->gpio[3] = wm97xx_reg_read(wm, AC97_GPIO_WAKEUP); 619 + wm->gpio[4] = wm97xx_reg_read(wm, AC97_GPIO_STATUS); 620 + wm->gpio[5] = wm97xx_reg_read(wm, AC97_MISC_AFE); 621 + 622 wm->input_dev = input_allocate_device(); 623 if (wm->input_dev == NULL) { 624 ret = -ENOMEM; ··· 634 ret = input_register_device(wm->input_dev); 635 if (ret < 0) 636 goto dev_alloc_err; 637 638 /* register our battery device */ 639 wm->battery_dev = platform_device_alloc("wm97xx-battery", -1);