提交 f7a89811 编写于 作者: R Roger Quadros 提交者: Chanwoo Choi

extcon: Fix extcon_cable_get_state() from getting old state after notification

Currently the extcon code notifiers the interested listeners
before it updates the extcon state with the new state.
This will cause the listeners that use extcon_cable_get_state()
to get the stale state and loose the new state.

Fix this by first changing the extcon state variable and then
notifying listeners.
Signed-off-by: NRoger Quadros <rogerq@ti.com>
Tested-by: NIvan T. Ivanov <ivan.ivanov@linaro.org>
Signed-off-by: NChanwoo Choi <cw00.choi@samsung.com>
上级 be052cc8
...@@ -275,20 +275,25 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) ...@@ -275,20 +275,25 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state)
spin_lock_irqsave(&edev->lock, flags); spin_lock_irqsave(&edev->lock, flags);
if (edev->state != ((edev->state & ~mask) | (state & mask))) { if (edev->state != ((edev->state & ~mask) | (state & mask))) {
u32 old_state;
if (check_mutually_exclusive(edev, (edev->state & ~mask) | if (check_mutually_exclusive(edev, (edev->state & ~mask) |
(state & mask))) { (state & mask))) {
spin_unlock_irqrestore(&edev->lock, flags); spin_unlock_irqrestore(&edev->lock, flags);
return -EPERM; return -EPERM;
} }
for (index = 0; index < edev->max_supported; index++) { old_state = edev->state;
if (is_extcon_changed(edev->state, state, index, &attached))
raw_notifier_call_chain(&edev->nh[index], attached, edev);
}
edev->state &= ~mask; edev->state &= ~mask;
edev->state |= state & mask; edev->state |= state & mask;
for (index = 0; index < edev->max_supported; index++) {
if (is_extcon_changed(old_state, edev->state, index,
&attached))
raw_notifier_call_chain(&edev->nh[index],
attached, edev);
}
/* This could be in interrupt handler */ /* This could be in interrupt handler */
prop_buf = (char *)get_zeroed_page(GFP_ATOMIC); prop_buf = (char *)get_zeroed_page(GFP_ATOMIC);
if (prop_buf) { if (prop_buf) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册