public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi/hosts.c device_register fix
@ 2002-11-28 16:47 Andries.Brouwer
  2002-11-28 16:57 ` James Bottomley
  0 siblings, 1 reply; 4+ messages in thread
From: Andries.Brouwer @ 2002-11-28 16:47 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, linux-scsi

Many scsi hosts do scsi_register, and when the corresponding
host is not found or fails to work, do scsi_unregister again.
Thus, actions in scsi_unregister should be the inverses of those
in scsi_register, just like actions in scsi_remove_host should be
the inverses of those in scsi_add_host.

However, device_register() is done in scsi_add_host() while the
corresponding device_unregister() is done in scsi_unregister().

This causes crashes at boot (in 2.5.49 and 2.5.50).

Below a fix. This patch was first given by James Bottomley.

Andries

diff -u --recursive --new-file -X /linux/dontdiff a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
--- a/drivers/scsi/hosts.c	Thu Nov 28 15:28:19 2002
+++ b/drivers/scsi/hosts.c	Thu Nov 28 17:22:02 2002
@@ -309,7 +309,6 @@
 	printk(KERN_INFO "scsi%d : %s\n", shost->host_no,
 			sht->info ? sht->info(shost) : sht->name);
 
-	device_register(&shost->host_driverfs_dev);
 	scsi_scan_host(shost);
 			
 	list_for_each_entry (sdev, &shost->my_devices, siblings) {
@@ -358,11 +357,6 @@
  * @shost_tp:	pointer to scsi host template
  * @xtr_bytes:	extra bytes to allocate for driver
  *
- * Note:
- * 	We call this when we come across a new host adapter. We only do
- * 	this once we are 100% sure that we want to use this host adapter -
- * 	it is a pain to reverse this, so we try to avoid it 
- *
  * Return value:
  * 	Pointer to a new Scsi_Host
  **/
@@ -478,6 +472,8 @@
 
 	shost->hostt->present++;
 
+	device_register(&shost->host_driverfs_dev);
+
 	return shost;
 }
 

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: [PATCH] scsi/hosts.c device_register fix
@ 2002-11-28 17:18 Andries.Brouwer
  0 siblings, 0 replies; 4+ messages in thread
From: Andries.Brouwer @ 2002-11-28 17:18 UTC (permalink / raw)
  To: Andries.Brouwer, James.Bottomley; +Cc: linux-kernel, linux-scsi, torvalds

	From James.Bottomley@steeleye.com  Thu Nov 28 17:57:52 2002

	Actually, the patch is wrong.
	The device_register has to be done in scsi_add_host,
	The correct fix is to move the corresponding device_unregister
	into scsi_remove_host so that they match.

Very good. That was what I had done first, but a google search
turned up your patch and I thought that it was also OK.

	I'll also commit it to the scsi-misc-2.5 BK tree.

Hope to see it in 2.5.51.

Andries

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

end of thread, other threads:[~2002-11-28 23:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-28 16:47 [PATCH] scsi/hosts.c device_register fix Andries.Brouwer
2002-11-28 16:57 ` James Bottomley
2002-11-28 22:53   ` Douglas Gilbert
  -- strict thread matches above, loose matches on Subject: below --
2002-11-28 17:18 Andries.Brouwer

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