From 0fb0b6e1c0f065b8dbaa3583e78d614b80a1fe0e Mon Sep 17 00:00:00 2001
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Date: Mon, 28 Oct 2013 17:53:43 +0100
Subject: [PATCH 3/4] ARM: convert 3 soc-camera users to the new platform data
 layout

pcm990, armadillo800eva and mackerel are the three ARM boards, currently
supported in the mainline, that use V4L2 soc-camera subdevices - camera
sensors and TV-decoders - with their own platform data. It is important to
convert these ones first, because for other such drivers their platform
data is provided by struct soc_camera_desc, which is equivalent to the
legacy struct soc_camera_link. Therefore those boards will not break,
when we switch to using driver-specific platform data in soc-camera.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 arch/arm/mach-pxa/pcm990-baseboard.c           | 46 +++++++++++++++-----------
 arch/arm/mach-shmobile/board-armadillo800eva.c | 22 +++++++-----
 arch/arm/mach-shmobile/board-mackerel.c        | 26 +++++++++------
 3 files changed, 55 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c
index 2897da2..178b7a0 100644
--- a/arch/arm/mach-pxa/pcm990-baseboard.c
+++ b/arch/arm/mach-pxa/pcm990-baseboard.c
@@ -417,7 +417,7 @@ static struct pca953x_platform_data pca9536_data = {
 
 static int gpio_bus_switch = -EINVAL;
 
-static int pcm990_camera_set_bus_param(struct soc_camera_link *link,
+static int pcm990_camera_set_bus_param(struct soc_camera_subdev_desc *ssdd,
 				       unsigned long flags)
 {
 	if (gpio_bus_switch < 0) {
@@ -435,7 +435,7 @@ static int pcm990_camera_set_bus_param(struct soc_camera_link *link,
 	return 0;
 }
 
-static unsigned long pcm990_camera_query_bus_param(struct soc_camera_link *link)
+static unsigned long pcm990_camera_query_bus_param(struct soc_camera_subdev_desc *ssdd)
 {
 	int ret;
 
@@ -453,7 +453,7 @@ static unsigned long pcm990_camera_query_bus_param(struct soc_camera_link *link)
 		return SOCAM_DATAWIDTH_10;
 }
 
-static void pcm990_camera_free_bus(struct soc_camera_link *link)
+static void pcm990_camera_free_bus(struct soc_camera_subdev_desc *ssdd)
 {
 	if (gpio_bus_switch < 0)
 		return;
@@ -471,10 +471,6 @@ static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
 	},
 };
 
-static struct mt9v022_platform_data mt9v022_pdata = {
-	.y_skip_top = 1,
-};
-
 static struct i2c_board_info pcm990_camera_i2c[] = {
 	{
 		I2C_BOARD_INFO("mt9v022", 0x48),
@@ -483,22 +479,34 @@ static struct i2c_board_info pcm990_camera_i2c[] = {
 	},
 };
 
-static struct soc_camera_link iclink[] = {
-	{
-		.bus_id			= 0, /* Must match with the camera ID */
-		.board_info		= &pcm990_camera_i2c[0],
-		.priv			= &mt9v022_pdata,
-		.i2c_adapter_id		= 0,
+static struct mt9v022_platform_data mt9v022_pdata = {
+	.sdesc = {
+		.subdev_desc	= {
+			.drv_priv		= &mt9v022_pdata,
+			.query_bus_param	= pcm990_camera_query_bus_param,
+			.set_bus_param		= pcm990_camera_set_bus_param,
+			.free_bus		= pcm990_camera_free_bus,
+			.sd_pdata.host_priv	= &mt9v022_pdata.sdesc.host_desc,
+		},
+		.host_desc	= {
+			.bus_id			= 0, /* Must match with the camera ID */
+			.i2c_adapter_id		= 0,
+			.board_info		= &pcm990_camera_i2c[0],
+		},
+	},
+	.y_skip_top = 1,
+};
+
+static struct soc_camera_desc mt9m001 = {
+	.subdev_desc = {
 		.query_bus_param	= pcm990_camera_query_bus_param,
 		.set_bus_param		= pcm990_camera_set_bus_param,
 		.free_bus		= pcm990_camera_free_bus,
-	}, {
+	},
+	.host_desc = {
 		.bus_id			= 0, /* Must match with the camera ID */
 		.board_info		= &pcm990_camera_i2c[1],
 		.i2c_adapter_id		= 0,
-		.query_bus_param	= pcm990_camera_query_bus_param,
-		.set_bus_param		= pcm990_camera_set_bus_param,
-		.free_bus		= pcm990_camera_free_bus,
 	},
 };
 
@@ -507,13 +515,13 @@ static struct platform_device pcm990_camera[] = {
 		.name	= "soc-camera-pdrv",
 		.id	= 0,
 		.dev	= {
-			.platform_data = &iclink[0],
+			.platform_data = &mt9v022_pdata.sdesc,
 		},
 	}, {
 		.name	= "soc-camera-pdrv",
 		.id	= 1,
 		.dev	= {
-			.platform_data = &iclink[1],
+			.platform_data = &mt9m001,
 		},
 	},
 };
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index fbcbabe..ff2d877 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -893,22 +893,26 @@ static struct i2c_board_info i2c_camera_mt9t111 = {
 };
 
 static struct mt9t112_camera_info mt9t111_info = {
+	.sdesc = {
+		.subdev_desc	= {
+			.drv_priv	= &mt9t111_info,
+			.power		= mt9t111_power,
+			.sd_pdata.host_priv = &mt9t111_info.sdesc.host_desc,
+		},
+		.host_desc	= {
+			.i2c_adapter_id	= 0,
+			.bus_id		= 0,
+			.board_info	= &i2c_camera_mt9t111,
+		},
+	},
 	.divider = { 16, 0, 0, 7, 0, 10, 14, 7, 7 },
 };
 
-static struct soc_camera_link mt9t111_link = {
-	.i2c_adapter_id	= 0,
-	.bus_id		= 0,
-	.board_info	= &i2c_camera_mt9t111,
-	.power		= mt9t111_power,
-	.priv		= &mt9t111_info,
-};
-
 static struct platform_device camera_device = {
 	.name	= "soc-camera-pdrv",
 	.id	= 0,
 	.dev	= {
-		.platform_data = &mt9t111_link,
+		.platform_data = &mt9t111_info.sdesc,
 	},
 };
 
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index b3ee96e..77e9ac9 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -1147,6 +1147,18 @@ static int camera_set_capture(struct soc_camera_platform_info *info,
 }
 
 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	= mackerel_camera_add,
+			.del_device	= mackerel_camera_del,
+			.module_name	= "soc_camera_platform",
+		},
+	},
 	.format_name = "UYVY",
 	.format_depth = 16,
 	.format = {
@@ -1163,14 +1175,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	= mackerel_camera_add,
-	.del_device	= mackerel_camera_del,
-	.module_name	= "soc_camera_platform",
-	.priv		= &camera_info,
-};
-
 static struct platform_device *camera_device;
 
 static void mackerel_camera_release(struct device *dev)
@@ -1180,13 +1184,13 @@ static void mackerel_camera_release(struct device *dev)
 
 static int mackerel_camera_add(struct soc_camera_device *icd)
 {
-	return soc_camera_platform_add(icd, &camera_device, &camera_link,
+	return soc_camera_platform_add_sd(icd, &camera_device, &camera_info.sdesc.subdev_desc,
 				       mackerel_camera_release, 0);
 }
 
 static void mackerel_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);
 }
 
 static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
@@ -1226,7 +1230,7 @@ static struct platform_device mackerel_camera = {
 	.name	= "soc-camera-pdrv",
 	.id	= 0,
 	.dev	= {
-		.platform_data = &camera_link,
+		.platform_data = &camera_info.sdesc,
 	},
 };
 
-- 
1.9.3

