aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/hcd.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-20 19:00:33 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-20 19:00:33 -0400
commit1d345dac1f30af1cd9f3a1faa12f9f18f17f236e (patch)
tree42a7deda7589edf704fe60dc262046755bd3f6a8 /drivers/usb/core/hcd.c
parentfb395884576684ebb54b19b1054f4caed589d5f0 (diff)
parent87c8a4433b608261a9becdb0ce2d2f2ed4b71d05 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
Diffstat (limited to 'drivers/usb/core/hcd.c')
-rw-r--r--drivers/usb/core/hcd.c61
1 files changed, 27 insertions, 34 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 266e9e06a9f5..d041782e0c8b 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -651,50 +651,45 @@ static int usb_rh_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
651/*-------------------------------------------------------------------------*/ 651/*-------------------------------------------------------------------------*/
652 652
653/* exported only within usbcore */ 653/* exported only within usbcore */
654struct usb_bus *usb_bus_get (struct usb_bus *bus) 654struct usb_bus *usb_bus_get(struct usb_bus *bus)
655{ 655{
656 struct class_device *tmp; 656 if (bus)
657 kref_get(&bus->kref);
658 return bus;
659}
657 660
658 if (!bus) 661static void usb_host_release(struct kref *kref)
659 return NULL; 662{
663 struct usb_bus *bus = container_of(kref, struct usb_bus, kref);
660 664
661 tmp = class_device_get(&bus->class_dev); 665 if (bus->release)
662 if (tmp) 666 bus->release(bus);
663 return to_usb_bus(tmp);
664 else
665 return NULL;
666} 667}
667 668
668/* exported only within usbcore */ 669/* exported only within usbcore */
669void usb_bus_put (struct usb_bus *bus) 670void usb_bus_put(struct usb_bus *bus)
670{ 671{
671 if (bus) 672 if (bus)
672 class_device_put(&bus->class_dev); 673 kref_put(&bus->kref, usb_host_release);
673} 674}
674 675
675/*-------------------------------------------------------------------------*/ 676/*-------------------------------------------------------------------------*/
676 677
677static void usb_host_release(struct class_device *class_dev) 678static struct class *usb_host_class;
678{
679 struct usb_bus *bus = to_usb_bus(class_dev);
680
681 if (bus->release)
682 bus->release(bus);
683}
684
685static struct class usb_host_class = {
686 .name = "usb_host",
687 .release = &usb_host_release,
688};
689 679
690int usb_host_init(void) 680int usb_host_init(void)
691{ 681{
692 return class_register(&usb_host_class); 682 int retval = 0;
683
684 usb_host_class = class_create(THIS_MODULE, "usb_host");
685 if (IS_ERR(usb_host_class))
686 retval = PTR_ERR(usb_host_class);
687 return retval;
693} 688}
694 689
695void usb_host_cleanup(void) 690void usb_host_cleanup(void)
696{ 691{
697 class_unregister(&usb_host_class); 692 class_destroy(usb_host_class);
698} 693}
699 694
700/** 695/**
@@ -719,8 +714,7 @@ static void usb_bus_init (struct usb_bus *bus)
719 714
720 INIT_LIST_HEAD (&bus->bus_list); 715 INIT_LIST_HEAD (&bus->bus_list);
721 716
722 class_device_initialize(&bus->class_dev); 717 kref_init(&bus->kref);
723 bus->class_dev.class = &usb_host_class;
724} 718}
725 719
726/** 720/**
@@ -761,7 +755,6 @@ struct usb_bus *usb_alloc_bus (struct usb_operations *op)
761static int usb_register_bus(struct usb_bus *bus) 755static int usb_register_bus(struct usb_bus *bus)
762{ 756{
763 int busnum; 757 int busnum;
764 int retval;
765 758
766 down (&usb_bus_list_lock); 759 down (&usb_bus_list_lock);
767 busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1); 760 busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1);
@@ -774,15 +767,15 @@ static int usb_register_bus(struct usb_bus *bus)
774 return -E2BIG; 767 return -E2BIG;
775 } 768 }
776 769
777 snprintf(bus->class_dev.class_id, BUS_ID_SIZE, "usb%d", busnum); 770 bus->class_dev = class_device_create(usb_host_class, MKDEV(0,0), bus->controller, "usb%d", busnum);
778 bus->class_dev.dev = bus->controller; 771 if (IS_ERR(bus->class_dev)) {
779 retval = class_device_add(&bus->class_dev);
780 if (retval) {
781 clear_bit(busnum, busmap.busmap); 772 clear_bit(busnum, busmap.busmap);
782 up(&usb_bus_list_lock); 773 up(&usb_bus_list_lock);
783 return retval; 774 return PTR_ERR(bus->class_dev);
784 } 775 }
785 776
777 class_set_devdata(bus->class_dev, bus);
778
786 /* Add it to the local list of buses */ 779 /* Add it to the local list of buses */
787 list_add (&bus->bus_list, &usb_bus_list); 780 list_add (&bus->bus_list, &usb_bus_list);
788 up (&usb_bus_list_lock); 781 up (&usb_bus_list_lock);
@@ -820,7 +813,7 @@ static void usb_deregister_bus (struct usb_bus *bus)
820 813
821 clear_bit (bus->busnum, busmap.busmap); 814 clear_bit (bus->busnum, busmap.busmap);
822 815
823 class_device_del(&bus->class_dev); 816 class_device_unregister(bus->class_dev);
824} 817}
825 818
826/** 819/**