add fc transport events
RFC PATCH 2/3 add fc transport events
02-sdev-transport-kobj.patch - converts the transport class_device in the scsi_device to a kobject.
drivers/scsi/scsi_scan.c | 7 +++---- drivers/scsi/scsi_sysfs.c | 22 +++++----------------- include/scsi/scsi_device.h | 6 +++--- 3 files changed, 11 insertions(+), 24 deletions(-)
drivers/scsi/scsi_scan.c +3 -4
@@ -259,10 +259,9 @@ static struct scsi_device *scsi_alloc_sd"%d:%d:%d:%d" , sdev->host->host_no, sdev->channel, sdev->id, sdev->lun); -class_device_initialize (&sdev->transport_classdev); - sdev->transport_classdev.dev = &sdev->sdev_gendev; - sdev->transport_classdev.class = sdev->host->transportt->class; -snprintf (sdev->transport_classdev.class_id,BUS_ID_SIZE , +kobject_init (&sdev->transport_kobj); + sdev->transport_kobj.parent = &sdev->host->transport_classdev.kobj; +snprintf (sdev->transport_kobj.name,KOBJ_NAME_LEN ,"%d:%d:%d:%d" , sdev->host->host_no, sdev->channel, sdev->id, sdev->lun); }else
drivers/scsi/scsi_sysfs.c +5 -17
@@ -438,7 +438,6 @@ static int attr_add(struct device *dev,**/ int scsi_sysfs_add_sdev (struct scsi_device *sdev) { -struct class_device_attribute **attrs;int error, i;if ((error =scsi_device_set_state (sdev,SDEV_RUNNING )) !=0 )
@@ -459,8 +458,9 @@ int scsi_sysfs_add_sdev(struct scsi_devi* released by the sdev_class .release */ get_device (&sdev->sdev_gendev); -if (sdev->transport_classdev.class) { - error =class_device_add (&sdev->transport_classdev); +if (sdev->host->transportt->class) { + sdev->transport_kobj.ktype = sdev->host->transportt->sdev_attrs; + error =kobject_add (&sdev->transport_kobj);if (error) goto clean_device2;/* take a reference for the transport_classdev; this
@@ -492,18 +492,6 @@ int scsi_sysfs_add_sdev(struct scsi_devi } } -if (sdev->transport_classdev.class) { - attrs = sdev->host->transportt->attrs; -for (i =0 ; attrs[i]; i++) { - error =class_device_create_file (&sdev->transport_classdev, - attrs[i]); -if (error) { -scsi_remove_device (sdev); - goto out; - } - } - } - out:return error;
@@ -528,8 +516,8 @@ void scsi_remove_device(struct scsi_devireturn ;class_device_unregister (&sdev->sdev_classdev); -if (sdev->transport_classdev.class) -class_device_unregister (&sdev->transport_classdev); +if (sdev->host->transportt->class) +kobject_unregister (&sdev->transport_kobj);device_del (&sdev->sdev_gendev);scsi_device_set_state (sdev,SDEV_DEL );if (sdev->host->hostt->slave_destroy)
include/scsi/scsi_device.h +3 -3
@@ -117,7 +117,7 @@ struct scsi_device {struct device sdev_gendev;struct class_device sdev_classdev; -struct class_device transport_classdev; +struct kobject transport_kobj;enum scsi_device_state sdev_state;unsigned long transport_data[0 ];
@@ -126,8 +126,8 @@ struct scsi_device { container_of(d, struct scsi_device, sdev_gendev)#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) +#define transport_class_to_sdev (_kobj) \ + container_of(_kobj, struct scsi_device, transport_kobj)extern struct scsi_device *scsi_add_device (struct Scsi_Host *,uint ,uint ,uint );