usb: chipidea: using one inline function to cover queue work operations
The otg queue work include operations: one is disable interrupt, another one is call kernel queue work API. Many codes do this operation, using one inline function to instead of them. Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2dbd633f3a
commit
be6b0c1bd0
@ -425,8 +425,7 @@ static irqreturn_t ci_irq(int irq, void *data)
|
|||||||
ci->id_event = true;
|
ci->id_event = true;
|
||||||
/* Clear ID change irq status */
|
/* Clear ID change irq status */
|
||||||
hw_write_otgsc(ci, OTGSC_IDIS, OTGSC_IDIS);
|
hw_write_otgsc(ci, OTGSC_IDIS, OTGSC_IDIS);
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,8 +437,7 @@ static irqreturn_t ci_irq(int irq, void *data)
|
|||||||
ci->b_sess_valid_event = true;
|
ci->b_sess_valid_event = true;
|
||||||
/* Clear BSV irq */
|
/* Clear BSV irq */
|
||||||
hw_write_otgsc(ci, OTGSC_BSVIS, OTGSC_BSVIS);
|
hw_write_otgsc(ci, OTGSC_BSVIS, OTGSC_BSVIS);
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,5 +17,10 @@ int ci_hdrc_otg_init(struct ci_hdrc *ci);
|
|||||||
void ci_hdrc_otg_destroy(struct ci_hdrc *ci);
|
void ci_hdrc_otg_destroy(struct ci_hdrc *ci);
|
||||||
enum ci_role ci_otg_role(struct ci_hdrc *ci);
|
enum ci_role ci_otg_role(struct ci_hdrc *ci);
|
||||||
void ci_handle_vbus_change(struct ci_hdrc *ci);
|
void ci_handle_vbus_change(struct ci_hdrc *ci);
|
||||||
|
static inline void ci_otg_queue_work(struct ci_hdrc *ci)
|
||||||
|
{
|
||||||
|
disable_irq_nosync(ci->irq);
|
||||||
|
queue_work(ci->wq, &ci->work);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */
|
#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */
|
||||||
|
@ -84,8 +84,7 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
|
|||||||
ci->fsm.a_bus_req = 1;
|
ci->fsm.a_bus_req = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
mutex_unlock(&ci->fsm.lock);
|
mutex_unlock(&ci->fsm.lock);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@ -125,8 +124,7 @@ set_a_bus_drop(struct device *dev, struct device_attribute *attr,
|
|||||||
ci->fsm.a_bus_req = 0;
|
ci->fsm.a_bus_req = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
mutex_unlock(&ci->fsm.lock);
|
mutex_unlock(&ci->fsm.lock);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@ -165,8 +163,7 @@ set_b_bus_req(struct device *dev, struct device_attribute *attr,
|
|||||||
else if (buf[0] == '1')
|
else if (buf[0] == '1')
|
||||||
ci->fsm.b_bus_req = 1;
|
ci->fsm.b_bus_req = 1;
|
||||||
|
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
mutex_unlock(&ci->fsm.lock);
|
mutex_unlock(&ci->fsm.lock);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@ -186,8 +183,7 @@ set_a_clr_err(struct device *dev, struct device_attribute *attr,
|
|||||||
if (buf[0] == '1')
|
if (buf[0] == '1')
|
||||||
ci->fsm.a_clr_err = 1;
|
ci->fsm.a_clr_err = 1;
|
||||||
|
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
mutex_unlock(&ci->fsm.lock);
|
mutex_unlock(&ci->fsm.lock);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@ -297,8 +293,7 @@ static void set_tmout_and_fsm(void *ptr, unsigned long indicator)
|
|||||||
|
|
||||||
set_tmout(ci, indicator);
|
set_tmout(ci, indicator);
|
||||||
|
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void a_wait_vfall_tmout_func(void *ptr, unsigned long indicator)
|
static void a_wait_vfall_tmout_func(void *ptr, unsigned long indicator)
|
||||||
@ -312,8 +307,7 @@ static void a_wait_vfall_tmout_func(void *ptr, unsigned long indicator)
|
|||||||
hw_write_otgsc(ci, OTGSC_DPIS, OTGSC_DPIS);
|
hw_write_otgsc(ci, OTGSC_DPIS, OTGSC_DPIS);
|
||||||
/* Enable data pulse irq */
|
/* Enable data pulse irq */
|
||||||
hw_write_otgsc(ci, OTGSC_DPIE, OTGSC_DPIE);
|
hw_write_otgsc(ci, OTGSC_DPIE, OTGSC_DPIE);
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_ase0_brst_tmout_func(void *ptr, unsigned long indicator)
|
static void b_ase0_brst_tmout_func(void *ptr, unsigned long indicator)
|
||||||
@ -324,8 +318,7 @@ static void b_ase0_brst_tmout_func(void *ptr, unsigned long indicator)
|
|||||||
if (!hw_read_otgsc(ci, OTGSC_BSV))
|
if (!hw_read_otgsc(ci, OTGSC_BSV))
|
||||||
ci->fsm.b_sess_vld = 0;
|
ci->fsm.b_sess_vld = 0;
|
||||||
|
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
|
static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
|
||||||
@ -335,10 +328,8 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
|
|||||||
set_tmout(ci, indicator);
|
set_tmout(ci, indicator);
|
||||||
|
|
||||||
/* only vbus fall below B_sess_vld in b_idle state */
|
/* only vbus fall below B_sess_vld in b_idle state */
|
||||||
if (ci->transceiver->state == OTG_STATE_B_IDLE) {
|
if (ci->transceiver->state == OTG_STATE_B_IDLE)
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_sess_vld_tmout_func(void *ptr, unsigned long indicator)
|
static void b_sess_vld_tmout_func(void *ptr, unsigned long indicator)
|
||||||
@ -349,8 +340,7 @@ static void b_sess_vld_tmout_func(void *ptr, unsigned long indicator)
|
|||||||
if (!(hw_read_otgsc(ci, OTGSC_BSV))) {
|
if (!(hw_read_otgsc(ci, OTGSC_BSV))) {
|
||||||
ci->fsm.b_sess_vld = 0;
|
ci->fsm.b_sess_vld = 0;
|
||||||
ci_otg_add_timer(ci, B_SSEND_SRP);
|
ci_otg_add_timer(ci, B_SSEND_SRP);
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,8 +355,7 @@ static void b_data_pulse_end(void *ptr, unsigned long indicator)
|
|||||||
|
|
||||||
hw_write_otgsc(ci, OTGSC_HABA, 0);
|
hw_write_otgsc(ci, OTGSC_HABA, 0);
|
||||||
|
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize timers */
|
/* Initialize timers */
|
||||||
@ -607,10 +596,8 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
|
|||||||
* a_idle to a_wait_vrise when power up
|
* a_idle to a_wait_vrise when power up
|
||||||
*/
|
*/
|
||||||
if ((ci->fsm.id) || (ci->id_event) ||
|
if ((ci->fsm.id) || (ci->id_event) ||
|
||||||
(ci->fsm.power_up)) {
|
(ci->fsm.power_up))
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
|
||||||
if (ci->id_event)
|
if (ci->id_event)
|
||||||
ci->id_event = false;
|
ci->id_event = false;
|
||||||
} else if (ci->transceiver->state == OTG_STATE_B_IDLE) {
|
} else if (ci->transceiver->state == OTG_STATE_B_IDLE) {
|
||||||
@ -620,8 +607,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
|
|||||||
* Further transite to b_periphearl state
|
* Further transite to b_periphearl state
|
||||||
* when register gadget driver with vbus on
|
* when register gadget driver with vbus on
|
||||||
*/
|
*/
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -646,22 +632,19 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
|
|||||||
if (port_conn) {
|
if (port_conn) {
|
||||||
fsm->b_conn = 1;
|
fsm->b_conn = 1;
|
||||||
fsm->a_bus_req = 1;
|
fsm->a_bus_req = 1;
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OTG_STATE_B_IDLE:
|
case OTG_STATE_B_IDLE:
|
||||||
if (otg_bsess_vld && (intr_sts & USBi_PCI) && port_conn) {
|
if (otg_bsess_vld && (intr_sts & USBi_PCI) && port_conn) {
|
||||||
fsm->b_sess_vld = 1;
|
fsm->b_sess_vld = 1;
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OTG_STATE_B_PERIPHERAL:
|
case OTG_STATE_B_PERIPHERAL:
|
||||||
if ((intr_sts & USBi_SLI) && port_conn && otg_bsess_vld) {
|
if ((intr_sts & USBi_SLI) && port_conn && otg_bsess_vld) {
|
||||||
fsm->a_bus_suspend = 1;
|
fsm->a_bus_suspend = 1;
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
} else if (intr_sts & USBi_PCI) {
|
} else if (intr_sts & USBi_PCI) {
|
||||||
if (fsm->a_bus_suspend == 1)
|
if (fsm->a_bus_suspend == 1)
|
||||||
fsm->a_bus_suspend = 0;
|
fsm->a_bus_suspend = 0;
|
||||||
@ -671,8 +654,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
|
|||||||
if ((intr_sts & USBi_PCI) && !port_conn) {
|
if ((intr_sts & USBi_PCI) && !port_conn) {
|
||||||
fsm->a_conn = 0;
|
fsm->a_conn = 0;
|
||||||
fsm->b_bus_req = 0;
|
fsm->b_bus_req = 0;
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
ci_otg_add_timer(ci, B_SESS_VLD);
|
ci_otg_add_timer(ci, B_SESS_VLD);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -706,22 +688,19 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
|
|||||||
/* A device to be peripheral mode */
|
/* A device to be peripheral mode */
|
||||||
ci->gadget.is_a_peripheral = 1;
|
ci->gadget.is_a_peripheral = 1;
|
||||||
}
|
}
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OTG_STATE_A_HOST:
|
case OTG_STATE_A_HOST:
|
||||||
if ((intr_sts & USBi_PCI) && !port_conn) {
|
if ((intr_sts & USBi_PCI) && !port_conn) {
|
||||||
fsm->b_conn = 0;
|
fsm->b_conn = 0;
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OTG_STATE_B_WAIT_ACON:
|
case OTG_STATE_B_WAIT_ACON:
|
||||||
if ((intr_sts & USBi_PCI) && port_conn) {
|
if ((intr_sts & USBi_PCI) && port_conn) {
|
||||||
fsm->a_conn = 1;
|
fsm->a_conn = 1;
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -782,8 +761,7 @@ irqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci)
|
|||||||
fsm->b_conn = 0;
|
fsm->b_conn = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,8 +772,7 @@ irqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci)
|
|||||||
|
|
||||||
void ci_hdrc_otg_fsm_start(struct ci_hdrc *ci)
|
void ci_hdrc_otg_fsm_start(struct ci_hdrc *ci)
|
||||||
{
|
{
|
||||||
disable_irq_nosync(ci->irq);
|
ci_otg_queue_work(ci);
|
||||||
queue_work(ci->wq, &ci->work);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
|
int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user