Merge tag 'driver-core-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / Documentation / media / uapi / mediactl / media-func-open.rst
1 .. Permission is granted to copy, distribute and/or modify this
2 .. document under the terms of the GNU Free Documentation License,
3 .. Version 1.1 or any later version published by the Free Software
4 .. Foundation, with no Invariant Sections, no Front-Cover Texts
5 .. and no Back-Cover Texts. A copy of the license is included at
6 .. Documentation/media/uapi/fdl-appendix.rst.
7 ..
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9
10 .. _media-func-open:
11
12 ************
13 media open()
14 ************
15
16 Name
17 ====
18
19 media-open - Open a media device
20
21
22 Synopsis
23 ========
24
25 .. code-block:: c
26
27     #include <fcntl.h>
28
29
30 .. c:function:: int open( const char *device_name, int flags )
31     :name: mc-open
32
33 Arguments
34 =========
35
36 ``device_name``
37     Device to be opened.
38
39 ``flags``
40     Open flags. Access mode must be either ``O_RDONLY`` or ``O_RDWR``.
41     Other flags have no effect.
42
43
44 Description
45 ===========
46
47 To open a media device applications call :ref:`open() <media-func-open>` with the
48 desired device name. The function has no side effects; the device
49 configuration remain unchanged.
50
51 When the device is opened in read-only mode, attempts to modify its
52 configuration will result in an error, and ``errno`` will be set to
53 EBADF.
54
55
56 Return Value
57 ============
58
59 :ref:`open() <func-open>` returns the new file descriptor on success. On error,
60 -1 is returned, and ``errno`` is set appropriately. Possible error codes
61 are:
62
63 EACCES
64     The requested access to the file is not allowed.
65
66 EMFILE
67     The process already has the maximum number of files open.
68
69 ENFILE
70     The system limit on the total number of open files has been reached.
71
72 ENOMEM
73     Insufficient kernel memory was available.
74
75 ENXIO
76     No device corresponding to this device special file exists.