All of lore.kernel.org
 help / color / mirror / Atom feed
From: laurent.pinchart@ideasonboard.com
To: linux-media@vger.kernel.org
Cc: sakari.ailus@maxwell.research.nokia.com, hverkuil@xs4all.nl,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: [RFC/PATCH 06/14] v4l-mc: Remove subdev v4l2_dev field
Date: Tue, 20 Oct 2009 03:12:16 +0200	[thread overview]
Message-ID: <20091020011215.243408842@ideasonboard.com> (raw)
In-Reply-To: 20091020011210.623421213@ideasonboard.com

[-- Attachment #1: v4l-mc-remove-subdev-v4l2-dev-field.diff --]
[-- Type: text/plain, Size: 4163 bytes --]

A pointer to the v4l2_device is stored in the v4l2_entity structure that
v4l2_subdev derives from. There is no need to hold an extra copy of the
pointer.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Index: v4l-dvb-mc/linux/include/media/v4l2-subdev.h
===================================================================
--- v4l-dvb-mc.orig/linux/include/media/v4l2-subdev.h
+++ v4l-dvb-mc/linux/include/media/v4l2-subdev.h
@@ -261,7 +261,6 @@ struct v4l2_subdev {
 	struct v4l2_entity entity;
 	struct module *owner;
 	u32 flags;
-	struct v4l2_device *v4l2_dev;
 	const struct v4l2_subdev_ops *ops;
 	/* name must be unique */
 	char name[V4L2_SUBDEV_NAME_SIZE];
@@ -290,7 +289,6 @@ static inline void v4l2_subdev_init(stru
 	sd->entity.subtype = V4L2_SUBDEV_TYPE_MISC;
 	sd->entity.name = sd->name;
 	sd->ops = ops;
-	sd->v4l2_dev = NULL;
 	sd->flags = 0;
 	sd->name[0] = '\0';
 	sd->grp_id = 0;
@@ -308,7 +306,7 @@ static inline void v4l2_subdev_init(stru
 
 /* Send a notification to v4l2_device. */
 #define v4l2_subdev_notify(sd, notification, arg)			   \
-	((!(sd) || !(sd)->v4l2_dev || !(sd)->v4l2_dev->notify) ? -ENODEV : \
-	 (sd)->v4l2_dev->notify((sd), (notification), (arg)))
+	((!(sd) || !(sd)->entity.parent || !(sd)->entity.parent->notify) ? \
+	  -ENODEV : (sd)->entity.parent->notify((sd), (notification), (arg)))
 
 #endif
Index: v4l-dvb-mc/linux/drivers/media/video/bt819.c
===================================================================
--- v4l-dvb-mc.orig/linux/drivers/media/video/bt819.c
+++ v4l-dvb-mc/linux/drivers/media/video/bt819.c
@@ -256,7 +256,7 @@ static int bt819_s_std(struct v4l2_subde
 
 	v4l2_dbg(1, debug, sd, "set norm %llx\n", (unsigned long long)std);
 
-	if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL)
+	if (sd->entity.parent == NULL || sd->entity.parent->notify == NULL)
 		v4l2_err(sd, "no notify found!\n");
 
 	if (std & V4L2_STD_NTSC) {
@@ -308,7 +308,7 @@ static int bt819_s_routing(struct v4l2_s
 	if (input < 0 || input > 7)
 		return -EINVAL;
 
-	if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL)
+	if (sd->entity.parent == NULL || sd->entity.parent->notify == NULL)
 		v4l2_err(sd, "no notify found!\n");
 
 	if (decoder->input != input) {
Index: v4l-dvb-mc/linux/drivers/media/video/v4l2-device.c
===================================================================
--- v4l-dvb-mc.orig/linux/drivers/media/video/v4l2-device.c
+++ v4l-dvb-mc/linux/drivers/media/video/v4l2-device.c
@@ -333,10 +333,10 @@ int v4l2_device_register_subdev(struct v
 	if (v4l2_dev == NULL || sd == NULL || !sd->name[0])
 		return -EINVAL;
 	/* Warn if we apparently re-register a subdev */
-	WARN_ON(sd->v4l2_dev != NULL);
+	WARN_ON(sd->entity.parent != NULL);
 	if (!try_module_get(sd->owner))
 		return -ENODEV;
-	sd->v4l2_dev = v4l2_dev;
+	sd->entity.parent = v4l2_dev;
 	spin_lock(&v4l2_dev->lock);
 	sd->entity.id = v4l2_dev->subdev_id++;
 	list_add_tail(&sd->entity.list, &v4l2_dev->subdevs);
@@ -348,12 +348,12 @@ EXPORT_SYMBOL_GPL(v4l2_device_register_s
 void v4l2_device_unregister_subdev(struct v4l2_subdev *sd)
 {
 	/* return if it isn't registered */
-	if (sd == NULL || sd->v4l2_dev == NULL)
+	if (sd == NULL || sd->entity.parent == NULL)
 		return;
-	spin_lock(&sd->v4l2_dev->lock);
+	spin_lock(&sd->entity.parent->lock);
 	list_del(&sd->entity.list);
-	spin_unlock(&sd->v4l2_dev->lock);
-	sd->v4l2_dev = NULL;
+	spin_unlock(&sd->entity.parent->lock);
+	sd->entity.parent = NULL;
 	module_put(sd->owner);
 }
 EXPORT_SYMBOL_GPL(v4l2_device_unregister_subdev);
Index: v4l-dvb-mc/linux/drivers/media/video/zoran/zoran_card.c
===================================================================
--- v4l-dvb-mc.orig/linux/drivers/media/video/zoran/zoran_card.c
+++ v4l-dvb-mc/linux/drivers/media/video/zoran/zoran_card.c
@@ -1196,7 +1196,7 @@ zoran_setup_videocodec (struct zoran *zr
 
 static void zoran_subdev_notify(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
 {
-	struct zoran *zr = to_zoran(sd->v4l2_dev);
+	struct zoran *zr = to_zoran(sd->entity.parent);
 
 	/* Bt819 needs to reset its FIFO buffer using #FRST pin and
 	   LML33 card uses GPIO(7) for that. */



  parent reply	other threads:[~2009-10-20  8:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-20  1:12 [RFC/PATCH 00/14] Media controller update based on Hans' v4l-dvb-mc tree laurent.pinchart
2009-10-20  1:12 ` [RFC/PATCH 01/14] v4l-mc: Rename pins to pads laurent.pinchart
2009-10-20  1:12 ` [RFC/PATCH 02/14] v4l-mc: Merge input and output pads laurent.pinchart
2009-10-20  1:12 ` [RFC/PATCH 03/14] v4l-mc: Replace the active pads bitmask by a link flag laurent.pinchart
2009-10-20  1:12 ` [RFC/PATCH 04/14] v4l-subdev: Add pads operations laurent.pinchart
2009-10-20  1:12 ` [RFC/PATCH 05/14] v4l-mc: Clean up link API laurent.pinchart
2009-10-20  1:12 ` laurent.pinchart [this message]
2009-10-20  1:12 ` [RFC/PATCH 07/14] v4l-mc: Remove devnode v4l2_dev field laurent.pinchart
2009-10-20  1:12 ` [RFC/PATCH 08/14] uvcvideo: Rely on videodev to reference-count the device laurent.pinchart
2009-10-20  1:12 ` [RFC/PATCH 09/14] uvcvideo: Merge iterms, oterms and extensions linked lists laurent.pinchart
2009-10-20  1:12 ` [RFC/PATCH 10/14] uvcvideo: Fix extension units parsing laurent.pinchart
2009-10-20  1:12 ` [RFC/PATCH 11/14] uvcvideo: Refactor chain scan laurent.pinchart
2009-10-20  1:12 ` [RFC/PATCH 12/14] uvcvideo: Factorize common field in uvc_entity structure laurent.pinchart
2009-10-20  1:12 ` [RFC/PATCH 13/14] uvcvideo: Register a v4l2_device laurent.pinchart
2009-10-20  1:12 ` [RFC/PATCH 14/14] uvcvideo: Register subdevices for each entity laurent.pinchart
2009-10-20 22:15 ` [RFC/PATCH 00/14] Media controller update based on Hans' v4l-dvb-mc tree Hans Verkuil
2009-10-20 22:32   ` Laurent Pinchart

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=20091020011215.243408842@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@maxwell.research.nokia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.