USB: msm_otg: Make power supply properties writeable

Define a property_is_writeable() power supply framework callback
function for the USB power supply device which specifies that the
power supply properties: present, online, and current_max are
writeable from userspace.

Adding write permissions for these properties in sysfs enables
further debug and testing capabilities for the msm_otg driver.
One particularly useful case is the ability to force a connected
charger power supply device into USB suspend mode without any
involvement from the USB host.

Change-Id: Iddd3d350fbf561d174551566d1ddc3848c896566
Signed-off-by: David Collins <collinsd@codeaurora.org>
diff --git a/drivers/usb/otg/msm_otg.c b/drivers/usb/otg/msm_otg.c
index b9e95ab..dde9312 100644
--- a/drivers/usb/otg/msm_otg.c
+++ b/drivers/usb/otg/msm_otg.c
@@ -3493,6 +3493,21 @@
 	return 0;
 }
 
+static int otg_power_property_is_writeable_usb(struct power_supply *psy,
+						enum power_supply_property psp)
+{
+	switch (psp) {
+	case POWER_SUPPLY_PROP_PRESENT:
+	case POWER_SUPPLY_PROP_ONLINE:
+	case POWER_SUPPLY_PROP_CURRENT_MAX:
+		return 1;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
 static char *otg_pm_power_supplied_to[] = {
 	"battery",
 };
@@ -4073,6 +4088,8 @@
 	motg->usb_psy.num_properties = ARRAY_SIZE(otg_pm_power_props_usb);
 	motg->usb_psy.get_property = otg_power_get_property_usb;
 	motg->usb_psy.set_property = otg_power_set_property_usb;
+	motg->usb_psy.property_is_writeable
+		= otg_power_property_is_writeable_usb;
 
 	if (!pm8921_charger_register_vbus_sn(NULL)) {
 		/* if pm8921 use legacy implementation */