blob: 0e8cd6293debbaa177d9ae232e61bbb500b40c7d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _LINUX_CDEV_H
3#define _LINUX_CDEV_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
Jan Engelhardt5ec68b22006-12-06 20:36:14 -08005#include <linux/kobject.h>
6#include <linux/kdev_t.h>
7#include <linux/list.h>
Logan Gunthorpe233ed092017-03-17 12:48:08 -06008#include <linux/device.h>
Jan Engelhardt5ec68b22006-12-06 20:36:14 -08009
Jan Engelhardt3d8b3032007-01-29 13:19:56 -080010struct file_operations;
11struct inode;
12struct module;
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014struct cdev {
15 struct kobject kobj;
16 struct module *owner;
Arjan van de Ven99ac48f2006-03-28 01:56:41 -080017 const struct file_operations *ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 struct list_head list;
19 dev_t dev;
20 unsigned int count;
Kees Cook3859a272016-10-28 01:22:25 -070021} __randomize_layout;
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Arjan van de Ven99ac48f2006-03-28 01:56:41 -080023void cdev_init(struct cdev *, const struct file_operations *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25struct cdev *cdev_alloc(void);
26
27void cdev_put(struct cdev *p);
28
29int cdev_add(struct cdev *, dev_t, unsigned);
30
Logan Gunthorpe233ed092017-03-17 12:48:08 -060031void cdev_set_parent(struct cdev *p, struct kobject *kobj);
32int cdev_device_add(struct cdev *cdev, struct device *dev);
33void cdev_device_del(struct cdev *cdev, struct device *dev);
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035void cdev_del(struct cdev *);
36
37void cd_forget(struct inode *);
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#endif