Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
[cascardo/linux.git] / Documentation / media / uapi / mediactl / media-func-open.rst
1 .. -*- coding: utf-8; mode: rst -*-
2
3 .. _media-func-open:
4
5 ************
6 media open()
7 ************
8
9 Name
10 ====
11
12 media-open - Open a media device
13
14
15 Synopsis
16 ========
17
18 .. code-block:: c
19
20     #include <fcntl.h>
21
22
23 .. c:function:: int open( const char *device_name, int flags )
24     :name: mc-open
25
26 Arguments
27 =========
28
29 ``device_name``
30     Device to be opened.
31
32 ``flags``
33     Open flags. Access mode must be either ``O_RDONLY`` or ``O_RDWR``.
34     Other flags have no effect.
35
36
37 Description
38 ===========
39
40 To open a media device applications call :ref:`open() <media-func-open>` with the
41 desired device name. The function has no side effects; the device
42 configuration remain unchanged.
43
44 When the device is opened in read-only mode, attempts to modify its
45 configuration will result in an error, and ``errno`` will be set to
46 EBADF.
47
48
49 Return Value
50 ============
51
52 :ref:`open() <func-open>` returns the new file descriptor on success. On error,
53 -1 is returned, and ``errno`` is set appropriately. Possible error codes
54 are:
55
56 EACCES
57     The requested access to the file is not allowed.
58
59 EMFILE
60     The process already has the maximum number of files open.
61
62 ENFILE
63     The system limit on the total number of open files has been reached.
64
65 ENOMEM
66     Insufficient kernel memory was available.
67
68 ENXIO
69     No device corresponding to this device special file exists.