lkml.org 
[lkml]   [2000]   [Sep]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Re: SCSI scanning
On Sun, Sep 17 2000, Jan Niehusmann wrote:
> On Sun, Sep 17, 2000 at 09:59:30AM -0700, Linus Torvalds wrote:
> > On Sun, 17 Sep 2000, Torben Mathiasen wrote:
> > >
> > > The proper way of fixing this is to add #ifdef MODULE around the init
> > > functions or going back to init/exit_module.
> >
> > Please explain why it does it twice for compiled-in, and only once for
> > modules. There must be some other logic that does the extra
> > initializations (and that does not trigger for modules), and I'd much
> > rather just get rid of THAT thing instead.
>
> #ifdef CONFIG_BLK_DEV_SD
> scsi_register_device(&sd_template);
> #endif
>

I've attached a patch that seems to do "The Right Thing". The problem was
that the host detection routines would initialize the upper layers of scsi
drivers (sd/st/sr), and then the module_init routines would
do it again. I've removed this so now all device initialization is
done through the module_init stuff. Now this change has required all upper
layers to use this init method, and the patch therefore also updates st.

I've done some testing the last few hours with different configs to be sure
nothing breaks, but to be absolutely sure I've CC'ed Eric to verify. This
change makes the upper layers initialize a litte later when the initcall
functions are called.

--
Torben Mathiasen <tmm@image.dk>
Linux ThunderLAN maintainer
http://tlan.kernel.dk
diff -ur --exclude-from=/root/torben linux-2.4.0-test9p2/drivers/scsi/hosts.c linux/drivers/scsi/hosts.c
--- linux-2.4.0-test9p2/drivers/scsi/hosts.c Tue Jul 11 20:17:45 2000
+++ linux/drivers/scsi/hosts.c Sun Sep 17 21:28:35 2000
@@ -11,6 +11,10 @@
* Jiffies wrap fixes (host->resetting), 3 Dec 1998 Andrea Arcangeli
* Added QLOGIC QLA1280 SCSI controller kernel host support.
* August 4, 1999 Fred Lewis, Intel DuPont
+ *
+ * Updated to reflect the new initialization scheme for the higher
+ * level of scsi drivers (sd/sr/st)
+ * September 17, 2000 Torben Mathiasen <tmm@image.dk>
*/


@@ -998,20 +1002,7 @@
printk ("scsi : %d host%s.\n", next_scsi_host,
(next_scsi_host == 1) ? "" : "s");

- /* Now attach the high level drivers */
-#ifdef CONFIG_BLK_DEV_SD
- scsi_register_device(&sd_template);
-#endif
-#ifdef CONFIG_BLK_DEV_SR
- scsi_register_device(&sr_template);
-#endif
-#ifdef CONFIG_CHR_DEV_ST
- scsi_register_device(&st_template);
-#endif
-#ifdef CONFIG_CHR_DEV_SG
- scsi_register_device(&sg_template);
-#endif
-
+
#if 0
max_scsi_hosts = next_scsi_host;
#endif
diff -ur --exclude-from=/root/torben linux-2.4.0-test9p2/drivers/scsi/sd.c linux/drivers/scsi/sd.c
--- linux-2.4.0-test9p2/drivers/scsi/sd.c Sun Sep 17 21:23:48 2000
+++ linux/drivers/scsi/sd.c Sun Sep 17 21:26:46 2000
@@ -1335,13 +1335,13 @@
return;
}

-static int init_sd(void)
+static int __init init_sd(void)
{
sd_template.module = THIS_MODULE;
return scsi_register_module(MODULE_SCSI_DEV, &sd_template);
}

-static void exit_sd(void)
+static void __exit exit_sd(void)
{
struct gendisk **prev_sdgd_link;
struct gendisk *sdgd;
diff -ur --exclude-from=/root/torben linux-2.4.0-test9p2/drivers/scsi/st.c linux/drivers/scsi/st.c
--- linux-2.4.0-test9p2/drivers/scsi/st.c Wed Sep 6 21:53:14 2000
+++ linux/drivers/scsi/st.c Sun Sep 17 21:27:12 2000
@@ -3700,9 +3700,7 @@
}


-#ifdef MODULE
-
-int __init init_module(void)
+static int __init init_st(void)
{
validate_options();

@@ -3710,7 +3708,7 @@
return scsi_register_module(MODULE_SCSI_DEV, &st_template);
}

-void cleanup_module(void)
+static void __exit exit_st(void)
{
int i;

@@ -3736,4 +3734,6 @@
st_template.dev_max = 0;
printk(KERN_INFO "st: Unloaded.\n");
}
-#endif /* MODULE */
+
+module_init(init_st);
+module_exit(exit_st);
\
 
 \ /
  Last update: 2005-03-22 12:45    [W:0.067 / U:6.956 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site