From 2cdb1ce3a9148bd929ebbae5eeaab5b4994366d4 Mon Sep 17 00:00:00 2001
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Date: Mon, 28 Oct 2013 15:06:12 +0100
Subject: [PATCH 2/4] sh: switch all soc-camera users to the new platform data
 layout

Soc-camera is undergoing a switch from standardised platform data for
subdevices to arbitrary platform data. Only if the respective subdevice
driver is used within the soc-camera framework, then it has to use an
soc-camera specific struct.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 arch/sh/boards/mach-ap325rxa/setup.c | 55 ++++++++++++++++++------------
 arch/sh/boards/mach-ecovec24/setup.c | 66 +++++++++++++++++++++---------------
 arch/sh/boards/mach-kfr2r09/setup.c  | 20 ++++++-----
 arch/sh/boards/mach-migor/setup.c    | 41 +++++++++++++---------
 4 files changed, 109 insertions(+), 73 deletions(-)

diff --git a/arch/sh/boards/mach-ap325rxa/setup.c b/arch/sh/boards/mach-ap325rxa/setup.c
index 5620e33..4713c6f 100644
--- a/arch/sh/boards/mach-ap325rxa/setup.c
+++ b/arch/sh/boards/mach-ap325rxa/setup.c
@@ -335,6 +335,18 @@ static int ap325rxa_camera_add(struct soc_camera_device *icd);
 static void ap325rxa_camera_del(struct soc_camera_device *icd);
 
 static struct soc_camera_platform_info camera_info = {
+	.sdesc = {
+		.subdev_desc	= {
+			.drv_priv	= &camera_info,
+			.sd_pdata.host_priv = &camera_info.sdesc.host_desc,
+		},
+		.host_desc	= {
+			.bus_id		= 0,
+			.add_device	= ap325rxa_camera_add,
+			.del_device	= ap325rxa_camera_del,
+			.module_name	= "soc_camera_platform",
+		},
+	},
 	.format_name = "UYVY",
 	.format_depth = 16,
 	.format = {
@@ -351,14 +363,6 @@ static struct soc_camera_platform_info camera_info = {
 	.set_capture = camera_set_capture,
 };
 
-static struct soc_camera_link camera_link = {
-	.bus_id		= 0,
-	.add_device	= ap325rxa_camera_add,
-	.del_device	= ap325rxa_camera_del,
-	.module_name	= "soc_camera_platform",
-	.priv		= &camera_info,
-};
-
 static struct platform_device *camera_device;
 
 static void ap325rxa_camera_release(struct device *dev)
@@ -368,21 +372,24 @@ static void ap325rxa_camera_release(struct device *dev)
 
 static int ap325rxa_camera_add(struct soc_camera_device *icd)
 {
-	int ret = soc_camera_platform_add(icd, &camera_device, &camera_link,
-					  ap325rxa_camera_release, 0);
+	int ret = soc_camera_platform_add_sd(icd, &camera_device,
+					     &camera_info.sdesc.subdev_desc,
+					     ap325rxa_camera_release, 0);
 	if (ret < 0)
 		return ret;
 
 	ret = camera_probe();
 	if (ret < 0)
-		soc_camera_platform_del(icd, camera_device, &camera_link);
+		soc_camera_platform_del_sd(icd, camera_device,
+					   &camera_info.sdesc.subdev_desc);
 
 	return ret;
 }
 
 static void ap325rxa_camera_del(struct soc_camera_device *icd)
 {
-	soc_camera_platform_del(icd, camera_device, &camera_link);
+	soc_camera_platform_del_sd(icd, camera_device,
+				   &camera_info.sdesc.subdev_desc);
 }
 #endif /* CONFIG_I2C */
 
@@ -501,30 +508,34 @@ static struct i2c_board_info ap325rxa_i2c_camera[] = {
 };
 
 static struct ov772x_camera_info ov7725_info = {
+	.sdesc		= {
+		.subdev_desc	= {
+			.power		= ov7725_power,
+			.drv_priv	= &ov7725_info,
+			.sd_pdata.host_priv = &ov7725_info.sdesc.host_desc,
+		},
+		.host_desc	= {
+			.bus_id		= 0,
+			.board_info	= &ap325rxa_i2c_camera[0],
+			.i2c_adapter_id	= 0,
+		},
+	},
 	.flags		= OV772X_FLAG_VFLIP | OV772X_FLAG_HFLIP,
 	.edgectrl	= OV772X_AUTO_EDGECTRL(0xf, 0),
 };
 
-static struct soc_camera_link ov7725_link = {
-	.bus_id		= 0,
-	.power		= ov7725_power,
-	.board_info	= &ap325rxa_i2c_camera[0],
-	.i2c_adapter_id	= 0,
-	.priv		= &ov7725_info,
-};
-
 static struct platform_device ap325rxa_camera[] = {
 	{
 		.name	= "soc-camera-pdrv",
 		.id	= 0,
 		.dev	= {
-			.platform_data = &ov7725_link,
+			.platform_data = &ov7725_info.sdesc,
 		},
 	}, {
 		.name	= "soc-camera-pdrv",
 		.id	= 1,
 		.dev	= {
-			.platform_data = &camera_link,
+			.platform_data = &camera_info.sdesc,
 		},
 	},
 };
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 5bc3a15..54034bf 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -754,18 +754,22 @@ static int tw9910_power(struct device *dev, int mode)
 }
 
 static struct tw9910_video_info tw9910_info = {
+	.sdesc = {
+		.subdev_desc	= {
+			.power		= tw9910_power,
+			.drv_priv	= &tw9910_info,
+			.sd_pdata.host_priv = &tw9910_info.sdesc.host_desc,
+		},
+		.host_desc	= {
+			.i2c_adapter_id	= 0,
+			.bus_id		= 1,
+			.board_info	= &i2c_camera[0],
+		},
+	},
 	.buswidth	= SOCAM_DATAWIDTH_8,
 	.mpout		= TW9910_MPO_FIELD,
 };
 
-static struct soc_camera_link tw9910_link = {
-	.i2c_adapter_id	= 0,
-	.bus_id		= 1,
-	.power		= tw9910_power,
-	.board_info	= &i2c_camera[0],
-	.priv		= &tw9910_info,
-};
-
 /* mt9t112 */
 static int mt9t112_power1(struct device *dev, int mode)
 {
@@ -777,18 +781,22 @@ static int mt9t112_power1(struct device *dev, int mode)
 }
 
 static struct mt9t112_camera_info mt9t112_info1 = {
+	.sdesc = {
+		.subdev_desc	= {
+			.power		= mt9t112_power1,
+			.drv_priv	= &mt9t112_info1,
+			.sd_pdata.host_priv = &mt9t112_info1.sdesc.host_desc,
+		},
+		.host_desc	= {
+			.i2c_adapter_id	= 0,
+			.bus_id		= 0,
+			.board_info	= &i2c_camera[1],
+		},
+	},
 	.flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
 	.divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
 };
 
-static struct soc_camera_link mt9t112_link1 = {
-	.i2c_adapter_id	= 0,
-	.power		= mt9t112_power1,
-	.bus_id		= 0,
-	.board_info	= &i2c_camera[1],
-	.priv		= &mt9t112_info1,
-};
-
 static int mt9t112_power2(struct device *dev, int mode)
 {
 	gpio_set_value(GPIO_PTA4, mode);
@@ -799,38 +807,42 @@ static int mt9t112_power2(struct device *dev, int mode)
 }
 
 static struct mt9t112_camera_info mt9t112_info2 = {
+	.sdesc = {
+		.subdev_desc	= {
+			.power		= mt9t112_power2,
+			.drv_priv	= &mt9t112_info2,
+			.sd_pdata.host_priv = &mt9t112_info2.sdesc.host_desc,
+		},
+		.host_desc	= {
+			.i2c_adapter_id	= 1,
+			.bus_id		= 1,
+			.board_info	= &i2c_camera[2],
+		},
+	},
 	.flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
 	.divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
 };
 
-static struct soc_camera_link mt9t112_link2 = {
-	.i2c_adapter_id	= 1,
-	.power		= mt9t112_power2,
-	.bus_id		= 1,
-	.board_info	= &i2c_camera[2],
-	.priv		= &mt9t112_info2,
-};
-
 static struct platform_device camera_devices[] = {
 	{
 		.name	= "soc-camera-pdrv",
 		.id	= 0,
 		.dev	= {
-			.platform_data = &tw9910_link,
+			.platform_data = &tw9910_info.sdesc,
 		},
 	},
 	{
 		.name	= "soc-camera-pdrv",
 		.id	= 1,
 		.dev	= {
-			.platform_data = &mt9t112_link1,
+			.platform_data = &mt9t112_info1.sdesc,
 		},
 	},
 	{
 		.name	= "soc-camera-pdrv",
 		.id	= 2,
 		.dev	= {
-			.platform_data = &mt9t112_link2,
+			.platform_data = &mt9t112_info2.sdesc,
 		},
 	},
 };
diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c
index 1df4398..500882f 100644
--- a/arch/sh/boards/mach-kfr2r09/setup.c
+++ b/arch/sh/boards/mach-kfr2r09/setup.c
@@ -334,22 +334,26 @@ eclkrate:
 }
 
 static struct rj54n1_pdata rj54n1_priv = {
+	.sdesc = {
+		.subdev_desc	= {
+			.power		= camera_power,
+			.drv_priv	= &rj54n1_priv,
+			.sd_pdata.host_priv = &rj54n1_priv.sdesc.host_desc,
+		},
+		.host_desc	= {
+			.board_info	= &kfr2r09_i2c_camera,
+			.i2c_adapter_id	= 1,
+		},
+	},
 	.mclk_freq	= CEU_MCLK_FREQ,
 	.ioctl_high	= false,
 };
 
