|
|
Subscribe / Log in / New account

MidLayer updates - extending transport/attribute container changes

From:  James.Smart@Emulex.Com
To:  <linux-scsi@vger.kernel.org>
Subject:  [PATCH 1/3] MidLayer updates - extending transport/attribute container changes
Date:  Sat, 29 Jan 2005 09:03:01 -0500


Patch 1: 
  Updates the recent transport container patch for :
  - allow device driver-specific attributes to be added to class objects
  - exposes classdev to transport via setup function

-- James S



  Updates the recent transport container patch for :
  - allow device driver-specific attributes to be added to class objects
  - exposes classdev to transport via setup function


  Signed-off-by: James Smart <james.smart@emulex.com>

---

 b/drivers/base/transport_class.c      |   26 +++++++++++++++--
 b/drivers/scsi/scsi_transport_fc.c    |    4 +-
 b/drivers/scsi/scsi_transport_spi.c   |    5 +--
 b/attribute_container.h |    1 
 b/transport_class.h     |    2 -
 5 files changed, 31 insertions(+), 7 deletions(-)

diff -puN a/include/b/attribute_container.h
linux/include/linux/attribute_container.h
--- a/attribute_container.h	2005-01-29 06:44:59.000000000 -0500
+++ b/attribute_container.h	2005-01-29 06:44:59.000000000 -0500
@@ -17,6 +17,7 @@ struct attribute_container {
 	struct list_head	containers;
 	struct class		*class;
 	struct class_device_attribute **attrs;
+	struct class_device_attribute **dd_attrs;
 	int (*match)(struct attribute_container *, struct device *);
 #define	ATTRIBUTE_CONTAINER_NO_CLASSDEVS	0x01
 	unsigned long		flags;
diff -puN a/include/b/transport_class.h linux/include/linux/transport_class.h
--- a/transport_class.h	2005-01-29 06:44:59.000000000 -0500
+++ b/transport_class.h	2005-01-29 06:44:59.000000000 -0500
@@ -14,7 +14,7 @@
 
 struct transport_class {
 	struct class class;
-	int (*setup)(struct device *);
+	int (*setup)(struct device *, struct class_device *classdev);
 	int (*configure)(struct device *);
 	int (*remove)(struct device *);
 };
diff -puN a/drivers/base/transport_class.c b/drivers/base/transport_class.c
--- a/drivers/base/transport_class.c	2005-01-29 06:44:59.000000000 -0500
+++ b/drivers/base/transport_class.c	2005-01-29 06:44:59.000000000 -0500
@@ -64,6 +64,13 @@ void transport_class_unregister(struct t
 }
 EXPORT_SYMBOL_GPL(transport_class_unregister);
 
+static int anon_transport_dummy_setup_function(struct device *dev,
+					struct class_device *classdev)
+{
+	/* do nothing */
+	return 0;
+}
+
 static int anon_transport_dummy_function(struct device *dev)
 {
 	/* do nothing */
@@ -90,7 +97,7 @@ int anon_transport_class_register(struct
 	error = attribute_container_register(&atc->container);
 	if (error)
 		return error;
-	atc->tclass.setup = anon_transport_dummy_function;
+	atc->tclass.setup = anon_transport_dummy_setup_function;
 	atc->tclass.remove = anon_transport_dummy_function;
 	return 0;
 }
@@ -117,7 +124,7 @@ static int transport_setup_classdev(stru
 	struct transport_class *tclass = class_to_transport_class(cont->class);
 
 	if (tclass->setup)
-		tclass->setup(dev);
+		tclass->setup(dev, classdev);
 
 	return 0;
 }
@@ -161,6 +168,14 @@ static int transport_add_classdev(struct
 		if (error)
 			return error;
 	}
+	if (cont->dd_attrs) {
+		attrs =	cont->dd_attrs;
+		for (i = 0; attrs[i]; i++) {
+			error = class_device_create_file(classdev, attrs[i]);
+			if (error)
+				return error;
+		}
+	}
 
 	return 0;
 }
@@ -224,6 +239,13 @@ static int transport_remove_classdev(str
 
 	for (i = 0; attrs[i]; i++)
 		class_device_remove_file(classdev, attrs[i]);
+
+	if (cont->dd_attrs) {
+		attrs =	cont->dd_attrs;
+		for (i = 0; attrs[i]; i++)
+			class_device_remove_file(classdev, attrs[i]);
+	}
+
 	class_device_del(classdev);
 
 	return 0;
diff -puN a/drivers/scsi/scsi_transport_fc.c
b/drivers/scsi/scsi_transport_fc.c
--- a/drivers/scsi/scsi_transport_fc.c	2005-01-29 06:44:59.000000000 -0500
+++ b/drivers/scsi/scsi_transport_fc.c	2005-01-29 06:45:33.000000000 -0500
@@ -205,7 +205,7 @@ struct fc_internal {
 
 #define to_fc_internal(tmpl)	container_of(tmpl, struct fc_internal, t)
 
-static int fc_add_target(struct device *dev)
+static int fc_add_target(struct device *dev, struct class_device *classdev)
 {
 	struct scsi_target *starget = to_scsi_target(dev);
 	/* 
@@ -237,7 +237,7 @@ static DECLARE_TRANSPORT_CLASS(fc_transp
 			       fc_remove_target,
 			       NULL);
 
-static int fc_add_host(struct device *dev)
+static int fc_add_host(struct device *dev, struct class_device *classdev)
 {
 	struct Scsi_Host *shost = dev_to_shost(dev);
 	/* 
diff -puN a/drivers/scsi/scsi_transport_spi.c
b/drivers/scsi/scsi_transport_spi.c
--- a/drivers/scsi/scsi_transport_spi.c	2005-01-29 06:44:59.000000000 -0500
+++ b/drivers/scsi/scsi_transport_spi.c	2005-01-29 06:44:59.000000000 -0500
@@ -117,7 +117,7 @@ static inline enum spi_signal_type spi_s
 	return SPI_SIGNAL_UNKNOWN;
 }
 
-static int spi_host_setup(struct device *dev)
+static int spi_host_setup(struct device *dev, struct class_device *classdev)
 {
 	struct Scsi_Host *shost = dev_to_shost(dev);
 
@@ -165,7 +165,8 @@ static int spi_device_configure(struct d
 	return 0;
 }
 
-static int spi_setup_transport_attrs(struct device *dev)
+static int spi_setup_transport_attrs(struct device *dev,
+				    struct class_device *classdev)
 {
 	struct scsi_target *starget = to_scsi_target(dev);
 
_


Copyright © 2005, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds