[PATCH] add missing class_device_del to transport classes

Mike Christie
2005-01-26T23:59:36Z

[-- Attachment #1: Type: text/plain, Size: 1117 bytes --]

James,

It appears there is a missing class_device_del.
The comments for transport_remove_device indicate
that transport_remove_classdev should call it
(which the attached patch does), but the comment in
attribute_container_remove_device:

If you want a
* two phase release: remove from visibility and then delete the
* device, then you should use this routine with a fn that calls
* class_device_del() and then use
* attribute_container_device_trigger() to do the final put on the
* classdev.

Indicate that maybe transport_destroy_classdev and
transport_remove_device are incorrect. However,
attribute_container_remove_device will do a
list_del(&ic->node); so that later calls to
attribute_container_device_trigger would not be able
to do the final put on that classdev. I assumed the
comments in attribute_container_remove_device
are incorrect, so the attached patch made against
scsi-rc-fixes-2.6 adds a call to class_device_del
to transport_remove_classdev.

I did not fix the comments in attribute_container_remove_device
becuase I was not 100% certain what is the correct behavior or
usage.

Mike

[-- Attachment #2: add-classdev-del.patch --]
[-- Type: text/x-patch, Size: 613 bytes --]

--- scsi-rc-fixes-2.6.orig/drivers/base/transport_class.c 2005-01-25 13:30:27.000000000 -0800
+++ scsi-rc-fixes-2.6.newtest/drivers/base/transport_class.c 2005-01-26 15:22:52.000000000 -0800
@@ -216,10 +216,16 @@ static int transport_remove_classdev(str
struct class_device *classdev)
{
struct transport_class *tclass = class_to_transport_class(cont->class);
+ struct class_device_attribute **attrs = cont->attrs;
+ int i;

if (tclass->remove)
tclass->remove(dev);

+ for (i = 0; attrs[i]; i++)
+ class_device_remove_file(classdev, attrs[i]);
+ class_device_del(classdev);
+
return 0;
}