OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / linux-man9 / original / man9 / register_chrdev.9
1 .\" -*- nroff -*-
2 .TH register_chrdev 9 "$Date:$" "Linux 2.0" "Kernel Functions"
3 .SH NAME
4 register_chrdev, unregister_chrdev \- register a driver major number
5 .SH SYNOPSIS
6 .B #include <linux/fs.h>
7 .sp
8 .BI "int register_chrdev(unsigned int " major ", const char*" name ","
9 .BI "struct file_operations*" ops ");"
10 .br
11 .BI "int unregister_chrdev(unsigned int " major ", const char *" name ");"
12 .SH DESCRIPTION
13 The
14 .B register_chrdev
15 function associates a character major number with set of driver entry
16 points. The file_operations structure contains pointers to functions
17 that the the driver uses to implement the kernel interface to the
18 driver.
19 .PP
20 The paramter
21 .I major
22 is the character major number assigned to the device driver and to be
23 mapped to the function table. The
24 .I name
25 parameter is a short name for the device and is displayed in the
26 The
27 .I "/proc/devices"
28 list. It also must exactly match the name passed to
29 .B unregister_chrdev
30 function when releasing the functions.
31 .PP
32 A device driver module may register as many different major numbers as
33 it supports, though this is not typically done.
34 .PP
35 The
36 .B unregister_chrdev
37 function releases the major number, and is normally called in the
38 module_cleanup function to remove the driver from the kernel.
39 .SH "RETURN VALUE"
40 On success,
41 .B register_chrdev
42 returns 0 if
43 .I major
44 is a number other then 0, otherwise Linux will choose a major number
45 and return the chosen value.
46 .PP
47 If there is an error, one of the following codes is returned instead:
48 .RS
49 .TP
50 -EINVAL
51 The specified number is not valid (> MAX_CHRDEV)
52 .TP
53 -EBUSY
54 The major number is busy
55 .RE
56 .PP
57 The
58 .B unregister_chrdev
59 function will return 0 if successful, or
60 .B "-EINVAL"
61 if the major number is not registered with the matching name.
62 .SH AVAILABILITY
63 Linux 1.0+
64 .SH "SEE ALSO"
65 .BR register_blkdev "(9) " mknod "(2)"
66 .SH AUTHOR
67 Stephen Williams (steve@icarus.com)
68 .SH BUGS