-static struct soc_camera_link rj54n1_link = {
-	.power		= camera_power,
-	.board_info	= &kfr2r09_i2c_camera,
-	.i2c_adapter_id	= 1,
-	.priv		= &rj54n1_priv,
-};
-
 static struct platform_device kfr2r09_camera = {
 	.name	= "soc-camera-pdrv",
 	.id	= 0,
 	.dev	= {
-		.platform_data = &rj54n1_link,
+		.platform_data = &rj54n1_priv.sdesc,
 	},
 };
 
diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c
index 8b73194e..f0d2ab6 100644
--- a/arch/sh/boards/mach-migor/setup.c
+++ b/arch/sh/boards/mach-migor/setup.c
@@ -445,39 +445,48 @@ static struct i2c_board_info migor_i2c_camera[] = {
 	},
 };
 
-static struct ov772x_camera_info ov7725_info;
-
-static struct soc_camera_link ov7725_link = {
-	.power		= ov7725_power,
-	.board_info	= &migor_i2c_camera[0],
-	.i2c_adapter_id	= 0,
-	.priv		= &ov7725_info,
+static struct ov772x_camera_info ov7725_info = {
+	.sdesc = {
+		.subdev_desc	= {
+			.power		= ov7725_power,
+			.drv_priv	= &ov7725_info,
+			.sd_pdata.host_priv = &ov7725_info.sdesc.host_desc,
+		},
+		.host_desc	= {
+			.board_info	= &migor_i2c_camera[0],
+			.i2c_adapter_id	= 0,
+		},
+	},
 };
 
 static struct tw9910_video_info tw9910_info = {
+	.sdesc = {
+		.subdev_desc	= {
+			.power		= tw9910_power,
+			.drv_priv	= &tw9910_info,
+			.sd_pdata.host_priv = &tw9910_info.sdesc.host_desc,
+		},
+		.host_desc	= {
+			.board_info	= &migor_i2c_camera[1],
+			.i2c_adapter_id	= 0,
+		},
+	},
 	.buswidth	= SOCAM_DATAWIDTH_8,
 	.mpout		= TW9910_MPO_FIELD,
 };
 
-static struct soc_camera_link tw9910_link = {
-	.power		= tw9910_power,
-	.board_info	= &migor_i2c_camera[1],
-	.i2c_adapter_id	= 0,
-	.priv		= &tw9910_info,
-};
-
 static struct platform_device migor_camera[] = {
 	{
 		.name	= "soc-camera-pdrv",
 		.id	= 0,
 		.dev	= {
-			.platform_data = &ov7725_link,
+			.platform_data = &ov7725_info.sdesc,
 		},
 	}, {
 		.name	= "soc-camera-pdrv",
 		.id	= 1,
 		.dev	= {
-			.platform_data = &tw9910_link,
+			.platform_data = &tw9910_info.sdesc,
 		},
 	},
 };
-- 
1.9.3

