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
Subject: [PATCH] scsi_host sysfs updates scsi-misc-2.5 [2/2]
Date: Thu, 8 May 2003 23:35:45 -0700	[thread overview]
Message-ID: <20030509063545.GC3259@beaverton.ibm.com> (raw)
In-Reply-To: <20030509063453.GB3259@beaverton.ibm.com>

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


DESC
scsi shost sysfs cleanups for scsi-misc-2.5
- Add LLDD short name to scsi_host struct device.
- scsi_host_release now calls scsi_free_shost.
- Switched from device_register / device_unregister and class_register
/ class_register to initialize, add, del, put pairs.
- Moved some function from scsi_register and scsi_unregister.
- Filled in scsi_host_put and scsi_host_get.
EDESC


 drivers/scsi/hosts.c      |   33 ++++++++++++++++++++++++++++-----
 drivers/scsi/hosts.h      |    2 ++
 drivers/scsi/scsi_sysfs.c |   19 +++++++++++--------
 3 files changed, 41 insertions(+), 13 deletions(-)

diff -puN drivers/scsi/scsi_sysfs.c~scsi_shost_sysfs-misc-fix drivers/scsi/scsi_sysfs.c
--- sysfs-scsi-misc-2.5/drivers/scsi/scsi_sysfs.c~scsi_shost_sysfs-misc-fix	Thu May  8 22:46:53 2003
+++ sysfs-scsi-misc-2.5-andmike/drivers/scsi/scsi_sysfs.c	Thu May  8 22:46:53 2003
@@ -317,7 +317,8 @@ static void scsi_host_release(struct dev
 	shost = dev_to_shost(dev);
 	if (!shost)
 		return;
-	shost->hostt->release(shost);
+
+	scsi_free_shost(shost);
 }
 
 /**
@@ -329,13 +330,15 @@ int scsi_sysfs_add_host(struct Scsi_Host
 {
 	int i, error;
 
-	sprintf(shost->host_gendev.bus_id,"host%d",
+	snprintf(shost->host_gendev.bus_id, BUS_ID_SIZE, "host%d",
 		shost->host_no);
+	snprintf(shost->host_gendev.name, DEVICE_NAME_SIZE, "%s",
+		shost->hostt->proc_name);
 	if (!shost->host_gendev.parent)
 		shost->host_gendev.parent = (dev) ? dev : &legacy_bus;
 	shost->host_gendev.release = scsi_host_release;
 
-	error = device_register(&shost->host_gendev);
+	error = device_add(&shost->host_gendev);
 	if (error)
 		return error;
 
@@ -343,7 +346,7 @@ int scsi_sysfs_add_host(struct Scsi_Host
 	shost->class_dev.class = &shost_class;
 	snprintf(shost->class_dev.class_id, BUS_ID_SIZE, "host%d",
 		  shost->host_no);
-	error = class_device_register(&shost->class_dev);
+	error = class_device_add(&shost->class_dev);
 	if (error)
 		goto clean_device;
 
@@ -356,9 +359,9 @@ int scsi_sysfs_add_host(struct Scsi_Host
 	return error;
 
 clean_class:
-	class_device_unregister(&shost->class_dev);
+	class_device_del(&shost->class_dev);
 clean_device:
-	device_unregister(&shost->host_gendev);
+	device_del(&shost->host_gendev);
 
 	return error;
 }
@@ -369,7 +372,7 @@ clean_device:
  **/
 void scsi_sysfs_remove_host(struct Scsi_Host *shost)
 {
-	class_device_unregister(&shost->class_dev);
-	device_unregister(&shost->host_gendev);
+	class_device_del(&shost->class_dev);
+	device_del(&shost->host_gendev);
 }
 
