aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/media-device.c
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2016-04-27 09:39:17 -0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-09-22 10:22:15 -0300
commitcf439d5f4d609b296cabf9a896fcf571b57e260b (patch)
tree075557ee70809e2a734f8bceac8d32357663e258 /drivers/media/media-device.c
parent2950da489520ed66da0934d04ebeb32054263e12 (diff)
[media] media: Determine early whether an IOCTL is supported
Preparation for refactoring media IOCTL handling to unify common parts. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/media-device.c')
-rw-r--r--drivers/media/media-device.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 1795abeda658..f3212640858b 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -419,6 +419,22 @@ static long media_device_get_topology(struct media_device *mdev,
return 0;
}
+#define MEDIA_IOC(__cmd) \
+ [_IOC_NR(MEDIA_IOC_##__cmd)] = { .cmd = MEDIA_IOC_##__cmd }
+
+/* the table is indexed by _IOC_NR(cmd) */
+struct media_ioctl_info {
+ unsigned int cmd;
+};
+
+static const struct media_ioctl_info ioctl_info[] = {
+ MEDIA_IOC(DEVICE_INFO),
+ MEDIA_IOC(ENUM_ENTITIES),
+ MEDIA_IOC(ENUM_LINKS),
+ MEDIA_IOC(SETUP_LINK),
+ MEDIA_IOC(G_TOPOLOGY),
+};
+
static long media_device_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg)
{
@@ -426,6 +442,10 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd,
struct media_device *dev = devnode->media_dev;
long ret;
+ if (_IOC_NR(cmd) >= ARRAY_SIZE(ioctl_info)
+ || ioctl_info[_IOC_NR(cmd)].cmd != cmd)
+ return -ENOIOCTLCMD;
+
mutex_lock(&dev->graph_mutex);
switch (cmd) {
case MEDIA_IOC_DEVICE_INFO:

Privacy Policy