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>
This commit is contained in:
parent
d49dd78884
commit
16e569e966
@ -848,7 +848,7 @@ static int fsl_otg_conf(struct platform_device *pdev)
|
|||||||
pr_info("Couldn't init OTG timers\n");
|
pr_info("Couldn't init OTG timers\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
spin_lock_init(&fsl_otg_tc->fsm.lock);
|
mutex_init(&fsl_otg_tc->fsm.lock);
|
||||||
|
|
||||||
/* Set OTG state machine operations */
|
/* Set OTG state machine operations */
|
||||||
fsl_otg_tc->fsm.ops = &fsl_otg_ops;
|
fsl_otg_tc->fsm.ops = &fsl_otg_ops;
|
||||||
@ -1017,10 +1017,9 @@ static int show_fsl_usb2_otg_state(struct device *dev,
|
|||||||
struct otg_fsm *fsm = &fsl_otg_dev->fsm;
|
struct otg_fsm *fsm = &fsl_otg_dev->fsm;
|
||||||
char *next = buf;
|
char *next = buf;
|
||||||
unsigned size = PAGE_SIZE;
|
unsigned size = PAGE_SIZE;
|
||||||
unsigned long flags;
|
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
spin_lock_irqsave(&fsm->lock, flags);
|
mutex_lock(&fsm->lock);
|
||||||
|
|
||||||
/* basic driver infomation */
|
/* basic driver infomation */
|
||||||
t = scnprintf(next, size,
|
t = scnprintf(next, size,
|
||||||
@ -1088,7 +1087,7 @@ static int show_fsl_usb2_otg_state(struct device *dev,
|
|||||||
size -= t;
|
size -= t;
|
||||||
next += t;
|
next += t;
|
||||||
|
|
||||||
spin_unlock_irqrestore(&fsm->lock, flags);
|
mutex_unlock(&fsm->lock);
|
||||||
|
|
||||||
return PAGE_SIZE - size;
|
return PAGE_SIZE - size;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
#include <linux/usb/gadget.h>
|
#include <linux/usb/gadget.h>
|
||||||
@ -245,9 +245,8 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
|
|||||||
int otg_statemachine(struct otg_fsm *fsm)
|
int otg_statemachine(struct otg_fsm *fsm)
|
||||||
{
|
{
|
||||||
enum usb_otg_state state;
|
enum usb_otg_state state;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&fsm->lock, flags);
|
mutex_lock(&fsm->lock);
|
||||||
|
|
||||||
state = fsm->otg->phy->state;
|
state = fsm->otg->phy->state;
|
||||||
state_changed = 0;
|
state_changed = 0;
|
||||||
@ -359,7 +358,7 @@ int otg_statemachine(struct otg_fsm *fsm)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&fsm->lock, flags);
|
mutex_lock(&fsm->lock);
|
||||||
|
|
||||||
VDBG("quit statemachine, changed = %d\n", state_changed);
|
VDBG("quit statemachine, changed = %d\n", state_changed);
|
||||||
return state_changed;
|
return state_changed;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#ifndef __LINUX_USB_OTG_FSM_H
|
#ifndef __LINUX_USB_OTG_FSM_H
|
||||||
#define __LINUX_USB_OTG_FSM_H
|
#define __LINUX_USB_OTG_FSM_H
|
||||||
|
|
||||||
#include <linux/spinlock.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/errno.h>
|
#include <linux/errno.h>
|
||||||
|
|
||||||
#undef VERBOSE
|
#undef VERBOSE
|
||||||
@ -116,7 +116,7 @@ struct otg_fsm {
|
|||||||
|
|
||||||
/* Current usb protocol used: 0:undefine; 1:host; 2:client */
|
/* Current usb protocol used: 0:undefine; 1:host; 2:client */
|
||||||
int protocol;
|
int protocol;
|
||||||
spinlock_t lock;
|
struct mutex lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct otg_fsm_ops {
|
struct otg_fsm_ops {
|
||||||
|
Loading…
Reference in New Issue
Block a user