Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Variables
char_dev.c File Reference
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/kdev_t.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/major.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/seq_file.h>
#include <linux/kobject.h>
#include <linux/kobj_map.h>
#include <linux/cdev.h>
#include <linux/mutex.h>
#include <linux/backing-dev.h>
#include <linux/tty.h>
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  char_device_struct
 

Functions

: the name of the device or driver.

register_chrdev_region() - register a range of device numbers : the first in the desired range of device numbers; must include the major number. : the number of consecutive device numbers required

Return value is zero on success, a negative error code on failure.

int register_chrdev_region (dev_t from, unsigned count, const char *name)
 
: the name of the associated device or driver

alloc_chrdev_region() - register a range of char device numbers : output parameter for first assigned number : first of the requested range of minor numbers : the number of minor numbers required

Allocates a range of char device numbers. The major number will be chosen dynamically, and returned (along with the first minor number) in . Returns zero or a negative error code.

int alloc_chrdev_region (dev_t *dev, unsigned baseminor, unsigned count, const char *name)
 

Variables

struct backing_dev_info directly_mappable_cdev_bdi
 

: name of this range of devices

__unregister_chrdev - unregister and destroy a cdev : major device number : first of the range of minor numbers : the number of minor numbers this cdev is occupying

Unregister and destroy the cdev occupying the region described by , and . This function undoes what __register_chrdev() did.

struct file_operations def_chr_fops
 
int __register_chrdev (unsigned int major, unsigned int baseminor, unsigned int count, const char *name, const struct file_operations *fops)
 
void unregister_chrdev_region (dev_t from, unsigned count)
 
void __unregister_chrdev (unsigned int major, unsigned int baseminor, unsigned int count, const char *name)
 
void cdev_put (struct cdev *p)
 
void cd_forget (struct inode *inode)
 
int cdev_add (struct cdev *p, dev_t dev, unsigned count)
 
void cdev_del (struct cdev *p)
 
struct cdevcdev_alloc (void)
 
void cdev_init (struct cdev *cdev, const struct file_operations *fops)
 
void __init chrdev_init (void)
 
 EXPORT_SYMBOL (register_chrdev_region)
 
 EXPORT_SYMBOL (unregister_chrdev_region)
 
 EXPORT_SYMBOL (alloc_chrdev_region)
 
 EXPORT_SYMBOL (cdev_init)
 
 EXPORT_SYMBOL (cdev_alloc)
 
 EXPORT_SYMBOL (cdev_del)
 
 EXPORT_SYMBOL (cdev_add)
 
 EXPORT_SYMBOL (__register_chrdev)
 
 EXPORT_SYMBOL (__unregister_chrdev)
 
 EXPORT_SYMBOL (directly_mappable_cdev_bdi)
 

Function Documentation

int __register_chrdev ( unsigned int  major,
unsigned int  baseminor,
unsigned int  count,
const char name,
const struct file_operations fops 
)

Definition at line 264 of file char_dev.c.

void __unregister_chrdev ( unsigned int  major,
unsigned int  baseminor,
unsigned int  count,
const char name 
)

Definition at line 331 of file char_dev.c.

int alloc_chrdev_region ( dev_t dev,
unsigned  baseminor,
unsigned  count,
const char name 
)

Definition at line 232 of file char_dev.c.

void cd_forget ( struct inode inode)

Definition at line 420 of file char_dev.c.

int cdev_add ( struct cdev p,
dev_t  dev,
unsigned  count 
)

cdev_add() - add a char device to the system : the cdev structure for the device : the first device number for which this device is responsible : the number of consecutive minor numbers corresponding to this device

cdev_add() adds the device represented by to the system, making it live immediately. A negative error code is returned on failure.

Definition at line 472 of file char_dev.c.

struct cdev* cdev_alloc ( void  )
read

cdev_alloc() - allocate a cdev structure

Allocates and returns a cdev structure, or NULL on failure.

Definition at line 540 of file char_dev.c.

void cdev_del ( struct cdev p)

cdev_del() - remove a cdev from the system : the cdev structure to be removed

cdev_del() removes from the system, possibly freeing the structure itself.

Definition at line 501 of file char_dev.c.

void cdev_init ( struct cdev cdev,
const struct file_operations fops 
)

cdev_init() - initialize a cdev structure : the structure to initialize : the file_operations for this device

Initializes , remembering , making it ready to add to the system with cdev_add().

Definition at line 558 of file char_dev.c.

void cdev_put ( struct cdev p)

Definition at line 357 of file char_dev.c.

void __init chrdev_init ( void  )

Definition at line 574 of file char_dev.c.

EXPORT_SYMBOL ( register_chrdev_region  )
EXPORT_SYMBOL ( unregister_chrdev_region  )
EXPORT_SYMBOL ( alloc_chrdev_region  )
EXPORT_SYMBOL ( cdev_init  )
EXPORT_SYMBOL ( cdev_alloc  )
EXPORT_SYMBOL ( cdev_del  )
EXPORT_SYMBOL ( cdev_add  )
EXPORT_SYMBOL ( __register_chrdev  )
EXPORT_SYMBOL ( __unregister_chrdev  )
EXPORT_SYMBOL ( directly_mappable_cdev_bdi  )
int register_chrdev_region ( dev_t  from,
unsigned  count,
const char name 
)

Definition at line 196 of file char_dev.c.

void unregister_chrdev_region ( dev_t  from,
unsigned  count 
)

unregister_chrdev_region() - return a range of device numbers : the first in the range of numbers to unregister : the number of device numbers to unregister

This function will unregister a range of device numbers, starting with . The caller should normally be the one who allocated those numbers in the first place...

Definition at line 307 of file char_dev.c.

Variable Documentation

struct file_operations def_chr_fops
Initial value:
= {
.open = chrdev_open,
.llseek = noop_llseek,
}

Definition at line 445 of file char_dev.c.

struct backing_dev_info directly_mappable_cdev_bdi
Initial value:

Definition at line 34 of file char_dev.c.