mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@kernel.org>
To: Hans Verkuil <hverkuil+cisco@kernel.org>,
	 Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	 Kieran Bingham <kieran.bingham@ideasonboard.com>,
	 Sakari Ailus <sakari.ailus@linux.intel.com>,
	 Mauro Carvalho Chehab <mchehab@kernel.org>,
	 Andy Walls <awalls@md.metrocast.net>,
	Kees Cook <kees@kernel.org>,
	 "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Mattijs Korpershoek <mkorpershoek@kernel.org>,
	 Nicolas Dufresne <nicolas.dufres@collabora.com>,
	 Hans de Goede <hansg@kernel.org>,
	 Michael Riesch <michael.riesch@collabora.com>,
	 Dave Stevenson <dave.stevenson@raspberrypi.com>,
	 Maxime Ripard <mripard@kernel.org>,
	linux-media@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: [PATCH RFC v2 01/16] media: mc: Add struct media_device_fh pointer to media device IOCTL op
Date: Wed, 18 Nov 2026 13:43:45 +0100	[thread overview]
Message-ID: <20261118-v4l2-sensor-detect-v2-1-1bb1a445b556@kernel.org> (raw)
In-Reply-To: <20261118-v4l2-sensor-detect-v2-0-1bb1a445b556@kernel.org>

From: Sakari Ailus <sakari.ailus@linux.intel.com>

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@linux.intel.com>
---
 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


  reply	other threads:[~2026-11-18 12:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 12:43 [PATCH RFC v2 00/16] media: Fault-Tolerant V4L2 Mattijs Korpershoek
2026-11-18 12:43 ` Mattijs Korpershoek [this message]
2026-11-18 12:43 ` [PATCH RFC v2 02/16] media: mc: Add per-file-handle data support Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 03/16] v4l: event: Separate event related information from struct v4l2_fh Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 04/16] v4l: event: Rework data structures for separating events and V4L2 Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 05/16] v4l: event: Split the event framework into generic and V4L2 bits Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 06/16] media: mc: Maintain a list of open file handles in a media device Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 07/16] media: mc: Add MEDIA_IOC_DQEVENT Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 08/16] media: mc: Add MEDIA_EVENT_ENTITY_REGISTRATION Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 09/16] Documentation: media: Add Media controller event documentation Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 10/16] media: media.h: Add entity connection status Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 11/16] media: mc: Add .detect() to media_entity_operations Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 12/16] media: mc: Add MEDIA_IOC_G_ENTITY_STATUS ioctl Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 13/16] media: mc: Add MEDIA_EVENT_ENTITY_STATUS_CHANGE event Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 14/16] media: mc: Add detect polling helpers for drivers Mattijs Korpershoek
2026-11-18 12:43 ` [PATCH RFC v2 15/16] media: imx219: Allow driver probe with missing sensor Mattijs Korpershoek
2026-11-18 12:44 ` [PATCH RFC v2 16/16] media: imx219: Implement .detect() sensor operation Mattijs Korpershoek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261118-v4l2-sensor-detect-v2-1-1bb1a445b556@kernel.org \
    --to=mkorpershoek@kernel.org \
    --cc=awalls@md.metrocast.net \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=gustavoars@kernel.org \
    --cc=hansg@kernel.org \
    --cc=hverkuil+cisco@kernel.org \
    --cc=kees@kernel.org \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=michael.riesch@collabora.com \
    --cc=mripard@kernel.org \
    --cc=nicolas.dufres@collabora.com \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®