public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] don't create /proc/scsi/ entries for drivers without ->proc_info
@ 2003-06-03 20:19 Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2003-06-03 20:19 UTC (permalink / raw)
  To: James.Bottomley; +Cc: linux-scsi

Current code just puts the driver name into it which is utterly useless


diff -Nru a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
--- a/drivers/scsi/scsi_proc.c	Tue May 27 14:52:15 2003
+++ b/drivers/scsi/scsi_proc.c	Tue May 27 14:52:15 2003
@@ -42,48 +42,15 @@
 EXPORT_SYMBOL(proc_scsi);
 
 
-/* Used if the driver currently has no own support for /proc/scsi */
-static int generic_proc_info(char *buffer, char **start, off_t offset,
-			     int count, const char *(*info)(struct Scsi_Host *),
-			     struct Scsi_Host *shost)
-{
-	int len, pos, begin = 0;
-	static const char noprocfs[] =
-		"The driver does not yet support the proc-fs\n";
-
-	if (info && shost)
-		len = sprintf(buffer, "%s\n", info(shost));
-	else
-		len = sprintf(buffer, "%s\n", noprocfs);
-
-	pos = len;
-	if (pos < offset) {
-		len = 0;
-		begin = pos;
-	}
-
-	*start = buffer + (offset - begin);
-	len -= (offset - begin);
-	if (len > count)
-		len = count;
-
-	return len;
-}
-
 static int proc_scsi_read(char *buffer, char **start, off_t offset,
 			  int length, int *eof, void *data)
 {
 	struct Scsi_Host *shost = data;
 	int n;
 
-	if (shost->hostt->proc_info == NULL)
-		n = generic_proc_info(buffer, start, offset, length,
-				      shost->hostt->info, shost);
-	else
-		n = shost->hostt->proc_info(shost, buffer, start, offset,
-					   length, 0);
-
+	n = shost->hostt->proc_info(shost, buffer, start, offset, length, 0);
 	*eof = (n < length);
+
 	return n;
 }
 
@@ -95,8 +62,6 @@
 	char *page;
 	char *start;
     
-	if (!shost->hostt->proc_info)
-		return -ENOSYS;
 	if (count > PROC_BLOCK_SIZE)
 		return -EOVERFLOW;
 
@@ -118,6 +83,9 @@
 	struct proc_dir_entry *p;
 	char name[10];
 
+	if (!sht->proc_info)
+		return;
+
 	if (!sht->proc_dir) {
 		sht->proc_dir = proc_mkdir(sht->proc_name, proc_scsi);
         	if (!sht->proc_dir) {
@@ -130,27 +98,29 @@
 
 	sprintf(name,"%d", shost->host_no);
 	p = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
-			shost->hostt->proc_dir, proc_scsi_read, shost);
+			sht->proc_dir, proc_scsi_read, shost);
 	if (!p) {
 		printk(KERN_ERR "%s: Failed to register host %d in"
 		       "%s\n", __FUNCTION__, shost->host_no,
-		       shost->hostt->proc_name);
+		       sht->proc_name);
 		return;
 	} 
 
 	p->write_proc = proc_scsi_write_proc;
 	p->owner = shost->hostt->module;
-
 }
 
 void scsi_proc_host_rm(struct Scsi_Host *shost)
 {
+	Scsi_Host_Template *sht = shost->hostt;
 	char name[10];
 
-	sprintf(name,"%d", shost->host_no);
-	remove_proc_entry(name, shost->hostt->proc_dir);
-	if (!shost->hostt->present)
-		remove_proc_entry(shost->hostt->proc_name, proc_scsi);
+	if (sht->proc_info) {
+		sprintf(name,"%d", shost->host_no);
+		remove_proc_entry(name, sht->proc_dir);
+		if (!sht->present)
+			remove_proc_entry(sht->proc_name, proc_scsi);
+	}
 }
 
 static int proc_print_scsidevice(struct device *dev, void *data)

