* [PATCH 1/3] MidLayer updates - extending transport/attribute container changes
@ 2005-01-29 14:03 James.Smart
2005-02-04 22:57 ` James Bottomley
0 siblings, 1 reply; 2+ messages in thread
From: James.Smart @ 2005-01-29 14:03 UTC (permalink / raw)
To: linux-scsi
[-- Attachment #1: Type: text/plain, Size: 209 bytes --]
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
[-- Attachment #2: p00001_xpt.patch --]
[-- Type: application/octet-stream, Size: 4860 bytes --]
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);
_
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/3] MidLayer updates - extending transport/attribute container changes
2005-01-29 14:03 [PATCH 1/3] MidLayer updates - extending transport/attribute container changes James.Smart
@ 2005-02-04 22:57 ` James Bottomley
0 siblings, 0 replies; 2+ messages in thread
From: James Bottomley @ 2005-02-04 22:57 UTC (permalink / raw)
To: James.Smart; +Cc: SCSI Mailing List
On Sat, 2005-01-29 at 09:03 -0500, James.Smart@Emulex.Com wrote:
> 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
I'm not very keen on this for two reasons:
1) The driver should be tampering with class attributes. A class and
its attributes are the presentation of an interface. If the driver has
something more to add then surely that's an indication that the original
interface is missing pieces (i.e. every driver should have this) or that
the driver is trying to export a different interface (and so, logically
should use a new class. i.e. just add a transport_class to the driver
and everything will work nicely).
2) classdevs are sysfs's representation of the interface. I'd rather
they weren't exposed any more than necessary internally to avoid the
urge to hack the interface.
James
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-02-04 22:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-29 14:03 [PATCH 1/3] MidLayer updates - extending transport/attribute container changes James.Smart
2005-02-04 22:57 ` James Bottomley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).