Skip to contentSkip to conversation

V4L: Int if: Set slave's master before attach, remove master argument

PATCH In review Sakari Ailus 2 participants 4 messages Oct 16, 2007 – Oct 31, 2007 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 V4L: Int if: Set slave's master before attach, remove master argument

Set slave's master before master's attach call.

The master also now gets its own pointer from slave's structure.

---
 drivers/media/video/v4l2-int-device.c |    6 +++---
 include/media/v4l2-int-device.h       |    5 ++---
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/media/video/v4l2-int-device.c +3 -3
index f497c94..286b7f0 100644
@@ -65,12 +65,12 @@ static void v4l2_int_device_try_attach_all(void)
 			if (!try_module_get(m->module))
 				continue;
 
-			if (m->u.master->attach(m, s)) {
+			s->u.slave->master = m;
+			if (m->u.master->attach(s)) {
+				s->u.slave->master = NULL;
 				module_put(m->module);
 				continue;
 			}
-
-			s->u.slave->master = m;
 		}
 	}
 }
include/media/v4l2-int-device.h +2 -3
index 066ebfc..c8b80e0 100644
@@ -44,9 +44,8 @@ enum v4l2_int_type {
 struct v4l2_int_device;
 
 struct v4l2_int_master {
-	int (*attach)(struct v4l2_int_device *master,
-		      struct v4l2_int_device *slave);
-	void (*detach)(struct v4l2_int_device *master);
+	int (*attach)(struct v4l2_int_device *slave);
+	void (*detach)(struct v4l2_int_device *slave);
 };
 
 typedef int (v4l2_int_ioctl_func)(struct v4l2_int_device *);
Signature · 1 line
1.5.0.6
#1 lore raw

PATCH 1/1 ARM: OMAP2: Camera: Fix v4l2 int device detach

omap24xxcam_device_unregister expected the argument to be its own device structure but it's actually that of its slave.

Also get master from slave's structure in omap24xxcam_device_register.

---
 drivers/media/video/omap24xxcam.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
drivers/media/video/omap24xxcam.c +6 -7
index 7da1668..8fda9e1 100644
@@ -46,7 +46,7 @@
 
 static void omap24xxcam_reset(struct omap24xxcam_device *cam);
 static int omap24xxcam_sensor_if_enable(struct omap24xxcam_device *cam);
-static void omap24xxcam_device_unregister(struct v4l2_int_device *ctl);
+static void omap24xxcam_device_unregister(struct v4l2_int_device *s);
 static int omap24xxcam_remove(struct platform_device *pdev);
 
 /* module parameters */
@@ -1603,10 +1603,9 @@ static int omap24xxcam_resume(struct platform_device *pdev)
  *
  */
 
-static int omap24xxcam_device_register(struct v4l2_int_device *ctl,
-				       struct v4l2_int_device *s)
+static int omap24xxcam_device_register(struct v4l2_int_device *s)
 {
-	struct omap24xxcam_device *cam = ctl->priv;
+	struct omap24xxcam_device *cam = s->u.slave->master->priv;
 	struct video_device *vfd;
 	int rval;
 
@@ -1681,14 +1680,14 @@ static int omap24xxcam_device_register(struct v4l2_int_device *ctl,
 	return 0;
 
 err:
-	omap24xxcam_device_unregister(ctl);
+	omap24xxcam_device_unregister(s);
 
 	return rval;
 }
 
-static void omap24xxcam_device_unregister(struct v4l2_int_device *ctl)
+static void omap24xxcam_device_unregister(struct v4l2_int_device *s)
 {
-	struct omap24xxcam_device *cam = ctl->priv;
+	struct omap24xxcam_device *cam = s->u.slave->master->priv;
 
 	omap24xxcam_sensor_exit(cam);
 
Signature · 1 line
1.5.0.6
#2 lore raw

Re: [PATCH] ARM: OMAP2: Camera: Fix v4l2 int device detach

Quoted 44 lines · Sakari Ailus

omap24xxcam_device_unregister expected the argument to be its own device structure but it's actually that of its slave.

Also get master from slave's structure in omap24xxcam_device_register.

---
 drivers/media/video/omap24xxcam.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
drivers/media/video/omap24xxcam.c +4 -5
index 7da1668..8fda9e1 100644
@@ -46,7 +46,7 @@
 
 static void omap24xxcam_reset(struct omap24xxcam_device *cam);
 static int omap24xxcam_sensor_if_enable(struct omap24xxcam_device *cam);
-static void omap24xxcam_device_unregister(struct v4l2_int_device *ctl);
+static void omap24xxcam_device_unregister(struct v4l2_int_device *s);
 static int omap24xxcam_remove(struct platform_device *pdev);
 
 /* module parameters */
@@ -1603,10 +1603,9 @@ static int omap24xxcam_resume(struct platform_device *pdev)
  *
  */
 
-static int omap24xxcam_device_register(struct v4l2_int_device *ctl,
-				       struct v4l2_int_device *s)
+static int omap24xxcam_device_register(struct v4l2_int_device *s)
 {
-	struct omap24xxcam_device *cam = ctl->priv;
+	struct omap24xxcam_device *cam = s->u.slave->master->priv;
 	struct video_device *vfd;
 	int rval;
 
@@ -1681,14 +1680,14 @@ static int omap24xxcam_device_register(struct v4l2_int_device *ctl,
 	return 0;
 
 err:
-	omap24xxcam_device_unregister(ctl);
+	omap24xxcam_device_unregister(s);
 
 	return rval;

drivers/media/video/omap24xxcam.c static int omap24xxcam_device_register(struct v4l2_int_device *ctl, · line 1693

Quoted 10 lines
drivers/media/video/omap24xxcam.c +2 -2
 }
 
-static void omap24xxcam_device_unregister(struct v4l2_int_device *ctl)
+static void omap24xxcam_device_unregister(struct v4l2_int_device *s)
 {
-	struct omap24xxcam_device *cam = ctl->priv;
+	struct omap24xxcam_device *cam = s->u.slave->master->priv;
 
 	omap24xxcam_sensor_exit(cam);
 

Pushing today.

Tony

#3 lore raw
In reply to Sakari Ailus
Quoted 49 lines · Sakari Ailus

Set slave's master before master's attach call.

The master also now gets its own pointer from slave's structure.

---
 drivers/media/video/v4l2-int-device.c |    6 +++---
 include/media/v4l2-int-device.h       |    5 ++---
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/media/video/v4l2-int-device.c +3 -3
index f497c94..286b7f0 100644
@@ -65,12 +65,12 @@ static void v4l2_int_device_try_attach_all(void)
 			if (!try_module_get(m->module))
 				continue;
 
-			if (m->u.master->attach(m, s)) {
+			s->u.slave->master = m;
+			if (m->u.master->attach(s)) {
+				s->u.slave->master = NULL;
 				module_put(m->module);
 				continue;
 			}
-
-			s->u.slave->master = m;
 		}
 	}
 }
include/media/v4l2-int-device.h +2 -3
index 066ebfc..c8b80e0 100644
@@ -44,9 +44,8 @@ enum v4l2_int_type {
 struct v4l2_int_device;
 
 struct v4l2_int_master {
-	int (*attach)(struct v4l2_int_device *master,
-		      struct v4l2_int_device *slave);
-	void (*detach)(struct v4l2_int_device *master);
+	int (*attach)(struct v4l2_int_device *slave);
+	void (*detach)(struct v4l2_int_device *slave);
 };
 
 typedef int (v4l2_int_ioctl_func)(struct v4l2_int_device *);
Signature · 1 line
1.5.0.6

Pushing today.

Tony