1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds #ifndef _LINUX_CDEV_H 31da177e4SLinus Torvalds #define _LINUX_CDEV_H 41da177e4SLinus Torvalds 55ec68b2eSJan Engelhardt #include <linux/kobject.h> 65ec68b2eSJan Engelhardt #include <linux/kdev_t.h> 75ec68b2eSJan Engelhardt #include <linux/list.h> 8233ed09dSLogan Gunthorpe #include <linux/device.h> 95ec68b2eSJan Engelhardt 103d8b3036SJan Engelhardt struct file_operations; 113d8b3036SJan Engelhardt struct inode; 123d8b3036SJan Engelhardt struct module; 133d8b3036SJan Engelhardt 141da177e4SLinus Torvalds struct cdev { 151da177e4SLinus Torvalds struct kobject kobj; 161da177e4SLinus Torvalds struct module *owner; 1799ac48f5SArjan van de Ven const struct file_operations *ops; 181da177e4SLinus Torvalds struct list_head list; 191da177e4SLinus Torvalds dev_t dev; 201da177e4SLinus Torvalds unsigned int count; 213859a271SKees Cook } __randomize_layout; 221da177e4SLinus Torvalds 2399ac48f5SArjan van de Ven void cdev_init(struct cdev *, const struct file_operations *); 241da177e4SLinus Torvalds 251da177e4SLinus Torvalds struct cdev *cdev_alloc(void); 261da177e4SLinus Torvalds 271da177e4SLinus Torvalds void cdev_put(struct cdev *p); 281da177e4SLinus Torvalds 291da177e4SLinus Torvalds int cdev_add(struct cdev *, dev_t, unsigned); 301da177e4SLinus Torvalds 31233ed09dSLogan Gunthorpe void cdev_set_parent(struct cdev *p, struct kobject *kobj); 32233ed09dSLogan Gunthorpe int cdev_device_add(struct cdev *cdev, struct device *dev); 33233ed09dSLogan Gunthorpe void cdev_device_del(struct cdev *cdev, struct device *dev); 34233ed09dSLogan Gunthorpe 351da177e4SLinus Torvalds void cdev_del(struct cdev *); 361da177e4SLinus Torvalds 371da177e4SLinus Torvalds void cd_forget(struct inode *); 381da177e4SLinus Torvalds 391da177e4SLinus Torvalds #endif 40