2 * Copyright (C) 2003 Christoph Hellwig.
3 * Released under GPL v2.
5 * Support for old-style host templates.
7 * NOTE: Do not use this for new drivers ever.
10 #include <linux/init.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
14 #include <scsi/scsi_host.h>
17 static int __init
init_this_scsi_driver(void)
19 struct scsi_host_template
*sht
= &driver_template
;
20 struct Scsi_Host
*shost
;
26 "scsi HBA driver %s didn't set a release method.\n",
31 sht
->module
= THIS_MODULE
;
32 INIT_LIST_HEAD(&sht
->legacy_hosts
);
35 if (list_empty(&sht
->legacy_hosts
))
38 list_for_each_entry(shost
, &sht
->legacy_hosts
, sht_legacy_list
) {
39 error
= scsi_add_host(shost
, NULL
);
42 scsi_scan_host(shost
);
46 l
= &shost
->sht_legacy_list
;
47 while ((l
= l
->prev
) != &sht
->legacy_hosts
)
48 scsi_remove_host(list_entry(l
, struct Scsi_Host
, sht_legacy_list
));
52 static void __exit
exit_this_scsi_driver(void)
54 struct scsi_host_template
*sht
= &driver_template
;
55 struct Scsi_Host
*shost
, *s
;
57 list_for_each_entry(shost
, &sht
->legacy_hosts
, sht_legacy_list
)
58 scsi_remove_host(shost
);
59 list_for_each_entry_safe(shost
, s
, &sht
->legacy_hosts
, sht_legacy_list
)
62 if (list_empty(&sht
->legacy_hosts
))
65 printk(KERN_WARNING
"%s did not call scsi_unregister\n", sht
->name
);
68 list_for_each_entry_safe(shost
, s
, &sht
->legacy_hosts
, sht_legacy_list
)
69 scsi_unregister(shost
);
72 module_init(init_this_scsi_driver
);
73 module_exit(exit_this_scsi_driver
);