WIP: extcon: do not update cable state if notifier cannot handle it
authorChanho Park <chanho61.park@samsung.com>
Wed, 25 Sep 2013 07:47:33 +0000 (16:47 +0900)
committerChanho Park <chanho61.park@samsung.com>
Tue, 18 Nov 2014 02:44:48 +0000 (11:44 +0900)
During probing a extcon-max77693 driver, extcon-port driver can't receive nb
callback due to initializing sequences.
Thus, if the callback can't be handled, we do not update the cable state.
I'm not sure this patch is good solution :)

Signed-off-by: Chanho Park <chanho61.park@samsung.com>
drivers/extcon/extcon-class.c

index 60adc04..e7b851b 100644 (file)
@@ -229,6 +229,7 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state)
        int env_offset = 0;
        int length;
        unsigned long flags;
+       int ret;
 
        spin_lock_irqsave(&edev->lock, flags);
 
@@ -244,7 +245,12 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state)
                edev->state &= ~mask;
                edev->state |= state & mask;
 
-               raw_notifier_call_chain(&edev->nh, old_state, edev);
+               ret = raw_notifier_call_chain(&edev->nh, old_state, edev);
+               if ((ret & ~NOTIFY_STOP_MASK) != NOTIFY_OK) {
+                       edev->state = old_state;
+                       spin_unlock_irqrestore(&edev->lock, flags);
+                       return -ENODEV;
+               }
 
                /* This could be in interrupt handler */
                prop_buf = (char *)get_zeroed_page(GFP_ATOMIC);