xref: /OK3568_Linux_fs/kernel/include/linux/cdev.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _LINUX_CDEV_H
3*4882a593Smuzhiyun #define _LINUX_CDEV_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/kobject.h>
6*4882a593Smuzhiyun #include <linux/kdev_t.h>
7*4882a593Smuzhiyun #include <linux/list.h>
8*4882a593Smuzhiyun #include <linux/device.h>
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun struct file_operations;
11*4882a593Smuzhiyun struct inode;
12*4882a593Smuzhiyun struct module;
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun struct cdev {
15*4882a593Smuzhiyun 	struct kobject kobj;
16*4882a593Smuzhiyun 	struct module *owner;
17*4882a593Smuzhiyun 	const struct file_operations *ops;
18*4882a593Smuzhiyun 	struct list_head list;
19*4882a593Smuzhiyun 	dev_t dev;
20*4882a593Smuzhiyun 	unsigned int count;
21*4882a593Smuzhiyun } __randomize_layout;
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun void cdev_init(struct cdev *, const struct file_operations *);
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun struct cdev *cdev_alloc(void);
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun void cdev_put(struct cdev *p);
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun int cdev_add(struct cdev *, dev_t, unsigned);
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun void cdev_set_parent(struct cdev *p, struct kobject *kobj);
32*4882a593Smuzhiyun int cdev_device_add(struct cdev *cdev, struct device *dev);
33*4882a593Smuzhiyun void cdev_device_del(struct cdev *cdev, struct device *dev);
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun void cdev_del(struct cdev *);
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun void cd_forget(struct inode *);
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #endif
40