file.c (a9de18eb761f7c1c860964b2e5addc1a35c7e861) file.c (f7a386c5b8ff34cd84ae922603d1c6f9d234edee)
1/*
2 * drivers/usb/core/file.c
3 *
4 * (C) Copyright Linus Torvalds 1999
5 * (C) Copyright Johannes Erdfelt 1999-2001
6 * (C) Copyright Andreas Gal 1999
7 * (C) Copyright Gregory P. Smith 1999
8 * (C) Copyright Deti Fliegl 1999 (new USB architecture)

--- 53 unchanged lines hidden (view full) ---

62 .open = usb_open,
63};
64
65static struct usb_class {
66 struct kref kref;
67 struct class *class;
68} *usb_class;
69
1/*
2 * drivers/usb/core/file.c
3 *
4 * (C) Copyright Linus Torvalds 1999
5 * (C) Copyright Johannes Erdfelt 1999-2001
6 * (C) Copyright Andreas Gal 1999
7 * (C) Copyright Gregory P. Smith 1999
8 * (C) Copyright Deti Fliegl 1999 (new USB architecture)

--- 53 unchanged lines hidden (view full) ---

62 .open = usb_open,
63};
64
65static struct usb_class {
66 struct kref kref;
67 struct class *class;
68} *usb_class;
69
70static char *usb_nodename(struct device *dev)
71{
72 struct usb_class_driver *drv;
73
74 drv = dev_get_drvdata(dev);
75 if (!drv || !drv->nodename)
76 return NULL;
77 return drv->nodename(dev);
78}
79
70static int init_usb_class(void)
71{
72 int result = 0;
73
74 if (usb_class != NULL) {
75 kref_get(&usb_class->kref);
76 goto exit;
77 }

--- 7 unchanged lines hidden (view full) ---

85 kref_init(&usb_class->kref);
86 usb_class->class = class_create(THIS_MODULE, "usb");
87 if (IS_ERR(usb_class->class)) {
88 result = IS_ERR(usb_class->class);
89 printk(KERN_ERR "class_create failed for usb devices\n");
90 kfree(usb_class);
91 usb_class = NULL;
92 }
80static int init_usb_class(void)
81{
82 int result = 0;
83
84 if (usb_class != NULL) {
85 kref_get(&usb_class->kref);
86 goto exit;
87 }

--- 7 unchanged lines hidden (view full) ---

95 kref_init(&usb_class->kref);
96 usb_class->class = class_create(THIS_MODULE, "usb");
97 if (IS_ERR(usb_class->class)) {
98 result = IS_ERR(usb_class->class);
99 printk(KERN_ERR "class_create failed for usb devices\n");
100 kfree(usb_class);
101 usb_class = NULL;
102 }
103 usb_class->class->nodename = usb_nodename;
93
94exit:
95 return result;
96}
97
98static void release_usb_class(struct kref *kref)
99{
100 /* Ok, we cheat as we know we only have one usb_class */

--- 92 unchanged lines hidden (view full) ---

193 /* create a usb class device for this usb interface */
194 snprintf(name, sizeof(name), class_driver->name, minor - minor_base);
195 temp = strrchr(name, '/');
196 if (temp && (temp[1] != '\0'))
197 ++temp;
198 else
199 temp = name;
200 intf->usb_dev = device_create(usb_class->class, &intf->dev,
104
105exit:
106 return result;
107}
108
109static void release_usb_class(struct kref *kref)
110{
111 /* Ok, we cheat as we know we only have one usb_class */

--- 92 unchanged lines hidden (view full) ---

204 /* create a usb class device for this usb interface */
205 snprintf(name, sizeof(name), class_driver->name, minor - minor_base);
206 temp = strrchr(name, '/');
207 if (temp && (temp[1] != '\0'))
208 ++temp;
209 else
210 temp = name;
211 intf->usb_dev = device_create(usb_class->class, &intf->dev,
201 MKDEV(USB_MAJOR, minor), NULL,
212 MKDEV(USB_MAJOR, minor), class_driver,
202 "%s", temp);
203 if (IS_ERR(intf->usb_dev)) {
204 down_write(&minor_rwsem);
205 usb_minors[intf->minor] = NULL;
206 up_write(&minor_rwsem);
207 retval = PTR_ERR(intf->usb_dev);
208 }
209exit:

--- 44 unchanged lines hidden ---
213 "%s", temp);
214 if (IS_ERR(intf->usb_dev)) {
215 down_write(&minor_rwsem);
216 usb_minors[intf->minor] = NULL;
217 up_write(&minor_rwsem);
218 retval = PTR_ERR(intf->usb_dev);
219 }
220exit:

--- 44 unchanged lines hidden ---