summaryrefslogtreecommitdiff
path: root/fs/cifs/cached_dir.c
diff options
context:
space:
mode:
authorYang Yingliang <yangyingliang@huawei.com>2022-10-17 11:55:08 +0300
committerSteve French <stfrench@microsoft.com>2022-10-18 19:33:43 +0300
commitd32f211adb6aa179c00ee1c251315d1ef1433a38 (patch)
treebfa811d75d68db6ab0cade623147ce606e9c8dfe /fs/cifs/cached_dir.c
parent10269f13257d4eb6061d09ccce61666316df9838 (diff)
downloadlinux-d32f211adb6aa179c00ee1c251315d1ef1433a38.tar.xz
cifs: use LIST_HEAD() and list_move() to simplify code
list_head can be initialized automatically with LIST_HEAD() instead of calling INIT_LIST_HEAD(). Using list_move() instead of list_del() and list_add(). Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/cached_dir.c')
-rw-r--r--fs/cifs/cached_dir.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/fs/cifs/cached_dir.c b/fs/cifs/cached_dir.c
index fe88b67c863f..8cad528a8722 100644
--- a/fs/cifs/cached_dir.c
+++ b/fs/cifs/cached_dir.c
@@ -378,13 +378,11 @@ void invalidate_all_cached_dirs(struct cifs_tcon *tcon)
{
struct cached_fids *cfids = tcon->cfids;
struct cached_fid *cfid, *q;
- struct list_head entry;
+ LIST_HEAD(entry);
- INIT_LIST_HEAD(&entry);
spin_lock(&cfids->cfid_list_lock);
list_for_each_entry_safe(cfid, q, &cfids->entries, entry) {
- list_del(&cfid->entry);
- list_add(&cfid->entry, &entry);
+ list_move(&cfid->entry, &entry);
cfids->num_entries--;
cfid->is_open = false;
/* To prevent race with smb2_cached_lease_break() */
@@ -518,15 +516,13 @@ struct cached_fids *init_cached_dirs(void)
void free_cached_dirs(struct cached_fids *cfids)
{
struct cached_fid *cfid, *q;
- struct list_head entry;
+ LIST_HEAD(entry);
- INIT_LIST_HEAD(&entry);
spin_lock(&cfids->cfid_list_lock);
list_for_each_entry_safe(cfid, q, &cfids->entries, entry) {
cfid->on_list = false;
cfid->is_open = false;
- list_del(&cfid->entry);
- list_add(&cfid->entry, &entry);
+ list_move(&cfid->entry, &entry);
}
spin_unlock(&cfids->cfid_list_lock);