file.c (b7d3622a39fde7658170b7f3cf6c6889bb8db30d) | file.c (f8868ed0078a8456ac725103a97cbe6d833e13f3) |
---|---|
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) --- 5 unchanged lines hidden (view full) --- 14 * (C) Copyright Greg Kroah-Hartman 2002-2003 15 * 16 */ 17 18#include <linux/module.h> 19#include <linux/errno.h> 20#include <linux/rwsem.h> 21#include <linux/slab.h> | 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) --- 5 unchanged lines hidden (view full) --- 14 * (C) Copyright Greg Kroah-Hartman 2002-2003 15 * 16 */ 17 18#include <linux/module.h> 19#include <linux/errno.h> 20#include <linux/rwsem.h> 21#include <linux/slab.h> |
22#include <linux/string.h> |
|
22#include <linux/usb.h> 23 24#include "usb.h" 25 26#define MAX_USB_MINORS 256 27static const struct file_operations *usb_minors[MAX_USB_MINORS]; 28static DECLARE_RWSEM(minor_rwsem); 29 --- 120 unchanged lines hidden (view full) --- 150 */ 151int usb_register_dev(struct usb_interface *intf, 152 struct usb_class_driver *class_driver) 153{ 154 int retval; 155 int minor_base = class_driver->minor_base; 156 int minor; 157 char name[20]; | 23#include <linux/usb.h> 24 25#include "usb.h" 26 27#define MAX_USB_MINORS 256 28static const struct file_operations *usb_minors[MAX_USB_MINORS]; 29static DECLARE_RWSEM(minor_rwsem); 30 --- 120 unchanged lines hidden (view full) --- 151 */ 152int usb_register_dev(struct usb_interface *intf, 153 struct usb_class_driver *class_driver) 154{ 155 int retval; 156 int minor_base = class_driver->minor_base; 157 int minor; 158 char name[20]; |
158 char *temp; | |
159 160#ifdef CONFIG_USB_DYNAMIC_MINORS 161 /* 162 * We don't care what the device tries to start at, we want to start 163 * at zero to pack the devices into the smallest available space with 164 * no holes in the minor range. 165 */ 166 minor_base = 0; --- 20 unchanged lines hidden (view full) --- 187 break; 188 } 189 up_write(&minor_rwsem); 190 if (intf->minor < 0) 191 return -EXFULL; 192 193 /* create a usb class device for this usb interface */ 194 snprintf(name, sizeof(name), class_driver->name, minor - minor_base); | 159 160#ifdef CONFIG_USB_DYNAMIC_MINORS 161 /* 162 * We don't care what the device tries to start at, we want to start 163 * at zero to pack the devices into the smallest available space with 164 * no holes in the minor range. 165 */ 166 minor_base = 0; --- 20 unchanged lines hidden (view full) --- 187 break; 188 } 189 up_write(&minor_rwsem); 190 if (intf->minor < 0) 191 return -EXFULL; 192 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, 201 MKDEV(USB_MAJOR, minor), class_driver, | 195 intf->usb_dev = device_create(usb_class->class, &intf->dev, 196 MKDEV(USB_MAJOR, minor), class_driver, |
202 "%s", temp); | 197 "%s", kbasename(name)); |
203 if (IS_ERR(intf->usb_dev)) { 204 down_write(&minor_rwsem); 205 usb_minors[minor] = NULL; 206 intf->minor = -1; 207 up_write(&minor_rwsem); 208 retval = PTR_ERR(intf->usb_dev); 209 } 210 return retval; --- 35 unchanged lines hidden --- | 198 if (IS_ERR(intf->usb_dev)) { 199 down_write(&minor_rwsem); 200 usb_minors[minor] = NULL; 201 intf->minor = -1; 202 up_write(&minor_rwsem); 203 retval = PTR_ERR(intf->usb_dev); 204 } 205 return retval; --- 35 unchanged lines hidden --- |