phy: phy-twl4030-usb: Fix cable state handling
authorTony Lindgren <tony@atomide.com>
Sun, 24 Mar 2019 23:26:54 +0000 (16:26 -0700)
committerKishon Vijay Abraham I <kishon@ti.com>
Wed, 17 Apr 2019 04:59:49 +0000 (10:29 +0530)
commit20f795881f4f186fd98d9425053d575b2e577ff5
tree1a36d52fd8f6fc16f6d09d1463c7251479282f3c
parent9e98c678c2d6ae3a17cb2de55d17f69dddaa231b
phy: phy-twl4030-usb: Fix cable state handling

With the recent regulator changes I noticed new warnings on doing rmmod of
phy-twl4030-usb:

WARNING: CPU: 0 PID: 1080 at drivers/regulator/core.c:2046 _regulator_put
...

Turns out we can currently miss disconnect at least for cases where status
is 0 and linkstat is 0. And in that case doing rmmod phy-twl4030-usb will
produce the regulator_put() warning.

This is because the missed disconnect causes unbalanced PM runtime calls
and the regulators will be on exit.

Let's fix the issue by using an atomic flag for the cable state to make
sure that PM runtime won't get out of sync with the cable state. That
way we can also simplify the code a bit.

Note that we can also drop the old comments, those relate to issues that
the battery charger driver and musb driver is dealing with rather than
the USB PHY driver.

Cc: NeilBrown <neilb@suse.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
drivers/phy/ti/phy-twl4030-usb.c