aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/soc_camera.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@pengutronix.de>2008-04-04 12:41:25 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:07:57 -0400
commitb8d9904c3525c0a149976ffaad48fcb03e8703f7 (patch)
treeac116e518f70a694046752a05c16a5285bc4713f /drivers/media/video/soc_camera.c
parentce54093cefd64c1a2cb6b8c5ed1d68d2bd7a34ab (diff)
V4L/DVB (7500): soc-camera: extract function pointers from host object into operations
Function pointers and the driver owner are not expected to change throughout soc-camera host's life. Extract them into an operations struct. 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.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 4af38d444e0..43c8110599e 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -76,12 +76,12 @@ static int soc_camera_try_fmt_cap(struct file *file, void *priv,
76 } 76 }
77 77
78 /* test physical bus parameters */ 78 /* test physical bus parameters */
79 ret = ici->try_bus_param(icd, f->fmt.pix.pixelformat); 79 ret = ici->ops->try_bus_param(icd, f->fmt.pix.pixelformat);
80 if (ret) 80 if (ret)
81 return ret; 81 return ret;
82 82
83 /* limit format to hardware capabilities */ 83 /* limit format to hardware capabilities */
84 ret = ici->try_fmt_cap(icd, f); 84 ret = ici->ops->try_fmt_cap(icd, f);
85 85
86 /* calculate missing fields */ 86 /* calculate missing fields */
87 f->fmt.pix.field = field; 87 f->fmt.pix.field = field;
@@ -143,7 +143,7 @@ static int soc_camera_reqbufs(struct file *file, void *priv,
143 if (ret < 0) 143 if (ret < 0)
144 return ret; 144 return ret;
145 145
146 return ici->reqbufs(icf, p); 146 return ici->ops->reqbufs(icf, p);
147 147
148 return ret; 148 return ret;
149} 149}
@@ -203,7 +203,7 @@ static int soc_camera_open(struct inode *inode, struct file *file)
203 goto emgd; 203 goto emgd;
204 } 204 }
205 205
206 if (!try_module_get(ici->owner)) { 206 if (!try_module_get(ici->ops->owner)) {
207 dev_err(&icd->dev, "Couldn't lock capture bus driver.\n"); 207 dev_err(&icd->dev, "Couldn't lock capture bus driver.\n");
208 ret = -EINVAL; 208 ret = -EINVAL;
209 goto emgi; 209 goto emgi;
@@ -215,7 +215,7 @@ static int soc_camera_open(struct inode *inode, struct file *file)
215 215
216 /* Now we really have to activate the camera */ 216 /* Now we really have to activate the camera */
217 if (icd->use_count == 1) { 217 if (icd->use_count == 1) {
218 ret = ici->add(icd); 218 ret = ici->ops->add(icd);
219 if (ret < 0) { 219 if (ret < 0) {
220 dev_err(&icd->dev, "Couldn't activate the camera: %d\n", ret); 220 dev_err(&icd->dev, "Couldn't activate the camera: %d\n", ret);
221 icd->use_count--; 221 icd->use_count--;
@@ -238,7 +238,7 @@ static int soc_camera_open(struct inode *inode, struct file *file)
238 238
239 /* All errors are entered with the video_lock held */ 239 /* All errors are entered with the video_lock held */
240eiciadd: 240eiciadd:
241 module_put(ici->owner); 241 module_put(ici->ops->owner);
242emgi: 242emgi:
243 module_put(icd->ops->owner); 243 module_put(icd->ops->owner);
244emgd: 244emgd:
@@ -257,9 +257,9 @@ static int soc_camera_close(struct inode *inode, struct file *file)
257 mutex_lock(&video_lock); 257 mutex_lock(&video_lock);
258 icd->use_count--; 258 icd->use_count--;
259 if (!icd->use_count) 259 if (!icd->use_count)
260 ici->remove(icd); 260 ici->ops->remove(icd);
261 module_put(icd->ops->owner); 261 module_put(icd->ops->owner);
262 module_put(ici->owner); 262 module_put(ici->ops->owner);
263 mutex_unlock(&video_lock); 263 mutex_unlock(&video_lock);
264 264
265 vfree(file->private_data); 265 vfree(file->private_data);
@@ -312,7 +312,7 @@ static unsigned int soc_camera_poll(struct file *file, poll_table *pt)
312 return POLLERR; 312 return POLLERR;
313 } 313 }
314 314
315 return ici->poll(file, pt); 315 return ici->ops->poll(file, pt);
316} 316}
317 317
318 318
@@ -356,7 +356,7 @@ static int soc_camera_s_fmt_cap(struct file *file, void *priv,
356 rect.top = icd->y_current; 356 rect.top = icd->y_current;
357 rect.width = f->fmt.pix.width; 357 rect.width = f->fmt.pix.width;
358 rect.height = f->fmt.pix.height; 358 rect.height = f->fmt.pix.height;
359 ret = ici->set_fmt_cap(icd, f->fmt.pix.pixelformat, &rect); 359 ret = ici->ops->set_fmt_cap(icd, f->fmt.pix.pixelformat, &rect);
360 if (ret < 0) 360 if (ret < 0)
361 return ret; 361 return ret;
362 362
@@ -372,7 +372,7 @@ static int soc_camera_s_fmt_cap(struct file *file, void *priv,
372 icd->width, icd->height); 372 icd->width, icd->height);
373 373
374 /* set physical bus parameters */ 374 /* set physical bus parameters */
375 return ici->set_bus_param(icd, f->fmt.pix.pixelformat); 375 return ici->ops->set_bus_param(icd, f->fmt.pix.pixelformat);
376} 376}
377 377
378static int soc_camera_enum_fmt_cap(struct file *file, void *priv, 378static int soc_camera_enum_fmt_cap(struct file *file, void *priv,
@@ -426,7 +426,7 @@ static int soc_camera_querycap(struct file *file, void *priv,
426 WARN_ON(priv != file->private_data); 426 WARN_ON(priv != file->private_data);
427 427
428 strlcpy(cap->driver, ici->drv_name, sizeof(cap->driver)); 428 strlcpy(cap->driver, ici->drv_name, sizeof(cap->driver));
429 return ici->querycap(ici, cap); 429 return ici->ops->querycap(ici, cap);
430} 430}
431 431
432static int soc_camera_streamon(struct file *file, void *priv, 432static int soc_camera_streamon(struct file *file, void *priv,
@@ -579,7 +579,7 @@ static int soc_camera_s_crop(struct file *file, void *fh,
579 if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 579 if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
580 return -EINVAL; 580 return -EINVAL;
581 581
582 ret = ici->set_fmt_cap(icd, 0, &a->c); 582 ret = ici->ops->set_fmt_cap(icd, 0, &a->c);
583 if (!ret) { 583 if (!ret) {
584 icd->width = a->c.width; 584 icd->width = a->c.width;
585 icd->height = a->c.height; 585 icd->height = a->c.height;
@@ -706,7 +706,7 @@ static int soc_camera_probe(struct device *dev)
706 706
707 /* We only call ->add() here to activate and probe the camera. 707 /* We only call ->add() here to activate and probe the camera.
708 * We shall ->remove() and deactivate it immediately afterwards. */ 708 * We shall ->remove() and deactivate it immediately afterwards. */
709 ret = ici->add(icd); 709 ret = ici->ops->add(icd);
710 if (ret < 0) 710 if (ret < 0)
711 return ret; 711 return ret;
712 712
@@ -720,7 +720,7 @@ static int soc_camera_probe(struct device *dev)
720 icd->exposure = qctrl ? qctrl->default_value : 720 icd->exposure = qctrl ? qctrl->default_value :
721 (unsigned short)~0; 721 (unsigned short)~0;
722 } 722 }
723 ici->remove(icd); 723 ici->ops->remove(icd);
724 724
725 return ret; 725 return ret;
726} 726}
@@ -762,12 +762,12 @@ static void dummy_release(struct device *dev)
762{ 762{
763} 763}
764 764
765int soc_camera_host_register(struct soc_camera_host *ici, struct module *owner) 765int soc_camera_host_register(struct soc_camera_host *ici)
766{ 766{
767 int ret; 767 int ret;
768 struct soc_camera_host *ix; 768 struct soc_camera_host *ix;
769 769
770 if (!ici->vbq_ops || !ici->add || !ici->remove || !owner) 770 if (!ici->vbq_ops || !ici->ops->add || !ici->ops->remove)
771 return -EINVAL; 771 return -EINVAL;
772 772
773 /* Number might be equal to the platform device ID */ 773 /* Number might be equal to the platform device ID */
@@ -785,7 +785,6 @@ int soc_camera_host_register(struct soc_camera_host *ici, struct module *owner)
785 list_add_tail(&ici->list, &hosts); 785 list_add_tail(&ici->list, &hosts);
786 mutex_unlock(&list_lock); 786 mutex_unlock(&list_lock);
787 787
788 ici->owner = owner;
789 ici->dev.release = dummy_release; 788 ici->dev.release = dummy_release;
790 789
791 ret = device_register(&ici->dev); 790 ret = device_register(&ici->dev);
@@ -819,7 +818,7 @@ void soc_camera_host_unregister(struct soc_camera_host *ici)
819 if (icd->dev.parent == &ici->dev) { 818 if (icd->dev.parent == &ici->dev) {
820 device_unregister(&icd->dev); 819 device_unregister(&icd->dev);
821 /* Not before device_unregister(), .remove 820 /* Not before device_unregister(), .remove
822 * needs parent to call ici->remove() */ 821 * needs parent to call ici->ops->remove() */
823 icd->dev.parent = NULL; 822 icd->dev.parent = NULL;
824 memset(&icd->dev.kobj, 0, sizeof(icd->dev.kobj)); 823 memset(&icd->dev.kobj, 0, sizeof(icd->dev.kobj));
825 } 824 }