aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2006-12-02 22:23:34 +0100
committerStefan Richter <stefanr@s5r6.in-berlin.de>2006-12-07 23:12:16 +0100
commit1e4f7bc8f8ce07b850a5831d01a6eae83055bb42 (patch)
treea03737f744c499055c22690d93b19dff0a2341e0 /drivers
parent3015c7397876f5c5de0e178e2dfe22859b5d8754 (diff)
downloadkernel_goldelico_gta04-1e4f7bc8f8ce07b850a5831d01a6eae83055bb42.zip
kernel_goldelico_gta04-1e4f7bc8f8ce07b850a5831d01a6eae83055bb42.tar.gz
kernel_goldelico_gta04-1e4f7bc8f8ce07b850a5831d01a6eae83055bb42.tar.bz2
ieee1394: nodemgr: remove a kcalloc
Was I sleepwalking when I wrote this? Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ieee1394/nodemgr.c66
1 files changed, 20 insertions, 46 deletions
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 2953aeb..61307ca 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -754,59 +754,33 @@ static DEFINE_MUTEX(nodemgr_serialize_remove_uds);
static void nodemgr_remove_uds(struct node_entry *ne)
{
struct class_device *cdev;
- struct unit_directory *ud, **unreg;
- size_t i, count;
+ struct unit_directory *tmp, *ud;
- /*
- * This is awkward:
- * Iteration over nodemgr_ud_class.children has to be protected by
+ /* Iteration over nodemgr_ud_class.children has to be protected by
* nodemgr_ud_class.sem, but class_device_unregister() will eventually
- * take nodemgr_ud_class.sem too. Therefore store all uds to be
- * unregistered in a temporary array, release the semaphore, and then
- * unregister the uds.
- *
- * Since nodemgr_remove_uds can also run in other contexts than the
- * knodemgrds (which are currently globally serialized), protect the
+ * take nodemgr_ud_class.sem too. Therefore pick out one ud at a time,
+ * release the semaphore, and then unregister the ud. Since this code
+ * may be called from other contexts besides the knodemgrds, protect the
* gap after release of the semaphore by nodemgr_serialize_remove_uds.
*/
-
mutex_lock(&nodemgr_serialize_remove_uds);
-
- down(&nodemgr_ud_class.sem);
- count = 0;
- list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
- ud = container_of(cdev, struct unit_directory, class_dev);
- if (ud->ne == ne)
- count++;
- }
- if (!count) {
- up(&nodemgr_ud_class.sem);
- mutex_unlock(&nodemgr_serialize_remove_uds);
- return;
- }
- unreg = kcalloc(count, sizeof(*unreg), GFP_KERNEL);
- if (!unreg) {
- HPSB_ERR("NodeMgr: out of memory in nodemgr_remove_uds");
- up(&nodemgr_ud_class.sem);
- mutex_unlock(&nodemgr_serialize_remove_uds);
- return;
- }
- i = 0;
- list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
- ud = container_of(cdev, struct unit_directory, class_dev);
- if (ud->ne == ne) {
- BUG_ON(i >= count);
- unreg[i++] = ud;
+ for (;;) {
+ ud = NULL;
+ down(&nodemgr_ud_class.sem);
+ list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
+ tmp = container_of(cdev, struct unit_directory,
+ class_dev);
+ if (tmp->ne == ne) {
+ ud = tmp;
+ break;
+ }
}
+ up(&nodemgr_ud_class.sem);
+ if (ud == NULL)
+ break;
+ class_device_unregister(&ud->class_dev);
+ device_unregister(&ud->device);
}
- up(&nodemgr_ud_class.sem);
-
- for (i = 0; i < count; i++) {
- class_device_unregister(&unreg[i]->class_dev);
- device_unregister(&unreg[i]->device);
- }
- kfree(unreg);
-
mutex_unlock(&nodemgr_serialize_remove_uds);
}