aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Chen <peter.chen@freescale.com>2014-05-22 20:12:49 -0400
committerPeter Chen <peter.chen@freescale.com>2014-06-26 00:28:39 -0400
commitf9c7ccc1ce793b569f9695da91b165402c5154a9 (patch)
treed19a8fc2422a2418077fecb8c909f3f6d471049e
parent52643b0416167d67251908e13086b65de11ca076 (diff)
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> (cherry picked from commit c8b188d2900a7a9c833f67585cc11e47b47ad6b2)
-rw-r--r--drivers/usb/chipidea/core.c9
-rw-r--r--drivers/usb/chipidea/otg.h5
-rw-r--r--drivers/usb/chipidea/otg_fsm.c69
3 files changed, 31 insertions, 52 deletions
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index cd987ea7c332..9e6d638cbfca 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -448,8 +448,7 @@ static irqreturn_t ci_irq(int irq, void *data)
448 if (ci->is_otg && (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS)) { 448 if (ci->is_otg && (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS)) {
449 ci->id_event = true; 449 ci->id_event = true;
450 hw_write_otgsc(ci, OTGSC_IDIS, OTGSC_IDIS); 450 hw_write_otgsc(ci, OTGSC_IDIS, OTGSC_IDIS);
451 disable_irq_nosync(ci->irq); 451 ci_otg_queue_work(ci);
452 queue_work(ci->wq, &ci->work);
453 return IRQ_HANDLED; 452 return IRQ_HANDLED;
454 } 453 }
455 454
@@ -460,8 +459,7 @@ static irqreturn_t ci_irq(int irq, void *data)
460 if (ci->is_otg && (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS)) { 459 if (ci->is_otg && (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS)) {
461 ci->b_sess_valid_event = true; 460 ci->b_sess_valid_event = true;
462 hw_write_otgsc(ci, OTGSC_BSVIS, OTGSC_BSVIS); 461 hw_write_otgsc(ci, OTGSC_BSVIS, OTGSC_BSVIS);
463 disable_irq_nosync(ci->irq); 462 ci_otg_queue_work(ci);
464 queue_work(ci->wq, &ci->work);
465 return IRQ_HANDLED; 463 return IRQ_HANDLED;
466 } 464 }
467 465
@@ -824,8 +822,7 @@ static void ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci)
824 if (!hw_read_otgsc(ci, OTGSC_ID)) { 822 if (!hw_read_otgsc(ci, OTGSC_ID)) {
825 ci->fsm.a_srp_det = 1; 823 ci->fsm.a_srp_det = 1;
826 ci->fsm.a_bus_drop = 0; 824 ci->fsm.a_bus_drop = 0;
827 disable_irq_nosync(ci->irq); 825 ci_otg_queue_work(ci);
828 queue_work(ci->wq, &ci->work);
829 } else { 826 } else {
830 ci->fsm.id = 1; 827 ci->fsm.id = 1;
831 } 828 }
diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h
index a8de8169bce7..05ad33707b72 100644
--- a/drivers/usb/chipidea/otg.h
+++ b/drivers/usb/chipidea/otg.h
@@ -18,5 +18,10 @@ void ci_hdrc_otg_destroy(struct ci_hdrc *ci);
18enum ci_role ci_otg_role(struct ci_hdrc *ci); 18enum ci_role ci_otg_role(struct ci_hdrc *ci);
19void ci_handle_vbus_change(struct ci_hdrc *ci); 19void ci_handle_vbus_change(struct ci_hdrc *ci);
20void ci_handle_vbus_connected(struct ci_hdrc *ci); 20void ci_handle_vbus_connected(struct ci_hdrc *ci);
21static inline void ci_otg_queue_work(struct ci_hdrc *ci)
22{
23 disable_irq_nosync(ci->irq);
24 queue_work(ci->wq, &ci->work);
25}
21 26
22#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */ 27#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 630ae7560b75..fc9d865d0f25 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -84,8 +84,7 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
84 ci->fsm.a_bus_req = 1; 84 ci->fsm.a_bus_req = 1;
85 } 85 }
86 86
87 disable_irq_nosync(ci->irq); 87 ci_otg_queue_work(ci);
88 queue_work(ci->wq, &ci->work);
89 mutex_unlock(&ci->fsm.lock); 88 mutex_unlock(&ci->fsm.lock);
90 89
91 return count; 90 return count;
@@ -125,8 +124,7 @@ set_a_bus_drop(struct device *dev, struct device_attribute *attr,
125 ci->fsm.a_bus_req = 0; 124 ci->fsm.a_bus_req = 0;
126 } 125 }
127 126
128 disable_irq_nosync(ci->irq); 127 ci_otg_queue_work(ci);
129 queue_work(ci->wq, &ci->work);
130 mutex_unlock(&ci->fsm.lock); 128 mutex_unlock(&ci->fsm.lock);
131 129
132 return count; 130 return count;
@@ -165,8 +163,7 @@ set_b_bus_req(struct device *dev, struct device_attribute *attr,
165 else if (buf[0] == '1') 163 else if (buf[0] == '1')
166 ci->fsm.b_bus_req = 1; 164 ci->fsm.b_bus_req = 1;
167 165
168 disable_irq_nosync(ci->irq); 166 ci_otg_queue_work(ci);
169 queue_work(ci->wq, &ci->work);
170 mutex_unlock(&ci->fsm.lock); 167 mutex_unlock(&ci->fsm.lock);
171 168
172 return count; 169 return count;
@@ -186,8 +183,7 @@ set_a_clr_err(struct device *dev, struct device_attribute *attr,
186 if (buf[0] == '1') 183 if (buf[0] == '1')
187 ci->fsm.a_clr_err = 1; 184 ci->fsm.a_clr_err = 1;
188 185
189 disable_irq_nosync(ci->irq); 186 ci_otg_queue_work(ci);
190 queue_work(ci->wq, &ci->work);
191 mutex_unlock(&ci->fsm.lock); 187 mutex_unlock(&ci->fsm.lock);
192 188
193 return count; 189 return count;
@@ -307,8 +303,7 @@ static void set_tmout_and_fsm(void *ptr, unsigned long indicator)
307 303
308 set_tmout(ci, indicator); 304 set_tmout(ci, indicator);
309 305
310 disable_irq_nosync(ci->irq); 306 ci_otg_queue_work(ci);
311 queue_work(ci->wq, &ci->work);
312} 307}
313 308
314static void a_wait_vfall_tmout_func(void *ptr, unsigned long indicator) 309static void a_wait_vfall_tmout_func(void *ptr, unsigned long indicator)
@@ -323,8 +318,7 @@ static void a_wait_vfall_tmout_func(void *ptr, unsigned long indicator)
323 hw_write_otgsc(ci, OTGSC_DPIS, OTGSC_DPIS); 318 hw_write_otgsc(ci, OTGSC_DPIS, OTGSC_DPIS);
324 /* Enable data pulse irq */ 319 /* Enable data pulse irq */
325 hw_write_otgsc(ci, OTGSC_DPIE, OTGSC_DPIE); 320 hw_write_otgsc(ci, OTGSC_DPIE, OTGSC_DPIE);
326 disable_irq_nosync(ci->irq); 321 ci_otg_queue_work(ci);
327 queue_work(ci->wq, &ci->work);
328} 322}
329 323
330static void b_ase0_brst_tmout_func(void *ptr, unsigned long indicator) 324static void b_ase0_brst_tmout_func(void *ptr, unsigned long indicator)
@@ -335,8 +329,7 @@ static void b_ase0_brst_tmout_func(void *ptr, unsigned long indicator)
335 if (!hw_read_otgsc(ci, OTGSC_BSV)) 329 if (!hw_read_otgsc(ci, OTGSC_BSV))
336 ci->fsm.b_sess_vld = 0; 330 ci->fsm.b_sess_vld = 0;
337 331
338 disable_irq_nosync(ci->irq); 332 ci_otg_queue_work(ci);
339 queue_work(ci->wq, &ci->work);
340} 333}
341 334
342static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator) 335static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
@@ -346,10 +339,8 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
346 set_tmout(ci, indicator); 339 set_tmout(ci, indicator);
347 340
348 /* only vbus fall below B_sess_vld in b_idle state */ 341 /* only vbus fall below B_sess_vld in b_idle state */
349 if (ci->transceiver->state == OTG_STATE_B_IDLE) { 342 if (ci->transceiver->state == OTG_STATE_B_IDLE)
350 disable_irq_nosync(ci->irq); 343 ci_otg_queue_work(ci);
351 queue_work(ci->wq, &ci->work);
352 }
353} 344}
354 345
355static void b_sess_vld_tmout_func(void *ptr, unsigned long indicator) 346static void b_sess_vld_tmout_func(void *ptr, unsigned long indicator)
@@ -360,8 +351,7 @@ static void b_sess_vld_tmout_func(void *ptr, unsigned long indicator)
360 if (!(hw_read_otgsc(ci, OTGSC_BSV))) { 351 if (!(hw_read_otgsc(ci, OTGSC_BSV))) {
361 ci->fsm.b_sess_vld = 0; 352 ci->fsm.b_sess_vld = 0;
362 ci_otg_add_timer(ci, B_SSEND_SRP); 353 ci_otg_add_timer(ci, B_SSEND_SRP);
363 disable_irq_nosync(ci->irq); 354 ci_otg_queue_work(ci);
364 queue_work(ci->wq, &ci->work);
365 } 355 }
366} 356}
367 357
@@ -376,8 +366,7 @@ static void b_data_pulse_end(void *ptr, unsigned long indicator)
376 366
377 hw_write_otgsc(ci, OTGSC_HABA, 0); 367 hw_write_otgsc(ci, OTGSC_HABA, 0);
378 368
379 disable_irq_nosync(ci->irq); 369 ci_otg_queue_work(ci);
380 queue_work(ci->wq, &ci->work);
381} 370}
382 371
383/* Initialize timers */ 372/* Initialize timers */
@@ -627,10 +616,8 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
627 * a_idle to a_wait_vrise when power up 616 * a_idle to a_wait_vrise when power up
628 */ 617 */
629 if ((ci->fsm.id) || (ci->id_event) || 618 if ((ci->fsm.id) || (ci->id_event) ||
630 (ci->fsm.power_up)) { 619 (ci->fsm.power_up))
631 disable_irq_nosync(ci->irq); 620 ci_otg_queue_work(ci);
632 queue_work(ci->wq, &ci->work);
633 }
634 if (ci->id_event) 621 if (ci->id_event)
635 ci->id_event = false; 622 ci->id_event = false;
636 } else if (ci->transceiver->state == OTG_STATE_B_IDLE) { 623 } else if (ci->transceiver->state == OTG_STATE_B_IDLE) {
@@ -640,8 +627,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
640 * Further transite to b_periphearl 627 * Further transite to b_periphearl
641 * when register gadget driver with vbus on 628 * when register gadget driver with vbus on
642 */ 629 */
643 disable_irq_nosync(ci->irq); 630 ci_otg_queue_work(ci);
644 queue_work(ci->wq, &ci->work);
645 } 631 }
646 } 632 }
647 } 633 }
@@ -667,22 +653,19 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
667 if (port_conn) { 653 if (port_conn) {
668 fsm->b_conn = 1; 654 fsm->b_conn = 1;
669 fsm->a_bus_req = 1; 655 fsm->a_bus_req = 1;
670 disable_irq_nosync(ci->irq); 656 ci_otg_queue_work(ci);
671 queue_work(ci->wq, &ci->work);
672 } 657 }
673 break; 658 break;
674 case OTG_STATE_B_IDLE: 659 case OTG_STATE_B_IDLE:
675 if (otg_bsess_vld && (intr_sts & USBi_PCI) && port_conn) { 660 if (otg_bsess_vld && (intr_sts & USBi_PCI) && port_conn) {
676 fsm->b_sess_vld = 1; 661 fsm->b_sess_vld = 1;
677 disable_irq_nosync(ci->irq); 662 ci_otg_queue_work(ci);
678 queue_work(ci->wq, &ci->work);
679 } 663 }
680 break; 664 break;
681 case OTG_STATE_B_PERIPHERAL: 665 case OTG_STATE_B_PERIPHERAL:
682 if ((intr_sts & USBi_SLI) && port_conn && otg_bsess_vld) { 666 if ((intr_sts & USBi_SLI) && port_conn && otg_bsess_vld) {
683 fsm->a_bus_suspend = 1; 667 fsm->a_bus_suspend = 1;
684 disable_irq_nosync(ci->irq); 668 ci_otg_queue_work(ci);
685 queue_work(ci->wq, &ci->work);
686 } else if (intr_sts & USBi_PCI) { 669 } else if (intr_sts & USBi_PCI) {
687 if (fsm->a_bus_suspend == 1) 670 if (fsm->a_bus_suspend == 1)
688 fsm->a_bus_suspend = 0; 671 fsm->a_bus_suspend = 0;
@@ -692,8 +675,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
692 if ((intr_sts & USBi_PCI) && !port_conn) { 675 if ((intr_sts & USBi_PCI) && !port_conn) {
693 fsm->a_conn = 0; 676 fsm->a_conn = 0;
694 fsm->b_bus_req = 0; 677 fsm->b_bus_req = 0;
695 disable_irq_nosync(ci->irq); 678 ci_otg_queue_work(ci);
696 queue_work(ci->wq, &ci->work);
697 ci_otg_add_timer(ci, B_SESS_VLD); 679 ci_otg_add_timer(ci, B_SESS_VLD);
698 } 680 }
699 break; 681 break;
@@ -727,22 +709,19 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
727 /* A device to be peripheral mode */ 709 /* A device to be peripheral mode */
728 ci->gadget.is_a_peripheral = 1; 710 ci->gadget.is_a_peripheral = 1;
729 } 711 }
730 disable_irq_nosync(ci->irq); 712 ci_otg_queue_work(ci);
731 queue_work(ci->wq, &ci->work);
732 } 713 }
733 break; 714 break;
734 case OTG_STATE_A_HOST: 715 case OTG_STATE_A_HOST:
735 if ((intr_sts & USBi_PCI) && !port_conn) { 716 if ((intr_sts & USBi_PCI) && !port_conn) {
736 fsm->b_conn = 0; 717 fsm->b_conn = 0;
737 disable_irq_nosync(ci->irq); 718 ci_otg_queue_work(ci);
738 queue_work(ci->wq, &ci->work);
739 } 719 }
740 break; 720 break;
741 case OTG_STATE_B_WAIT_ACON: 721 case OTG_STATE_B_WAIT_ACON:
742 if ((intr_sts & USBi_PCI) && port_conn) { 722 if ((intr_sts & USBi_PCI) && port_conn) {
743 fsm->a_conn = 1; 723 fsm->a_conn = 1;
744 disable_irq_nosync(ci->irq); 724 ci_otg_queue_work(ci);
745 queue_work(ci->wq, &ci->work);
746 } 725 }
747 break; 726 break;
748 default: 727 default:
@@ -804,8 +783,7 @@ irqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci)
804 fsm->b_conn = 0; 783 fsm->b_conn = 0;
805 } 784 }
806 } 785 }
807 disable_irq_nosync(ci->irq); 786 ci_otg_queue_work(ci);
808 queue_work(ci->wq, &ci->work);
809 return IRQ_HANDLED; 787 return IRQ_HANDLED;
810 } 788 }
811 789
@@ -816,8 +794,7 @@ irqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci)
816 794
817void ci_hdrc_otg_fsm_start(struct ci_hdrc *ci) 795void ci_hdrc_otg_fsm_start(struct ci_hdrc *ci)
818{ 796{
819 disable_irq_nosync(ci->irq); 797 ci_otg_queue_work(ci);
820 queue_work(ci->wq, &ci->work);
821} 798}
822 799
823int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci) 800int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)