Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: f699c4c149
94 lines (69 sloc) 2.616 kb
print_hex_dump_bytes - need dev_dbg_print_hex_dump_bytes()
What we have today:
extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);
extern int register_chrdev_region(dev_t, unsigned, const char *);
extern int __register_chrdev(unsigned int major, unsigned int baseminor,
unsigned int count, const char *name,
const struct file_operations *fops);
extern void __unregister_chrdev(unsigned int major, unsigned int baseminor,
unsigned int count, const char *name);
extern void unregister_chrdev_region(dev_t, unsigned);
extern void chrdev_show(struct seq_file *,off_t);
static inline int register_chrdev(unsigned int major, const char *name,
const struct file_operations *fops)
return __register_chrdev(major, 0, 256, name, fops);
static inline void unregister_chrdev(unsigned int major, const char *name)
__unregister_chrdev(major, 0, 256, name);
Then there is the whole cdev.h stuff:
cdev_init(struct cdev *, const struct file_operations)
cdev_del(struct cdev *)
cdev_add(struct cdev *, dev_t, unsigned)
What we want:
Register a char dev for a region and assign it a file operations.
Unregister the region.
That's it.
owner of module (different at times from fops)
major/minor range, or dynamic
name (for /proc)
Watch out, i_cdev is a cdev in the inode, and it can be embedded within
something else that grabs it when open() is called, so we need to know
the size of struct cdev in drivers, it can't just be a "token".
register needs:
register_chrdev_region, with same options as cdev_add() had
register_chrdev() and unregister_chrdev() are the "simple" ones, need to
combine cdev with those somehow to make things easier for poeple to keep
from the cdev_init/add/del mess.
Unless we really want to force everyone to do this? It might be nicer...
cdev * cdev_create(major, minor, fops, name, private);
cdev_destroy(* cdev);
Can break cdev_create() into two parts:
then after cdev_init(), can do "special" things if needed:
- different module owner
- different private
- anything else?
TODO - talk with Kay about better names
set inode pointer to be cdev *.
once have cdev *:
void *cdev_private(cdev *)
gets private back
- can get anything else back with accessor function, not
direct as we don't want to expose structure to
anything outside of the cdev core to prevent people
from poking with things directly. But is this really
Jump to Line
Something went wrong with that request. Please try again.