xref: /freebsd/share/man/man9/devfs_set_cdevpriv.9 (revision a6d11f7139f1379415d6ac544c8ff778059622e6)
1630f2c3bSKonstantin Belousov.\" Copyright (c) 2008 Konstantin Belousov
2630f2c3bSKonstantin Belousov.\" All rights reserved.
3630f2c3bSKonstantin Belousov.\"
4630f2c3bSKonstantin Belousov.\" Redistribution and use in source and binary forms, with or without
5630f2c3bSKonstantin Belousov.\" modification, are permitted provided that the following conditions
6630f2c3bSKonstantin Belousov.\" are met:
7630f2c3bSKonstantin Belousov.\" 1. Redistributions of source code must retain the above copyright
8630f2c3bSKonstantin Belousov.\"    notice, this list of conditions and the following disclaimer.
9630f2c3bSKonstantin Belousov.\" 2. Redistributions in binary form must reproduce the above copyright
10630f2c3bSKonstantin Belousov.\"    notice, this list of conditions and the following disclaimer in the
11630f2c3bSKonstantin Belousov.\"    documentation and/or other materials provided with the distribution.
12630f2c3bSKonstantin Belousov.\"
13630f2c3bSKonstantin Belousov.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14630f2c3bSKonstantin Belousov.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15630f2c3bSKonstantin Belousov.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16630f2c3bSKonstantin Belousov.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17630f2c3bSKonstantin Belousov.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18630f2c3bSKonstantin Belousov.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19630f2c3bSKonstantin Belousov.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20630f2c3bSKonstantin Belousov.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21630f2c3bSKonstantin Belousov.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22630f2c3bSKonstantin Belousov.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23630f2c3bSKonstantin Belousov.\" SUCH DAMAGE.
24630f2c3bSKonstantin Belousov.\"
25630f2c3bSKonstantin Belousov.\" $FreeBSD$
26630f2c3bSKonstantin Belousov.\"
27630f2c3bSKonstantin Belousov.Dd September 8, 2008
28*a6d11f71SRuslan Ermilov.Dt DEVFS_CDEVPRIV 9
29aa12cea2SUlrich Spörlein.Os
30630f2c3bSKonstantin Belousov.Sh NAME
31630f2c3bSKonstantin Belousov.Nm devfs_set_cdevpriv ,
32630f2c3bSKonstantin Belousov.Nm devfs_get_cdevpriv ,
33630f2c3bSKonstantin Belousov.Nm devfs_clear_cdevpriv
34630f2c3bSKonstantin Belousov.Nd manage per-open filedescriptor data for devices
35630f2c3bSKonstantin Belousov.Sh SYNOPSIS
36630f2c3bSKonstantin Belousov.In sys/param.h
37630f2c3bSKonstantin Belousov.In sys/conf.h
38630f2c3bSKonstantin Belousov.Bd -literal
39630f2c3bSKonstantin Belousovtypedef	void (*cdevpriv_dtr_t)(void *data);
40630f2c3bSKonstantin Belousov.Ed
41630f2c3bSKonstantin Belousov.Ft int
426da593a2SEd Schouten.Fn devfs_get_cdevpriv "void **datap"
43630f2c3bSKonstantin Belousov.Ft int
44630f2c3bSKonstantin Belousov.Fn devfs_set_cdevpriv "void *priv" "cdevpriv_dtr_t dtr"
45630f2c3bSKonstantin Belousov.Ft void
46630f2c3bSKonstantin Belousov.Fn devfs_clear_cdevpriv "void"
47630f2c3bSKonstantin Belousov.Sh DESCRIPTION
48630f2c3bSKonstantin BelousovThe
49630f2c3bSKonstantin Belousov.Fn devfs_xxx_cdevpriv
50630f2c3bSKonstantin Belousovfamily of functions allows the
51630f2c3bSKonstantin Belousov.Fa cdev
52630f2c3bSKonstantin Belousovdriver methods to associate some driver-specific data with each
53630f2c3bSKonstantin Belousovuser process
54630f2c3bSKonstantin Belousov.Xr open 2
55630f2c3bSKonstantin Belousovof the device special file.
56630f2c3bSKonstantin BelousovCurrently, functioning of these functions is restricted to the context
57630f2c3bSKonstantin Belousovof the
58630f2c3bSKonstantin Belousov.Fa cdevsw
59630f2c3bSKonstantin Belousovswitch method calls performed as
60630f2c3bSKonstantin Belousov.Xr devfs 5
61630f2c3bSKonstantin Belousovoperations in response to system calls that use filedescriptors.
62630f2c3bSKonstantin Belousov.Pp
63630f2c3bSKonstantin BelousovThe
64630f2c3bSKonstantin Belousov.Fn devfs_set_cdevpriv
65630f2c3bSKonstantin Belousovfunction associates a data pointed by
66630f2c3bSKonstantin Belousov.Va priv
67630f2c3bSKonstantin Belousovwith current calling context (filedescriptor).
68630f2c3bSKonstantin BelousovThe data may be retrieved later, possibly from another call
69630f2c3bSKonstantin Belousovperformed on this filedescriptor, by the
70630f2c3bSKonstantin Belousov.Fn devfs_get_cdevpriv
71630f2c3bSKonstantin Belousovfunction.
72630f2c3bSKonstantin BelousovThe
73630f2c3bSKonstantin Belousov.Fn devfs_clear_cdevpriv
74630f2c3bSKonstantin Belousovdisassociates previously attached data from context.
75630f2c3bSKonstantin BelousovImmediately after
76630f2c3bSKonstantin Belousov.Fn devfs_clear_cdevpriv
77630f2c3bSKonstantin Belousovfinished operating, the
78630f2c3bSKonstantin Belousov.Va dtr
79630f2c3bSKonstantin Belousovcallback is called, with private data supplied
80630f2c3bSKonstantin Belousov.Va data
81630f2c3bSKonstantin Belousovargument.
82630f2c3bSKonstantin Belousov.Pp
83630f2c3bSKonstantin BelousovOn the last filedescriptor close, system automatically arranges
84630f2c3bSKonstantin Belousov.Fn devfs_clear_cdevpriv
85630f2c3bSKonstantin Belousovcall.
86630f2c3bSKonstantin Belousov.Pp
87630f2c3bSKonstantin BelousovIf successful, the functions return 0.
88630f2c3bSKonstantin Belousov.Pp
89630f2c3bSKonstantin BelousovThe function
90630f2c3bSKonstantin Belousov.Fn devfs_set_cdevpriv
91630f2c3bSKonstantin Belousovreturns the following values on error:
92630f2c3bSKonstantin Belousov.Bl -tag -width Er
93630f2c3bSKonstantin Belousov.It Bq Er ENOENT
94630f2c3bSKonstantin BelousovThe current call is not associated with some filedescriptor.
95630f2c3bSKonstantin Belousov.It Bq Er EBUSY
96630f2c3bSKonstantin BelousovThe private driver data is already associated with current
97630f2c3bSKonstantin Belousovfiledescriptor.
98630f2c3bSKonstantin Belousov.El
99630f2c3bSKonstantin Belousov.Pp
100630f2c3bSKonstantin BelousovThe function
101630f2c3bSKonstantin Belousov.Fn devfs_get_cdevpriv
102630f2c3bSKonstantin Belousovreturns the following values on error:
103630f2c3bSKonstantin Belousov.Bl -tag -width Er
104630f2c3bSKonstantin Belousov.It Bq Er EBADF
105630f2c3bSKonstantin BelousovThe current call is not associated with some filedescriptor.
106630f2c3bSKonstantin Belousov.It Bq Er ENOENT
107630f2c3bSKonstantin BelousovThe private driver data was not associated with current
108630f2c3bSKonstantin Belousovfiledescriptor, or
109630f2c3bSKonstantin Belousov.Fn devfs_clear_cdevpriv
110630f2c3bSKonstantin Belousovwas called.
1110a431e07SXin LI.El
112630f2c3bSKonstantin Belousov.Sh SEE ALSO
113630f2c3bSKonstantin Belousov.Xr open 2 ,
114630f2c3bSKonstantin Belousov.Xr close 2 ,
115630f2c3bSKonstantin Belousov.Xr devfs 5 ,
116630f2c3bSKonstantin Belousov.Xr kern_openat 9
117630f2c3bSKonstantin Belousov.Sh HISTORY
118630f2c3bSKonstantin BelousovThe
119630f2c3bSKonstantin Belousov.Fn devfs_cdevpriv
120630f2c3bSKonstantin Belousovfamily of functions first appeared in
121630f2c3bSKonstantin Belousov.Fx 7.1 .
122