aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2006-03-28 21:24:50 -0500
committerPaul Mackerras <paulus@samba.org>2006-03-28 21:24:50 -0500
commitbac30d1a78d0f11c613968fc8b351a91ed465386 (patch)
treee52f3c876522a2f6047a6ec1c27df2e8a79486b8 /drivers/usb/core
parente8222502ee6157e2713da9e0792c21f4ad458d50 (diff)
parentca9ba4471c1203bb6e759b76e83167fec54fe590 (diff)
Merge ../linux-2.6
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/file.c6
-rw-r--r--drivers/usb/core/notify.c65
2 files changed, 11 insertions, 60 deletions
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 37b13368c814..b263a54a13c0 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -24,15 +24,15 @@
24#include "usb.h" 24#include "usb.h"
25 25
26#define MAX_USB_MINORS 256 26#define MAX_USB_MINORS 256
27static struct file_operations *usb_minors[MAX_USB_MINORS]; 27static const struct file_operations *usb_minors[MAX_USB_MINORS];
28static DEFINE_SPINLOCK(minor_lock); 28static DEFINE_SPINLOCK(minor_lock);
29 29
30static int usb_open(struct inode * inode, struct file * file) 30static int usb_open(struct inode * inode, struct file * file)
31{ 31{
32 int minor = iminor(inode); 32 int minor = iminor(inode);
33 struct file_operations *c; 33 const struct file_operations *c;
34 int err = -ENODEV; 34 int err = -ENODEV;
35 struct file_operations *old_fops, *new_fops = NULL; 35 const struct file_operations *old_fops, *new_fops = NULL;
36 36
37 spin_lock (&minor_lock); 37 spin_lock (&minor_lock);
38 c = usb_minors[minor]; 38 c = usb_minors[minor];
diff --git a/drivers/usb/core/notify.c b/drivers/usb/core/notify.c
index 4b55285de9a0..fe0ed54fa0ae 100644
--- a/drivers/usb/core/notify.c
+++ b/drivers/usb/core/notify.c
@@ -16,57 +16,7 @@
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17#include "usb.h" 17#include "usb.h"
18 18
19 19static BLOCKING_NOTIFIER_HEAD(usb_notifier_list);
20static struct notifier_block *usb_notifier_list;
21static DEFINE_MUTEX(usb_notifier_lock);
22
23static void usb_notifier_chain_register(struct notifier_block **list,
24 struct notifier_block *n)
25{
26 mutex_lock(&usb_notifier_lock);
27 while (*list) {
28 if (n->priority > (*list)->priority)
29 break;
30 list = &((*list)->next);
31 }
32 n->next = *list;
33 *list = n;
34 mutex_unlock(&usb_notifier_lock);
35}
36
37static void usb_notifier_chain_unregister(struct notifier_block **nl,
38 struct notifier_block *n)
39{
40 mutex_lock(&usb_notifier_lock);
41 while ((*nl)!=NULL) {
42 if ((*nl)==n) {
43 *nl = n->next;
44 goto exit;
45 }
46 nl=&((*nl)->next);
47 }
48exit:
49 mutex_unlock(&usb_notifier_lock);
50}
51
52static int usb_notifier_call_chain(struct notifier_block **n,
53 unsigned long val, void *v)
54{
55 int ret=NOTIFY_DONE;
56 struct notifier_block *nb = *n;
57
58 mutex_lock(&usb_notifier_lock);
59 while (nb) {
60 ret = nb->notifier_call(nb,val,v);
61 if (ret&NOTIFY_STOP_MASK) {
62 goto exit;
63 }
64 nb = nb->next;
65 }
66exit:
67 mutex_unlock(&usb_notifier_lock);
68 return ret;
69}
70 20
71/** 21/**
72 * usb_register_notify - register a notifier callback whenever a usb change happens 22 * usb_register_notify - register a notifier callback whenever a usb change happens
@@ -76,7 +26,7 @@ exit:
76 */ 26 */
77void usb_register_notify(struct notifier_block *nb) 27void usb_register_notify(struct notifier_block *nb)
78{ 28{
79 usb_notifier_chain_register(&usb_notifier_list, nb); 29 blocking_notifier_chain_register(&usb_notifier_list, nb);
80} 30}
81EXPORT_SYMBOL_GPL(usb_register_notify); 31EXPORT_SYMBOL_GPL(usb_register_notify);
82 32
@@ -89,27 +39,28 @@ EXPORT_SYMBOL_GPL(usb_register_notify);
89 */ 39 */
90void usb_unregister_notify(struct notifier_block *nb) 40void usb_unregister_notify(struct notifier_block *nb)
91{ 41{
92 usb_notifier_chain_unregister(&usb_notifier_list, nb); 42 blocking_notifier_chain_unregister(&usb_notifier_list, nb);
93} 43}
94EXPORT_SYMBOL_GPL(usb_unregister_notify); 44EXPORT_SYMBOL_GPL(usb_unregister_notify);
95 45
96 46
97void usb_notify_add_device(struct usb_device *udev) 47void usb_notify_add_device(struct usb_device *udev)
98{ 48{
99 usb_notifier_call_chain(&usb_notifier_list, USB_DEVICE_ADD, udev); 49 blocking_notifier_call_chain(&usb_notifier_list, USB_DEVICE_ADD, udev);
100} 50}
101 51
102void usb_notify_remove_device(struct usb_device *udev) 52void usb_notify_remove_device(struct usb_device *udev)
103{ 53{
104 usb_notifier_call_chain(&usb_notifier_list, USB_DEVICE_REMOVE, udev); 54 blocking_notifier_call_chain(&usb_notifier_list,
55 USB_DEVICE_REMOVE, udev);
105} 56}
106 57
107void usb_notify_add_bus(struct usb_bus *ubus) 58void usb_notify_add_bus(struct usb_bus *ubus)
108{ 59{
109 usb_notifier_call_chain(&usb_notifier_list, USB_BUS_ADD, ubus); 60 blocking_notifier_call_chain(&usb_notifier_list, USB_BUS_ADD, ubus);
110} 61}
111 62
112void usb_notify_remove_bus(struct usb_bus *ubus) 63void usb_notify_remove_bus(struct usb_bus *ubus)
113{ 64{
114 usb_notifier_call_chain(&usb_notifier_list, USB_BUS_REMOVE, ubus); 65 blocking_notifier_call_chain(&usb_notifier_list, USB_BUS_REMOVE, ubus);
115} 66}