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

[PATCH] USB HCDs: no longer need to register root hub

This patch changes the host controller drivers; they no longer need to
register their root hubs because usbcore will take care of it for them.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
247f3105 8ec8d20b

+4 -135
+2 -22
drivers/usb/gadget/dummy_hcd.c
··· 1625 1625 static int dummy_start (struct usb_hcd *hcd) 1626 1626 { 1627 1627 struct dummy *dum; 1628 - struct usb_device *root; 1629 1628 int retval; 1630 1629 1631 1630 dum = hcd_to_dummy (hcd); ··· 1641 1642 1642 1643 INIT_LIST_HEAD (&dum->urbp_list); 1643 1644 1644 - root = usb_alloc_dev (NULL, &hcd->self, 0); 1645 - if (!root) 1646 - return -ENOMEM; 1645 + if ((retval = dummy_register_udc (dum)) != 0) 1646 + return retval; 1647 1647 1648 1648 /* only show a low-power port: just 8mA */ 1649 1649 hcd->power_budget = 8; 1650 - 1651 - /* root hub enters addressed state... */ 1652 1650 hcd->state = HC_STATE_RUNNING; 1653 - root->speed = USB_SPEED_HIGH; 1654 - 1655 - /* ...then configured, so khubd sees us. */ 1656 - if ((retval = usb_hcd_register_root_hub (root, hcd)) != 0) { 1657 - goto err1; 1658 - } 1659 - 1660 - if ((retval = dummy_register_udc (dum)) != 0) 1661 - goto err2; 1662 1651 1663 1652 /* FIXME 'urbs' should be a per-device thing, maybe in usbcore */ 1664 1653 device_create_file (dummy_dev(dum), &dev_attr_urbs); 1665 1654 return 0; 1666 - 1667 - err2: 1668 - usb_disconnect (&hcd->self.root_hub); 1669 - err1: 1670 - usb_put_dev (root); 1671 - hcd->state = HC_STATE_QUIESCING; 1672 - return retval; 1673 1655 } 1674 1656 1675 1657 static void dummy_stop (struct usb_hcd *hcd)
-31
drivers/usb/host/ehci-hcd.c
··· 492 492 { 493 493 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 494 494 u32 temp; 495 - struct usb_device *udev; 496 - struct usb_bus *bus; 497 495 int retval; 498 496 u32 hcc_params; 499 497 u8 sbrn = 0; ··· 629 631 630 632 /* set async sleep time = 10 us ... ? */ 631 633 632 - /* wire up the root hub */ 633 - bus = hcd_to_bus (hcd); 634 - udev = first ? usb_alloc_dev (NULL, bus, 0) : bus->root_hub; 635 - if (!udev) { 636 - done2: 637 - ehci_mem_cleanup (ehci); 638 - return -ENOMEM; 639 - } 640 - udev->speed = USB_SPEED_HIGH; 641 - udev->state = first ? USB_STATE_ATTACHED : USB_STATE_CONFIGURED; 642 - 643 634 /* 644 635 * Start, enabling full USB 2.0 functionality ... usb 1.1 devices 645 636 * are explicitly handed to companion controller(s), so no TT is ··· 650 663 ((sbrn & 0xf0)>>4), (sbrn & 0x0f), 651 664 first ? "initialized" : "restarted", 652 665 temp >> 8, temp & 0xff, DRIVER_VERSION); 653 - 654 - /* 655 - * From here on, khubd concurrently accesses the root 656 - * hub; drivers will be talking to enumerated devices. 657 - * (On restart paths, khubd already knows about the root 658 - * hub and could find work as soon as we wrote FLAG_CF.) 659 - * 660 - * Before this point the HC was idle/ready. After, khubd 661 - * and device drivers may start it running. 662 - */ 663 - if (first && usb_hcd_register_root_hub (udev, hcd) != 0) { 664 - if (hcd->state == HC_STATE_RUNNING) 665 - ehci_quiesce (ehci); 666 - ehci_reset (ehci); 667 - usb_put_dev (udev); 668 - retval = -ENODEV; 669 - goto done2; 670 - } 671 666 672 667 writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */ 673 668
-16
drivers/usb/host/isp116x-hcd.c
··· 1547 1547 { 1548 1548 struct isp116x *isp116x = hcd_to_isp116x(hcd); 1549 1549 struct isp116x_platform_data *board = isp116x->board; 1550 - struct usb_device *udev; 1551 1550 u32 val; 1552 1551 unsigned long flags; 1553 1552 ··· 1608 1609 isp116x->rhstatus = isp116x_read_reg32(isp116x, HCRHSTATUS); 1609 1610 1610 1611 isp116x_write_reg32(isp116x, HCFMINTVL, 0x27782edf); 1611 - spin_unlock_irqrestore(&isp116x->lock, flags); 1612 1612 1613 - udev = usb_alloc_dev(NULL, &hcd->self, 0); 1614 - if (!udev) { 1615 - isp116x_stop(hcd); 1616 - return -ENOMEM; 1617 - } 1618 - 1619 - udev->speed = USB_SPEED_FULL; 1620 1613 hcd->state = HC_STATE_RUNNING; 1621 1614 1622 - if (usb_hcd_register_root_hub(udev, hcd) != 0) { 1623 - isp116x_stop(hcd); 1624 - usb_put_dev(udev); 1625 - return -ENODEV; 1626 - } 1627 - 1628 - spin_lock_irqsave(&isp116x->lock, flags); 1629 1615 /* Set up interrupts */ 1630 1616 isp116x->intenb = HCINT_MIE | HCINT_RHSC | HCINT_UE; 1631 1617 if (board->remote_wakeup_enable)
+2 -28
drivers/usb/host/ohci-hcd.c
··· 505 505 /* Start an OHCI controller, set the BUS operational 506 506 * resets USB and controller 507 507 * enable interrupts 508 - * connect the virtual root hub 509 508 */ 510 509 static int ohci_run (struct ohci_hcd *ohci) 511 510 { 512 511 u32 mask, temp; 513 - struct usb_device *udev; 514 - struct usb_bus *bus; 515 512 int first = ohci->fminterval == 0; 516 513 517 514 disable (ohci); ··· 669 672 670 673 // POTPGT delay is bits 24-31, in 2 ms units. 671 674 mdelay ((temp >> 23) & 0x1fe); 672 - bus = &ohci_to_hcd(ohci)->self; 673 675 ohci_to_hcd(ohci)->state = HC_STATE_RUNNING; 674 676 675 677 ohci_dump (ohci, 1); 676 678 677 - udev = bus->root_hub; 678 - if (udev) { 679 - return 0; 680 - } 681 - 682 - /* connect the virtual root hub */ 683 - udev = usb_alloc_dev (NULL, bus, 0); 684 - if (!udev) { 685 - disable (ohci); 686 - ohci->hc_control &= ~OHCI_CTRL_HCFS; 687 - ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); 688 - return -ENOMEM; 689 - } 679 + if (ohci_to_hcd(ohci)->self.root_hub == NULL) 680 + create_debug_files (ohci); 690 681 691 - udev->speed = USB_SPEED_FULL; 692 - if (usb_hcd_register_root_hub (udev, ohci_to_hcd(ohci)) != 0) { 693 - usb_put_dev (udev); 694 - disable (ohci); 695 - ohci->hc_control &= ~OHCI_CTRL_HCFS; 696 - ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); 697 - return -ENODEV; 698 - } 699 - 700 - register_reboot_notifier (&ohci->reboot_notifier); 701 - create_debug_files (ohci); 702 682 return 0; 703 683 } 704 684
-13
drivers/usb/host/sl811-hcd.c
··· 1563 1563 sl811h_start(struct usb_hcd *hcd) 1564 1564 { 1565 1565 struct sl811 *sl811 = hcd_to_sl811(hcd); 1566 - struct usb_device *udev; 1567 1566 1568 1567 /* chip has been reset, VBUS power is off */ 1569 - 1570 - udev = usb_alloc_dev(NULL, &hcd->self, 0); 1571 - if (!udev) 1572 - return -ENOMEM; 1573 - 1574 - udev->speed = USB_SPEED_FULL; 1575 1568 hcd->state = HC_STATE_RUNNING; 1576 1569 1577 1570 if (sl811->board) { 1578 1571 hcd->can_wakeup = sl811->board->can_wakeup; 1579 1572 hcd->power_budget = sl811->board->power * 2; 1580 - } 1581 - 1582 - if (usb_hcd_register_root_hub(udev, hcd) != 0) { 1583 - usb_put_dev(udev); 1584 - sl811h_stop(hcd); 1585 - return -ENODEV; 1586 1573 } 1587 1574 1588 1575 /* enable power and interupts */
-25
drivers/usb/host/uhci-hcd.c
··· 562 562 int retval = -EBUSY; 563 563 int i; 564 564 dma_addr_t dma_handle; 565 - struct usb_device *udev; 566 565 struct dentry *dentry; 567 566 568 567 hcd->uses_new_polling = 1; ··· 623 624 if (!uhci->qh_pool) { 624 625 dev_err(uhci_dev(uhci), "unable to create qh dma_pool\n"); 625 626 goto err_create_qh_pool; 626 - } 627 - 628 - /* Initialize the root hub */ 629 - 630 - udev = usb_alloc_dev(NULL, &hcd->self, 0); 631 - if (!udev) { 632 - dev_err(uhci_dev(uhci), "unable to allocate root hub\n"); 633 - goto err_alloc_root_hub; 634 627 } 635 628 636 629 uhci->term_td = uhci_alloc_td(uhci); ··· 704 713 705 714 configure_hc(uhci); 706 715 start_rh(uhci); 707 - 708 - udev->speed = USB_SPEED_FULL; 709 - 710 - if (usb_hcd_register_root_hub(udev, hcd) != 0) { 711 - dev_err(uhci_dev(uhci), "unable to start root hub\n"); 712 - retval = -ENOMEM; 713 - goto err_start_root_hub; 714 - } 715 - 716 716 return 0; 717 717 718 718 /* 719 719 * error exits: 720 720 */ 721 - err_start_root_hub: 722 - reset_hc(uhci); 723 - del_timer_sync(&uhci->stall_timer); 724 - 725 721 err_alloc_skelqh: 726 722 for (i = 0; i < UHCI_NUM_SKELQH; i++) 727 723 if (uhci->skelqh[i]) { ··· 720 742 uhci->term_td = NULL; 721 743 722 744 err_alloc_term_td: 723 - usb_put_dev(udev); 724 - 725 - err_alloc_root_hub: 726 745 dma_pool_destroy(uhci->qh_pool); 727 746 uhci->qh_pool = NULL; 728 747