patch-2.3.37 linux/drivers/net/pcmcia/ray_cs.c

Next file: linux/drivers/net/pcmcia/tulip_cb.c
Previous file: linux/drivers/macintosh/via-pmu.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.36/linux/drivers/net/pcmcia/ray_cs.c linux/drivers/net/pcmcia/ray_cs.c
@@ -2529,13 +2529,23 @@
  * eg ifconfig 
  */
     int i;
-    dev_link_t *link = dev_list;
-    struct net_device *dev = (struct net_device *)link->priv;
-    ray_dev_t *local = (ray_dev_t *)dev->priv;
+    dev_link_t *link;
+    struct net_device *dev;
+    ray_dev_t *local;
     UCHAR *p;
     struct freq_hop_element *pfh;
     UCHAR c[33];
 
+    link = dev_list;
+    if (!link)
+    	return 0;
+    dev = (struct net_device *)link->priv;
+    if (!dev)
+    	return 0;
+    local = (ray_dev_t *)dev->priv;
+    if (!local)
+    	return 0;
+
     len = 0;
 
     len += sprintf(buf + len, "Raylink Wireless LAN driver status\n");
@@ -2663,7 +2673,59 @@
     }
     return 0;
 } /* End build_auth_frame */
+
 /*===========================================================================*/
+
+static void raycs_write(const char *name, write_proc_t *w, void *data)
+{
+	struct proc_dir_entry * entry = create_proc_entry(name, S_IFREG | S_IWUSR, NULL);
+	if (entry) {
+		entry->write_proc = w;
+		entry->data = data;
+	}
+}
+
+static int write_essid(struct file *file, const char *buffer, unsigned long count, void *data)
+{
+	static char proc_essid[33];
+	int len = count;
+
+	if (len > 32)
+		len = 32;
+	memset(proc_essid, 0, 33);
+	if (copy_from_user(proc_essid, buffer, len))
+		return -EFAULT;
+	essid = proc_essid;
+	return count;
+}
+
+static int write_int(struct file *file, const char *buffer, unsigned long count, void *data)
+{
+	static char proc_number[10];
+	char *p;
+	int nr, len;
+
+	if (!count)
+		return 0;
+
+	if (count > 9)
+		return -EINVAL;
+	if (copy_from_user(proc_number, buffer, count))
+		return -EFAULT;
+	p = proc_number;
+	nr = 0;
+	len = count;
+	do {
+		unsigned int c = *p - '0';
+		if (c > 9)
+			return -EINVAL;
+		nr = nr*10 + c;
+		p++;
+	} while (--len);
+	*(int *)data = nr;
+	return count;
+}
+
 static int __init init_ray_cs(void)
 {
     int rc;
@@ -2671,41 +2733,35 @@
     DEBUG(1, "%s\n", rcsid);
     rc = register_pcmcia_driver(&dev_info, &ray_attach, &ray_detach);
     DEBUG(1, "raylink init_module register_pcmcia_driver returns 0x%x\n",rc);
-#ifdef CONFIG_PROC_FS    
-    /* [proc-namespace][fixme] It shouldn't be under root, damnit! */
-    create_proc_info_entry("ray_cs", 0, &proc_root, ray_cs_proc_read);
-#endif    
+
+    proc_mkdir("driver/ray_cs", 0);
+
+    create_proc_info_entry("driver/ray_cs/ray_cs", 0, NULL, ray_cs_proc_read);
+    raycs_write("driver/ray_cs/essid", write_essid, NULL);
+    raycs_write("driver/ray_cs/net_type", write_int, &net_type);
+    raycs_write("driver/ray_cs/translate", write_int, &translate);
     if (translate != 0) translate = 1;
     return 0;
 } /* init_ray_cs */
 
-#ifndef MODULE
-
-static char init_ess_id[ESSID_SIZE];
-static int __init essid_setup(char *str)
-{
-	strncpy(init_ess_id, str, ESSID_SIZE);
-	essid = init_ess_id;
-	return 1;
-}
-__setup("essid=", essid_setup);
-
-#endif
-
 /*===========================================================================*/
 
 static void __exit exit_ray_cs(void)
 {
     DEBUG(0, "ray_cs: cleanup_module\n");
 
+
+    remove_proc_entry("ray_cs", proc_root_driver);
     unregister_pcmcia_driver(&dev_info);
     while (dev_list != NULL) {
         if (dev_list->state & DEV_CONFIG) ray_release((u_long)dev_list);
         ray_detach(dev_list);
     }
-#ifdef CONFIG_PROC_FS    
-    remove_proc_entry("ray_cs", &proc_root);
-#endif   
+    remove_proc_entry("driver/ray_cs/ray_cs", NULL);
+    remove_proc_entry("driver/ray_cs/essid", NULL);
+    remove_proc_entry("driver/ray_cs/net_type", NULL);
+    remove_proc_entry("driver/ray_cs/translate", NULL);
+    remove_proc_entry("driver/ray_cs", NULL);
 } /* exit_ray_cs */
 
 module_init(init_ray_cs);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)