From 1dd9f5babfd95fea5a77b27bab48c04c29db1f5f Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 9 Dec 2019 11:09:20 +0000 Subject: fs/adfs: dir: add common directory buffer release method With the bhs pointer in place, we have no need for separate per-format free() methods, since a generic version will do. Provide a generic implementation, remove the format specific implementations and the method function pointer. Signed-off-by: Russell King Signed-off-by: Al Viro --- fs/adfs/dir.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'fs/adfs/dir.c') diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c index c1b8b5bccbec..f50302775504 100644 --- a/fs/adfs/dir.c +++ b/fs/adfs/dir.c @@ -6,6 +6,7 @@ * * Common directory handling for ADFS */ +#include #include "adfs.h" /* @@ -13,6 +14,20 @@ */ static DEFINE_RWLOCK(adfs_dir_lock); +void adfs_dir_relse(struct adfs_dir *dir) +{ + unsigned int i; + + for (i = 0; i < dir->nr_buffers; i++) + brelse(dir->bhs[i]); + dir->nr_buffers = 0; + + if (dir->bhs != dir->bh) + kfree(dir->bhs); + dir->bhs = NULL; + dir->sb = NULL; +} + static int adfs_dir_read(struct super_block *sb, u32 indaddr, unsigned int size, struct adfs_dir *dir) { @@ -105,7 +120,7 @@ unlock_out: read_unlock(&adfs_dir_lock); free_out: - ops->free(&dir); + adfs_dir_relse(&dir); return ret; } @@ -139,7 +154,7 @@ adfs_dir_update(struct super_block *sb, struct object_info *obj, int wait) ret = err; } - ops->free(&dir); + adfs_dir_relse(&dir); out: #endif return ret; @@ -211,7 +226,7 @@ unlock_out: read_unlock(&adfs_dir_lock); free_out: - ops->free(&dir); + adfs_dir_relse(&dir); out: return ret; } -- cgit v1.2.3-58-ga151