summaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-08-25 11:06:21 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-19 00:18:24 -0300
commitc41debafc6e396a8e15f1f017aec7c0cf67e1b54 (patch)
tree4f128d3acb39deab3eb9f8ab1a9681fc07148432 /drivers/media
parent2639ead140aa7063188b6599a1a7398d60db2712 (diff)
downloadblackbird-op-linux-c41debafc6e396a8e15f1f017aec7c0cf67e1b54.tar.gz
blackbird-op-linux-c41debafc6e396a8e15f1f017aec7c0cf67e1b54.zip
V4L/DVB (12504): soc-camera: prepare soc_camera_platform.c and its users for conversion
soc_camera_platform.c is only used by y SuperH ap325rxa board. This patch converts soc_camera_platform.c and its users for the soc-camera platform- device conversion and also extends soc-camera core to handle non-I2C cameras. Cc: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/soc_camera.c61
1 files changed, 46 insertions, 15 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 9f5ae8167855..0340754e5406 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -1165,45 +1165,76 @@ void soc_camera_video_stop(struct soc_camera_device *icd)
}
EXPORT_SYMBOL(soc_camera_video_stop);
-static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev)
+#ifdef CONFIG_I2C_BOARDINFO
+static int soc_camera_init_i2c(struct platform_device *pdev,
+ struct soc_camera_link *icl)
{
- struct soc_camera_link *icl = pdev->dev.platform_data;
- struct i2c_adapter *adap;
struct i2c_client *client;
+ struct i2c_adapter *adap = i2c_get_adapter(icl->i2c_adapter_id);
+ int ret;
- if (!icl)
- return -EINVAL;
-
- adap = i2c_get_adapter(icl->i2c_adapter_id);
if (!adap) {
- dev_warn(&pdev->dev, "Cannot get adapter #%d. No driver?\n",
- icl->i2c_adapter_id);
- /* -ENODEV and -ENXIO do not produce an error on probe()... */
- return -ENOENT;
+ ret = -ENODEV;
+ dev_err(&pdev->dev, "Cannot get adapter #%d. No driver?\n",
+ icl->i2c_adapter_id);
+ goto ei2cga;
}
icl->board_info->platform_data = icl;
client = i2c_new_device(adap, icl->board_info);
if (!client) {
- i2c_put_adapter(adap);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto ei2cnd;
}
platform_set_drvdata(pdev, client);
return 0;
+ei2cnd:
+ i2c_put_adapter(adap);
+ei2cga:
+ return ret;
}
-static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev)
+static void soc_camera_free_i2c(struct platform_device *pdev)
{
struct i2c_client *client = platform_get_drvdata(pdev);
if (!client)
- return -ENODEV;
+ return;
i2c_unregister_device(client);
i2c_put_adapter(client->adapter);
+}
+#else
+#define soc_camera_init_i2c(d, icl) (-ENODEV)
+#define soc_camera_free_i2c(d) do {} while (0)
+#endif
+static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev)
+{
+ struct soc_camera_link *icl = pdev->dev.platform_data;
+
+ if (!icl)
+ return -EINVAL;
+
+ if (icl->board_info)
+ return soc_camera_init_i2c(pdev, icl);
+ else if (!icl->add_device || !icl->del_device)
+ return -EINVAL;
+
+ /* &pdev->dev will become &icd->dev */
+ return icl->add_device(icl, &pdev->dev);
+}
+
+static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev)
+{
+ struct soc_camera_link *icl = pdev->dev.platform_data;
+
+ if (icl->board_info)
+ soc_camera_free_i2c(pdev);
+ else
+ icl->del_device(icl);
return 0;
}
OpenPOWER on IntegriCloud