From 7e4296583b29c9e77c03df5da05ae911c168ba90 Mon Sep 17 00:00:00 2001
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Date: Fri, 25 Oct 2013 23:59:32 +0100
Subject: [PATCH 1/4] V4L2: soc-camera: prepare for private subdevice data

Soc-camera subdevice drivers, that need platform data, should receive a
pointer to it directly from the I2C device instead of an soc-camera
specific struct.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 include/media/mt9t112.h             |  3 +++
 include/media/mt9v022.h             |  3 +++
 include/media/ov772x.h              |  3 +++
 include/media/rj54n1cb0c.h          |  3 +++
 include/media/soc_camera_platform.h | 33 +++++++++++++++++++++++++--------
 include/media/tw9910.h              |  1 +
 6 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/include/media/mt9t112.h b/include/media/mt9t112.h
index a43c74a..3e05bf6 100644
--- a/include/media/mt9t112.h
+++ b/include/media/mt9t112.h
@@ -11,6 +11,8 @@
 #ifndef __MT9T112_H__
 #define __MT9T112_H__
 
+#include <media/soc_camera.h>
+
 #define MT9T112_FLAG_PCLK_RISING_EDGE	(1 << 0)
 #define MT9T112_FLAG_DATAWIDTH_8	(1 << 1) /* default width is 10 */
 
@@ -23,6 +25,7 @@ struct mt9t112_pll_divider {
  * mt9t112 camera info
  */
 struct mt9t112_camera_info {
+	struct soc_camera_desc sdesc;
 	u32 flags;
 	struct mt9t112_pll_divider divider;
 };
diff --git a/include/media/mt9v022.h b/include/media/mt9v022.h
index 4056180..ae94495 100644
--- a/include/media/mt9v022.h
+++ b/include/media/mt9v022.h
@@ -9,7 +9,10 @@
 #ifndef __MT9V022_H__
 #define __MT9V022_H__
 
+#include <media/soc_camera.h>
+
 struct mt9v022_platform_data {
+	struct soc_camera_desc sdesc;
 	unsigned short y_skip_top;	/* Lines to skip at the top */
 };
 
diff --git a/include/media/ov772x.h b/include/media/ov772x.h
index 00dbb7c..f295388 100644
--- a/include/media/ov772x.h
+++ b/include/media/ov772x.h
@@ -12,6 +12,8 @@
 #ifndef __OV772X_H__
 #define __OV772X_H__
 
+#include <media/soc_camera.h>
+
 /* for flags */
 #define OV772X_FLAG_VFLIP	(1 << 0) /* Vertical flip image */
 #define OV772X_FLAG_HFLIP	(1 << 1) /* Horizontal flip image */
@@ -52,6 +54,7 @@ struct ov772x_edge_ctrl {
  * ov772x camera info
  */
 struct ov772x_camera_info {
+	struct soc_camera_desc	sdesc;
 	unsigned long		flags;
 	struct ov772x_edge_ctrl	edgectrl;
 };
diff --git a/include/media/rj54n1cb0c.h b/include/media/rj54n1cb0c.h
index 8ae3288..0f16ee8a 100644
--- a/include/media/rj54n1cb0c.h
+++ b/include/media/rj54n1cb0c.h
@@ -11,7 +11,10 @@
 #ifndef __RJ54N1CB0C_H__
 #define __RJ54N1CB0C_H__
 
+#include <media/soc_camera.h>
+
 struct rj54n1_pdata {
+	struct soc_camera_desc sdesc;
 	unsigned int	mclk_freq;
 	bool		ioctl_high;
 };
diff --git a/include/media/soc_camera_platform.h b/include/media/soc_camera_platform.h
index 1e5065da..8031f12 100644
--- a/include/media/soc_camera_platform.h
+++ b/include/media/soc_camera_platform.h
@@ -18,6 +18,7 @@
 struct device;
 
 struct soc_camera_platform_info {
+	struct soc_camera_desc sdesc;
 	const char *format_name;
 	unsigned long format_depth;
 	struct v4l2_mbus_framefmt format;
@@ -32,14 +33,12 @@ static inline void soc_camera_platform_release(struct platform_device **pdev)
 	*pdev = NULL;
 }
 
-static inline int soc_camera_platform_add(struct soc_camera_device *icd,
+static inline int soc_camera_platform_add_sd(struct soc_camera_device *icd,
 					  struct platform_device **pdev,
-					  struct soc_camera_link *plink,
+					  struct soc_camera_subdev_desc *ssdd,
 					  void (*release)(struct device *dev),
 					  int id)
 {
-	struct soc_camera_subdev_desc *ssdd =
-		(struct soc_camera_subdev_desc *)plink;
 	struct soc_camera_platform_info *info = ssdd->drv_priv;
 	int ret;
 
@@ -68,16 +67,34 @@ static inline int soc_camera_platform_add(struct soc_camera_device *icd,
 	return ret;
 }
 
-static inline void soc_camera_platform_del(const struct soc_camera_device *icd,
+static inline int soc_camera_platform_add(struct soc_camera_device *icd,
+					  struct platform_device **pdev,
+					  struct soc_camera_link *plink,
+					  void (*release)(struct device *dev),
+					  int id)
+{
+	struct soc_camera_subdev_desc *ssdd =
+		(struct soc_camera_subdev_desc *)plink;
+	return soc_camera_platform_add_sd(icd, pdev, ssdd, release, id);
+}
+
+static inline void soc_camera_platform_del_sd(const struct soc_camera_device *icd,
 					   struct platform_device *pdev,
-					   const struct soc_camera_link *plink)
+					   const struct soc_camera_subdev_desc *ssdd)
 {
-	const struct soc_camera_subdev_desc *ssdd =
-		(const struct soc_camera_subdev_desc *)plink;
 	if (&icd->sdesc->subdev_desc != ssdd || !pdev)
 		return;
 
 	platform_device_unregister(pdev);
 }
 
+static inline void soc_camera_platform_del(const struct soc_camera_device *icd,
+					   struct platform_device *pdev,
+					   const struct soc_camera_link *plink)
+{
+	const struct soc_camera_subdev_desc *ssdd =
+		(const struct soc_camera_subdev_desc *)plink;
+	soc_camera_platform_del_sd(icd, pdev, ssdd);
+}
+
 #endif /* __SOC_CAMERA_H__ */
diff --git a/include/media/tw9910.h b/include/media/tw9910.h
index 90bcf1f..853c3ef 100644
--- a/include/media/tw9910.h
+++ b/include/media/tw9910.h
@@ -30,6 +30,7 @@ enum tw9910_mpout_pin {
 };
 
 struct tw9910_video_info {
+	struct soc_camera_desc	sdesc;
 	unsigned long		buswidth;
 	enum tw9910_mpout_pin	mpout;
 };
-- 
1.9.3

