Commit da017c5b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Christoph Hellwig

[PATCH] fix usb_devfs_handle abuse

Many usb drivers use the usb_devfs_handle variable instead of just
adding the usb/ prefix directly to their devfs_register calls.  Fix
that and make usb_devfs_handle static and unexported.
parent 57a7fa4a
......@@ -186,8 +186,6 @@ static void usblp_dump(struct usblp *usblp) {
}
#endif
extern devfs_handle_t usb_devfs_handle; /* /dev/usb dir. */
/* Quirks: various printer quirks are handled by this table & its flags. */
struct quirk_printer_struct {
......@@ -820,7 +818,7 @@ static int usblp_probe(struct usb_interface *intf,
struct usblp *usblp = 0;
int protocol;
int retval;
char name[6];
char name[10];
/* Malloc and start initializing usblp structure so we can use it
* directly. */
......@@ -909,8 +907,8 @@ static int usblp_probe(struct usb_interface *intf,
#endif
/* If we have devfs, create with perms=660. */
sprintf(name, "lp%d", usblp->minor);
usblp->devfs = devfs_register(usb_devfs_handle, name,
sprintf(name, "usb/lp%d", usblp->minor);
usblp->devfs = devfs_register(NULL, name,
DEVFS_FL_DEFAULT, USB_MAJOR,
usblp->minor,
S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP |
......
......@@ -28,8 +28,7 @@
#endif
#include <linux/usb.h>
devfs_handle_t usb_devfs_handle; /* /dev/usb dir. */
EXPORT_SYMBOL(usb_devfs_handle);
static devfs_handle_t usb_devfs_handle; /* /dev/usb dir. */
#define MAX_USB_MINORS 256
static struct file_operations *usb_minors[MAX_USB_MINORS];
......
......@@ -878,7 +878,7 @@ probe_scanner(struct usb_interface *intf,
char valid_device = 0;
char have_bulk_in, have_bulk_out, have_intr;
char name[10];
char name[14];
dbg("probe_scanner: USB dev address:%p", dev);
......@@ -1099,9 +1099,9 @@ probe_scanner(struct usb_interface *intf,
scn->scn_minor = scn_minor;
scn->isopen = 0;
sprintf(name, "scanner%d", scn->scn_minor - SCN_BASE_MNR);
sprintf(name, "usb/scanner%d", scn->scn_minor - SCN_BASE_MNR);
scn->devfs = devfs_register(usb_devfs_handle, name,
scn->devfs = devfs_register(NULL, name,
DEVFS_FL_DEFAULT, USB_MAJOR,
scn->scn_minor,
S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP |
......
......@@ -352,6 +352,4 @@ struct scn_usb_data {
};
#define to_scanner(d) container_of(d, struct scn_usb_data, kobj)
extern devfs_handle_t usb_devfs_handle;
static struct usb_driver scanner_driver;
......@@ -72,9 +72,6 @@ do { \
#endif
/* prefix for the device descriptors in /dev/usb */
#define AU_PREFIX "auer"
/* Number of read buffers for each device */
#define AU_RBUFFERS 10
......@@ -243,7 +240,7 @@ typedef struct auerscon
typedef struct
{
struct semaphore mutex; /* protection in user context */
char name[16]; /* name of the /dev/usb entry */
char name[20]; /* name of the /dev/usb entry */
unsigned int dtindex; /* index in the device table */
devfs_handle_t devfs; /* devfs device node */
struct usb_device * usbdev; /* USB device handle */
......@@ -260,9 +257,6 @@ typedef struct
wait_queue_head_t bufferwait; /* wait for a control buffer */
} auerswald_t,*pauerswald_t;
/* the global usb devfs handle */
extern devfs_handle_t usb_devfs_handle;
/* array of pointers to our devices that are currently connected */
static pauerswald_t dev_table[AUER_MAX_DEVICES];
......@@ -1440,7 +1434,7 @@ static int auerchar_open (struct inode *inode, struct file *file)
cp->open_count++;
ccp->auerdev = cp;
dbg("open %s as /dev/usb/%s", cp->dev_desc, cp->name);
dbg("open %s as /dev/%s", cp->dev_desc, cp->name);
up (&cp->mutex);
/* file IO stuff */
......@@ -1970,7 +1964,7 @@ static int auerswald_probe (struct usb_interface *intf,
}
/* Give the device a name */
sprintf (cp->name, AU_PREFIX "%d", dtindex);
sprintf (cp->name, "usb/auer%d", dtindex);
/* Store the index */
cp->dtindex = dtindex;
......@@ -1978,8 +1972,7 @@ static int auerswald_probe (struct usb_interface *intf,
up (&dev_table_mutex);
/* initialize the devfs node for this device and register it */
cp->devfs = devfs_register (usb_devfs_handle, cp->name,
DEVFS_FL_DEFAULT, USB_MAJOR,
cp->devfs = devfs_register(NULL, cp->name, 0, USB_MAJOR,
AUER_MINOR_BASE + dtindex,
S_IFCHR | S_IRUGO | S_IWUGO,
&auerswald_fops, NULL);
......@@ -2089,7 +2082,7 @@ static void auerswald_disconnect (struct usb_interface *intf)
return;
down (&cp->mutex);
info ("device /dev/usb/%s now disconnecting", cp->name);
info ("device /dev/%s now disconnecting", cp->name);
/* remove from device table */
/* Nobody can open() this device any more */
......
......@@ -144,8 +144,6 @@ static int mycontrolmsg(const char *funcname,
#define rcvcontrolmsg(priv,a,b,c,d,e,f) \
controlmsg(priv, USB_DIR_IN, a,b,c,d,e,f)
extern devfs_handle_t usb_devfs_handle; /* /dev/usb dir. */
/* ----------------------------------------------------------------------- */
/* Data */
......@@ -294,7 +292,7 @@ brlvger_probe (struct usb_interface *intf,
/* protects against reentrance: once we've found a free slot
we reserve it.*/
static DECLARE_MUTEX(reserve_sem);
char devfs_name[16];
char devfs_name[20];
actifsettings = dev->actconfig->interface->altsetting;
......@@ -375,8 +373,8 @@ brlvger_probe (struct usb_interface *intf,
};
dbg("Display length: %d", priv->plength);
sprintf(devfs_name, "brlvger%d", priv->subminor);
priv->devfs = devfs_register(usb_devfs_handle, devfs_name,
sprintf(devfs_name, "usb/brlvger%d", priv->subminor);
priv->devfs = devfs_register(NULL, devfs_name,
DEVFS_FL_DEFAULT, USB_MAJOR,
BRLVGER_MINOR+priv->subminor,
S_IFCHR |S_IRUSR|S_IWUSR |S_IRGRP|S_IWGRP,
......
......@@ -76,8 +76,6 @@ struct rio_usb_data {
struct semaphore lock; /* general race avoidance */
};
extern devfs_handle_t usb_devfs_handle; /* /dev/usb dir. */
static struct rio_usb_data rio_instance;
static int open_rio(struct inode *inode, struct file *file)
......@@ -478,7 +476,7 @@ static int probe_rio(struct usb_interface *intf,
}
dbg("probe_rio: ibuf address:%p", rio->ibuf);
rio->devfs = devfs_register(usb_devfs_handle, "rio500",
rio->devfs = devfs_register(NULL, "usb/rio500",
DEVFS_FL_DEFAULT, USB_MAJOR,
RIO_MINOR,
S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP |
......
......@@ -107,7 +107,6 @@ struct rtl8150 {
typedef struct rtl8150 rtl8150_t;
/* the global usb devfs handle */
extern devfs_handle_t usb_devfs_handle;
unsigned long multicast_filter_limit = 32;
static void fill_skb_pool(rtl8150_t *);
......
......@@ -119,9 +119,6 @@ struct usb_skel {
};
/* the global usb devfs handle */
extern devfs_handle_t usb_devfs_handle;
/* prevent races between open() and disconnect() */
static DECLARE_MUTEX (disconnect_sem);
......@@ -514,7 +511,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
size_t buffer_size;
int i;
int retval;
char name[10];
char name[14];
/* See if the device offered us matches what we can accept */
......@@ -609,9 +606,9 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
}
/* initialize the devfs node for this device and register it */
sprintf(name, "skel%d", dev->minor);
sprintf(name, "usb/skel%d", dev->minor);
dev->devfs = devfs_register (usb_devfs_handle, name,
dev->devfs = devfs_register(NULL, name,
DEVFS_FL_DEFAULT, USB_MAJOR,
dev->minor,
S_IFCHR | S_IRUSR | S_IWUSR |
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment