diff options
| author | Alexander Viro <viro@www.linux.org.uk> | 2003-05-24 21:42:20 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2003-05-24 21:42:20 -0700 |
| commit | 787d458a0ce55dd6ca7595a3e9003d2e089cd60c (patch) | |
| tree | db6940dddd2ba2472c35999533c1fbfd036d1cf7 /include/linux | |
| parent | 6abc19b443e0df3a63500d184b756878a4692332 (diff) | |
[PATCH] cdev-cidr, part 1
New object: struct cdev. It contains a kobject, a pointer to
file_operations and a pointer to owner module. These guys have a search
structure of the same sort as gendisks and chrdev_open() picks
file_operations from them.
Intended use: embed such animal in driver-owned structure (e.g.
tty_driver) and register it as associated with given range of device
numbers. Generic code will do lookup for such object and use it for the
rest.
The behaviour of register_chrdev() is _not_ changed - it allocates
struct cdev and registers it; any old driver will work as if nothing had
changed.
On that stage we only use it during chrdev_open() to find
file_operations. Later it will be cached in inode->i_cdev (and index in
range - in inode->i_cindex) so that ->open() could get whatever objects
it wants directly without any special-cased lookups, etc.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/cdev.h | 30 | ||||
| -rw-r--r-- | include/linux/fs.h | 6 | ||||
| -rw-r--r-- | include/linux/tty_driver.h | 2 |
3 files changed, 34 insertions, 4 deletions
diff --git a/include/linux/cdev.h b/include/linux/cdev.h new file mode 100644 index 000000000000..faa67d2f4323 --- /dev/null +++ b/include/linux/cdev.h @@ -0,0 +1,30 @@ +#ifndef _LINUX_CDEV_H +#define _LINUX_CDEV_H +#ifdef __KERNEL__ + +struct cdev { + struct kobject kobj; + struct module *owner; + struct file_operations *ops; +}; + +void cdev_init(struct cdev *, struct file_operations *); + +struct cdev *cdev_alloc(void); + +static inline void cdev_put(struct cdev *p) +{ + if (p) + kobject_put(&p->kobj); +} + +struct kobject *cdev_get(struct cdev *); + +int cdev_add(struct cdev *, dev_t, unsigned); + +void cdev_del(struct cdev *); + +void cdev_unmap(dev_t, unsigned); + +#endif +#endif diff --git a/include/linux/fs.h b/include/linux/fs.h index 1b7fac010f1f..6b32c6ab8727 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1056,10 +1056,8 @@ extern void bd_release(struct block_device *); extern void blk_run_queues(void); /* fs/char_dev.c */ -extern int alloc_chrdev_region(dev_t *, unsigned, char *, - struct file_operations *); -extern int register_chrdev_region(dev_t, unsigned, char *, - struct file_operations *); +extern int alloc_chrdev_region(dev_t *, unsigned, char *); +extern int register_chrdev_region(dev_t, unsigned, char *); extern int register_chrdev(unsigned int, const char *, struct file_operations *); extern int unregister_chrdev(unsigned int, const char *); diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index d8d9fc435a3f..ef234da28a8c 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -117,9 +117,11 @@ #include <linux/fs.h> #include <linux/list.h> +#include <linux/cdev.h> struct tty_driver { int magic; /* magic number for this structure */ + struct cdev cdev; struct module *owner; const char *driver_name; const char *name; |
