convert the mid layer and the three transport classes to the generic one
PATCH 1/1 convert the mid layer and the three transport classes to the generic one
This basically removes our SCSI specific transport class mechanism and makes use of the generic one instead. The functionality all remains the same.
James
# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2005/01/11 16:26:32-06:00 [email protected]
# move the SCSI transport classes over to the generic transport class
#
# This converts the three transport classes (SPI, FC and iSCSI) over to
# the generic transport class code.
#
# It also converts the internals of the SCSI mid-layer to use generic
# transport class trigger points and pulls out some of the duplicated code.
#
# Signed-off-by: James Bottomley <[email protected]>
#
# include/scsi/scsi_transport_spi.h # 2005/01/11 16:26:19-06:00 [email protected] +1 -0 # move the SCSI transport classes over to the generic transport class # # include/scsi/scsi_transport.h # 2005/01/11 16:26:19-06:00 [email protected] +11 -22 # move the SCSI transport classes over to the generic transport class # # include/scsi/scsi_host.h # 2005/01/11 16:26:19-06:00 [email protected] +3 -3 # move the SCSI transport classes over to the generic transport class # # include/scsi/scsi_device.h # 2005/01/11 16:26:19-06:00 [email protected] +4 -5 # move the SCSI transport classes over to the generic transport class # # drivers/scsi/scsi_transport_spi.c # 2005/01/11 16:26:19-06:00 [email protected] +92 -47 # move the SCSI transport classes over to the generic transport class # # drivers/scsi/scsi_transport_iscsi.c # 2005/01/11 16:26:19-06:00 [email protected] +53 -32 # move the SCSI transport classes over to the generic transport class # # drivers/scsi/scsi_transport_fc.c # 2005/01/11 16:26:19-06:00 [email protected] +67 -45 # move the SCSI transport classes over to the generic transport class # # drivers/scsi/scsi_sysfs.c # 2005/01/11 16:26:19-06:00 [email protected] +25 -106 # move the SCSI transport classes over to the generic transport class # # drivers/scsi/scsi_scan.c # 2005/01/11 16:26:19-06:00 [email protected] +6 -18 # move the SCSI transport classes over to the generic transport class # # drivers/scsi/scsi_priv.h # 2005/01/11 16:26:19-06:00 [email protected] +1 -1 # move the SCSI transport classes over to the generic transport class # # drivers/scsi/hosts.c # 2005/01/11 16:26:19-06:00 [email protected] +8 -13 # move the SCSI transport classes over to the generic transport class # diff -Nru a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c --- a/drivers/scsi/hosts.c 2005-01-11 23:17:31 -06:00 +++ b/drivers/scsi/hosts.c 2005-01-11 23:17:31 -06:00 @@ -28,6 +28,7 @@ #include <linux/mm.h> #include <linux/init.h> #include <linux/completion.h> +#include <linux/transport_class.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
@@ -79,15 +80,8 @@
set_bit(SHOST_DEL, &shost->shost_state);
- if (shost->transportt->host_destroy)
- shost->transportt->host_destroy(shost);
+ transport_unregister_device(&shost->shost_gendev);
class_device_unregister(&shost->shost_classdev);
- if (shost->transport_classdev.class) {
- if (shost->transportt->host_statistics)
- sysfs_remove_group(&shost->transport_classdev.kobj,
- shost->transportt->host_statistics);
- class_device_unregister(&shost->transport_classdev);
- }
device_del(&shost->shost_gendev);
}
EXPORT_SYMBOL(scsi_remove_host);
@@ -135,9 +129,6 @@
GFP_KERNEL)) == NULL)
goto out_del_classdev;
- if (shost->transportt->host_setup)
- shost->transportt->host_setup(shost);
-
error = scsi_sysfs_add_host(shost);
if (error)
goto out_destroy_host;
@@ -146,8 +137,6 @@
return error;
out_destroy_host:
- if (shost->transportt->host_destroy)
- shost->transportt->host_destroy(shost);
out_del_classdev:
class_device_del(&shost->shost_classdev);
out_del_gendev:
@@ -397,3 +386,9 @@
{
class_unregister(&shost_class);
}
+
+int scsi_is_host_device(const struct device *dev) +{
+ return dev->release == scsi_host_dev_release;
+}
+EXPORT_SYMBOL(scsi_is_host_device);
drivers/scsi/scsi_priv.h +1 -1
@@ -146,7 +146,7 @@extern int scsi_sysfs_add_host (struct Scsi_Host *);extern int scsi_sysfs_register (void );extern void scsi_sysfs_unregister (void ); -extern int scsi_sysfs_device_initialize (struct scsi_device *); +extern void scsi_sysfs_device_initialize (struct scsi_device *);extern int scsi_sysfs_target_initialize (struct scsi_device *);extern struct scsi_transport_template blank_transport_template;
drivers/scsi/scsi_scan.c +6 -18
@@ -254,10 +254,7 @@ sdev->request_queue->queuedata = sdev;scsi_adjust_queue_depth (sdev,0 , sdev->host->cmd_per_lun); -if (shost->transportt->device_setup) { -if (shost->transportt->device_setup (sdev)) - goto out_free_queue; - } +scsi_sysfs_device_initialize (sdev);if (shost->hostt->slave_alloc) { ret = shost->hostt->slave_alloc (sdev);
@@ -272,10 +269,6 @@ } } -if (scsi_sysfs_device_initialize (sdev) !=0 ) - goto out_cleanup_slave; - -/* NOTE: this target initialisation code depends critically on * lun scanning being sequential. */ if (scsi_sysfs_target_initialize (sdev))
@@ -288,13 +281,11 @@list_del (&sdev->siblings);list_del (&sdev->same_target_siblings);spin_unlock_irqrestore (shost->host_lock, flags); -out_cleanup_slave: +if (shost->hostt->slave_destroy) shost->hostt->slave_destroy (sdev); out_device_destroy: -if (shost->transportt->device_destroy) - shost->transportt->device_destroy (sdev); -out_free_queue: +transport_destroy_device (&sdev->sdev_gendev);scsi_free_queue (sdev->request_queue); out_free_dev:kfree (sdev);
@@ -629,8 +620,7 @@if (*bflags &BLIST_NOT_LOCKABLE ) sdev->lockable =0 ; -if (sdev->host->transportt->device_configure) - sdev->host->transportt->device_configure (sdev); +transport_configure_device (&sdev->sdev_gendev);if (sdev->host->hostt->slave_configure) sdev->host->hostt->slave_configure (sdev);
@@ -749,8 +739,7 @@ }else {if (sdev->host->hostt->slave_destroy) sdev->host->hostt->slave_destroy (sdev); -if (sdev->host->transportt->device_destroy) - sdev->host->transportt->device_destroy (sdev); +transport_destroy_device (&sdev->sdev_gendev);put_device (&sdev->sdev_gendev); } out:
@@ -1330,8 +1319,7 @@if (sdev->host->hostt->slave_destroy) sdev->host->hostt->slave_destroy (sdev); -if (sdev->host->transportt->device_destroy) - sdev->host->transportt->device_destroy (sdev); +transport_destroy_device (&sdev->sdev_gendev);put_device (&sdev->sdev_gendev); }EXPORT_SYMBOL (scsi_free_host_dev);
drivers/scsi/scsi_sysfs.c +25 -106
220 lines not on this page · raw message
drivers/scsi/scsi_transport_fc.c +67 -45
170 lines not on this page · raw message
drivers/scsi/scsi_transport_iscsi.c +53 -32
122 lines not on this page · raw message
drivers/scsi/scsi_transport_spi.c +92 -47
199 lines not on this page · raw message
include/scsi/scsi_device.h +4 -5
@@ -123,8 +123,6 @@struct device sdev_gendev;struct class_device sdev_classdev; -struct class_device transport_classdev; -enum scsi_device_state sdev_state;unsigned long sdev_data[0 ]; } __attribute__((aligned(sizeof(unsigned long))));
@@ -133,7 +131,7 @@#define class_to_sdev (d) \ container_of(d, struct scsi_device, sdev_classdev)#define transport_class_to_sdev (class_dev) \ - container_of(class_dev, struct scsi_device, transport_classdev) + to_scsi_device(class_dev->dev)/* * scsi_target: representation of a scsi target, for now, this is only
@@ -146,7 +144,6 @@unsigned int channel;unsigned int id;/* target id ... replace * scsi_device.id eventually */ -struct class_device transport_classdev; unsigned long create:1; /* signal that it needs to be added */unsigned long starget_data[0 ]; } __attribute__((aligned(sizeof(unsigned long))));
@@ -157,7 +154,7 @@return to_scsi_target (sdev->sdev_gendev.parent); }#define transport_class_to_starget (class_dev) \ - container_of(class_dev, struct scsi_target, transport_classdev) + to_scsi_target(class_dev->dev)extern struct scsi_device *__scsi_add_device (struct Scsi_Host *,uint ,uint ,uint ,void *hostdata);
@@ -224,6 +221,8 @@extern void scsi_target_quiesce (struct scsi_target *);extern void scsi_target_resume (struct scsi_target *);extern const char *scsi_device_state_name (enum scsi_device_state ); +extern int scsi_is_sdev_device (const struct device *); +extern int scsi_is_target_device (const struct device *);static inline int scsi_device_online (struct scsi_device *sdev) {return sdev->sdev_state !=SDEV_OFFLINE ;
include/scsi/scsi_host.h +3 -3
@@ -528,7 +528,6 @@* separately */ void *shost_data; -struct class_device transport_classdev;/* * We should ensure that this is aligned, both for better performance
@@ -542,8 +541,6 @@ container_of(d, struct Scsi_Host, shost_gendev)#define class_to_shost (d) \ container_of(d, struct Scsi_Host, shost_classdev) -#define transport_class_to_shost (class_dev) \ - container_of(class_dev, struct Scsi_Host, transport_classdev)extern struct Scsi_Host *scsi_host_alloc (struct scsi_host_template *,int );
@@ -578,6 +575,7 @@extern void scsi_unblock_requests (struct Scsi_Host *);extern void scsi_block_requests (struct Scsi_Host *); +struct class_container ;/* * These two functions are used to allocate and free a pseudo device * which will connect to the host adapter itself rather than any
@@ -587,6 +585,8 @@*/ extern void scsi_free_host_dev (struct scsi_device *);extern struct scsi_device *scsi_get_host_dev (struct Scsi_Host *); +int scsi_is_host_device (const struct device *); +/* legacy interfaces */ extern struct Scsi_Host *scsi_register (struct scsi_host_template *,int );
include/scsi/scsi_transport.h +11 -22
@@ -20,31 +20,16 @@ #ifndef SCSI_TRANSPORT_H #define SCSI_TRANSPORT_H -struct scsi_transport_template { - /* The NULL terminated list of transport attributes - * that should be exported. - */ - struct class_device_attribute **device_attrs; - struct class_device_attribute **target_attrs; - struct class_device_attribute **host_attrs; - +#include <linux/transport_class.h> - /* The transport class that the device is in */ - struct class *device_class; - struct class *target_class; - struct class *host_class; +struct scsi_transport_template { + /* The statistics attached to the host class only */ struct attribute_group *host_statistics; - /* Constructor functions */ - int (*device_setup)(struct scsi_device *); - int (*device_configure)(struct scsi_device *); - int (*target_setup)(struct scsi_target *); - int (*host_setup)(struct Scsi_Host *); - - /* Destructor functions */ - void (*device_destroy)(struct scsi_device *); - void (*target_destroy)(struct scsi_target *); - void (*host_destroy)(struct Scsi_Host *); + /* the attribute containers */ + struct attribute_container host_attrs; + struct attribute_container target_attrs; + struct attribute_container device_attrs; /* The size of the specific transport attribute structure (a * space of this size will be left at the end of the
@@ -53,5 +38,9 @@int target_size; int host_size; }; + +#define transport_class_to_shost (tc) \ + dev_to_shost((tc)->dev) +#endif /* SCSI_TRANSPORT_H */
include/scsi/scsi_transport_spi.h +1 -0
@@ -21,6 +21,7 @@#define SCSI_TRANSPORT_SPI_H #include <linux/config.h> +#include <linux/transport_class.h> struct scsi_transport_template ;