1 .\" Copyright (c) 2008 Konstantin Belousov
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .Nm devfs_set_cdevpriv ,
32 .Nm devfs_get_cdevpriv ,
33 .Nm devfs_clear_cdevpriv
34 .Nd manage per-open filedescriptor data for devices
39 typedef void (*cdevpriv_dtr_t)(void *data);
42 .Fn devfs_get_cdevpriv "void **datap"
44 .Fn devfs_set_cdevpriv "void *priv" "cdevpriv_dtr_t dtr"
46 .Fn devfs_clear_cdevpriv "void"
49 .Fn devfs_xxx_cdevpriv
50 family of functions allows the
52 driver methods to associate some driver-specific data with each
55 of the device special file.
56 Currently, functioning of these functions is restricted to the context
59 switch method calls performed as
61 operations in response to system calls that use filedescriptors.
64 .Fn devfs_set_cdevpriv
65 function associates a data pointed by
67 with current calling context (filedescriptor).
68 The data may be retrieved later, possibly from another call
69 performed on this filedescriptor, by the
70 .Fn devfs_get_cdevpriv
73 .Fn devfs_clear_cdevpriv
74 disassociates previously attached data from context.
76 .Fn devfs_clear_cdevpriv
77 finished operating, the
79 callback is called, with private data supplied
83 .Fn devfs_clear_cdevpriv
84 function will be also be called if the open callback
85 function returns an error code.
87 On the last filedescriptor close, system automatically arranges
88 .Fn devfs_clear_cdevpriv
91 If successful, the functions return 0.
94 .Fn devfs_set_cdevpriv
95 returns the following values on error:
98 The current call is not associated with some filedescriptor.
100 The private driver data is already associated with current
105 .Fn devfs_get_cdevpriv
106 returns the following values on error:
109 The current call is not associated with some filedescriptor.
111 The private driver data was not associated with current
113 .Fn devfs_clear_cdevpriv
124 family of functions first appeared in