[PATCH RFC v2 01/16] media: mc: Add struct media_device_fh pointer to media device IOCTL op
From: Mattijs Korpershoek
Date: Wed Nov 18 2026 - 07:44:16 EST
From: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
In order to use the struct media_device_fh pointer in IOCTL callbacks, add
it to the callback, between the Media device and the IOCTL argument.
Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
---
drivers/media/mc/mc-device.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c
index f8ea7cfe10b2..32e5c9f02ed4 100644
--- a/drivers/media/mc/mc-device.c
+++ b/drivers/media/mc/mc-device.c
@@ -55,7 +55,8 @@ static int media_device_close(struct file *filp)
return 0;
}
-static long media_device_get_info(struct media_device *dev, void *arg)
+static long media_device_get_info(struct media_device *dev,
+ struct file *file, void *arg)
{
struct media_device_info *info = arg;
@@ -95,7 +96,8 @@ static struct media_entity *find_entity(struct media_device *mdev, u32 id)
return NULL;
}
-static long media_device_enum_entities(struct media_device *mdev, void *arg)
+static long media_device_enum_entities(struct media_device *mdev,
+ struct file *file, void *arg)
{
struct media_entity_desc *entd = arg;
struct media_entity *ent;
@@ -148,7 +150,8 @@ static void media_device_kpad_to_upad(const struct media_pad *kpad,
upad->flags = kpad->flags;
}
-static long media_device_enum_links(struct media_device *mdev, void *arg)
+static long media_device_enum_links(struct media_device *mdev,
+ struct file *file, void *arg)
{
struct media_links_enum *links = arg;
struct media_entity *entity;
@@ -197,7 +200,8 @@ static long media_device_enum_links(struct media_device *mdev, void *arg)
return 0;
}
-static long media_device_setup_link(struct media_device *mdev, void *arg)
+static long media_device_setup_link(struct media_device *mdev,
+ struct file *file, void *arg)
{
struct media_link_desc *linkd = arg;
struct media_link *link = NULL;
@@ -227,7 +231,8 @@ static long media_device_setup_link(struct media_device *mdev, void *arg)
return __media_entity_setup_link(link, linkd->flags);
}
-static long media_device_get_topology(struct media_device *mdev, void *arg)
+static long media_device_get_topology(struct media_device *mdev,
+ struct file *file, void *arg)
{
struct media_v2_topology *topo = arg;
struct media_entity *entity;
@@ -370,7 +375,8 @@ static long media_device_get_topology(struct media_device *mdev, void *arg)
return ret;
}
-static long media_device_request_alloc(struct media_device *mdev, void *arg)
+static long media_device_request_alloc(struct media_device *mdev,
+ struct file *file, void *arg)
{
int *alloc_fd = arg;
@@ -417,7 +423,8 @@ static long copy_arg_to_user(void __user *uarg, void *karg, unsigned int cmd)
struct media_ioctl_info {
unsigned int cmd;
unsigned short flags;
- long (*fn)(struct media_device *dev, void *arg);
+ long (*fn)(struct media_device *dev, struct file *file,
+ void *arg);
long (*arg_from_user)(void *karg, void __user *uarg, unsigned int cmd);
long (*arg_to_user)(void __user *uarg, void *karg, unsigned int cmd);
};
@@ -462,7 +469,7 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd,
if (info->flags & MEDIA_IOC_FL_GRAPH_MUTEX)
mutex_lock(&dev->graph_mutex);
- ret = info->fn(dev, karg);
+ ret = info->fn(dev, filp, karg);
if (info->flags & MEDIA_IOC_FL_GRAPH_MUTEX)
mutex_unlock(&dev->graph_mutex);
@@ -487,6 +494,7 @@ struct media_links_enum32 {
};
static long media_device_enum_links32(struct media_device *mdev,
+ struct file *file,
struct media_links_enum32 __user *ulinks)
{
struct media_links_enum links;
@@ -503,7 +511,7 @@ static long media_device_enum_links32(struct media_device *mdev,
links.pads = compat_ptr(pads_ptr);
links.links = compat_ptr(links_ptr);
- ret = media_device_enum_links(mdev, &links);
+ ret = media_device_enum_links(mdev, file, &links);
if (ret)
return ret;
@@ -525,8 +533,8 @@ static long media_device_compat_ioctl(struct file *filp, unsigned int cmd,
switch (cmd) {
case MEDIA_IOC_ENUM_LINKS32:
mutex_lock(&dev->graph_mutex);
- ret = media_device_enum_links32(dev,
- (struct media_links_enum32 __user *)arg);
+ ret = media_device_enum_links32(dev, filp,
+ (struct media_links_enum32 __user *)arg);
mutex_unlock(&dev->graph_mutex);
break;
--
2.56.0