From 87f15d4add758fb7fc76655721af94be57a4c17d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Mar 2016 14:43:24 -0400 Subject: mtd: switch open_mtd_by_chdev() to use of vfs_stat() Signed-off-by: Al Viro --- drivers/mtd/ubi/build.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'drivers/mtd') diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 22fd19c0c5d3..a7d1febf667a 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -1142,22 +1142,19 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) */ static struct mtd_info * __init open_mtd_by_chdev(const char *mtd_dev) { - int err, major, minor, mode; - struct path path; + struct kstat stat; + int err, minor; /* Probably this is an MTD character device node path */ - err = kern_path(mtd_dev, LOOKUP_FOLLOW, &path); + err = vfs_stat(mtd_dev, &stat); if (err) return ERR_PTR(err); /* MTD device number is defined by the major / minor numbers */ - major = imajor(d_backing_inode(path.dentry)); - minor = iminor(d_backing_inode(path.dentry)); - mode = d_backing_inode(path.dentry)->i_mode; - path_put(&path); - if (major != MTD_CHAR_MAJOR || !S_ISCHR(mode)) + if (MAJOR(stat.rdev) != MTD_CHAR_MAJOR || !S_ISCHR(stat.mode)) return ERR_PTR(-EINVAL); + minor = MINOR(stat.rdev); if (minor & 1) /* * Just do not think the "/dev/mtdrX" devices support is need, -- cgit v1.2.3 From 322ea0bbf3003df17b6253f76e572c37d79a6810 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Mar 2016 14:47:18 -0400 Subject: mtd: switch ubi_open_volume_path() to vfs_stat() Signed-off-by: Al Viro --- drivers/mtd/ubi/kapi.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'drivers/mtd') diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c index e844887732fb..437757c89b9e 100644 --- a/drivers/mtd/ubi/kapi.c +++ b/drivers/mtd/ubi/kapi.c @@ -301,27 +301,24 @@ EXPORT_SYMBOL_GPL(ubi_open_volume_nm); */ struct ubi_volume_desc *ubi_open_volume_path(const char *pathname, int mode) { - int error, ubi_num, vol_id, mod; - struct inode *inode; - struct path path; + int error, ubi_num, vol_id; + struct kstat stat; dbg_gen("open volume %s, mode %d", pathname, mode); if (!pathname || !*pathname) return ERR_PTR(-EINVAL); - error = kern_path(pathname, LOOKUP_FOLLOW, &path); + error = vfs_stat(pathname, &stat); if (error) return ERR_PTR(error); - inode = d_backing_inode(path.dentry); - mod = inode->i_mode; - ubi_num = ubi_major2num(imajor(inode)); - vol_id = iminor(inode) - 1; - path_put(&path); - - if (!S_ISCHR(mod)) + if (!S_ISCHR(stat.mode)) return ERR_PTR(-EINVAL); + + ubi_num = ubi_major2num(MAJOR(stat.rdev)); + vol_id = MINOR(stat.rdev) - 1; + if (vol_id >= 0 && ubi_num >= 0) return ubi_open_volume(ubi_num, vol_id, mode); return ERR_PTR(-ENODEV); -- cgit v1.2.3