diff options
author | Anton Tikhomirov <av.tikhomirov@samsung.com> | 2013-11-25 21:46:05 -0500 |
---|---|---|
committer | Nitin Garg <nitin.garg@freescale.com> | 2014-04-16 12:02:27 -0400 |
commit | 77ad4a580d30d5f623cbe4b4dafc0d505dd8b723 (patch) | |
tree | 8642397778936ba74d872e07af163cbd2e79ae25 | |
parent | 3315f825f1005399fc52511d1c20d4005892708b (diff) |
usb: phy: replace spinlock with mutex in OTG FSM
OTG Final State Machine calls functions which may sleep.
For example, start_gadget callback implementation can use
usb_gadget_vbus_connect(), whose context: can sleep.
If so, mutex should be used instead of spinlock.
Signed-off-by: Anton Tikhomirov <av.tikhomirov@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
(cherry-picked from commit 16e569e9661ea2b964b8abb607a51e5285254021)
-rw-r--r-- | drivers/usb/phy/phy-fsl-usb.c | 7 | ||||
-rw-r--r-- | drivers/usb/phy/phy-fsm-usb.c | 7 | ||||
-rw-r--r-- | drivers/usb/phy/phy-fsm-usb.h | 4 |
3 files changed, 8 insertions, 10 deletions
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c index d58a510d0287..880172830473 100644 --- a/drivers/usb/phy/phy-fsl-usb.c +++ b/drivers/usb/phy/phy-fsl-usb.c | |||
@@ -848,7 +848,7 @@ static int fsl_otg_conf(struct platform_device *pdev) | |||
848 | pr_info("Couldn't init OTG timers\n"); | 848 | pr_info("Couldn't init OTG timers\n"); |
849 | goto err; | 849 | goto err; |
850 | } | 850 | } |
851 | spin_lock_init(&fsl_otg_tc->fsm.lock); | 851 | mutex_init(&fsl_otg_tc->fsm.lock); |
852 | 852 | ||
853 | /* Set OTG state machine operations */ | 853 | /* Set OTG state machine operations */ |
854 | fsl_otg_tc->fsm.ops = &fsl_otg_ops; | 854 | fsl_otg_tc->fsm.ops = &fsl_otg_ops; |
@@ -1017,10 +1017,9 @@ static int show_fsl_usb2_otg_state(struct device *dev, | |||
1017 | struct otg_fsm *fsm = &fsl_otg_dev->fsm; | 1017 | struct otg_fsm *fsm = &fsl_otg_dev->fsm; |
1018 | char *next = buf; | 1018 | char *next = buf; |
1019 | unsigned size = PAGE_SIZE; | 1019 | unsigned size = PAGE_SIZE; |
1020 | unsigned long flags; | ||
1021 | int t; | 1020 | int t; |
1022 | 1021 | ||
1023 | spin_lock_irqsave(&fsm->lock, flags); | 1022 | mutex_lock(&fsm->lock); |
1024 | 1023 | ||
1025 | /* basic driver infomation */ | 1024 | /* basic driver infomation */ |
1026 | t = scnprintf(next, size, | 1025 | t = scnprintf(next, size, |
@@ -1088,7 +1087,7 @@ static int show_fsl_usb2_otg_state(struct device *dev, | |||
1088 | size -= t; | 1087 | size -= t; |
1089 | next += t; | 1088 | next += t; |
1090 | 1089 | ||
1091 | spin_unlock_irqrestore(&fsm->lock, flags); | 1090 | mutex_unlock(&fsm->lock); |
1092 | 1091 | ||
1093 | return PAGE_SIZE - size; | 1092 | return PAGE_SIZE - size; |
1094 | } | 1093 | } |
diff --git a/drivers/usb/phy/phy-fsm-usb.c b/drivers/usb/phy/phy-fsm-usb.c index 329c2d2f8595..2817b04a6c47 100644 --- a/drivers/usb/phy/phy-fsm-usb.c +++ b/drivers/usb/phy/phy-fsm-usb.c | |||
@@ -23,7 +23,7 @@ | |||
23 | 23 | ||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/types.h> | 25 | #include <linux/types.h> |
26 | #include <linux/spinlock.h> | 26 | #include <linux/mutex.h> |
27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | #include <linux/usb.h> | 28 | #include <linux/usb.h> |
29 | #include <linux/usb/gadget.h> | 29 | #include <linux/usb/gadget.h> |
@@ -245,9 +245,8 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) | |||
245 | int otg_statemachine(struct otg_fsm *fsm) | 245 | int otg_statemachine(struct otg_fsm *fsm) |
246 | { | 246 | { |
247 | enum usb_otg_state state; | 247 | enum usb_otg_state state; |
248 | unsigned long flags; | ||
249 | 248 | ||
250 | spin_lock_irqsave(&fsm->lock, flags); | 249 | mutex_lock(&fsm->lock); |
251 | 250 | ||
252 | state = fsm->otg->phy->state; | 251 | state = fsm->otg->phy->state; |
253 | state_changed = 0; | 252 | state_changed = 0; |
@@ -359,7 +358,7 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
359 | default: | 358 | default: |
360 | break; | 359 | break; |
361 | } | 360 | } |
362 | spin_unlock_irqrestore(&fsm->lock, flags); | 361 | mutex_lock(&fsm->lock); |
363 | 362 | ||
364 | VDBG("quit statemachine, changed = %d\n", state_changed); | 363 | VDBG("quit statemachine, changed = %d\n", state_changed); |
365 | return state_changed; | 364 | return state_changed; |
diff --git a/drivers/usb/phy/phy-fsm-usb.h b/drivers/usb/phy/phy-fsm-usb.h index 200f4d156020..b6ba1bfb86f2 100644 --- a/drivers/usb/phy/phy-fsm-usb.h +++ b/drivers/usb/phy/phy-fsm-usb.h | |||
@@ -18,7 +18,7 @@ | |||
18 | #ifndef __LINUX_USB_OTG_FSM_H | 18 | #ifndef __LINUX_USB_OTG_FSM_H |
19 | #define __LINUX_USB_OTG_FSM_H | 19 | #define __LINUX_USB_OTG_FSM_H |
20 | 20 | ||
21 | #include <linux/spinlock.h> | 21 | #include <linux/mutex.h> |
22 | #include <linux/errno.h> | 22 | #include <linux/errno.h> |
23 | 23 | ||
24 | #undef VERBOSE | 24 | #undef VERBOSE |
@@ -116,7 +116,7 @@ struct otg_fsm { | |||
116 | 116 | ||
117 | /* Current usb protocol used: 0:undefine; 1:host; 2:client */ | 117 | /* Current usb protocol used: 0:undefine; 1:host; 2:client */ |
118 | int protocol; | 118 | int protocol; |
119 | spinlock_t lock; | 119 | struct mutex lock; |
120 | }; | 120 | }; |
121 | 121 | ||
122 | struct otg_fsm_ops { | 122 | struct otg_fsm_ops { |