From 364595a6851bf64e1c38224ae68f5dd6651906d1 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 30 Mar 2023 06:41:43 -0400 Subject: fs: consolidate duplicate dt_type helpers There are three copies of the same dt_type helper sprinkled around the tree. Convert them to use the common fs_umode_to_dtype function instead, which has the added advantage of properly returning DT_UNKNOWN when given a mode that contains an unrecognized type. Cc: Chuck Lever Cc: Phillip Potter Suggested-by: Christian Brauner Signed-off-by: Jeff Layton Acked-by: Greg Kroah-Hartman Reviewed-by: Christian Brauner Message-Id: <20230330104144.75547-1-jlayton@kernel.org> Signed-off-by: Christian Brauner --- fs/kernfs/dir.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'fs/kernfs') diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index ef00b5fe8cee..90de0e498371 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -1748,12 +1748,6 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent, return error; } -/* Relationship between mode and the DT_xxx types */ -static inline unsigned char dt_type(struct kernfs_node *kn) -{ - return (kn->mode >> 12) & 15; -} - static int kernfs_dir_fop_release(struct inode *inode, struct file *filp) { kernfs_put(filp->private_data); @@ -1831,7 +1825,7 @@ static int kernfs_fop_readdir(struct file *file, struct dir_context *ctx) pos; pos = kernfs_dir_next_pos(ns, parent, ctx->pos, pos)) { const char *name = pos->name; - unsigned int type = dt_type(pos); + unsigned int type = fs_umode_to_dtype(pos->mode); int len = strlen(name); ino_t ino = kernfs_ino(pos); -- cgit