diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2009-08-25 10:06:21 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 23:18:24 -0400 |
commit | c41debafc6e396a8e15f1f017aec7c0cf67e1b54 (patch) | |
tree | 4f128d3acb39deab3eb9f8ab1a9681fc07148432 /drivers/media/video | |
parent | 2639ead140aa7063188b6599a1a7398d60db2712 (diff) |
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/video')
-rw-r--r-- | drivers/media/video/soc_camera.c | 61 |
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) | |||
1165 | } | 1165 | } |
1166 | EXPORT_SYMBOL(soc_camera_video_stop); | 1166 | EXPORT_SYMBOL(soc_camera_video_stop); |
1167 | 1167 | ||
1168 | static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev) | 1168 | #ifdef CONFIG_I2C_BOARDINFO |
1169 | static int soc_camera_init_i2c(struct platform_device *pdev, | ||
1170 | struct soc_camera_link *icl) | ||
1169 | { | 1171 | { |
1170 | struct soc_camera_link *icl = pdev->dev.platform_data; | ||
1171 | struct i2c_adapter *adap; | ||
1172 | struct i2c_client *client; | 1172 | struct i2c_client *client; |
1173 | struct i2c_adapter *adap = i2c_get_adapter(icl->i2c_adapter_id); | ||
1174 | int ret; | ||
1173 | 1175 | ||
1174 | if (!icl) | ||
1175 | return -EINVAL; | ||
1176 | |||
1177 | adap = i2c_get_adapter(icl->i2c_adapter_id); | ||
1178 | if (!adap) { | 1176 | if (!adap) { |
1179 | dev_warn(&pdev->dev, "Cannot get adapter #%d. No driver?\n", | 1177 | ret = -ENODEV; |
1180 | icl->i2c_adapter_id); | 1178 | dev_err(&pdev->dev, "Cannot get adapter #%d. No driver?\n", |
1181 | /* -ENODEV and -ENXIO do not produce an error on probe()... */ | 1179 | icl->i2c_adapter_id); |
1182 | return -ENOENT; | 1180 | goto ei2cga; |
1183 | } | 1181 | } |
1184 | 1182 | ||
1185 | icl->board_info->platform_data = icl; | 1183 | icl->board_info->platform_data = icl; |
1186 | client = i2c_new_device(adap, icl->board_info); | 1184 | client = i2c_new_device(adap, icl->board_info); |
1187 | if (!client) { | 1185 | if (!client) { |
1188 | i2c_put_adapter(adap); | 1186 | ret = -ENOMEM; |
1189 | return -ENOMEM; | 1187 | goto ei2cnd; |
1190 | } | 1188 | } |
1191 | 1189 | ||
1192 | platform_set_drvdata(pdev, client); | 1190 | platform_set_drvdata(pdev, client); |
1193 | 1191 | ||
1194 | return 0; | 1192 | return 0; |
1193 | ei2cnd: | ||
1194 | i2c_put_adapter(adap); | ||
1195 | ei2cga: | ||
1196 | return ret; | ||
1195 | } | 1197 | } |
1196 | 1198 | ||
1197 | static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev) | 1199 | static void soc_camera_free_i2c(struct platform_device *pdev) |
1198 | { | 1200 | { |
1199 | struct i2c_client *client = platform_get_drvdata(pdev); | 1201 | struct i2c_client *client = platform_get_drvdata(pdev); |
1200 | 1202 | ||
1201 | if (!client) | 1203 | if (!client) |
1202 | return -ENODEV; | 1204 | return; |
1203 | 1205 | ||
1204 | i2c_unregister_device(client); | 1206 | i2c_unregister_device(client); |
1205 | i2c_put_adapter(client->adapter); | 1207 | i2c_put_adapter(client->adapter); |
1208 | } | ||
1209 | #else | ||
1210 | #define soc_camera_init_i2c(d, icl) (-ENODEV) | ||
1211 | #define soc_camera_free_i2c(d) do {} while (0) | ||
1212 | #endif | ||
1206 | 1213 | ||
1214 | static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev) | ||
1215 | { | ||
1216 | struct soc_camera_link *icl = pdev->dev.platform_data; | ||
1217 | |||
1218 | if (!icl) | ||
1219 | return -EINVAL; | ||
1220 | |||
1221 | if (icl->board_info) | ||
1222 | return soc_camera_init_i2c(pdev, icl); | ||
1223 | else if (!icl->add_device || !icl->del_device) | ||
1224 | return -EINVAL; | ||
1225 | |||
1226 | /* &pdev->dev will become &icd->dev */ | ||
1227 | return icl->add_device(icl, &pdev->dev); | ||
1228 | } | ||
1229 | |||
1230 | static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev) | ||
1231 | { | ||
1232 | struct soc_camera_link *icl = pdev->dev.platform_data; | ||
1233 | |||
1234 | if (icl->board_info) | ||
1235 | soc_camera_free_i2c(pdev); | ||
1236 | else | ||
1237 | icl->del_device(icl); | ||
1207 | return 0; | 1238 | return 0; |
1208 | } | 1239 | } |
1209 | 1240 | ||