[PATCH v2 09/35] fs: char_dev: introduce lookup_cdev to get cdev by pathname

Jan Kara jack at suse.cz
Mon Aug 3 13:08:45 PDT 2015


On Thu 30-07-15 13:48:05, Dongsheng Yang wrote:
> Function lookup_cdev works similarly with lookup_bdev, we can get
> a cdev instance by lookup_cdev with a parameter of dev name.
> 
> This function will be used in quotactl to get a cdev by a dev name.
> 
> Signed-off-by: Dongsheng Yang <yangds.fnst at cn.fujitsu.com>

The patch looks good. You can add:

Reviewed-by: Jan Kara <jack at suse.com>

								Honza

> ---
>  fs/char_dev.c      | 13 +++++++++++++
>  include/linux/fs.h |  2 ++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/fs/char_dev.c b/fs/char_dev.c
> index e818faa..12c1bd5 100644
> --- a/fs/char_dev.c
> +++ b/fs/char_dev.c
> @@ -474,6 +474,18 @@ out:
>  	return cdev;
>  }
>  
> +struct cdev *lookup_cdev(const char *pathname)
> +{
> +	struct cdev *cdev;
> +	int error;
> +
> +	error = __lookup_dev(pathname, &cdev, NULL);
> +	if (error)
> +		return ERR_PTR(error);
> +
> +	return cdev;
> +}
> +
>  /**
>   * cdev_add() - add a char device to the system
>   * @p: the cdev structure for the device
> @@ -596,6 +608,7 @@ void __init chrdev_init(void)
>  EXPORT_SYMBOL(register_chrdev_region);
>  EXPORT_SYMBOL(unregister_chrdev_region);
>  EXPORT_SYMBOL(alloc_chrdev_region);
> +EXPORT_SYMBOL(lookup_cdev);
>  EXPORT_SYMBOL(cdev_init);
>  EXPORT_SYMBOL(cdev_alloc);
>  EXPORT_SYMBOL(cdev_del);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 5c7d789..860b235 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2308,6 +2308,8 @@ extern void __unregister_chrdev(unsigned int major, unsigned int baseminor,
>  				unsigned int count, const char *name);
>  extern void unregister_chrdev_region(dev_t, unsigned);
>  extern void chrdev_show(struct seq_file *,off_t);
> +extern struct cdev *lookup_cdev(const char *);
> +
>  
>  static inline int register_chrdev(unsigned int major, const char *name,
>  				  const struct file_operations *fops)
> -- 
> 1.8.4.2
> 
-- 
Jan Kara <jack at suse.com>
SUSE Labs, CR



More information about the linux-mtd mailing list