patch-2.3.27 linux/drivers/scsi/scsi.c

Next file: linux/drivers/scsi/scsi.h
Previous file: linux/drivers/scsi/qlogicpti.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.26/linux/drivers/scsi/scsi.c linux/drivers/scsi/scsi.c
@@ -70,6 +70,14 @@
 
 #undef USE_STATIC_SCSI_MEMORY
 
+struct proc_dir_entry *proc_scsi = NULL;
+
+#ifdef CONFIG_PROC_FS
+static int scsi_proc_info(char *buffer, char **start, off_t offset,
+			  int length, int inout);
+static void scsi_dump_status(int level);
+#endif
+
 /*
    static const char RCSid[] = "$Header: /vger/u4/cvs/linux/drivers/scsi/scsi.c,v 1.38 1997/01/19 23:07:18 davem Exp $";
  */
@@ -141,21 +149,6 @@
 
 volatile struct Scsi_Host *host_active = NULL;
 
-#if CONFIG_PROC_FS
-/* 
- * This is the pointer to the /proc/scsi code.
- * It is only initialized to !=0 if the scsi code is present
- */
-struct proc_dir_entry proc_scsi_scsi =
-{
-	PROC_SCSI_SCSI, 4, "scsi",
-	S_IFREG | S_IRUGO | S_IWUSR, 1, 0, 0, 0,
-	NULL,
-	NULL, NULL,
-	NULL, NULL, NULL
-};
-#endif
-
 
 const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE] =
 {
@@ -194,20 +187,12 @@
 extern void scsi_old_done(Scsi_Cmnd * SCpnt);
 extern void scsi_old_times_out(Scsi_Cmnd * SCpnt);
 
-#if CONFIG_PROC_FS
-extern int (*dispatch_scsi_info_ptr) (int ino, char *buffer, char **start,
-				    off_t offset, int length, int inout);
-extern int dispatch_scsi_info(int ino, char *buffer, char **start,
-			      off_t offset, int length, int inout);
-#endif
-
 #define SCSI_BLOCK(DEVICE, HOST)                                                \
                 ((HOST->block && host_active && HOST != host_active)            \
 		  || ((HOST)->can_queue && HOST->host_busy >= HOST->can_queue)    \
                   || ((HOST)->host_blocked)                                       \
                   || ((DEVICE) != NULL && (DEVICE)->device_blocked) )
 
-static void scsi_dump_status(int level);
 
 
 struct dev_info {
@@ -1997,18 +1982,23 @@
 #endif
 
 	/* Yes we're here... */
-#if CONFIG_PROC_FS
-	dispatch_scsi_info_ptr = dispatch_scsi_info;
+
+	/*
+	 * This makes /proc/scsi and /proc/scsi/scsi visible.
+	 */
+#ifdef CONFIG_PROC_FS
+	proc_scsi = create_proc_entry ("scsi", S_IFDIR, 0);
+	if (!proc_scsi) {
+		printk (KERN_ERR "cannot init /proc/scsi\n");
+		return -ENOMEM;
+	}
+	
+	create_proc_info_entry ("scsi/scsi", 0, 0, scsi_proc_info);
 #endif
 
 	/* Init a few things so we can "malloc" memory. */
 	scsi_loadable_module_flag = 0;
 
-	/* Register the /proc/scsi/scsi entry */
-#if CONFIG_PROC_FS
-	proc_scsi_register(0, &proc_scsi_scsi);
-#endif
-
 	/* initialize all hosts */
 	scsi_init();
 
@@ -2114,8 +2104,8 @@
 
 
 #ifdef CONFIG_PROC_FS
-int scsi_proc_info(char *buffer, char **start, off_t offset, int length,
-		   int hostno, int inout)
+static int scsi_proc_info(char *buffer, char **start, off_t offset,
+			  int length, int inout)
 {
 	Scsi_Cmnd *SCpnt;
 	struct Scsi_Device_Template *SDTpnt;
@@ -2191,7 +2181,7 @@
 	 * where token is one of [error,scan,mlqueue,mlcomplete,llqueue,
 	 * llcomplete,hlqueue,hlcomplete]
 	 */
-#if CONFIG_SCSI_LOGGING		/* { */
+#ifdef CONFIG_SCSI_LOGGING		/* { */
 
 	if (!strncmp("log", buffer + 5, 3)) {
 		char *token;
@@ -2627,7 +2617,7 @@
 		scsi_hosts = tpnt;
 
 		/* Add the new driver to /proc/scsi */
-#if CONFIG_PROC_FS
+#ifdef CONFIG_PROC_FS
 		build_proc_dir_entries(tpnt);
 #endif
 
@@ -2893,33 +2883,28 @@
 
 	for (shpnt = scsi_hostlist; shpnt; shpnt = sh1) {
 		sh1 = shpnt->next;
-		if (shpnt->hostt == tpnt) {
-			if (shpnt->loaded_as_module) {
-				pcount = next_scsi_host;
-				/* Remove the /proc/scsi directory entry */
-#if CONFIG_PROC_FS
-				proc_scsi_unregister(tpnt->proc_dir,
-					shpnt->host_no + PROC_SCSI_FILE);
-#endif
-				if (tpnt->release)
-					(*tpnt->release) (shpnt);
-				else {
-					/* This is the default case for the release function.
-					 * It should do the right thing for most correctly
-					 * written host adapters.
-					 */
-					if (shpnt->irq)
-						free_irq(shpnt->irq, NULL);
-					if (shpnt->dma_channel != 0xff)
-						free_dma(shpnt->dma_channel);
-					if (shpnt->io_port && shpnt->n_io_port)
-						release_region(shpnt->io_port, shpnt->n_io_port);
-				}
-				if (pcount == next_scsi_host)
-					scsi_unregister(shpnt);
-				tpnt->present--;
-			}
-		}
+		if (shpnt->hostt != tpnt || !shpnt->loaded_as_module)
+			continue;
+		pcount = next_scsi_host;
+		/* Remove the /proc/scsi directory entry */
+		remove_proc_entry(shpnt->proc_name, tpnt->proc_dir);
+		if (tpnt->release)
+			(*tpnt->release) (shpnt);
+		else {
+			/* This is the default case for the release function.
+			 * It should do the right thing for most correctly
+			 * written host adapters.
+			 */
+			if (shpnt->irq)
+			free_irq(shpnt->irq, NULL);
+			if (shpnt->dma_channel != 0xff)
+				free_dma(shpnt->dma_channel);
+			if (shpnt->io_port && shpnt->n_io_port)
+				release_region(shpnt->io_port, shpnt->n_io_port);
+		}
+		if (pcount == next_scsi_host)
+			scsi_unregister(shpnt);
+		tpnt->present--;
 	}
 
 	/*
@@ -2959,9 +2944,7 @@
 			break;
 		}
 	/* Rebuild the /proc/scsi directory entries */
-#if CONFIG_PROC_FS
-	proc_scsi_unregister(tpnt->proc_dir, tpnt->proc_dir->low_ino);
-#endif
+	remove_proc_entry(tpnt->proc_name, proc_scsi);
 	MOD_DEC_USE_COUNT;
 }
 
@@ -3146,6 +3129,7 @@
 
 #endif				/* CONFIG_MODULES */
 
+#ifdef CONFIG_PROC_FS
 /*
  * Function:    scsi_dump_status
  *
@@ -3166,8 +3150,7 @@
  */
 static void scsi_dump_status(int level)
 {
-#if CONFIG_PROC_FS
-#if CONFIG_SCSI_LOGGING		/* { */
+#ifdef CONFIG_SCSI_LOGGING		/* { */
 	int i;
 	struct Scsi_Host *shpnt;
 	Scsi_Cmnd *SCpnt;
@@ -3246,8 +3229,8 @@
 	}
 	/* printk("wait_for_request = %p\n", &wait_for_request); */
 #endif	/* CONFIG_SCSI_LOGGING */ /* } */
-#endif				/* CONFIG_PROC_FS */
 }
+#endif				/* CONFIG_PROC_FS */
 
 #ifdef MODULE
 
@@ -3257,19 +3240,19 @@
 	int has_space = 0;
 
 	/*
-	 * This makes /proc/scsi visible.
+	 * This makes /proc/scsi and /proc/scsi/scsi visible.
 	 */
-#if CONFIG_PROC_FS
-	dispatch_scsi_info_ptr = dispatch_scsi_info;
+#ifdef CONFIG_PROC_FS
+	proc_scsi = create_proc_entry ("scsi", S_IFDIR, 0);
+	if (!proc_scsi) {
+		printk (KERN_ERR "cannot init /proc/scsi\n");
+		return -ENOMEM;
+	}
+	create_proc_info_entry ("scsi/scsi", 0, 0, scsi_proc_info);
 #endif
 
 	scsi_loadable_module_flag = 1;
 
-	/* Register the /proc/scsi/scsi entry */
-#if CONFIG_PROC_FS
-	proc_scsi_register(0, &proc_scsi_scsi);
-#endif
-
 	dma_sectors = PAGE_SIZE / SECTOR_SIZE;
 	scsi_dma_free_sectors = dma_sectors;
 	/*
@@ -3316,13 +3299,12 @@
 {
 	remove_bh(SCSI_BH);
 
-#if CONFIG_PROC_FS
-	proc_scsi_unregister(0, PROC_SCSI_SCSI);
-
+#ifdef CONFIG_PROC_FS
 	/* No, we're not here anymore. Don't show the /proc/scsi files. */
-	dispatch_scsi_info_ptr = 0L;
+	remove_proc_entry ("scsi/scsi", 0);
+	remove_proc_entry ("scsi", 0);
 #endif
-
+	
 	/*
 	 * Free up the DMA pool.
 	 */

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