usb: msm_otg: always register USB power_supply
usb: msm_otg: always register USB power_supply

Commit 7380a876 ("otg: msm_otg: don't register USB supply in some
cases") incorrectly stated USB power supply need not be registered
when OTG_PMIC_CONTROL is not used, when in fact it is needed.
Consider the case when OTG_PHY_CONTROL is used, but the OTG driver
still needs to notify PMIC about current limits, host mode, etc.
The issue it attempted to fix was caused from the call to the
power_supply_register failing which was due to CONFIG_POWER_SUPPLY
being undefined. This would fail the probe and the USB driver would
not get loaded. But simply removing the call will cause crashes
when the various power_supply framework APIs are called on an
unintialized power_supply instance.

Another case that wasn't considered fully is that on legacy targets
the PM8921 charger driver already registers a USB power_supply, so
there is the possibility that both drivers could clash. OTG driver
should not register the power_supply in this case.

This change fixes the problem in several ways. First, check for the
possibilty that the PM8921 charger driver exists and rely on that
to provide a power_supply. If not, then we can register our own.
Second, to allow for CONFIG_POWER_SUPPLY being undefined, handle
the failing power_supply_register call by keeping the global psy
variable NULL. This way, the various notifier functions can check
for this and won't attempt to call any of the power_supply APIs.

Change-Id: Idca4e80191b72370dbcbb85ece6a3d551dac3858
Signed-off-by: Jack Pham <cbd79eb9617449d4bb49d0087b0eb70c6cf062b0@codeaurora.org>

TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas