]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
power: extcon:convert extcon lock to spinlock from mutex
authorVenkat Reddy Talla <vreddytalla@nvidia.com>
Wed, 11 Jun 2014 05:24:03 +0000 (10:54 +0530)
committerHarshada Kale <hkale@nvidia.com>
Mon, 16 Jun 2014 14:40:24 +0000 (07:40 -0700)
use spinlock instread of mutex to avoid kernel warning "sleeping
function called from invalid context" if CONFIG_DEBUG_ATOMIC_SLEEP
(sleep inside atomic section checking config) enabled and usb cable
plugged/unplugged.

Bug 1522398

Change-Id: I813f959dc5cb3ce666794a8d57152b6f562046a6
Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
Reviewed-on: http://git-master/r/421988
(cherry picked from commit dbca4e0d9f5cdd7da5270288bf1e8add4e164e6a)
Reviewed-on: http://git-master/r/422555
GVS: Gerrit_Virtual_Submit
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
drivers/power/power_supply_extcon.c

index 4d75d7f757279a7d678f68321e1272cf41c8755d..9b09c2708bea902740e051f40d08393528e9208d 100644 (file)
@@ -28,7 +28,7 @@
 #include <linux/power/power_supply_extcon.h>
 #include <linux/slab.h>
 #include <linux/extcon.h>
-#include <linux/mutex.h>
+#include <linux/spinlock.h>
 
 #define CHARGER_TYPE_DETECTION_DEFAULT_DEBOUNCE_TIME_MS                500
 
@@ -41,7 +41,7 @@ struct power_supply_extcon {
        uint8_t                                 ac_online;
        uint8_t                                 usb_online;
        struct power_supply_extcon_plat_data    *pdata;
-       struct mutex                            lock;
+       spinlock_t                              lock;
 };
 
 struct power_supply_cables {
@@ -208,14 +208,14 @@ static int psy_extcon_extcon_notifier(struct notifier_block *self,
        struct power_supply_extcon *psy_extcon = cable->psy_extcon;
        struct extcon_dev *edev = cable->extcon_dev->edev;
 
-       mutex_lock(&psy_extcon->lock);
+       spin_lock(&psy_extcon->lock);
        cable->event = event;
        if (cable->event == 0)
                power_supply_extcon_remove_cable(psy_extcon, edev);
        else if (cable->event == 1)
                power_supply_extcon_attach_cable(psy_extcon, edev);
 
-       mutex_unlock(&psy_extcon->lock);
+       spin_unlock(&psy_extcon->lock);
 
        return NOTIFY_DONE;
 }
@@ -240,7 +240,7 @@ static int psy_extcon_probe(struct platform_device *pdev)
 
        psy_extcon->dev = &pdev->dev;
        dev_set_drvdata(&pdev->dev, psy_extcon);
-       mutex_init(&psy_extcon->lock);
+       spin_lock_init(&psy_extcon->lock);
 
        psy_extcon->ac.name             = "ac";
        psy_extcon->ac.type             = POWER_SUPPLY_TYPE_MAINS;
@@ -299,9 +299,9 @@ static int psy_extcon_probe(struct platform_device *pdev)
        if (!psy_extcon->edev)
                        goto econ_err;
 
-       mutex_lock(&psy_extcon->lock);
+       spin_lock(&psy_extcon->lock);
        power_supply_extcon_attach_cable(psy_extcon, psy_extcon->edev);
-       mutex_unlock(&psy_extcon->lock);
+       spin_unlock(&psy_extcon->lock);
 
        if (pdata->y_cable_extcon_name) {
                psy_extcon->y_cable_edev =
@@ -309,10 +309,10 @@ static int psy_extcon_probe(struct platform_device *pdev)
                if (!psy_extcon->y_cable_edev)
                        goto econ_err;
 
-               mutex_lock(&psy_extcon->lock);
+               spin_lock(&psy_extcon->lock);
                power_supply_extcon_attach_cable(psy_extcon,
                                psy_extcon->y_cable_edev);
-               mutex_unlock(&psy_extcon->lock);
+               spin_unlock(&psy_extcon->lock);
        }
 
        dev_info(&pdev->dev, "%s() get success\n", __func__);