Skip to main content.
Navigation:
DENX
>
Training2
>
LddOpenAndRelease
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{LddOpenAndRelease}% The open and release methods * open * called when device opened * prepares _actual_ device for use (initalize it, enable interrupts ...) * every open gets its own =filp= (this allow virtual devices: one for each open) * release * called when device is finally closed (once) * multiple close (=fork=, =dup=) avoided by ref counting. * flush is called for every =close()=, but seldomly used. * does cleanup (stop device, free memory, ...) * Problem: how identify which device has been opened? 1 =imajor()=, =iminor()= 2 use =container_of= macro to find superstructure from =inode->i_cdev= ---++API *open and release:* <verbatim> int open(struct inode *i, struct file *filp) int release(struct inode *i, struct file *filp) </verbatim> *find device numbers given an inode:* <verbatim> unsigned int imajor(struct inode* i); unsigned int iminor(struct inode* i); </verbatim> *find containing structure:* <verbatim> container_of(container_field_ptr, container_type, name_of_container_field); </verbatim>
5.3.3. Registering a character driver
1. Denx Training Topics
5.3.5. The read and write system calls
Prev
Home
Next