Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef _LINUX_CDEV_H |
| 3 | #define _LINUX_CDEV_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | |
Jan Engelhardt | 5ec68b2 | 2006-12-06 20:36:14 -0800 | [diff] [blame] | 5 | #include <linux/kobject.h> |
| 6 | #include <linux/kdev_t.h> |
| 7 | #include <linux/list.h> |
Logan Gunthorpe | 233ed09 | 2017-03-17 12:48:08 -0600 | [diff] [blame] | 8 | #include <linux/device.h> |
Jan Engelhardt | 5ec68b2 | 2006-12-06 20:36:14 -0800 | [diff] [blame] | 9 | |
Jan Engelhardt | 3d8b303 | 2007-01-29 13:19:56 -0800 | [diff] [blame] | 10 | struct file_operations; |
| 11 | struct inode; |
| 12 | struct module; |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | struct cdev { |
| 15 | struct kobject kobj; |
| 16 | struct module *owner; |
Arjan van de Ven | 99ac48f | 2006-03-28 01:56:41 -0800 | [diff] [blame] | 17 | const struct file_operations *ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | struct list_head list; |
| 19 | dev_t dev; |
| 20 | unsigned int count; |
Kees Cook | 3859a27 | 2016-10-28 01:22:25 -0700 | [diff] [blame] | 21 | } __randomize_layout; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Arjan van de Ven | 99ac48f | 2006-03-28 01:56:41 -0800 | [diff] [blame] | 23 | void cdev_init(struct cdev *, const struct file_operations *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | struct cdev *cdev_alloc(void); |
| 26 | |
| 27 | void cdev_put(struct cdev *p); |
| 28 | |
| 29 | int cdev_add(struct cdev *, dev_t, unsigned); |
| 30 | |
Logan Gunthorpe | 233ed09 | 2017-03-17 12:48:08 -0600 | [diff] [blame] | 31 | void cdev_set_parent(struct cdev *p, struct kobject *kobj); |
| 32 | int cdev_device_add(struct cdev *cdev, struct device *dev); |
| 33 | void cdev_device_del(struct cdev *cdev, struct device *dev); |
| 34 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | void cdev_del(struct cdev *); |
| 36 | |
| 37 | void cd_forget(struct inode *); |
| 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #endif |