This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / usb / gadget / rndis.c
index c3d064b..1cd445a 100644 (file)
@@ -70,6 +70,8 @@ MODULE_PARM_DESC (rndis_debug, "enable debugging");
 
 #define RNDIS_MAX_CONFIGS      1
 
+static struct proc_dir_entry *rndis_connect_dir;
+static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS];
 
 static rndis_params rndis_per_dev_params [RNDIS_MAX_CONFIGS];
 
@@ -121,7 +123,7 @@ static int gen_ndis_query_resp (int configNr, u32 OID, rndis_resp_t *r)
                DEBUG("%s: OID_GEN_HARDWARE_STATUS\n", __FUNCTION__);
                length = 4;
                /* Bogus question! 
-                * Hardware must be ready to receive high level protocols.
+                * Hardware must be ready to recieve high level protocols.
                 * BTW: 
                 * reddite ergo quae sunt Caesaris Caesari
                 * et quae sunt Dei Deo!
@@ -1273,9 +1275,7 @@ int rndis_rm_hdr (u8 *buf, u32 *length)
        return 0;
 }
 
-#ifdef CONFIG_USB_GADGET_DEBUG_FILES
-
-static int rndis_proc_read (char *page, char **start, off_t off, int count, int *eof, 
+int rndis_proc_read (char *page, char **start, off_t off, int count, int *eof, 
                     void *data)
 {
        char *out = page;
@@ -1320,7 +1320,7 @@ static int rndis_proc_read (char *page, char **start, off_t off, int count, int
        return len;
 }
 
-static int rndis_proc_write (struct file *file, const char __user *buffer, 
+int rndis_proc_write (struct file *file, const char __user *buffer, 
                      unsigned long count, void *data)
 {
        rndis_params *p = data;
@@ -1365,40 +1365,43 @@ static int rndis_proc_write (struct file *file, const char __user *buffer,
        return count;
 }
 
-#define        NAME_TEMPLATE   "driver/rndis-%03d"
-
-static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS];
-
-#endif /* CONFIG_USB_GADGET_DEBUG_FILES */
-
-
 int __init rndis_init (void)
 {
        u8 i;
+       char name [4];
 
+       /* FIXME this should probably be /proc/driver/rndis,
+        * and only if debugging is enabled
+        */
+       
+       if (!(rndis_connect_dir =  proc_mkdir ("rndis", NULL))) {
+               printk (KERN_ERR "%s: couldn't create /proc/rndis entry", 
+                       __FUNCTION__);
+               return -EIO;
+       }
+       
        for (i = 0; i < RNDIS_MAX_CONFIGS; i++) {
-#ifdef CONFIG_USB_GADGET_DEBUG_FILES
-               char name [20];
-
-               sprintf (name, NAME_TEMPLATE, i);
+               sprintf (name, "%03d", i);
                if (!(rndis_connect_state [i]
-                               = create_proc_entry (name, 0660, NULL))) 
+                               = create_proc_entry (name, 0660,
+                                               rndis_connect_dir))) 
                {
                        DEBUG ("%s :remove entries", __FUNCTION__);
-                       while (i) {
-                               sprintf (name, NAME_TEMPLATE, --i);
-                               remove_proc_entry (name, NULL);
+                       for (i--; i > 0; i--) {
+                               sprintf (name, "%03d", i);
+                               remove_proc_entry (name, rndis_connect_dir);
                        }
                        DEBUG ("\n");
+                       
+                       remove_proc_entry ("000", rndis_connect_dir);
+                       remove_proc_entry ("rndis", NULL);
                        return -EIO;
                }
-
                rndis_connect_state [i]->nlink = 1;
                rndis_connect_state [i]->write_proc = rndis_proc_write;
                rndis_connect_state [i]->read_proc = rndis_proc_read;
                rndis_connect_state [i]->data = (void *)
                                (rndis_per_dev_params + i);
-#endif
                rndis_per_dev_params [i].confignr = i;
                rndis_per_dev_params [i].used = 0;
                rndis_per_dev_params [i].state = RNDIS_UNINITIALIZED;
@@ -1412,14 +1415,14 @@ int __init rndis_init (void)
 
 void rndis_exit (void)
 {
-#ifdef CONFIG_USB_GADGET_DEBUG_FILES
        u8 i;
-       char name [20];
+       char name [4];
        
        for (i = 0; i < RNDIS_MAX_CONFIGS; i++) {
-               sprintf (name, NAME_TEMPLATE, i);
-               remove_proc_entry (name, NULL);
+               sprintf (name, "%03d", i);
+               remove_proc_entry (name, rndis_connect_dir);
        }
-#endif
+       remove_proc_entry ("rndis", NULL);
+       return;
 }