~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/media/media-devnode.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/media/media-devnode.h (Version linux-6.12-rc7) and /include/media/media-devnode.h (Version linux-4.10.17)


  1 /* SPDX-License-Identifier: GPL-2.0-only */    << 
  2 /*                                                  1 /*
  3  * Media device node                                2  * Media device node
  4  *                                                  3  *
  5  * Copyright (C) 2010 Nokia Corporation             4  * Copyright (C) 2010 Nokia Corporation
  6  *                                                  5  *
  7  * Contacts: Laurent Pinchart <laurent.pinchar      6  * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  8  *           Sakari Ailus <sakari.ailus@iki.fi      7  *           Sakari Ailus <sakari.ailus@iki.fi>
  9  *                                                  8  *
                                                   >>   9  * This program is free software; you can redistribute it and/or modify
                                                   >>  10  * it under the terms of the GNU General Public License version 2 as
                                                   >>  11  * published by the Free Software Foundation.
                                                   >>  12  *
                                                   >>  13  * This program is distributed in the hope that it will be useful,
                                                   >>  14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
                                                   >>  15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                                                   >>  16  * GNU General Public License for more details.
                                                   >>  17  *
                                                   >>  18  * You should have received a copy of the GNU General Public License
                                                   >>  19  * along with this program; if not, write to the Free Software
                                                   >>  20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                                                   >>  21  *
 10  * --                                              22  * --
 11  *                                                 23  *
 12  * Common functions for media-related drivers      24  * Common functions for media-related drivers to register and unregister media
 13  * device nodes.                                   25  * device nodes.
 14  */                                                26  */
 15                                                    27 
 16 #ifndef _MEDIA_DEVNODE_H                           28 #ifndef _MEDIA_DEVNODE_H
 17 #define _MEDIA_DEVNODE_H                           29 #define _MEDIA_DEVNODE_H
 18                                                    30 
 19 #include <linux/poll.h>                            31 #include <linux/poll.h>
 20 #include <linux/fs.h>                              32 #include <linux/fs.h>
 21 #include <linux/device.h>                          33 #include <linux/device.h>
 22 #include <linux/cdev.h>                            34 #include <linux/cdev.h>
 23                                                    35 
 24 struct media_device;                               36 struct media_device;
 25                                                    37 
 26 /*                                                 38 /*
 27  * Flag to mark the media_devnode struct as re     39  * Flag to mark the media_devnode struct as registered. Drivers must not touch
 28  * this flag directly, it will be set and clea     40  * this flag directly, it will be set and cleared by media_devnode_register and
 29  * media_devnode_unregister.                       41  * media_devnode_unregister.
 30  */                                                42  */
 31 #define MEDIA_FLAG_REGISTERED   0                  43 #define MEDIA_FLAG_REGISTERED   0
 32                                                    44 
 33 /**                                                45 /**
 34  * struct media_file_operations - Media device     46  * struct media_file_operations - Media device file operations
 35  *                                                 47  *
 36  * @owner: should be filled with %THIS_MODULE      48  * @owner: should be filled with %THIS_MODULE
 37  * @read: pointer to the function that impleme     49  * @read: pointer to the function that implements read() syscall
 38  * @write: pointer to the function that implem     50  * @write: pointer to the function that implements write() syscall
 39  * @poll: pointer to the function that impleme     51  * @poll: pointer to the function that implements poll() syscall
 40  * @ioctl: pointer to the function that implem     52  * @ioctl: pointer to the function that implements ioctl() syscall
 41  * @compat_ioctl: pointer to the function that     53  * @compat_ioctl: pointer to the function that will handle 32 bits userspace
 42  *      calls to the ioctl() syscall on a Kern !!  54  *      calls to the the ioctl() syscall on a Kernel compiled with 64 bits.
 43  * @open: pointer to the function that impleme     55  * @open: pointer to the function that implements open() syscall
 44  * @release: pointer to the function that will     56  * @release: pointer to the function that will release the resources allocated
 45  *      by the @open function.                     57  *      by the @open function.
 46  */                                                58  */
 47 struct media_file_operations {                     59 struct media_file_operations {
 48         struct module *owner;                      60         struct module *owner;
 49         ssize_t (*read) (struct file *, char _     61         ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
 50         ssize_t (*write) (struct file *, const     62         ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
 51         __poll_t (*poll) (struct file *, struc !!  63         unsigned int (*poll) (struct file *, struct poll_table_struct *);
 52         long (*ioctl) (struct file *, unsigned     64         long (*ioctl) (struct file *, unsigned int, unsigned long);
 53         long (*compat_ioctl) (struct file *, u     65         long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
 54         int (*open) (struct file *);               66         int (*open) (struct file *);
 55         int (*release) (struct file *);            67         int (*release) (struct file *);
 56 };                                                 68 };
 57                                                    69 
 58 /**                                                70 /**
 59  * struct media_devnode - Media device node        71  * struct media_devnode - Media device node
 60  * @media_dev:  pointer to struct &media_devic     72  * @media_dev:  pointer to struct &media_device
 61  * @fops:       pointer to struct &media_file_     73  * @fops:       pointer to struct &media_file_operations with media device ops
 62  * @dev:        pointer to struct &device cont     74  * @dev:        pointer to struct &device containing the media controller device
 63  * @cdev:       struct cdev pointer character      75  * @cdev:       struct cdev pointer character device
 64  * @parent:     parent device                      76  * @parent:     parent device
 65  * @minor:      device node minor number           77  * @minor:      device node minor number
 66  * @flags:      flags, combination of the ``ME     78  * @flags:      flags, combination of the ``MEDIA_FLAG_*`` constants
 67  * @release:    release callback called at the     79  * @release:    release callback called at the end of ``media_devnode_release()``
 68  *              routine at media-device.c.         80  *              routine at media-device.c.
 69  *                                                 81  *
 70  * This structure represents a media-related d     82  * This structure represents a media-related device node.
 71  *                                                 83  *
 72  * The @parent is a physical device. It must b     84  * The @parent is a physical device. It must be set by core or device drivers
 73  * before registering the node.                    85  * before registering the node.
 74  */                                                86  */
 75 struct media_devnode {                             87 struct media_devnode {
 76         struct media_device *media_dev;            88         struct media_device *media_dev;
 77                                                    89 
 78         /* device ops */                           90         /* device ops */
 79         const struct media_file_operations *fo     91         const struct media_file_operations *fops;
 80                                                    92 
 81         /* sysfs */                                93         /* sysfs */
 82         struct device dev;              /* med     94         struct device dev;              /* media device */
 83         struct cdev cdev;               /* cha     95         struct cdev cdev;               /* character device */
 84         struct device *parent;          /* dev     96         struct device *parent;          /* device parent */
 85                                                    97 
 86         /* device info */                          98         /* device info */
 87         int minor;                                 99         int minor;
 88         unsigned long flags;            /* Use    100         unsigned long flags;            /* Use bitops to access flags */
 89                                                   101 
 90         /* callbacks */                           102         /* callbacks */
 91         void (*release)(struct media_devnode *    103         void (*release)(struct media_devnode *devnode);
 92 };                                                104 };
 93                                                   105 
 94 /* dev to media_devnode */                        106 /* dev to media_devnode */
 95 #define to_media_devnode(cd) container_of(cd,     107 #define to_media_devnode(cd) container_of(cd, struct media_devnode, dev)
 96                                                   108 
 97 /**                                               109 /**
 98  * media_devnode_register - register a media d    110  * media_devnode_register - register a media device node
 99  *                                                111  *
100  * @mdev: struct media_device we want to regis    112  * @mdev: struct media_device we want to register a device node
101  * @devnode: media device node structure we wa    113  * @devnode: media device node structure we want to register
102  * @owner: should be filled with %THIS_MODULE     114  * @owner: should be filled with %THIS_MODULE
103  *                                                115  *
104  * The registration code assigns minor numbers    116  * The registration code assigns minor numbers and registers the new device node
105  * with the kernel. An error is returned if no    117  * with the kernel. An error is returned if no free minor number can be found,
106  * or if the registration of the device node f    118  * or if the registration of the device node fails.
107  *                                                119  *
108  * Zero is returned on success.                   120  * Zero is returned on success.
109  *                                                121  *
110  * Note that if the media_devnode_register cal    122  * Note that if the media_devnode_register call fails, the release() callback of
111  * the media_devnode structure is *not* called    123  * the media_devnode structure is *not* called, so the caller is responsible for
112  * freeing any data.                              124  * freeing any data.
113  */                                               125  */
114 int __must_check media_devnode_register(struct    126 int __must_check media_devnode_register(struct media_device *mdev,
115                                         struct    127                                         struct media_devnode *devnode,
116                                         struct    128                                         struct module *owner);
117                                                   129 
118 /**                                               130 /**
119  * media_devnode_unregister_prepare - clear th    131  * media_devnode_unregister_prepare - clear the media device node register bit
120  * @devnode: the device node to prepare for un    132  * @devnode: the device node to prepare for unregister
121  *                                                133  *
122  * This clears the passed device register bit.    134  * This clears the passed device register bit. Future open calls will be met
123  * with errors. Should be called before media_    135  * with errors. Should be called before media_devnode_unregister() to avoid
124  * races with unregister and device file open     136  * races with unregister and device file open calls.
125  *                                                137  *
126  * This function can safely be called if the d    138  * This function can safely be called if the device node has never been
127  * registered or has already been unregistered    139  * registered or has already been unregistered.
128  */                                               140  */
129 void media_devnode_unregister_prepare(struct m    141 void media_devnode_unregister_prepare(struct media_devnode *devnode);
130                                                   142 
131 /**                                               143 /**
132  * media_devnode_unregister - unregister a med    144  * media_devnode_unregister - unregister a media device node
133  * @devnode: the device node to unregister        145  * @devnode: the device node to unregister
134  *                                                146  *
135  * This unregisters the passed device. Future     147  * This unregisters the passed device. Future open calls will be met with
136  * errors.                                        148  * errors.
137  *                                                149  *
138  * Should be called after media_devnode_unregi    150  * Should be called after media_devnode_unregister_prepare()
139  */                                               151  */
140 void media_devnode_unregister(struct media_dev    152 void media_devnode_unregister(struct media_devnode *devnode);
141                                                   153 
142 /**                                               154 /**
143  * media_devnode_data - returns a pointer to t    155  * media_devnode_data - returns a pointer to the &media_devnode
144  *                                                156  *
145  * @filp: pointer to struct &file                 157  * @filp: pointer to struct &file
146  */                                               158  */
147 static inline struct media_devnode *media_devn    159 static inline struct media_devnode *media_devnode_data(struct file *filp)
148 {                                                 160 {
149         return filp->private_data;                161         return filp->private_data;
150 }                                                 162 }
151                                                   163 
152 /**                                               164 /**
153  * media_devnode_is_registered - returns true     165  * media_devnode_is_registered - returns true if &media_devnode is registered;
154  *      false otherwise.                          166  *      false otherwise.
155  *                                                167  *
156  * @devnode: pointer to struct &media_devnode.    168  * @devnode: pointer to struct &media_devnode.
157  *                                                169  *
158  * Note: If mdev is NULL, it also returns fals    170  * Note: If mdev is NULL, it also returns false.
159  */                                               171  */
160 static inline int media_devnode_is_registered(    172 static inline int media_devnode_is_registered(struct media_devnode *devnode)
161 {                                                 173 {
162         if (!devnode)                             174         if (!devnode)
163                 return false;                     175                 return false;
164                                                   176 
165         return test_bit(MEDIA_FLAG_REGISTERED,    177         return test_bit(MEDIA_FLAG_REGISTERED, &devnode->flags);
166 }                                                 178 }
167                                                   179 
168 #endif /* _MEDIA_DEVNODE_H */                     180 #endif /* _MEDIA_DEVNODE_H */
169                                                   181 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php