diff --git a/libkmod/libkmod-list.c b/libkmod/libkmod-list.c index 6d75d66..d74d66d 100644 --- a/libkmod/libkmod-list.c +++ b/libkmod/libkmod-list.c @@ -138,6 +138,18 @@ struct kmod_list *kmod_list_remove_data(struct kmod_list *list, return container_of(node, struct kmod_list, node); } +KMOD_EXPORT struct kmod_list *kmod_list_prev(struct kmod_list *list, + struct kmod_list *curr) +{ + if (list == NULL || curr == NULL) + return NULL; + + if (curr->node.prev == &list->node) + return NULL; + + return container_of(curr->node.prev, struct kmod_list, node); +} + KMOD_EXPORT struct kmod_list *kmod_list_next(struct kmod_list *list, struct kmod_list *curr) { diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h index 2d5c281..8e262d4 100644 --- a/libkmod/libkmod.h +++ b/libkmod/libkmod.h @@ -56,6 +56,8 @@ void kmod_set_userdata(struct kmod_ctx *ctx, void *userdata); struct kmod_list; struct kmod_list *kmod_list_next(struct kmod_list *first_entry, struct kmod_list *list_entry); +struct kmod_list *kmod_list_prev(struct kmod_list *first_entry, + struct kmod_list *list_entry); #define kmod_list_foreach(list_entry, first_entry) \ for (list_entry = first_entry; \ list_entry != NULL; \ diff --git a/libkmod/libkmod.sym b/libkmod/libkmod.sym index 06f4077..70fdd00 100644 --- a/libkmod/libkmod.sym +++ b/libkmod/libkmod.sym @@ -10,6 +10,7 @@ global: kmod_set_userdata; kmod_unref; kmod_list_next; + kmod_list_prev; kmod_loaded_new; kmod_loaded_ref; kmod_loaded_unref;