===== drivers/scsi/Kconfig 1.57 vs edited ===== --- 1.57/drivers/scsi/Kconfig Mon Feb 23 14:41:38 2004 +++ edited/drivers/scsi/Kconfig Mon Feb 23 15:51:15 2004 @@ -200,14 +200,14 @@ depends on SCSI config SCSI_SPI_ATTRS - bool "Parallel SCSI (SPI) Transport Attributes" + tristate "Parallel SCSI (SPI) Transport Attributes" depends on SCSI help If you wish to export transport-specific information about each attached SCSI device to sysfs, say Y. Otherwise, say N. config SCSI_FC_ATTRS - bool "FiberChannel Transport Attributes" + tristate "FiberChannel Transport Attributes" depends on SCSI help If you wish to export transport-specific information about ===== drivers/scsi/Makefile 1.56 vs edited ===== --- 1.56/drivers/scsi/Makefile Mon Feb 23 14:59:02 2004 +++ edited/drivers/scsi/Makefile Mon Feb 23 15:53:07 2004 @@ -22,6 +22,14 @@ obj-$(CONFIG_SCSI) += scsi_mod.o +# --- NOTE ORDERING HERE --- +# For kernel non-modular link, transport attributes need to +# be initialised before drivers +# -------------------------- +obj-$(CONFIG_SCSI_SPI_ATTRS) += scsi_transport_spi.o +obj-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o + + obj-$(CONFIG_SCSI_AMIGA7XX) += amiga7xx.o 53c7xx.o obj-$(CONFIG_A3000_SCSI) += a3000.o wd33c93.o obj-$(CONFIG_A2091_SCSI) += a2091.o wd33c93.o @@ -130,8 +138,6 @@ scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o scsi_mod-$(CONFIG_X86_PC9800) += scsi_pc98.o -scsi_mod-$(CONFIG_SCSI_SPI_ATTRS) += scsi_transport_spi.o -scsi_mod-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o sd_mod-objs := sd.o sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o ===== drivers/scsi/hosts.c 1.96 vs edited ===== --- 1.96/drivers/scsi/hosts.c Mon Dec 29 15:38:10 2003 +++ edited/drivers/scsi/hosts.c Mon Feb 23 17:22:26 2004 @@ -32,6 +32,7 @@ #include #include +#include #include "scsi.h" #include "scsi_priv.h" @@ -221,6 +222,11 @@ shost->max_channel = 0; shost->max_id = 8; shost->max_lun = 8; + + /* Give each shost a default transportt if the driver + * doesn't yet support Transport Attributes */ + if (!shost->transportt) + shost->transportt = &blank_transport_template; /* * All drivers right now should be able to handle 12 byte ===== drivers/scsi/scsi_scan.c 1.116 vs edited ===== --- 1.116/drivers/scsi/scsi_scan.c Mon Feb 23 14:41:38 2004 +++ edited/drivers/scsi/scsi_scan.c Mon Feb 23 17:22:08 2004 @@ -193,7 +193,7 @@ struct scsi_device *sdev, *device; unsigned long flags; - sdev = kmalloc(sizeof(*sdev), GFP_ATOMIC); + sdev = kmalloc(sizeof(*sdev) + shost->transportt->size, GFP_ATOMIC); if (!sdev) goto out; @@ -237,11 +237,6 @@ if (shost->hostt->slave_alloc(sdev)) goto out_free_queue; } - - /* Give each shost a default transportt if the driver - * doesn't yet support Transport Attributes */ - if (!shost->transportt) - shost->transportt = &blank_transport_template; if (shost->transportt->setup) { if (shost->transportt->setup(sdev)) ===== drivers/scsi/scsi_sysfs.c 1.40 vs edited ===== --- 1.40/drivers/scsi/scsi_sysfs.c Mon Feb 23 14:41:38 2004 +++ edited/drivers/scsi/scsi_sysfs.c Mon Feb 23 15:34:41 2004 @@ -14,8 +14,6 @@ #include #include -#include -#include #include "scsi.h" #include "scsi_priv.h" @@ -165,31 +163,13 @@ int error; error = bus_register(&scsi_bus_type); - if (error) - return error; - - error = class_register(&sdev_class); - if (error) - goto undo_bus; - - error = scsi_spi_transport_init(); - if (error) - goto undo_sdev; - - error = scsi_fc_transport_init(); - if (error) - goto undo_all; + if (!error) { + error = class_register(&sdev_class); + if (error) + bus_unregister(&scsi_bus_type); + } - out: return error; - - undo_all: - scsi_spi_transport_exit(); - undo_sdev: - class_unregister(&sdev_class); - undo_bus: - bus_unregister(&scsi_bus_type); - goto out; } void scsi_sysfs_unregister(void) @@ -546,4 +526,4 @@ /* A blank transport template that is used in drivers that don't * yet implement Transport Attributes */ -struct scsi_transport_template blank_transport_template; +struct scsi_transport_template blank_transport_template = { 0, }; ===== drivers/scsi/scsi_transport_spi.c 1.1 vs edited ===== --- 1.1/drivers/scsi/scsi_transport_spi.c Mon Feb 23 14:41:41 2004 +++ edited/drivers/scsi/scsi_transport_spi.c Mon Feb 23 16:27:08 2004 @@ -17,7 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - +#include +#include #include #include #include @@ -30,34 +31,25 @@ .release = transport_class_release, }; -int scsi_spi_transport_init(void) +static __init int scsi_spi_transport_init(void) { return class_register(&spi_transport_class); } -void scsi_spi_transport_exit(void) +static void __exit scsi_spi_transport_exit(void) { class_unregister(&spi_transport_class); } -static int spi_alloc_transport_attrs(struct scsi_device *sdev) +static int spi_setup_transport_attrs(struct scsi_device *sdev) { - sdev->transport_attr_values = kmalloc(sizeof(struct spi_transport_attrs), - GFP_ATOMIC); - if (!sdev->transport_attr_values) - return -ENOMEM; - - memcpy(sdev->transport_attr_values, sdev->host->transportt->default_attr_values, - sizeof(struct spi_transport_attrs)); + /* FIXME: should callback into the driver to get these values */ + spi_period(sdev) = -1; + spi_offset(sdev) = -1; return 0; } -static void spi_destroy_transport_attrs(struct scsi_device *sdev) -{ - kfree(sdev->transport_attr_values); -} - static void transport_class_release(struct class_device *class_dev) { struct scsi_device *sdev = transport_class_to_sdev(class_dev); @@ -70,7 +62,7 @@ { \ struct scsi_device *sdev = transport_class_to_sdev(cdev); \ struct spi_transport_attrs *tp; \ - tp = (struct spi_transport_attrs *)sdev->transport_attr_values; \ + tp = (struct spi_transport_attrs *)&sdev->transport_data; \ return snprintf(buf, 20, format_string, tp->field); \ } @@ -89,16 +81,18 @@ NULL }; -struct spi_transport_attrs spi_transport_attr_defaults = { - .period = -1, - .offset = -1, -}; - struct scsi_transport_template spi_transport_template = { .attrs = spi_transport_attrs, .class = &spi_transport_class, - .setup = &spi_alloc_transport_attrs, - .cleanup = &spi_destroy_transport_attrs, - .default_attr_values = &spi_transport_attr_defaults, + .setup = &spi_setup_transport_attrs, + .cleanup = NULL, + .size = sizeof(struct spi_transport_attrs) - sizeof(unsigned long), }; EXPORT_SYMBOL(spi_transport_template); + +MODULE_AUTHOR("Martin Hicks"); +MODULE_DESCRIPTION("SPI Transport Attributes"); +MODULE_LICENSE("GPL"); + +module_init(scsi_spi_transport_init); +module_exit(scsi_spi_transport_exit);