Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Peter Chen and committed by
Greg Kroah-Hartman
be6b0c1b 2dbd633f

+30 -50
+2 -4
drivers/usb/chipidea/core.c
··· 425 425 ci->id_event = true; 426 426 /* Clear ID change irq status */ 427 427 hw_write_otgsc(ci, OTGSC_IDIS, OTGSC_IDIS); 428 - disable_irq_nosync(ci->irq); 429 - queue_work(ci->wq, &ci->work); 428 + ci_otg_queue_work(ci); 430 429 return IRQ_HANDLED; 431 430 } 432 431 ··· 437 438 ci->b_sess_valid_event = true; 438 439 /* Clear BSV irq */ 439 440 hw_write_otgsc(ci, OTGSC_BSVIS, OTGSC_BSVIS); 440 - disable_irq_nosync(ci->irq); 441 - queue_work(ci->wq, &ci->work); 441 + ci_otg_queue_work(ci); 442 442 return IRQ_HANDLED; 443 443 } 444 444
+5
drivers/usb/chipidea/otg.h
··· 17 17 void ci_hdrc_otg_destroy(struct ci_hdrc *ci); 18 18 enum ci_role ci_otg_role(struct ci_hdrc *ci); 19 19 void ci_handle_vbus_change(struct ci_hdrc *ci); 20 + static inline void ci_otg_queue_work(struct ci_hdrc *ci) 21 + { 22 + disable_irq_nosync(ci->irq); 23 + queue_work(ci->wq, &ci->work); 24 + } 20 25 21 26 #endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */
+23 -46
drivers/usb/chipidea/otg_fsm.c
··· 84 84 ci->fsm.a_bus_req = 1; 85 85 } 86 86 87 - disable_irq_nosync(ci->irq); 88 - queue_work(ci->wq, &ci->work); 87 + ci_otg_queue_work(ci); 89 88 mutex_unlock(&ci->fsm.lock); 90 89 91 90 return count; ··· 124 125 ci->fsm.a_bus_req = 0; 125 126 } 126 127 127 - disable_irq_nosync(ci->irq); 128 - queue_work(ci->wq, &ci->work); 128 + ci_otg_queue_work(ci); 129 129 mutex_unlock(&ci->fsm.lock); 130 130 131 131 return count; ··· 163 165 else if (buf[0] == '1') 164 166 ci->fsm.b_bus_req = 1; 165 167 166 - disable_irq_nosync(ci->irq); 167 - queue_work(ci->wq, &ci->work); 168 + ci_otg_queue_work(ci); 168 169 mutex_unlock(&ci->fsm.lock); 169 170 170 171 return count; ··· 183 186 if (buf[0] == '1') 184 187 ci->fsm.a_clr_err = 1; 185 188 186 - disable_irq_nosync(ci->irq); 187 - queue_work(ci->wq, &ci->work); 189 + ci_otg_queue_work(ci); 188 190 mutex_unlock(&ci->fsm.lock); 189 191 190 192 return count; ··· 293 297 294 298 set_tmout(ci, indicator); 295 299 296 - disable_irq_nosync(ci->irq); 297 - queue_work(ci->wq, &ci->work); 300 + ci_otg_queue_work(ci); 298 301 } 299 302 300 303 static void a_wait_vfall_tmout_func(void *ptr, unsigned long indicator) ··· 307 312 hw_write_otgsc(ci, OTGSC_DPIS, OTGSC_DPIS); 308 313 /* Enable data pulse irq */ 309 314 hw_write_otgsc(ci, OTGSC_DPIE, OTGSC_DPIE); 310 - disable_irq_nosync(ci->irq); 311 - queue_work(ci->wq, &ci->work); 315 + ci_otg_queue_work(ci); 312 316 } 313 317 314 318 static void b_ase0_brst_tmout_func(void *ptr, unsigned long indicator) ··· 318 324 if (!hw_read_otgsc(ci, OTGSC_BSV)) 319 325 ci->fsm.b_sess_vld = 0; 320 326 321 - disable_irq_nosync(ci->irq); 322 - queue_work(ci->wq, &ci->work); 327 + ci_otg_queue_work(ci); 323 328 } 324 329 325 330 static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator) ··· 328 335 set_tmout(ci, indicator); 329 336 330 337 /* only vbus fall below B_sess_vld in b_idle state */ 331 - if (ci->transceiver->state == OTG_STATE_B_IDLE) { 332 - disable_irq_nosync(ci->irq); 333 - queue_work(ci->wq, &ci->work); 334 - } 338 + if (ci->transceiver->state == OTG_STATE_B_IDLE) 339 + ci_otg_queue_work(ci); 335 340 } 336 341 337 342 static void b_sess_vld_tmout_func(void *ptr, unsigned long indicator) ··· 340 349 if (!(hw_read_otgsc(ci, OTGSC_BSV))) { 341 350 ci->fsm.b_sess_vld = 0; 342 351 ci_otg_add_timer(ci, B_SSEND_SRP); 343 - disable_irq_nosync(ci->irq); 344 - queue_work(ci->wq, &ci->work); 352 + ci_otg_queue_work(ci); 345 353 } 346 354 } 347 355 ··· 355 365 356 366 hw_write_otgsc(ci, OTGSC_HABA, 0); 357 367 358 - disable_irq_nosync(ci->irq); 359 - queue_work(ci->wq, &ci->work); 368 + ci_otg_queue_work(ci); 360 369 } 361 370 362 371 /* Initialize timers */ ··· 596 607 * a_idle to a_wait_vrise when power up 597 608 */ 598 609 if ((ci->fsm.id) || (ci->id_event) || 599 - (ci->fsm.power_up)) { 600 - disable_irq_nosync(ci->irq); 601 - queue_work(ci->wq, &ci->work); 602 - } 610 + (ci->fsm.power_up)) 611 + ci_otg_queue_work(ci); 603 612 if (ci->id_event) 604 613 ci->id_event = false; 605 614 } else if (ci->transceiver->state == OTG_STATE_B_IDLE) { ··· 607 620 * Further transite to b_periphearl state 608 621 * when register gadget driver with vbus on 609 622 */ 610 - disable_irq_nosync(ci->irq); 611 - queue_work(ci->wq, &ci->work); 623 + ci_otg_queue_work(ci); 612 624 } 613 625 } 614 626 } ··· 632 646 if (port_conn) { 633 647 fsm->b_conn = 1; 634 648 fsm->a_bus_req = 1; 635 - disable_irq_nosync(ci->irq); 636 - queue_work(ci->wq, &ci->work); 649 + ci_otg_queue_work(ci); 637 650 } 638 651 break; 639 652 case OTG_STATE_B_IDLE: 640 653 if (otg_bsess_vld && (intr_sts & USBi_PCI) && port_conn) { 641 654 fsm->b_sess_vld = 1; 642 - disable_irq_nosync(ci->irq); 643 - queue_work(ci->wq, &ci->work); 655 + ci_otg_queue_work(ci); 644 656 } 645 657 break; 646 658 case OTG_STATE_B_PERIPHERAL: 647 659 if ((intr_sts & USBi_SLI) && port_conn && otg_bsess_vld) { 648 660 fsm->a_bus_suspend = 1; 649 - disable_irq_nosync(ci->irq); 650 - queue_work(ci->wq, &ci->work); 661 + ci_otg_queue_work(ci); 651 662 } else if (intr_sts & USBi_PCI) { 652 663 if (fsm->a_bus_suspend == 1) 653 664 fsm->a_bus_suspend = 0; ··· 654 671 if ((intr_sts & USBi_PCI) && !port_conn) { 655 672 fsm->a_conn = 0; 656 673 fsm->b_bus_req = 0; 657 - disable_irq_nosync(ci->irq); 658 - queue_work(ci->wq, &ci->work); 674 + ci_otg_queue_work(ci); 659 675 ci_otg_add_timer(ci, B_SESS_VLD); 660 676 } 661 677 break; ··· 688 706 /* A device to be peripheral mode */ 689 707 ci->gadget.is_a_peripheral = 1; 690 708 } 691 - disable_irq_nosync(ci->irq); 692 - queue_work(ci->wq, &ci->work); 709 + ci_otg_queue_work(ci); 693 710 } 694 711 break; 695 712 case OTG_STATE_A_HOST: 696 713 if ((intr_sts & USBi_PCI) && !port_conn) { 697 714 fsm->b_conn = 0; 698 - disable_irq_nosync(ci->irq); 699 - queue_work(ci->wq, &ci->work); 715 + ci_otg_queue_work(ci); 700 716 } 701 717 break; 702 718 case OTG_STATE_B_WAIT_ACON: 703 719 if ((intr_sts & USBi_PCI) && port_conn) { 704 720 fsm->a_conn = 1; 705 - disable_irq_nosync(ci->irq); 706 - queue_work(ci->wq, &ci->work); 721 + ci_otg_queue_work(ci); 707 722 } 708 723 break; 709 724 default: ··· 761 782 fsm->b_conn = 0; 762 783 } 763 784 } 764 - disable_irq_nosync(ci->irq); 765 - queue_work(ci->wq, &ci->work); 785 + ci_otg_queue_work(ci); 766 786 return IRQ_HANDLED; 767 787 } 768 788 ··· 772 794 773 795 void ci_hdrc_otg_fsm_start(struct ci_hdrc *ci) 774 796 { 775 - disable_irq_nosync(ci->irq); 776 - queue_work(ci->wq, &ci->work); 797 + ci_otg_queue_work(ci); 777 798 } 778 799 779 800 int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)