[PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The last user of ->write_proc interface is scsi_proc.c passing through
data to individual drivers. There are still quite a few drivers using
->proc_info interface, so do conversion gradually.

Introduce temporary logic allowing both ->proc_info and ->proc_ops
with ->proc_ops being the first thing to check, convert drivers,
remove ->proc_info interface.

Removing all relevant SCSI proc files is risky because it'd take only one
broken user to revert whole thing and do it right.

Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx>
---
 drivers/scsi/scsi_proc.c |   20 +++++++++++++++-----
 include/scsi/scsi_host.h |    1 +
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index ad747dc..31da690 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -106,7 +106,7 @@ out:
 
 void scsi_proc_hostdir_add(struct scsi_host_template *sht)
 {
-	if (!sht->proc_info)
+	if (!sht->proc_info && !sht->proc_ops)
 		return;
 
 	mutex_lock(&global_host_template_mutex);
@@ -125,7 +125,7 @@ void scsi_proc_hostdir_add(struct scsi_host_template *sht)
  */
 void scsi_proc_hostdir_rm(struct scsi_host_template *sht)
 {
-	if (!sht->proc_info)
+	if (!sht->proc_info && !sht->proc_ops)
 		return;
 
 	mutex_lock(&global_host_template_mutex);
@@ -151,16 +151,26 @@ void scsi_proc_host_add(struct Scsi_Host *shost)
 		return;
 
 	sprintf(name,"%d", shost->host_no);
-	p = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
+	if (sht->proc_ops) {
+		mode_t mode;
+
+		mode = S_IRUGO;
+		if (sht->proc_ops->write)
+			mode |= S_IWUSR;
+		p = proc_create_data(name, mode, sht->proc_dir,
+				     sht->proc_ops, shost);
+	} else {
+		p = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
 			sht->proc_dir, proc_scsi_read, shost);
+		if (p)
+			p->write_proc = proc_scsi_write_proc;
+	}
 	if (!p) {
 		printk(KERN_ERR "%s: Failed to register host %d in"
 		       "%s\n", __func__, shost->host_no,
 		       sht->proc_name);
 		return;
 	} 
-
-	p->write_proc = proc_scsi_write_proc;
 }
 
 /**
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 5f7d5b3..f81c80f 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -341,6 +341,7 @@ struct scsi_host_template {
 	 * Status: OBSOLETE
 	 */
 	int (*proc_info)(struct Scsi_Host *, char *, char **, off_t, int, int);
+	const struct file_operations *proc_ops;
 
 	/*
 	 * This is an optional routine that allows the transport to become
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux