public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Anderson <andmike@us.ibm.com>
To: linux-scsi@vger.kernel.org, Patrick Mochel <mochel@osdl.org>
Subject: [RFC] scsi host sysfs support again [3/4]
Date: Mon, 5 May 2003 01:37:23 -0700	[thread overview]
Message-ID: <20030505083723.GE8416@beaverton.ibm.com> (raw)
In-Reply-To: <20030505083540.GD8416@beaverton.ibm.com>

-andmike
--
Michael Anderson
andmike@us.ibm.com


DESC
Change scsi host to class device model. Change scsi host and scsi device
to release when ref count goes to zero.
EDESC


 drivers/scsi/hosts.c     |   23 +++++------------------
 drivers/scsi/hosts.h     |   20 ++++++++++++++------
 drivers/scsi/scsi_scan.c |    4 +---
 3 files changed, 20 insertions(+), 27 deletions(-)

diff -puN drivers/scsi/hosts.h~scsi_shosts-sysfs drivers/scsi/hosts.h
--- sysfs-scsi-misc-2.5/drivers/scsi/hosts.h~scsi_shosts-sysfs	Thu May  1 18:10:59 2003
+++ sysfs-scsi-misc-2.5-andmike/drivers/scsi/hosts.h	Thu May  1 18:17:11 2003
@@ -482,9 +482,10 @@ struct Scsi_Host
     unsigned int max_host_blocked;
 
     /* 
-     * Support for driverfs filesystem
+     * Support for sysfs
      */
-    struct device *host_gendev;
+    struct device host_gendev;
+    struct class_device class_dev;
 
     /*
      * We should ensure that this is aligned, both for better performance
@@ -495,8 +496,11 @@ struct Scsi_Host
         __attribute__ ((aligned (sizeof(unsigned long))));
 };
 
-#define	to_scsi_host(d)	d->driver_data	/* Major logical breakage, but we compile again... */
-	
+#define		dev_to_shost(d)		\
+	container_of(d, struct Scsi_Host, host_gendev)
+#define		class_to_shost(d)	\
+	container_of(d, struct Scsi_Host, class_dev)
+
 /*
  * These two functions are used to allocate and free a pseudo device
  * which will connect to the host adapter itself rather than any
@@ -519,12 +523,12 @@ static inline void scsi_assign_lock(stru
 static inline void scsi_set_device(struct Scsi_Host *shost,
                                    struct device *dev)
 {
-        shost->host_gendev = dev;
+        shost->host_gendev.parent = dev;
 }
 
 static inline struct device *scsi_get_device(struct Scsi_Host *shost)
 {
-        return shost->host_gendev;
+        return shost->host_gendev.parent;
 }
 
 struct Scsi_Device_Template
@@ -591,6 +595,10 @@ static inline Scsi_Device *scsi_find_dev
  */
 extern int scsi_upper_driver_register(struct Scsi_Device_Template *);
 extern void scsi_upper_driver_unregister(struct Scsi_Device_Template *);
+extern int scsi_sysfs_add_host(struct Scsi_Host *, struct device *);
+extern void scsi_sysfs_remove_host(struct Scsi_Host *);
+
+extern void scsi_free_sdev(struct scsi_device *);
 
 extern struct class shost_class;
 
diff -puN drivers/scsi/hosts.c~scsi_shosts-sysfs drivers/scsi/hosts.c
--- sysfs-scsi-misc-2.5/drivers/scsi/hosts.c~scsi_shosts-sysfs	Thu May  1 18:10:59 2003
+++ sysfs-scsi-misc-2.5-andmike/drivers/scsi/hosts.c	Thu May  1 18:10:59 2003
@@ -193,16 +193,6 @@ static int scsi_host_legacy_release(stru
 	return 0;
 }
 