^ permalink raw reply	[flat|nested] 2+ messages in thread
* [PATCH] don't create /proc/scsi/ entries for drivers without ->proc_info
@ 2003-05-28 10:44 Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2003-05-28 10:44 UTC (permalink / raw)
  To: James.Bottomley; +Cc: linux-scsi

Current code just puts the driver name into it which is utterly useless


diff -Nru a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
--- a/drivers/scsi/scsi_proc.c	Tue May 27 14:52:15 2003
+++ b/drivers/scsi/scsi_proc.c	Tue May 27 14:52:15 2003
@@ -42,48 +42,15 @@
 EXPORT_SYMBOL(proc_scsi);
 
 
-/* Used if the driver currently has no own support for /proc/scsi */
-static int generic_proc_info(char *buffer, char **start, off_t offset,
-			     int count, const char *(*info)(struct Scsi_Host *),
-			     struct Scsi_Host *shost)
-{
-	int len, pos, begin = 0;
-	static const char noprocfs[] =
-		"The driver does not yet support the proc-fs\n";
-
-	if (info && shost)
-		len = sprintf(buffer, "%s\n", info(shost));
-	else
-		len = sprintf(buffer, "%s\n", noprocfs);
-
-	pos = len;
-	if (pos < offset) {
-		len = 0;
-		begin = pos;
-	}
-
-	*start = buffer + (offset - begin);
-	len -= (offset - begin);
-	if (len > count)
-		len = count;
-
-	return len;
-}
-
 static int proc_scsi_read(char *buffer, char **start, off_t offset,
 			  int length, int *eof, void *data)
 {
 	struct Scsi_Host *shost = data;
 	int n;
 
-	if (shost->hostt->proc_info == NULL)
-		n = generic_proc_info(buffer, start, offset, length,
-				      shost->hostt->info, shost);
-	else
-		n = shost->hostt->proc_info(shost, buffer, start, offset,
-					   length, 0);
-
+	n = shost->hostt->proc_info(shost, buffer, start, offset, length, 0);
 	*eof = (n < length);
+
 	return n;
 }
 
@@ -95,8 +62,6 @@
 	char *page;
 	char *start;
     
-	if (!shost->hostt->proc_info)
-		return -ENOSYS;
 	if (count > PROC_BLOCK_SIZE)
 		return -EOVERFLOW;
 
@@ -118,6 +83,9 @@
 	struct proc_dir_entry *p;
 	char name[10];
 
+	if (!sht->proc_info)
+		return;
+
 	if (!sht->proc_dir) {
 		sht->proc_dir = proc_mkdir(sht->proc_name, proc_scsi);
         	if (!sht->proc_dir) {
@@ -130,27 +98,29 @@
 
 	sprintf(name,"%d", shost->host_no);
 	p = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
-			shost->hostt->proc_dir, proc_scsi_read, shost);
+			sht->proc_dir, proc_scsi_read, shost);
 	if (!p) {
 		printk(KERN_ERR "%s: Failed to register host %d in"
 		       "%s\n", __FUNCTION__, shost->host_no,
-		       shost->hostt->proc_name);
+		       sht->proc_name);
 		return;
 	} 
 
 	p->write_proc = proc_scsi_write_proc;
 	p->owner = shost->hostt->module;
-
 }
 
 void scsi_proc_host_rm(struct Scsi_Host *shost)
 {
+	Scsi_Host_Template *sht = shost->hostt;
 	char name[10];
 
-	sprintf(name,"%d", shost->host_no);
-	remove_proc_entry(name, shost->hostt->proc_dir);
-	if (!shost->hostt->present)
-		remove_proc_entry(shost->hostt->proc_name, proc_scsi);
+	if (sht->proc_info) {
+		sprintf(name,"%d", shost->host_no);
+		remove_proc_entry(name, sht->proc_dir);
+		if (!sht->present)
+			remove_proc_entry(sht->proc_name, proc_scsi);
+	}
 }
 
 static int proc_print_scsidevice(struct device *dev, void *data)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-06-03 20:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-03 20:19 [PATCH] don't create /proc/scsi/ entries for drivers without ->proc_info Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2003-05-28 10:44 Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox