aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/soc_camera.c
diff options
context:
space:
mode:
authorMagnus Damm <magnus.damm@gmail.com>2008-07-11 19:59:34 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:25:21 -0400
commita034d1b76b173b37f9a3646aa8f50a2c14a0f3ea (patch)
tree318a5ccff6e07d0849c21a2d536ebadb96a767a7 /drivers/media/video/soc_camera.c
parent092d3921195c4553a1818e698cee7a281ab361f4 (diff)
V4L/DVB (8338): soc_camera: Move spinlocks
This patch moves the spinlock handling from soc_camera.c to the actual camera host driver. The spinlock_alloc/free callbacks are replaced with code in init_videobuf(). So far all camera host drivers implement their own spinlock_alloc/free methods anyway, and videobuf_queue_core_init() BUGs on a NULL spinlock argument, so, new camera host drivers will not forget to provide a spinlock when initialising their videobuf queues. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/soc_camera.c')
-rw-r--r--drivers/media/video/soc_camera.c39
1 files changed, 1 insertions, 38 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 38a89f133164..e39b98f1eca4 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -183,7 +183,6 @@ static int soc_camera_open(struct inode *inode, struct file *file)
183 struct soc_camera_device *icd; 183 struct soc_camera_device *icd;
184 struct soc_camera_host *ici; 184 struct soc_camera_host *ici;
185 struct soc_camera_file *icf; 185 struct soc_camera_file *icf;
186 spinlock_t *lock;
187 int ret; 186 int ret;
188 187
189 icf = vmalloc(sizeof(*icf)); 188 icf = vmalloc(sizeof(*icf));
@@ -210,13 +209,6 @@ static int soc_camera_open(struct inode *inode, struct file *file)
210 } 209 }
211 210
212 icf->icd = icd; 211 icf->icd = icd;
213
214 icf->lock = ici->ops->spinlock_alloc(icf);
215 if (!icf->lock) {
216 ret = -ENOMEM;
217 goto esla;
218 }
219
220 icd->use_count++; 212 icd->use_count++;
221 213
222 /* Now we really have to activate the camera */ 214 /* Now we really have to activate the camera */
@@ -234,17 +226,12 @@ static int soc_camera_open(struct inode *inode, struct file *file)
234 file->private_data = icf; 226 file->private_data = icf;
235 dev_dbg(&icd->dev, "camera device open\n"); 227 dev_dbg(&icd->dev, "camera device open\n");
236 228
237 ici->ops->init_videobuf(&icf->vb_vidq, icf->lock, icd); 229 ici->ops->init_videobuf(&icf->vb_vidq, icd);
238 230
239 return 0; 231 return 0;
240 232
241 /* All errors are entered with the video_lock held */ 233 /* All errors are entered with the video_lock held */
242eiciadd: 234eiciadd:
243 lock = icf->lock;
244 icf->lock = NULL;
245 if (ici->ops->spinlock_free)
246 ici->ops->spinlock_free(lock);
247esla:
248 module_put(ici->ops->owner); 235 module_put(ici->ops->owner);
249emgi: 236emgi:
250 module_put(icd->ops->owner); 237 module_put(icd->ops->owner);
@@ -260,15 +247,11 @@ static int soc_camera_close(struct inode *inode, struct file *file)
260 struct soc_camera_device *icd = icf->icd; 247 struct soc_camera_device *icd = icf->icd;
261 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 248 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
262 struct video_device *vdev = icd->vdev; 249 struct video_device *vdev = icd->vdev;
263 spinlock_t *lock = icf->lock;
264 250
265 mutex_lock(&video_lock); 251 mutex_lock(&video_lock);
266 icd->use_count--; 252 icd->use_count--;
267 if (!icd->use_count) 253 if (!icd->use_count)
268 ici->ops->remove(icd); 254 ici->ops->remove(icd);
269 icf->lock = NULL;
270 if (ici->ops->spinlock_free)
271 ici->ops->spinlock_free(lock);
272 module_put(icd->ops->owner); 255 module_put(icd->ops->owner);
273 module_put(ici->ops->owner); 256 module_put(ici->ops->owner);
274 mutex_unlock(&video_lock); 257 mutex_unlock(&video_lock);
@@ -764,21 +747,6 @@ static void dummy_release(struct device *dev)
764{ 747{
765} 748}
766 749
767static spinlock_t *spinlock_alloc(struct soc_camera_file *icf)
768{
769 spinlock_t *lock = kmalloc(sizeof(spinlock_t), GFP_KERNEL);
770
771 if (lock)
772 spin_lock_init(lock);
773
774 return lock;
775}
776
777static void spinlock_free(spinlock_t *lock)
778{
779 kfree(lock);
780}
781
782int soc_camera_host_register(struct soc_camera_host *ici) 750int soc_camera_host_register(struct soc_camera_host *ici)
783{ 751{
784 int ret; 752 int ret;
@@ -808,11 +776,6 @@ int soc_camera_host_register(struct soc_camera_host *ici)
808 if (ret) 776 if (ret)
809 goto edevr; 777 goto edevr;
810 778
811 if (!ici->ops->spinlock_alloc) {
812 ici->ops->spinlock_alloc = spinlock_alloc;
813 ici->ops->spinlock_free = spinlock_free;
814 }
815
816 scan_add_host(ici); 779 scan_add_host(ici);
817 780
818 return 0; 781 return 0;