xref: /freebsd/share/man/man9/devfs_set_cdevpriv.9 (revision 07da61a6cc849ba69b93275a7af4bae5fae6b509)
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.\"
27*07da61a6SHans Petter Selasky.Dd August 15, 2012
28a6d11f71SRuslan 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.
82*07da61a6SHans Petter SelaskyThe
83*07da61a6SHans Petter Selasky.Fn devfs_clear_cdevpriv
84*07da61a6SHans Petter Selaskyfunction will be also be called if the open callback
85*07da61a6SHans Petter Selaskyfunction returns an error code.
86630f2c3bSKonstantin Belousov.Pp
87630f2c3bSKonstantin BelousovOn the last filedescriptor close, system automatically arranges
88630f2c3bSKonstantin Belousov.Fn devfs_clear_cdevpriv
89630f2c3bSKonstantin Belousovcall.
90630f2c3bSKonstantin Belousov.Pp
91630f2c3bSKonstantin BelousovIf successful, the functions return 0.
92630f2c3bSKonstantin Belousov.Pp
93630f2c3bSKonstantin BelousovThe function
94630f2c3bSKonstantin Belousov.Fn devfs_set_cdevpriv
95630f2c3bSKonstantin Belousovreturns the following values on error:
96630f2c3bSKonstantin Belousov.Bl -tag -width Er
97630f2c3bSKonstantin Belousov.It Bq Er ENOENT
98630f2c3bSKonstantin BelousovThe current call is not associated with some filedescriptor.
99630f2c3bSKonstantin Belousov.It Bq Er EBUSY
100630f2c3bSKonstantin BelousovThe private driver data is already associated with current
101630f2c3bSKonstantin Belousovfiledescriptor.
102630f2c3bSKonstantin Belousov.El
103630f2c3bSKonstantin Belousov.Pp
104630f2c3bSKonstantin BelousovThe function
105630f2c3bSKonstantin Belousov.Fn devfs_get_cdevpriv
106630f2c3bSKonstantin Belousovreturns the following values on error:
107630f2c3bSKonstantin Belousov.Bl -tag -width Er
108630f2c3bSKonstantin Belousov.It Bq Er EBADF
109630f2c3bSKonstantin BelousovThe current call is not associated with some filedescriptor.
110630f2c3bSKonstantin Belousov.It Bq Er ENOENT
111630f2c3bSKonstantin BelousovThe private driver data was not associated with current
112630f2c3bSKonstantin Belousovfiledescriptor, or
113630f2c3bSKonstantin Belousov.Fn devfs_clear_cdevpriv
114630f2c3bSKonstantin Belousovwas called.
1150a431e07SXin LI.El
116630f2c3bSKonstantin Belousov.Sh SEE ALSO
117630f2c3bSKonstantin Belousov.Xr open 2 ,
118630f2c3bSKonstantin Belousov.Xr close 2 ,
119630f2c3bSKonstantin Belousov.Xr devfs 5 ,
120630f2c3bSKonstantin Belousov.Xr kern_openat 9
121630f2c3bSKonstantin Belousov.Sh HISTORY
122630f2c3bSKonstantin BelousovThe
123630f2c3bSKonstantin Belousov.Fn devfs_cdevpriv
124630f2c3bSKonstantin Belousovfamily of functions first appeared in
125630f2c3bSKonstantin Belousov.Fx 7.1 .
126