|
@@ -116,6 +116,23 @@ extern void kobject_put(struct kobject *kobj);
|
|
|
extern const void *kobject_namespace(struct kobject *kobj);
|
|
|
extern char *kobject_get_path(struct kobject *kobj, gfp_t flag);
|
|
|
|
|
|
+/**
|
|
|
+ * kobject_has_children - Returns whether a kobject has children.
|
|
|
+ * @kobj: the object to test
|
|
|
+ *
|
|
|
+ * This will return whether a kobject has other kobjects as children.
|
|
|
+ *
|
|
|
+ * It does NOT account for the presence of attribute files, only sub
|
|
|
+ * directories. It also assumes there is no concurrent addition or
|
|
|
+ * removal of such children, and thus relies on external locking.
|
|
|
+ */
|
|
|
+static inline bool kobject_has_children(struct kobject *kobj)
|
|
|
+{
|
|
|
+ WARN_ON_ONCE(kref_read(&kobj->kref) == 0);
|
|
|
+
|
|
|
+ return kobj->sd && kobj->sd->dir.subdirs;
|
|
|
+}
|
|
|
+
|
|
|
struct kobj_type {
|
|
|
void (*release)(struct kobject *kobj);
|
|
|
const struct sysfs_ops *sysfs_ops;
|