diff -puN drivers/scsi/hosts.c~scsi_shost_sysfs-misc-fix drivers/scsi/hosts.c
--- sysfs-scsi-misc-2.5/drivers/scsi/hosts.c~scsi_shost_sysfs-misc-fix	Thu May  8 22:46:53 2003
+++ sysfs-scsi-misc-2.5-andmike/drivers/scsi/hosts.c	Thu May  8 22:46:53 2003
@@ -212,6 +212,7 @@ int scsi_remove_host(struct Scsi_Host *s
 	list_for_each_entry(sdev, &shost->my_devices, siblings)
 		sdev->online = FALSE;
 
+	scsi_proc_host_rm(shost);
 	scsi_forget_host(shost);
 	scsi_sysfs_remove_host(shost);
 	return 0;
@@ -238,6 +239,8 @@ int scsi_add_host(struct Scsi_Host *shos
 	if (error)
 		return error;
 
+	scsi_proc_host_add(shost);
+
 	scsi_scan_host(shost);
 			
 	list_for_each_entry (sdev, &shost->my_devices, siblings) {
@@ -255,6 +258,15 @@ int scsi_add_host(struct Scsi_Host *shos
  **/
 void scsi_unregister(struct Scsi_Host *shost)
 {
+	scsi_host_put(shost);
+}
+
+/**
+ * scsi_free_sdev - free a scsi hosts resources
+ * @shost:	scsi host to free 
+ **/
+void scsi_free_shost(struct Scsi_Host *shost)
+{
 	/* Remove shost from scsi_host_list */
 	spin_lock(&scsi_host_list_lock);
 	list_del(&shost->sh_list);
@@ -273,7 +285,6 @@ void scsi_unregister(struct Scsi_Host *s
 	}
 
 	shost->hostt->present--;
-	scsi_proc_host_rm(shost);
 	scsi_destroy_command_freelist(shost);
 	kfree(shost);
 }
@@ -394,7 +405,8 @@ found:
 	rval = scsi_setup_command_freelist(shost);
 	if (rval)
 		goto fail;
-	scsi_proc_host_add(shost);
+	device_initialize(&shost->host_gendev);
+	class_device_initialize(&shost->class_dev);
 
 	shost->eh_notify = &sem;
 	kernel_thread((int (*)(void *)) scsi_error_handler, (void *) shost, 0);
@@ -523,15 +535,26 @@ struct Scsi_Host *scsi_host_hn_get(unsig
 }
 
 /**
+ * *scsi_host_get - inc a Scsi_Host ref count
+ * @shost:	Pointer to Scsi_Host to inc.
+ **/
+void scsi_host_get(struct Scsi_Host *shost)
+{
+
+	get_device(&shost->host_gendev);
+	class_device_get(&shost->class_dev);
+	return;
+}
+
+/**
  * *scsi_host_put - dec a Scsi_Host ref count
  * @shost:	Pointer to Scsi_Host to dec.
  **/
 void scsi_host_put(struct Scsi_Host *shost)
 {
 
-	/* XXX Get list lock */
-	/* XXX dec ref count */
-	/* XXX Release list lock */
+	put_device(&shost->host_gendev);
+	class_device_put(&shost->class_dev);
 	return;
 }
 
diff -puN drivers/scsi/hosts.h~scsi_shost_sysfs-misc-fix drivers/scsi/hosts.h
--- sysfs-scsi-misc-2.5/drivers/scsi/hosts.h~scsi_shost_sysfs-misc-fix	Thu May  8 22:46:53 2003
+++ sysfs-scsi-misc-2.5-andmike/drivers/scsi/hosts.h	Thu May  8 22:46:53 2003
@@ -556,6 +556,7 @@ extern int scsi_unregister_device(struct
  */
 extern struct Scsi_Host * scsi_register(Scsi_Host_Template *, int);
 extern void scsi_unregister(struct Scsi_Host *);
+extern void scsi_free_shost(struct Scsi_Host *);
 
 /*
  * HBA registration/unregistration.
@@ -570,6 +571,7 @@ extern int scsi_register_host(Scsi_Host_
 extern int scsi_unregister_host(Scsi_Host_Template *);
 
 extern struct Scsi_Host *scsi_host_hn_get(unsigned short);
+extern void scsi_host_get(struct Scsi_Host *);
 extern void scsi_host_put(struct Scsi_Host *);
 
 /**

_

  reply	other threads:[~2003-05-09  6:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-09  6:33 [PATCH] scsi_host sysfs updates scsi-misc-2.5 [0/2] Mike Anderson
2003-05-09  6:34 ` [PATCH] scsi_host sysfs updates scsi-misc-2.5 [1/2] Mike Anderson
2003-05-09  6:35   ` Mike Anderson [this message]
2003-05-09  6:59     ` [PATCH] scsi_host sysfs updates scsi-misc-2.5 [2/2] Christoph Hellwig
2003-05-09  7:50       ` Mike Anderson
2003-05-09  8:21         ` Mike Anderson
2003-05-12  3:57 ` [PATCH] scsi_host sysfs updates scsi-misc-2.5 [0/2] James Bottomley
2003-05-12  6:38   ` Mike Anderson
2003-05-12 17:50     ` James Bottomley
2003-05-12 17:59       ` James Bottomley
2003-05-12 18:41         ` Mike Anderson
2003-05-12 20:10           ` James Bottomley
2003-05-12 20:35             ` Mike Anderson
2003-05-12 20:42               ` James Bottomley
2003-05-12 20:53                 ` James Bottomley
2003-05-12 21:49                 ` Mike Anderson
2003-05-12 21:50                   ` James Bottomley
2003-05-12 22:15                     ` Mike Anderson
2003-05-14  0:00           ` Patrick Mochel
2003-05-12 18:18       ` Mike Anderson
2003-05-12 15:15 ` Andrew Vasquez
2003-05-13 18:51   ` 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=20030509063545.GC3259@beaverton.ibm.com \
    --to=andmike@us.ibm.com \
    --cc=linux-scsi@vger.kernel.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