Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide
[sfrench/cifs-2.6.git] / Documentation / media / uapi / cec / cec-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 .. _cec-func-open:
11
12 **********
13 cec open()
14 **********
15
16 Name
17 ====
18
19 cec-open - Open a cec device
20
21 Synopsis
22 ========
23
24 .. code-block:: c
25
26     #include <fcntl.h>
27
28
29 .. c:function:: int open( const char *device_name, int flags )
30    :name: cec-open
31
32
33 Arguments
34 =========
35
36 ``device_name``
37     Device to be opened.
38
39 ``flags``
40     Open flags. Access mode must be ``O_RDWR``.
41
42     When the ``O_NONBLOCK`` flag is given, the
43     :ref:`CEC_RECEIVE <CEC_RECEIVE>` and :ref:`CEC_DQEVENT <CEC_DQEVENT>` ioctls
44     will return the ``EAGAIN`` error code when no message or event is available, and
45     ioctls :ref:`CEC_TRANSMIT <CEC_TRANSMIT>`,
46     :ref:`CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>` and
47     :ref:`CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
48     all return 0.
49
50     Other flags have no effect.
51
52
53 Description
54 ===========
55
56 To open a cec device applications call :c:func:`open() <cec-open>` with the
57 desired device name. The function has no side effects; the device
58 configuration remain unchanged.
59
60 When the device is opened in read-only mode, attempts to modify its
61 configuration will result in an error, and ``errno`` will be set to
62 EBADF.
63
64
65 Return Value
66 ============
67
68 :c:func:`open() <cec-open>` returns the new file descriptor on success. On error,
69 -1 is returned, and ``errno`` is set appropriately. Possible error codes
70 include:
71
72 ``EACCES``
73     The requested access to the file is not allowed.
74
75 ``EMFILE``
76     The process already has the maximum number of files open.
77
78 ``ENFILE``
79     The system limit on the total number of open files has been reached.
80
81 ``ENOMEM``
82     Insufficient kernel memory was available.
83
84 ``ENXIO``
85     No device corresponding to this device special file exists.