Commit ff788a74 authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] Re: [PATCH] fix scsi device/driver model integration

On Fri, Oct 18, 2002 at 04:18:15PM -0500, James Bottomley wrote:
> hch@lst.de said:
> > In current 2.5 each scsi highlevel driver registers with the driver
> > model individually.   This is rather messy and in fact one driver was
> > left out in the change.  Make scsi_{,un}register_device do it instead
> > and deregister with the driver model first as we registered last.
>
> OK, Patrick Mochel just stomped all over this.  So I no longer trust my merge
> corrections.  Could you resend against the current 2.5-BK.

Patch below (Template changes will be part of a different patch
now)
parent ecf2c214
......@@ -1991,6 +1991,11 @@ int scsi_register_device(struct Scsi_Device_Template *tpnt)
tpnt->next = scsi_devicelist;
scsi_devicelist = tpnt;
tpnt->scsi_driverfs_driver.name = (char *)tpnt->tag;
tpnt->scsi_driverfs_driver.bus = &scsi_driverfs_bus_type;
driver_register(&tpnt->scsi_driverfs_driver);
/*
* First scan the devices that we know about, and see if we notice them.
*/
......@@ -2062,6 +2067,8 @@ int scsi_unregister_device(struct Scsi_Device_Template *tpnt)
if (GET_USE_COUNT(tpnt->module) != 0)
goto error_out;
driver_unregister(&tpnt->scsi_driverfs_driver);
/*
* Next, detach the devices from the driver.
*/
......
......@@ -1492,15 +1492,12 @@ static void sd_detach(Scsi_Device * sdp)
static int __init init_sd(void)
{
int rc;
SCSI_LOG_HLQUEUE(3, printk("init_sd: sd driver entry point\n"));
sd_template.module = THIS_MODULE;
rc = scsi_register_device(&sd_template);
if (!rc) {
sd_template.scsi_driverfs_driver.name = (char *)sd_template.tag;
sd_template.scsi_driverfs_driver.bus = &scsi_driverfs_bus_type;
driver_register(&sd_template.scsi_driverfs_driver);
if (!rc)
register_reboot_notifier(&sd_notifier_block);
}
return rc;
}
......@@ -1525,7 +1522,6 @@ static void __exit exit_sd(void)
vfree(sd_dsk_arr);
}
sd_template.dev_max = 0;
driver_unregister(&sd_template.scsi_driverfs_driver);
unregister_reboot_notifier(&sd_notifier_block);
}
......
......@@ -1629,17 +1629,9 @@ MODULE_PARM_DESC(def_reserved_size, "size of buffer reserved for each fd");
static int __init
init_sg(void)
{
int rc;
if (def_reserved_size >= 0)
sg_big_buff = def_reserved_size;
rc = scsi_register_device(&sg_template);
if (!rc) {
sg_template.scsi_driverfs_driver.name =
(char *) sg_template.tag;
sg_template.scsi_driverfs_driver.bus = &scsi_driverfs_bus_type;
driver_register(&sg_template.scsi_driverfs_driver);
}
return rc;
return scsi_register_device(&sg_template);
}
static void __exit
......@@ -1655,7 +1647,6 @@ exit_sg(void)
sg_dev_arr = NULL;
}
sg_template.dev_max = 0;
driver_unregister(&sg_template.scsi_driverfs_driver);
}
static int
......
......@@ -837,14 +837,7 @@ static void sr_detach(Scsi_Device * SDp)
static int __init init_sr(void)
{
int rc;
rc = scsi_register_device(&sr_template);
if (!rc) {
sr_template.scsi_driverfs_driver.name = (char *)sr_template.tag;
sr_template.scsi_driverfs_driver.bus = &scsi_driverfs_bus_type;
driver_register(&sr_template.scsi_driverfs_driver);
}
return rc;
return scsi_register_device(&sr_template);
}
static void __exit exit_sr(void)
......@@ -856,7 +849,6 @@ static void __exit exit_sr(void)
kfree(scsi_CDs);
sr_template.dev_max = 0;
driver_unregister(&sr_template.scsi_driverfs_driver);
}
module_init(init_sr);
......
......@@ -3965,14 +3965,8 @@ static int __init init_st(void)
st_max_sg_segs);
if (register_chrdev(SCSI_TAPE_MAJOR, "st", &st_fops) >= 0) {
if (scsi_register_device(&st_template) == 0) {
st_template.scsi_driverfs_driver.name =
(char *)st_template.tag;
st_template.scsi_driverfs_driver.bus =
&scsi_driverfs_bus_type;
driver_register(&st_template.scsi_driverfs_driver);
if (scsi_register_device(&st_template) == 0)
return 0;
}
}
printk(KERN_ERR "Unable to get major %d for SCSI tapes\n", MAJOR_NR);
......@@ -3992,7 +3986,6 @@ static void __exit exit_st(void)
kfree(scsi_tapes);
}
st_template.dev_max = 0;
driver_unregister(&st_template.scsi_driverfs_driver);
printk(KERN_INFO "st: Unloaded.\n");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment