From 36a674f30279fd2c1726ccad1fd1af715844c309 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 20 Apr 2003 00:39:44 -0700 Subject: [PATCH] [PATCH] devfs: usb --- drivers/usb/class/usblp.c | 7 ++----- drivers/usb/core/file.c | 7 ++----- drivers/usb/image/scanner.c | 7 +++---- drivers/usb/image/scanner.h | 2 -- drivers/usb/input/hiddev.c | 10 ++++------ drivers/usb/misc/auerswald.c | 5 ++--- drivers/usb/misc/brlvger.c | 10 ++-------- drivers/usb/misc/rio500.c | 7 ++----- drivers/usb/usb-skeleton.c | 5 ++--- 9 files changed, 19 insertions(+), 41 deletions(-) diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 5e04d7aebca13..4ecbf9ac41309 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -130,7 +130,6 @@ MFG:HEWLETT-PACKARD;MDL:DESKJET 970C;CMD:MLC,PCL,PML;CLASS:PRINTER;DESCRIPTION:H struct usblp { struct usb_device *dev; /* USB device */ - devfs_handle_t devfs; /* devfs device */ struct semaphore sem; /* locks this struct, especially "dev" */ char *writebuf; /* write transfer_buffer */ char *readbuf; /* read transfer_buffer */ @@ -163,7 +162,6 @@ static void usblp_dump(struct usblp *usblp) { dbg("usblp=0x%p", usblp); dbg("dev=0x%p", usblp->dev); - dbg("devfs=0x%p", usblp->devfs); dbg("buf=0x%p", usblp->buf); dbg("readcount=%d", usblp->readcount); dbg("ifnum=%d", usblp->ifnum); @@ -382,7 +380,7 @@ out: static void usblp_cleanup (struct usblp *usblp) { - devfs_unregister (usblp->devfs); + devfs_remove ("usb/lp%d", usblp->minor); usb_deregister_dev (1, usblp->minor); info("usblp%d: removed", usblp->minor); @@ -908,8 +906,7 @@ static int usblp_probe(struct usb_interface *intf, /* If we have devfs, create with perms=660. */ sprintf(name, "usb/lp%d", usblp->minor); - usblp->devfs = devfs_register(NULL, name, - DEVFS_FL_DEFAULT, USB_MAJOR, + devfs_register(NULL, name, 0, USB_MAJOR, usblp->minor, S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, &usblp_fops, NULL); diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 6550ecc36b536..070811df5b3bc 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c @@ -28,8 +28,6 @@ #endif #include -static devfs_handle_t usb_devfs_handle; /* /dev/usb dir. */ - #define MAX_USB_MINORS 256 static struct file_operations *usb_minors[MAX_USB_MINORS]; static spinlock_t minor_lock = SPIN_LOCK_UNLOCKED; @@ -75,14 +73,13 @@ int usb_major_init(void) return -EBUSY; } - usb_devfs_handle = devfs_mk_dir("usb"); - + devfs_mk_dir("usb"); return 0; } void usb_major_cleanup(void) { - devfs_unregister(usb_devfs_handle); + devfs_remove("usb"); unregister_chrdev(USB_MAJOR, "usb"); } diff --git a/drivers/usb/image/scanner.c b/drivers/usb/image/scanner.c index 1f8b64fbc4a42..d9363d46008ed 100644 --- a/drivers/usb/image/scanner.c +++ b/drivers/usb/image/scanner.c @@ -397,6 +397,7 @@ */ +#include #include /* @@ -843,7 +844,7 @@ static void destroy_scanner (struct kobject *kobj) kfree(scn->obuf); dbg("%s: De-allocating minor:%d", __FUNCTION__, scn->scn_minor); - devfs_unregister(scn->devfs); + devfs_remove("usb/scanner%d", scn->scn_minor - SCN_BASE_MNR); usb_deregister_dev(1, scn->scn_minor); usb_free_urb(scn->scn_irq); usb_put_dev(scn->scn_dev); @@ -1105,13 +1106,11 @@ probe_scanner(struct usb_interface *intf, sprintf(name, "usb/scanner%d", scn->scn_minor - SCN_BASE_MNR); - scn->devfs = devfs_register(NULL, name, + devfs_register(NULL, name, DEVFS_FL_DEFAULT, USB_MAJOR, scn->scn_minor, S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, &usb_scanner_fops, NULL); - if (scn->devfs == NULL) - dbg("scanner%d: device node registration failed", scn_minor); info ("USB scanner device (0x%04x/0x%04x) now attached to %s", dev->descriptor.idVendor, dev->descriptor.idProduct, name); diff --git a/drivers/usb/image/scanner.h b/drivers/usb/image/scanner.h index 0a3d271ccaed4..193fb2cd13f68 100644 --- a/drivers/usb/image/scanner.h +++ b/drivers/usb/image/scanner.h @@ -40,7 +40,6 @@ #include #include #include -#include // #define DEBUG @@ -336,7 +335,6 @@ static DECLARE_MUTEX (scn_mutex); /* Initializes to unlocked */ struct scn_usb_data { struct usb_device *scn_dev; - devfs_handle_t devfs; /* devfs device */ struct urb *scn_irq; unsigned int ifnum; /* Interface number of the USB device */ int scn_minor; /* Scanner minor - used in disconnect() */ diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index df85aec9e288a..3952399fb214e 100644 --- a/drivers/usb/input/hiddev.c +++ b/drivers/usb/input/hiddev.c @@ -50,7 +50,6 @@ struct hiddev { int open; int minor; wait_queue_head_t wait; - devfs_handle_t devfs; struct hid_device *hid; struct hiddev_list *list; }; @@ -66,7 +65,6 @@ struct hiddev_list { }; static struct hiddev *hiddev_table[HIDDEV_MINORS]; -static devfs_handle_t hiddev_devfs_handle; /* forward reference to make our lives easier */ extern struct usb_driver hiddev_driver; @@ -229,7 +227,7 @@ static int hiddev_fasync(int fd, struct file *file, int on) */ static void hiddev_cleanup(struct hiddev *hiddev) { - devfs_unregister(hiddev->devfs); + devfs_remove("usb/hid/hiddev%d", hiddev->minor); usb_deregister_dev(1, hiddev->minor); hiddev_table[hiddev->minor] = NULL; kfree(hiddev); @@ -716,8 +714,8 @@ int hiddev_connect(struct hid_device *hid) hiddev->exist = 1; sprintf(devfs_name, "usb/hid/hiddev%d", minor); - hiddev->devfs = devfs_register(NULL, devfs_name, - DEVFS_FL_DEFAULT, USB_MAJOR, minor + HIDDEV_MINOR_BASE, + devfs_register(NULL, devfs_name, 0, + USB_MAJOR, minor + HIDDEV_MINOR_BASE, S_IFCHR | S_IRUGO | S_IWUSR, &hiddev_fops, NULL); hid->minor = minor; hid->hiddev = hiddev; @@ -774,7 +772,7 @@ static /* const */ struct usb_driver hiddev_driver = { int __init hiddev_init(void) { - hiddev_devfs_handle = devfs_mk_dir("usb/hid"); + devfs_mk_dir("usb/hid"); usb_register(&hiddev_driver); return 0; } diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index ec56082f4548f..553206cd23904 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c @@ -242,7 +242,6 @@ typedef struct struct semaphore mutex; /* protection in user context */ 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 */ int open_count; /* count the number of open character channels */ char dev_desc[AUSI_DLEN];/* for storing a textual description */ @@ -1972,7 +1971,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(NULL, cp->name, 0, USB_MAJOR, + devfs_register(NULL, cp->name, 0, USB_MAJOR, AUER_MINOR_BASE + dtindex, S_IFCHR | S_IRUGO | S_IWUGO, &auerswald_fops, NULL); @@ -2092,7 +2091,7 @@ static void auerswald_disconnect (struct usb_interface *intf) /* remove our devfs node */ /* Nobody can see this device any more */ - devfs_unregister (cp->devfs); + devfs_remove(cp->name); /* give back our USB minor number */ usb_deregister_dev (1, cp->dtindex); diff --git a/drivers/usb/misc/brlvger.c b/drivers/usb/misc/brlvger.c index e22ce8220ed88..60d773a4eb846 100644 --- a/drivers/usb/misc/brlvger.c +++ b/drivers/usb/misc/brlvger.c @@ -156,7 +156,6 @@ struct brlvger_priv { struct usb_device *dev; /* USB device handle */ struct usb_endpoint_descriptor *in_interrupt; struct urb *intr_urb; - devfs_handle_t devfs; int subminor; /* which minor dev #? */ @@ -374,16 +373,11 @@ brlvger_probe (struct usb_interface *intf, dbg("Display length: %d", priv->plength); sprintf(devfs_name, "usb/brlvger%d", priv->subminor); - priv->devfs = devfs_register(NULL, devfs_name, + devfs_register(NULL, devfs_name, DEVFS_FL_DEFAULT, USB_MAJOR, BRLVGER_MINOR+priv->subminor, S_IFCHR |S_IRUSR|S_IWUSR |S_IRGRP|S_IWGRP, &brlvger_fops, NULL); - if (!priv->devfs) { -#ifdef CONFIG_DEVFS_FS - err("devfs node registration failed"); -#endif - } display_table[i] = priv; @@ -420,7 +414,7 @@ brlvger_disconnect(struct usb_interface *intf) if(priv){ info("Display %d disconnecting", priv->subminor); - devfs_unregister(priv->devfs); + devfs_remove("usb/brlvger%d", priv->subminor); usb_deregister_dev(1, priv->subminor); down(&disconnect_sem); diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 8b6a2f80a5bf3..7fee0d437fa5e 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c @@ -65,7 +65,6 @@ struct rio_usb_data { struct usb_device *rio_dev; /* init: probe_rio */ - devfs_handle_t devfs; /* devfs device */ unsigned int ifnum; /* Interface number of the USB device */ int isopen; /* nz if open */ int present; /* Device is present on the bus */ @@ -476,13 +475,11 @@ static int probe_rio(struct usb_interface *intf, } dbg("probe_rio: ibuf address:%p", rio->ibuf); - rio->devfs = devfs_register(NULL, "usb/rio500", + devfs_register(NULL, "usb/rio500", DEVFS_FL_DEFAULT, USB_MAJOR, RIO_MINOR, S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, &usb_rio_fops, NULL); - if (rio->devfs == NULL) - dbg("probe_rio: device node registration failed"); init_MUTEX(&(rio->lock)); @@ -496,7 +493,7 @@ static void disconnect_rio(struct usb_interface *intf) usb_set_intfdata (intf, NULL); if (rio) { - devfs_unregister(rio->devfs); + devfs_remove("usb/rio500"); usb_deregister_dev(1, rio->minor); down(&(rio->lock)); diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 0c833fdeee42c..906c619d575cc 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -98,7 +98,6 @@ MODULE_DEVICE_TABLE (usb, skel_table); struct usb_skel { struct usb_device * udev; /* save off the usb device pointer */ struct usb_interface * interface; /* the interface for this device */ - devfs_handle_t devfs; /* devfs device node */ unsigned char minor; /* the starting minor number for this device */ unsigned char num_ports; /* the number of ports this device has */ char num_interrupt_in; /* number of interrupt in endpoints we have */ @@ -610,7 +609,7 @@ 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, "usb/skel%d", dev->minor); - dev->devfs = devfs_register(NULL, name, + devfs = devfs_register(NULL, name, DEVFS_FL_DEFAULT, USB_MAJOR, dev->minor, S_IFCHR | S_IRUSR | S_IWUSR | @@ -674,7 +673,7 @@ static void skel_disconnect(struct usb_interface *interface) minor = dev->minor; /* remove our devfs node */ - devfs_unregister (dev->devfs); + devfs_remove("usb/skel%d", dev->minor); /* give back our dynamic minor */ usb_deregister_dev (1, minor); -- 2.53.0