Skip to main content.
Navigation:
DENX
>
Training2
>
LddDeviceNumbers
Translations:
Edit
|
Attach
|
Raw
|
Ref-By
|
Printable
|
More
Training2
Sections of this site:
DENX Home
|
DULG
|
ELDK-5
|
Know
|
Training
|
U-Boot
|
U-Bootdoc
Topics
Training2 Home
Changes
Index
Search
Go
List of pages in Training2
Search
%SECTION0{name=LddDeviceNumbers}% Device numbers * major and minor numbers * used by kernel to identify driver that handles request * many statically assigned (=Documentation/devices.txt=) (but no new ones will be) * need to be allocated (=claimed) * static or dynamic allocation * mapping number -> device can vary (1:1, n:1) ---++API: Device numbers *type:* <verbatim> dev_t </verbatim> _include/linux/types.h_ *creation, accessors:* <verbatim> MKDEV(int major, int minor) MAJOR(dev_t dev) MINOR(dev_t dev) </verbatim> _include/linux/kdev_t.h_ *register a (known) range of numbers:* <verbatim> int register_chrdev_region(dev_t first, unsigned int count, char *name); </verbatim> * *first:* first number in range * *count:* how many minor numbers? * *name:* name of device *allocate a range of free numbers:* <verbatim> int alloc_chrdev_region(dev_t *dev, unsigned int firstminor, unsigned int count, char *name); </verbatim> * *dev:* pointer to existing dev_t, will contain allocated major/minor * *firstminor:* usually 0 (but not required) * *name:* name of device *free allocated or registered range of numbers:* <verbatim> void unregister_chrdev_region(dev_t first, unsigned int count); </verbatim> _include/linux/fs.h_
5.3.1. Introduction to character drivers
1. Denx Training Topics
5.3.3. Registering a character driver
Prev
Home
Next