aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/soc_camera.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-04-24 11:55:48 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-16 17:20:43 -0400
commiteff505fa1511b753b7cfb397a754b8ff4367cd55 (patch)
tree0e15a9094777bbebcfd1331b9e78f1aa6c6a5070 /drivers/media/video/soc_camera.c
parenteb6c8558f7658b7f31ee022c7bea1d840eda33dc (diff)
V4L/DVB (11609): soc-camera: remove an extra device generation from struct soc_camera_host
Make camera devices direct children of host platform devices, move the inheritance management into the soc_camera.c core driver. 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.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 0e890cc23377..2d341f537d54 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -279,7 +279,7 @@ static int soc_camera_set_fmt(struct soc_camera_file *icf,
279 return ret; 279 return ret;
280 } else if (!icd->current_fmt || 280 } else if (!icd->current_fmt ||
281 icd->current_fmt->fourcc != pix->pixelformat) { 281 icd->current_fmt->fourcc != pix->pixelformat) {
282 dev_err(&ici->dev, 282 dev_err(ici->dev,
283 "Host driver hasn't set up current format correctly!\n"); 283 "Host driver hasn't set up current format correctly!\n");
284 return -EINVAL; 284 return -EINVAL;
285 } 285 }
@@ -794,7 +794,7 @@ static void scan_add_host(struct soc_camera_host *ici)
794 794
795 list_for_each_entry(icd, &devices, list) { 795 list_for_each_entry(icd, &devices, list) {
796 if (icd->iface == ici->nr) { 796 if (icd->iface == ici->nr) {
797 icd->dev.parent = &ici->dev; 797 icd->dev.parent = ici->dev;
798 device_register_link(icd); 798 device_register_link(icd);
799 } 799 }
800 } 800 }
@@ -818,7 +818,7 @@ static int scan_add_device(struct soc_camera_device *icd)
818 list_for_each_entry(ici, &hosts, list) { 818 list_for_each_entry(ici, &hosts, list) {
819 if (icd->iface == ici->nr) { 819 if (icd->iface == ici->nr) {
820 ret = 1; 820 ret = 1;
821 icd->dev.parent = &ici->dev; 821 icd->dev.parent = ici->dev;
822 break; 822 break;
823 } 823 }
824 } 824 }
@@ -952,7 +952,6 @@ static void dummy_release(struct device *dev)
952 952
953int soc_camera_host_register(struct soc_camera_host *ici) 953int soc_camera_host_register(struct soc_camera_host *ici)
954{ 954{
955 int ret;
956 struct soc_camera_host *ix; 955 struct soc_camera_host *ix;
957 956
958 if (!ici || !ici->ops || 957 if (!ici || !ici->ops ||
@@ -965,12 +964,10 @@ int soc_camera_host_register(struct soc_camera_host *ici)
965 !ici->ops->reqbufs || 964 !ici->ops->reqbufs ||
966 !ici->ops->add || 965 !ici->ops->add ||
967 !ici->ops->remove || 966 !ici->ops->remove ||
968 !ici->ops->poll) 967 !ici->ops->poll ||
968 !ici->dev)
969 return -EINVAL; 969 return -EINVAL;
970 970
971 /* Number might be equal to the platform device ID */
972 dev_set_name(&ici->dev, "camera_host%d", ici->nr);
973
974 mutex_lock(&list_lock); 971 mutex_lock(&list_lock);
975 list_for_each_entry(ix, &hosts, list) { 972 list_for_each_entry(ix, &hosts, list) {
976 if (ix->nr == ici->nr) { 973 if (ix->nr == ici->nr) {
@@ -979,26 +976,14 @@ int soc_camera_host_register(struct soc_camera_host *ici)
979 } 976 }
980 } 977 }
981 978
979 dev_set_drvdata(ici->dev, ici);
980
982 list_add_tail(&ici->list, &hosts); 981 list_add_tail(&ici->list, &hosts);
983 mutex_unlock(&list_lock); 982 mutex_unlock(&list_lock);
984 983
985 ici->dev.release = dummy_release;
986
987 ret = device_register(&ici->dev);
988
989 if (ret)
990 goto edevr;
991
992 scan_add_host(ici); 984 scan_add_host(ici);
993 985
994 return 0; 986 return 0;
995
996edevr:
997 mutex_lock(&list_lock);
998 list_del(&ici->list);
999 mutex_unlock(&list_lock);
1000
1001 return ret;
1002} 987}
1003EXPORT_SYMBOL(soc_camera_host_register); 988EXPORT_SYMBOL(soc_camera_host_register);
1004 989
@@ -1012,7 +997,7 @@ void soc_camera_host_unregister(struct soc_camera_host *ici)
1012 list_del(&ici->list); 997 list_del(&ici->list);
1013 998
1014 list_for_each_entry(icd, &devices, list) { 999 list_for_each_entry(icd, &devices, list) {
1015 if (icd->dev.parent == &ici->dev) { 1000 if (icd->dev.parent == ici->dev) {
1016 device_unregister(&icd->dev); 1001 device_unregister(&icd->dev);
1017 /* Not before device_unregister(), .remove 1002 /* Not before device_unregister(), .remove
1018 * needs parent to call ici->ops->remove() */ 1003 * needs parent to call ici->ops->remove() */
@@ -1023,7 +1008,7 @@ void soc_camera_host_unregister(struct soc_camera_host *ici)
1023 1008
1024 mutex_unlock(&list_lock); 1009 mutex_unlock(&list_lock);
1025 1010
1026 device_unregister(&ici->dev); 1011 dev_set_drvdata(ici->dev, NULL);
1027} 1012}
1028EXPORT_SYMBOL(soc_camera_host_unregister); 1013EXPORT_SYMBOL(soc_camera_host_unregister);
1029 1014
@@ -1130,7 +1115,7 @@ int soc_camera_video_start(struct soc_camera_device *icd)
1130 vdev = video_device_alloc(); 1115 vdev = video_device_alloc();
1131 if (!vdev) 1116 if (!vdev)
1132 goto evidallocd; 1117 goto evidallocd;
1133 dev_dbg(&ici->dev, "Allocated video_device %p\n", vdev); 1118 dev_dbg(ici->dev, "Allocated video_device %p\n", vdev);
1134 1119
1135 strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name)); 1120 strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name));
1136 1121