aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/core/hcd.c2
-rw-r--r--drivers/usb/core/hcd.h10
-rw-r--r--drivers/usb/core/hub.c3
-rw-r--r--drivers/usb/core/inode.c44
4 files changed, 31 insertions, 28 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index b700b6cdb683..16790ad0e2e4 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -793,7 +793,6 @@ static int usb_register_bus(struct usb_bus *bus)
793 up (&usb_bus_list_lock); 793 up (&usb_bus_list_lock);
794 794
795 usb_notify_add_bus(bus); 795 usb_notify_add_bus(bus);
796 usbfs_add_bus (bus);
797 usbmon_notify_bus_add (bus); 796 usbmon_notify_bus_add (bus);
798 797
799 dev_info (bus->controller, "new USB bus registered, assigned bus number %d\n", bus->busnum); 798 dev_info (bus->controller, "new USB bus registered, assigned bus number %d\n", bus->busnum);
@@ -823,7 +822,6 @@ static void usb_deregister_bus (struct usb_bus *bus)
823 822
824 usb_notify_remove_bus(bus); 823 usb_notify_remove_bus(bus);
825 usbmon_notify_bus_remove (bus); 824 usbmon_notify_bus_remove (bus);
826 usbfs_remove_bus (bus);
827 825
828 clear_bit (bus->busnum, busmap.busmap); 826 clear_bit (bus->busnum, busmap.busmap);
829 827
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index d8f0d29a45b7..cc33886260cd 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -400,23 +400,13 @@ static inline int hcd_bus_resume (struct usb_bus *bus)
400 * these are expected to be called from the USB core/hub thread 400 * these are expected to be called from the USB core/hub thread
401 * with the kernel lock held 401 * with the kernel lock held
402 */ 402 */
403extern void usbfs_add_bus(struct usb_bus *bus);
404extern void usbfs_remove_bus(struct usb_bus *bus);
405extern void usbfs_add_device(struct usb_device *dev);
406extern void usbfs_remove_device(struct usb_device *dev);
407extern void usbfs_update_special (void); 403extern void usbfs_update_special (void);
408
409extern int usbfs_init(void); 404extern int usbfs_init(void);
410extern void usbfs_cleanup(void); 405extern void usbfs_cleanup(void);
411 406
412#else /* CONFIG_USB_DEVICEFS */ 407#else /* CONFIG_USB_DEVICEFS */
413 408
414static inline void usbfs_add_bus(struct usb_bus *bus) {}
415static inline void usbfs_remove_bus(struct usb_bus *bus) {}
416static inline void usbfs_add_device(struct usb_device *dev) {}
417static inline void usbfs_remove_device(struct usb_device *dev) {}
418static inline void usbfs_update_special (void) {} 409static inline void usbfs_update_special (void) {}
419
420static inline int usbfs_init(void) { return 0; } 410static inline int usbfs_init(void) { return 0; }
421static inline void usbfs_cleanup(void) { } 411static inline void usbfs_cleanup(void) { }
422 412
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a9d16aff5de5..6a2ebd89916f 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1136,7 +1136,6 @@ void usb_disconnect(struct usb_device **pdev)
1136 */ 1136 */
1137 dev_dbg (&udev->dev, "unregistering device\n"); 1137 dev_dbg (&udev->dev, "unregistering device\n");
1138 release_address(udev); 1138 release_address(udev);
1139 usbfs_remove_device(udev);
1140 usb_remove_sysfs_dev_files(udev); 1139 usb_remove_sysfs_dev_files(udev);
1141 1140
1142 /* Avoid races with recursively_mark_NOTATTACHED() */ 1141 /* Avoid races with recursively_mark_NOTATTACHED() */
@@ -1374,8 +1373,6 @@ int usb_new_device(struct usb_device *udev)
1374 /* USB device state == configured ... usable */ 1373 /* USB device state == configured ... usable */
1375 usb_notify_add_device(udev); 1374 usb_notify_add_device(udev);
1376 1375
1377 /* add a /proc/bus/usb entry */
1378 usbfs_add_device(udev);
1379 return 0; 1376 return 0;
1380 1377
1381fail: 1378fail:
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index d07bba01995b..12f490fdee8f 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -39,6 +39,7 @@
39#include <linux/usbdevice_fs.h> 39#include <linux/usbdevice_fs.h>
40#include <linux/smp_lock.h> 40#include <linux/smp_lock.h>
41#include <linux/parser.h> 41#include <linux/parser.h>
42#include <linux/notifier.h>
42#include <asm/byteorder.h> 43#include <asm/byteorder.h>
43#include "usb.h" 44#include "usb.h"
44#include "hcd.h" 45#include "hcd.h"
@@ -619,7 +620,7 @@ void usbfs_update_special (void)
619 } 620 }
620} 621}
621 622
622void usbfs_add_bus(struct usb_bus *bus) 623static void usbfs_add_bus(struct usb_bus *bus)
623{ 624{
624 struct dentry *parent; 625 struct dentry *parent;
625 char name[8]; 626 char name[8];
@@ -642,12 +643,9 @@ void usbfs_add_bus(struct usb_bus *bus)
642 err ("error creating usbfs bus entry"); 643 err ("error creating usbfs bus entry");
643 return; 644 return;
644 } 645 }
645
646 usbfs_update_special();
647 usbfs_conn_disc_event();
648} 646}
649 647
650void usbfs_remove_bus(struct usb_bus *bus) 648static void usbfs_remove_bus(struct usb_bus *bus)
651{ 649{
652 if (bus->usbfs_dentry) { 650 if (bus->usbfs_dentry) {
653 fs_remove_file (bus->usbfs_dentry); 651 fs_remove_file (bus->usbfs_dentry);
@@ -659,12 +657,9 @@ void usbfs_remove_bus(struct usb_bus *bus)
659 remove_special_files(); 657 remove_special_files();
660 num_buses = 0; 658 num_buses = 0;
661 } 659 }
662
663 usbfs_update_special();
664 usbfs_conn_disc_event();
665} 660}
666 661
667void usbfs_add_device(struct usb_device *dev) 662static void usbfs_add_device(struct usb_device *dev)
668{ 663{
669 char name[8]; 664 char name[8];
670 int i; 665 int i;
@@ -690,12 +685,9 @@ void usbfs_add_device(struct usb_device *dev)
690 } 685 }
691 if (dev->usbfs_dentry->d_inode) 686 if (dev->usbfs_dentry->d_inode)
692 dev->usbfs_dentry->d_inode->i_size = i_size; 687 dev->usbfs_dentry->d_inode->i_size = i_size;
693
694 usbfs_update_special();
695 usbfs_conn_disc_event();
696} 688}
697 689
698void usbfs_remove_device(struct usb_device *dev) 690static void usbfs_remove_device(struct usb_device *dev)
699{ 691{
700 struct dev_state *ds; 692 struct dev_state *ds;
701 struct siginfo sinfo; 693 struct siginfo sinfo;
@@ -716,10 +708,33 @@ void usbfs_remove_device(struct usb_device *dev)
716 kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid); 708 kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid);
717 } 709 }
718 } 710 }
711}
712
713static int usbfs_notify(struct notifier_block *self, unsigned long action, void *dev)
714{
715 switch (action) {
716 case USB_DEVICE_ADD:
717 usbfs_add_device(dev);
718 break;
719 case USB_DEVICE_REMOVE:
720 usbfs_remove_device(dev);
721 break;
722 case USB_BUS_ADD:
723 usbfs_add_bus(dev);
724 break;
725 case USB_BUS_REMOVE:
726 usbfs_remove_bus(dev);
727 }
728
719 usbfs_update_special(); 729 usbfs_update_special();
720 usbfs_conn_disc_event(); 730 usbfs_conn_disc_event();
731 return NOTIFY_OK;
721} 732}
722 733
734static struct notifier_block usbfs_nb = {
735 .notifier_call = usbfs_notify,
736};
737
723/* --------------------------------------------------------------------- */ 738/* --------------------------------------------------------------------- */
724 739
725static struct proc_dir_entry *usbdir = NULL; 740static struct proc_dir_entry *usbdir = NULL;
@@ -732,6 +747,8 @@ int __init usbfs_init(void)
732 if (retval) 747 if (retval)
733 return retval; 748 return retval;
734 749
750 usb_register_notify(&usbfs_nb);
751
735 /* create mount point for usbfs */ 752 /* create mount point for usbfs */
736 usbdir = proc_mkdir("usb", proc_bus); 753 usbdir = proc_mkdir("usb", proc_bus);
737 754
@@ -740,6 +757,7 @@ int __init usbfs_init(void)
740 757
741void usbfs_cleanup(void) 758void usbfs_cleanup(void)
742{ 759{
760 usb_unregister_notify(&usbfs_nb);
743 unregister_filesystem(&usb_fs_type); 761 unregister_filesystem(&usb_fs_type);
744 if (usbdir) 762 if (usbdir)
745 remove_proc_entry("usb", proc_bus); 763 remove_proc_entry("usb", proc_bus);