-static int scsi_remove_legacy_host(struct Scsi_Host *shost)
-{
-	int error;
-
-	error = scsi_remove_host(shost);
-	if (!error)
-		(*shost->hostt->release)(shost);
-	return 0;
-}
-
 static int scsi_check_device_busy(struct scsi_device *sdev)
 {
 	struct Scsi_Host *shost = sdev->host;
@@ -268,11 +258,8 @@ int scsi_remove_host(struct Scsi_Host *s
 	list_for_each_entry(sdev, &shost->my_devices, siblings)
 		sdev->online = FALSE;
 
-	list_for_each_entry(sdev, &shost->my_devices, siblings)
-		if (scsi_check_device_busy(sdev))
-			return 1;
-
 	scsi_forget_host(shost);
+	scsi_sysfs_remove_host(shost);
 	return 0;
 }
 
@@ -293,9 +280,9 @@ int scsi_add_host(struct Scsi_Host *shos
 	printk(KERN_INFO "scsi%d : %s\n", shost->host_no,
 			sht->info ? sht->info(shost) : sht->name);
 
-	if (dev) {
-		shost->host_gendev = dev;
-	}
+	error = scsi_sysfs_add_host(shost, dev);
+	if (error)
+		return error;
 
 	scsi_scan_host(shost);
 			
@@ -531,7 +518,7 @@ out_of_space:
  **/
 int scsi_unregister_host(Scsi_Host_Template *shost_tp)
 {
-	scsi_tp_for_each_host(shost_tp, scsi_remove_legacy_host);
+	scsi_tp_for_each_host(shost_tp, scsi_remove_host);
 	return 0;
 
 }
diff -puN drivers/scsi/scsi_scan.c~scsi_shosts-sysfs drivers/scsi/scsi_scan.c
--- sysfs-scsi-misc-2.5/drivers/scsi/scsi_scan.c~scsi_shosts-sysfs	Thu May  1 18:10:59 2003
+++ sysfs-scsi-misc-2.5-andmike/drivers/scsi/scsi_scan.c	Thu May  1 18:10:59 2003
@@ -480,7 +480,7 @@ out:
  *     Undo the actions in scsi_alloc_sdev, including removing @sdev from
  *     the list, and freeing @sdev.
  **/
-static void scsi_free_sdev(struct scsi_device *sdev)
+void scsi_free_sdev(struct scsi_device *sdev)
 {
 	unsigned long flags;
 
@@ -1273,8 +1273,6 @@ int scsi_remove_device(struct scsi_devic
 		return -EINVAL;
 
 	scsi_device_unregister(sdev);
-
-	scsi_free_sdev(sdev);
 	return 0;
 }
 

_

  reply	other threads:[~2003-05-05  8:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-05  8:33 [RFC] scsi host sysfs support again [0/4] Mike Anderson
2003-05-05  8:34 ` [RFC] scsi host sysfs support again [1/4] Mike Anderson
2003-05-05  8:35   ` [RFC] scsi host sysfs support again [2/4] Mike Anderson
2003-05-05  8:37     ` Mike Anderson [this message]
2003-05-05  8:38       ` [RFC] scsi host sysfs support again [4/4] Mike Anderson
2003-05-05  8:38 ` [RFC] scsi host sysfs support again [0/4] Christoph Hellwig
2003-05-05  9:40   ` Douglas Gilbert
2003-05-05 10:00     ` Mike Anderson
2003-05-05  9:48   ` Mike Anderson
2003-05-05 10:17     ` Christoph Hellwig
2003-05-06  1:05       ` Mike Anderson
2003-05-07 15:44         ` Christoph Hellwig
2003-05-07 16:15           ` Mike Anderson
2003-05-07 16:41             ` Christoph Hellwig
2003-05-05 11:46 ` Douglas Gilbert
2003-05-05 21:45   ` Mike Anderson
2003-05-06  1:12     ` Douglas Gilbert
2003-05-06 16:28 ` James Bottomley
2003-05-06 17:23   ` Mike Anderson
2003-05-07 23:19     ` Willem Riede
2003-05-08  0:09       ` Douglas Gilbert
2003-05-08  1:44       ` Mike Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030505083723.GE8416@beaverton.ibm.com \
    --to=andmike@us.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mochel@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox