diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2009-05-07 12:25:32 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 17:20:54 -0400 |
commit | 0fd327bd0d1b508eb64da3876098f6f43bfc1509 (patch) | |
tree | 5be3f8e74fecd501e78cdfaba74c2599aa3159da /drivers/media/video/soc_camera.c | |
parent | f4672dffa126afe8c75bf45adc0f06c0a06d08e8 (diff) |
V4L/DVB (11705): soc-camera: prepare for the platform driver conversion
Add a platform driver to soc_camera.c. This way we preserve backwards
compatibility with existing platforms and can start converting them one by one
to the new platform-device soc-camera interface.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/soc_camera.c')
-rw-r--r-- | drivers/media/video/soc_camera.c | 71 |
1 files changed, 66 insertions, 5 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 2d341f537d54..2014e9e32b35 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -16,19 +16,21 @@ | |||
16 | * published by the Free Software Foundation. | 16 | * published by the Free Software Foundation. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/device.h> | 19 | #include <linux/device.h> |
22 | #include <linux/list.h> | ||
23 | #include <linux/err.h> | 20 | #include <linux/err.h> |
21 | #include <linux/i2c.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/list.h> | ||
24 | #include <linux/module.h> | ||
24 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/platform_device.h> | ||
25 | #include <linux/vmalloc.h> | 27 | #include <linux/vmalloc.h> |
26 | 28 | ||
29 | #include <media/soc_camera.h> | ||
27 | #include <media/v4l2-common.h> | 30 | #include <media/v4l2-common.h> |
28 | #include <media/v4l2-ioctl.h> | ||
29 | #include <media/v4l2-dev.h> | 31 | #include <media/v4l2-dev.h> |
32 | #include <media/v4l2-ioctl.h> | ||
30 | #include <media/videobuf-core.h> | 33 | #include <media/videobuf-core.h> |
31 | #include <media/soc_camera.h> | ||
32 | 34 | ||
33 | /* Default to VGA resolution */ | 35 | /* Default to VGA resolution */ |
34 | #define DEFAULT_WIDTH 640 | 36 | #define DEFAULT_WIDTH 640 |
@@ -1159,6 +1161,57 @@ void soc_camera_video_stop(struct soc_camera_device *icd) | |||
1159 | } | 1161 | } |
1160 | EXPORT_SYMBOL(soc_camera_video_stop); | 1162 | EXPORT_SYMBOL(soc_camera_video_stop); |
1161 | 1163 | ||
1164 | static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev) | ||
1165 | { | ||
1166 | struct soc_camera_link *icl = pdev->dev.platform_data; | ||
1167 | struct i2c_adapter *adap; | ||
1168 | struct i2c_client *client; | ||
1169 | |||
1170 | if (!icl) | ||
1171 | return -EINVAL; | ||
1172 | |||
1173 | adap = i2c_get_adapter(icl->i2c_adapter_id); | ||
1174 | if (!adap) { | ||
1175 | dev_warn(&pdev->dev, "Cannot get adapter #%d. No driver?\n", | ||
1176 | icl->i2c_adapter_id); | ||
1177 | /* -ENODEV and -ENXIO do not produce an error on probe()... */ | ||
1178 | return -ENOENT; | ||
1179 | } | ||
1180 | |||
1181 | icl->board_info->platform_data = icl; | ||
1182 | client = i2c_new_device(adap, icl->board_info); | ||
1183 | if (!client) { | ||
1184 | i2c_put_adapter(adap); | ||
1185 | return -ENOMEM; | ||
1186 | } | ||
1187 | |||
1188 | platform_set_drvdata(pdev, client); | ||
1189 | |||
1190 | return 0; | ||
1191 | } | ||
1192 | |||
1193 | static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev) | ||
1194 | { | ||
1195 | struct i2c_client *client = platform_get_drvdata(pdev); | ||
1196 | |||
1197 | if (!client) | ||
1198 | return -ENODEV; | ||
1199 | |||
1200 | i2c_unregister_device(client); | ||
1201 | i2c_put_adapter(client->adapter); | ||
1202 | |||
1203 | return 0; | ||
1204 | } | ||
1205 | |||
1206 | static struct platform_driver __refdata soc_camera_pdrv = { | ||
1207 | .probe = soc_camera_pdrv_probe, | ||
1208 | .remove = __exit_p(soc_camera_pdrv_remove), | ||
1209 | .driver = { | ||
1210 | .name = "soc-camera-pdrv", | ||
1211 | .owner = THIS_MODULE, | ||
1212 | }, | ||
1213 | }; | ||
1214 | |||
1162 | static int __init soc_camera_init(void) | 1215 | static int __init soc_camera_init(void) |
1163 | { | 1216 | { |
1164 | int ret = bus_register(&soc_camera_bus_type); | 1217 | int ret = bus_register(&soc_camera_bus_type); |
@@ -1168,8 +1221,14 @@ static int __init soc_camera_init(void) | |||
1168 | if (ret) | 1221 | if (ret) |
1169 | goto edrvr; | 1222 | goto edrvr; |
1170 | 1223 | ||
1224 | ret = platform_driver_register(&soc_camera_pdrv); | ||
1225 | if (ret) | ||
1226 | goto epdr; | ||
1227 | |||
1171 | return 0; | 1228 | return 0; |
1172 | 1229 | ||
1230 | epdr: | ||
1231 | driver_unregister(&ic_drv); | ||
1173 | edrvr: | 1232 | edrvr: |
1174 | bus_unregister(&soc_camera_bus_type); | 1233 | bus_unregister(&soc_camera_bus_type); |
1175 | return ret; | 1234 | return ret; |
@@ -1177,6 +1236,7 @@ edrvr: | |||
1177 | 1236 | ||
1178 | static void __exit soc_camera_exit(void) | 1237 | static void __exit soc_camera_exit(void) |
1179 | { | 1238 | { |
1239 | platform_driver_unregister(&soc_camera_pdrv); | ||
1180 | driver_unregister(&ic_drv); | 1240 | driver_unregister(&ic_drv); |
1181 | bus_unregister(&soc_camera_bus_type); | 1241 | bus_unregister(&soc_camera_bus_type); |
1182 | } | 1242 | } |
@@ -1187,3 +1247,4 @@ module_exit(soc_camera_exit); | |||
1187 | MODULE_DESCRIPTION("Image capture bus driver"); | 1247 | MODULE_DESCRIPTION("Image capture bus driver"); |
1188 | MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>"); | 1248 | MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>"); |
1189 | MODULE_LICENSE("GPL"); | 1249 | MODULE_LICENSE("GPL"); |
1250 | MODULE_ALIAS("platform:soc-camera-pdrv"); | ||