From: Philipp Zabel <p.zabel@pengutronix.de>
To: linux-media@vger.kernel.org
Cc: Steve Longerbeam <steve_longerbeam@mentor.com>,
Sascha Hauer <s.hauer@pengutronix.de>
Subject: [RFC PATCH 11/26] [media] v4l2: subdev: Add v4l2_device_register_subdev_node function
Date: Thu, 12 Jun 2014 19:06:25 +0200 [thread overview]
Message-ID: <1402592800-2925-12-git-send-email-p.zabel@pengutronix.de> (raw)
In-Reply-To: <1402592800-2925-1-git-send-email-p.zabel@pengutronix.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
We currently only have a function that registers all subdev
device nodes for a v4l2 device at once. This assumes that
there is a point when all subdevices are known and that all
subdevices are needed to make a functional device. With the
advent of asynchronous subdevices this may no longer be the
case, so add a function which registers a single subdevice for
a given v4l2 device only and let v4l2_device_register_subdev_nodes
use this function.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/media/v4l2-core/v4l2-device.c | 63 ++++++++++++++++++++---------------
include/media/v4l2-device.h | 5 +++
2 files changed, 42 insertions(+), 26 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
index 02d1b63..4211163 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -205,9 +205,43 @@ static void v4l2_device_release_subdev_node(struct video_device *vdev)
kfree(vdev);
}
-int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
+int v4l2_device_register_subdev_node(struct v4l2_device *v4l2_dev,
+ struct v4l2_subdev *sd)
{
struct video_device *vdev;
+ int err;
+
+ if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE))
+ return 0;
+
+ vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
+ if (!vdev)
+ return -ENOMEM;
+
+ video_set_drvdata(vdev, sd);
+ strlcpy(vdev->name, sd->name, sizeof(vdev->name));
+ vdev->v4l2_dev = v4l2_dev;
+ vdev->fops = &v4l2_subdev_fops;
+ vdev->release = v4l2_device_release_subdev_node;
+ vdev->ctrl_handler = sd->ctrl_handler;
+ err = __video_register_device(vdev, VFL_TYPE_SUBDEV, -1, 1,
+ sd->owner);
+ if (err < 0) {
+ kfree(vdev);
+ return err;
+ }
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ sd->entity.info.v4l.major = VIDEO_MAJOR;
+ sd->entity.info.v4l.minor = vdev->minor;
+#endif
+ sd->devnode = vdev;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_device_register_subdev_node);
+
+int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
+{
struct v4l2_subdev *sd;
int err;
@@ -215,32 +249,9 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
* V4L2_SUBDEV_FL_HAS_DEVNODE flag.
*/
list_for_each_entry(sd, &v4l2_dev->subdevs, list) {
- if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE))
- continue;
-
- vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
- if (!vdev) {
- err = -ENOMEM;
- goto clean_up;
- }
-
- video_set_drvdata(vdev, sd);
- strlcpy(vdev->name, sd->name, sizeof(vdev->name));
- vdev->v4l2_dev = v4l2_dev;
- vdev->fops = &v4l2_subdev_fops;
- vdev->release = v4l2_device_release_subdev_node;
- vdev->ctrl_handler = sd->ctrl_handler;
- err = __video_register_device(vdev, VFL_TYPE_SUBDEV, -1, 1,
- sd->owner);
- if (err < 0) {
- kfree(vdev);
+ err = v4l2_device_register_subdev_node(v4l2_dev, sd);
+ if (err)
goto clean_up;
- }
-#if defined(CONFIG_MEDIA_CONTROLLER)
- sd->entity.info.v4l.major = VIDEO_MAJOR;
- sd->entity.info.v4l.minor = vdev->minor;
-#endif
- sd->devnode = vdev;
}
return 0;
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index c9b1593..512cc4b 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -120,6 +120,11 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
int __must_check
v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev);
+/* Register a single device node for a subdev of a v4l2 device. */
+int __must_check
+v4l2_device_register_subdev_node(struct v4l2_device *v4l2_dev,
+ struct v4l2_subdev *sd);
+
/* Iterate over all subdevs. */
#define v4l2_device_for_each_subdev(sd, v4l2_dev) \
list_for_each_entry(sd, &(v4l2_dev)->subdevs, list)
--
2.0.0.rc2
next prev parent reply other threads:[~2014-06-12 17:06 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-12 17:06 [RFC PATCH 00/26] i.MX5/6 IPUv3 CSI/IC Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 01/26] gpu: ipu-v3: Add IC support Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 02/26] gpu: ipu-v3: Register IC with IPUv3 Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 03/26] gpu: ipu-v3: Add function to setup CP channel as interlaced Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 04/26] gpu: ipu-v3: Add ipu_cpmem_get_buffer function Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 05/26] gpu: ipu-v3: Add support for partial interleaved YCbCr 4:2:0 (NV12) format Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 06/26] gpu: ipu-v3: Add support for planar YUV 4:2:2 (YUV422P) format Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 07/26] imx-drm: currently only IPUv3 is supported, make it mandatory Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 08/26] [media] imx-ipu: add ipu media common code Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 09/26] [media] imx-ipu: Add i.MX IPUv3 scaler driver Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 10/26] [media] imx-ipu: Add i.MX IPUv3 deinterlacer driver Philipp Zabel
2014-06-12 17:06 ` Philipp Zabel [this message]
2014-06-12 17:06 ` [RFC PATCH 12/26] [media] v4l2: Fix V4L2_CID_PIXEL_RATE Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 13/26] [media] v4l2 async: remove from notifier list Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 14/26] [media] Add i.MX SoC wide media device driver Philipp Zabel
2014-06-24 10:04 ` Dave Müller
2014-06-24 14:05 ` Dave Müller
2014-06-12 17:06 ` [RFC PATCH 15/26] [media] imx-ipu: Add i.MX IPUv3 capture driver Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 16/26] [media] ipuv3-csi: Skip 3 lines for NTSC BT.656 Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 17/26] [media] ipuv3-csi: Pass ipucsi to v4l2_media_subdev_s_power Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 18/26] [media] ipuv3-csi: make subdev controls available on video device Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 19/26] [media] imx-ipuv3-csi: Add support for temporarily stopping the stream on sync loss Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 20/26] [media] imx-ipuv3-csi: Export sync lock event to userspace Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 21/26] [media] v4l2-subdev.h: Add lock status notification Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 22/26] [media] v4l2-subdev: Export v4l2_subdev_fops Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 23/26] mfd: syscon: add child device support Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 24/26] [media] imx: Add video switch Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 25/26] ARM: dts: Add IPU aliases on i.MX6 Philipp Zabel
2014-06-12 17:06 ` [RFC PATCH 26/26] ARM: dts: imx6qdl: Add mipi_ipu1/2 multiplexers, mipi_csi, and their connections Philipp Zabel
2014-08-05 6:52 ` [RFC PATCH 00/26] i.MX5/6 IPUv3 CSI/IC Zahari Doychev
2015-10-27 13:10 ` Fabio Estevam
2015-12-01 12:08 ` Fabio Estevam
2015-12-14 15:07 ` Tim Harvey
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=1402592800-2925-12-git-send-email-p.zabel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=linux-media@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=steve_longerbeam@mentor.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;
as well as URLs for NNTP newsgroup(s).