Comments
Patch
@@ -18,6 +18,10 @@
#include <linux/stat.h>
#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
+DECLARE_WAIT_QUEUE_HEAD(kset_wait);
+
/*
* populate_dir - populate directory with attributes.
* @kobj: object we're working on.
@@ -721,6 +725,7 @@ int kset_register(struct kset *k)
if (err)
return err;
kobject_uevent(&k->kobj, KOBJ_ADD);
+ wake_up_interruptible(&kset_wait);
return 0;
}
@@ -744,7 +749,7 @@ void kset_unregister(struct kset *k)
* looking for a matching kobject. If matching object is found
* take a reference and return the object.
*/
-struct kobject *kset_find_obj(struct kset *kset, const char *name)
+struct kobject *__kset_find_obj(struct kset *kset, const char *name)
{
struct kobject *k;
struct kobject *ret = NULL;
@@ -760,6 +765,14 @@ struct kobject *kset_find_obj(struct kset *kset,
const char *name)
return ret;
}
+struct kobject *kset_find_obj(struct kset *kset, const char *name)
+{
+ struct kobject *ret = NULL;
+ wait_event_interruptible(kset_wait, (ret = __kset_find_obj(kset,
name)));
+ return ret;
+}
+
static void kset_release(struct kobject *kobj)
{