

  With the conversion to the new attribute containers/transport work, the
  FC host statistics were lost. This patch re-enables them.

  This patch adds a statistics group to each attribute container and
  adds/removes them at the same time the base attributes are added/removed.



---

 b/drivers/base/attribute_container.c  |   16 ++++++++++++----
 b/drivers/scsi/scsi_sysfs.c           |    2 +-
 b/drivers/scsi/scsi_transport_fc.c    |    2 +-
 b/attribute_container.h               |    1 +
 b/include/scsi/scsi_transport.h       |    3 ---
 5 files changed, 15 insertions(+), 9 deletions(-)

diff -puN a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
--- a/drivers/base/attribute_container.c	2005-02-08 16:01:14.000000000 -0500
+++ b/drivers/base/attribute_container.c	2005-02-08 16:01:14.000000000 -0500
@@ -283,11 +283,16 @@ attribute_container_add_attrs(struct cla
 	struct class_device_attribute **attrs =	cont->attrs;
 	int i, error;
 
-	if (!attrs)
-		return 0;
+	if (attrs) {
+		for (i = 0; attrs[i]; i++) {
+			error = class_device_create_file(classdev, attrs[i]);
+			if (error)
+				return error;
+		}
+	}
 
-	for (i = 0; attrs[i]; i++) {
-		error = class_device_create_file(classdev, attrs[i]);
+	if (cont->statistics) {
+		error = sysfs_create_group(&classdev->kobj, cont->statistics);
 		if (error)
 			return error;
 	}
@@ -344,6 +349,9 @@ attribute_container_remove_attrs(struct 
 	struct class_device_attribute **attrs =	cont->attrs;
 	int i;
 
+	if (cont->statistics)
+		sysfs_remove_group(&classdev->kobj, cont->statistics);
+
 	if (!attrs)
 		return;
 
diff -puN a/include/linux/attribute_container.h b/include/linux/attribute_container.h
--- a/include/linux/attribute_container.h	2005-02-08 16:01:14.000000000 -0500
+++ b/include/linux/attribute_container.h	2005-02-08 16:01:14.000000000 -0500
@@ -17,6 +17,7 @@ struct attribute_container {
 	struct list_head	containers;
 	struct class		*class;
 	struct class_device_attribute **attrs;
+	struct attribute_group *statistics;
 	int (*match)(struct attribute_container *, struct device *);
 #define	ATTRIBUTE_CONTAINER_NO_CLASSDEVS	0x01
 	unsigned long		flags;
diff -puN a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
--- a/drivers/scsi/scsi_transport_fc.c	2005-02-08 16:01:14.000000000 -0500
+++ b/drivers/scsi/scsi_transport_fc.c	2005-02-08 16:01:14.000000000 -0500
@@ -788,7 +788,7 @@ fc_attach_transport(struct fc_function_t
 	i->t.host_size = sizeof(struct fc_host_attrs);
 
 	if (ft->get_fc_host_stats)
-		i->t.host_statistics = &fc_statistics_group;
+		i->t.host_attrs.statistics = &fc_statistics_group;
 
 	i->f = ft;
 
diff -puN a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h
--- a/include/scsi/scsi_transport.h	2005-02-08 16:01:14.000000000 -0500
+++ b/include/scsi/scsi_transport.h	2005-02-08 16:01:14.000000000 -0500
@@ -23,9 +23,6 @@
 #include <linux/transport_class.h>
 
 struct scsi_transport_template {
-	/* The statistics attached to the host class only */
-	struct attribute_group *host_statistics;
-
 	/* the attribute containers */
 	struct attribute_container host_attrs;
 	struct attribute_container target_attrs;
diff -puN a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c	2005-02-08 16:02:29.000000000 -0500
+++ b/drivers/scsi/scsi_sysfs.c	2005-02-08 16:03:15.000000000 -0500
@@ -833,4 +833,4 @@ EXPORT_SYMBOL(scsi_is_target_device);
 
 /* A blank transport template that is used in drivers that don't
  * yet implement Transport Attributes */
-struct scsi_transport_template blank_transport_template = { NULL, };
+struct scsi_transport_template blank_transport_template = { { {NULL, } }, };
_
