power: smb349: fix otg driver callback function
Syed Rafiuddin [Fri, 9 Mar 2012 11:08:09 +0000 (16:08 +0530)]
Allows OTG enable/disable only while USB OTG state
swithes between SUSPEND and HOST

Bug 937188

Change-Id: If651dfb19db37f8822e6d1473aa573246aca8d45
Signed-off-by: Syed Rafiuddin <srafiuddin@nvidia.com>
Reviewed-on: http://git-master/r/89111
Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>

drivers/power/smb349-charger.c
drivers/usb/otg/tegra-otg.c
include/linux/smb349-charger.h

index 300f919..8719e81 100644 (file)
@@ -450,12 +450,12 @@ error:
        return ret;
 }
 
-static void smb349_otg_status(enum usb_otg_state otg_state, void *data)
+static void smb349_otg_status(enum usb_otg_state to, enum usb_otg_state from, void *data)
 {
        struct i2c_client *client = charger->client;
        int ret;
 
-       if (otg_state == OTG_STATE_A_HOST) {
+       if ((from == OTG_STATE_A_SUSPEND) && (to == OTG_STATE_A_HOST)) {
 
                /* configure charger */
                ret = smb349_configure_charger(client, 0);
@@ -469,7 +469,7 @@ static void smb349_otg_status(enum usb_otg_state otg_state, void *data)
                        dev_err(&client->dev, "%s() error in configuring"
                                "otg..\n", __func__);
 
-       } else if (otg_state == OTG_STATE_A_SUSPEND) {
+       } else if ((from == OTG_STATE_A_HOST) && (to == OTG_STATE_A_SUSPEND)) {
 
                /* Disable OTG */
                ret = smb349_configure_otg(client, 0);
index ffbeede..e7a21f9 100644 (file)
@@ -43,7 +43,8 @@
 #define  USB_VBUS_STATUS       (1 << 10)
 #define  USB_INTS              (USB_VBUS_INT_STATUS | USB_ID_INT_STATUS)
 
-typedef void (*callback_t)(enum usb_otg_state otg_state, void *args);
+typedef void (*callback_t)(enum usb_otg_state to,
+                               enum usb_otg_state from, void *args);
 
 struct tegra_otg_data {
        struct otg_transceiver otg;
@@ -225,7 +226,7 @@ static void irq_work(struct work_struct *work)
                                              tegra_state_name(to));
 
                if (tegra->charger_cb)
-                       tegra->charger_cb(to, tegra->charger_cb_data);
+                       tegra->charger_cb(to, from, tegra->charger_cb_data);
 
                if (to == OTG_STATE_A_SUSPEND) {
                        if (from == OTG_STATE_A_HOST)
index ab02b88..116f036 100644 (file)
@@ -50,7 +50,8 @@ struct smb349_charger {
 };
 
 int smb349_battery_online(void);
-typedef void (*callback_t)(enum usb_otg_state otg_state, void *args);
+typedef void (*callback_t)(enum usb_otg_state to,
+               enum usb_otg_state from, void *args);
 /*
  * Register callback function for the client.
  * Used by fuel-gauge driver to get battery charging properties.