Skip to content
Snippets Groups Projects
Commit 792bcc42 authored by James Morse's avatar James Morse
Browse files

kobject: Add kset_get_next_obj() to allow a kset to be walked


To expose iommu_groups via the resctrl filesystem, the resctrl driver
needs to be able to walk the list of iommu_groups. These are exposed
via sysfs as a kset.

Add kset_get_next_obj() to allow resctrl to walk the kobjects in the
kset.

Signed-off-by: default avatarJames Morse <james.morse@arm.com>
parent 9605ad16
No related branches found
No related tags found
No related merge requests found
......@@ -205,6 +205,8 @@ static inline const struct kobj_type *get_ktype(const struct kobject *kobj)
extern struct kobject *kset_find_obj(struct kset *, const char *);
struct kobject *kset_get_next_obj(struct kset *kset, struct kobject *prev);
/* The global /sys/kernel/ kobject for people to chain off of */
extern struct kobject *kernel_kobj;
/* The global /sys/kernel/mm/ kobject for people to chain off of */
......
......@@ -907,6 +907,27 @@ struct kobject *kset_find_obj(struct kset *kset, const char *name)
}
EXPORT_SYMBOL_GPL(kset_find_obj);
struct kobject *kset_get_next_obj(struct kset *kset, struct kobject *prev)
{
struct kobject *k;
spin_lock(&kset->list_lock);
if (!prev)
k = list_first_entry_or_null(&kset->list, typeof(*k), entry);
else
k = list_next_entry(prev, entry);
if (list_entry_is_head(k, &kset->list, entry))
k = NULL;
kobject_get(k);
spin_unlock(&kset->list_lock);
kobject_put(prev);
return k;
}
static void kset_release(struct kobject *kobj)
{
struct kset *kset = container_of(kobj, struct kset, kobj);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment