mirror of
https://github.com/torvalds/linux.git
synced 2024-12-24 11:51:27 +00:00
[media] soc-camera: Make clock_start and clock_stop operations optional
Instead of forcing drivers to implement empty clock operations, make them optional. v4l2 clock registration in the soc-camera core should probably be conditionned on the availability of those operations, but careful review and/or testing of all drivers would be needed, so that should be a separate step. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
parent
2af12f0258
commit
3781760a3d
@ -177,6 +177,30 @@ static int __soc_camera_power_off(struct soc_camera_device *icd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int soc_camera_clock_start(struct soc_camera_host *ici)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!ici->ops->clock_start)
|
||||
return 0;
|
||||
|
||||
mutex_lock(&ici->clk_lock);
|
||||
ret = ici->ops->clock_start(ici);
|
||||
mutex_unlock(&ici->clk_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void soc_camera_clock_stop(struct soc_camera_host *ici)
|
||||
{
|
||||
if (!ici->ops->clock_stop)
|
||||
return;
|
||||
|
||||
mutex_lock(&ici->clk_lock);
|
||||
ici->ops->clock_stop(ici);
|
||||
mutex_unlock(&ici->clk_lock);
|
||||
}
|
||||
|
||||
const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
|
||||
struct soc_camera_device *icd, unsigned int fourcc)
|
||||
{
|
||||
@ -584,9 +608,7 @@ static int soc_camera_add_device(struct soc_camera_device *icd)
|
||||
return -EBUSY;
|
||||
|
||||
if (!icd->clk) {
|
||||
mutex_lock(&ici->clk_lock);
|
||||
ret = ici->ops->clock_start(ici);
|
||||
mutex_unlock(&ici->clk_lock);
|
||||
ret = soc_camera_clock_start(ici);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
@ -602,11 +624,8 @@ static int soc_camera_add_device(struct soc_camera_device *icd)
|
||||
return 0;
|
||||
|
||||
eadd:
|
||||
if (!icd->clk) {
|
||||
mutex_lock(&ici->clk_lock);
|
||||
ici->ops->clock_stop(ici);
|
||||
mutex_unlock(&ici->clk_lock);
|
||||
}
|
||||
if (!icd->clk)
|
||||
soc_camera_clock_stop(ici);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -619,11 +638,8 @@ static void soc_camera_remove_device(struct soc_camera_device *icd)
|
||||
|
||||
if (ici->ops->remove)
|
||||
ici->ops->remove(icd);
|
||||
if (!icd->clk) {
|
||||
mutex_lock(&ici->clk_lock);
|
||||
ici->ops->clock_stop(ici);
|
||||
mutex_unlock(&ici->clk_lock);
|
||||
}
|
||||
if (!icd->clk)
|
||||
soc_camera_clock_stop(ici);
|
||||
ici->icd = NULL;
|
||||
}
|
||||
|
||||
@ -1180,7 +1196,6 @@ static int soc_camera_clk_enable(struct v4l2_clk *clk)
|
||||
{
|
||||
struct soc_camera_device *icd = clk->priv;
|
||||
struct soc_camera_host *ici;
|
||||
int ret;
|
||||
|
||||
if (!icd || !icd->parent)
|
||||
return -ENODEV;
|
||||
@ -1194,10 +1209,7 @@ static int soc_camera_clk_enable(struct v4l2_clk *clk)
|
||||
* If a different client is currently being probed, the host will tell
|
||||
* you to go
|
||||
*/
|
||||
mutex_lock(&ici->clk_lock);
|
||||
ret = ici->ops->clock_start(ici);
|
||||
mutex_unlock(&ici->clk_lock);
|
||||
return ret;
|
||||
return soc_camera_clock_start(ici);
|
||||
}
|
||||
|
||||
static void soc_camera_clk_disable(struct v4l2_clk *clk)
|
||||
@ -1210,9 +1222,7 @@ static void soc_camera_clk_disable(struct v4l2_clk *clk)
|
||||
|
||||
ici = to_soc_camera_host(icd->parent);
|
||||
|
||||
mutex_lock(&ici->clk_lock);
|
||||
ici->ops->clock_stop(ici);
|
||||
mutex_unlock(&ici->clk_lock);
|
||||
soc_camera_clock_stop(ici);
|
||||
|
||||
module_put(ici->ops->owner);
|
||||
}
|
||||
@ -1754,9 +1764,7 @@ static int soc_camera_probe(struct soc_camera_host *ici,
|
||||
ret = -EINVAL;
|
||||
goto eadd;
|
||||
} else {
|
||||
mutex_lock(&ici->clk_lock);
|
||||
ret = ici->ops->clock_start(ici);
|
||||
mutex_unlock(&ici->clk_lock);
|
||||
ret = soc_camera_clock_start(ici);
|
||||
if (ret < 0)
|
||||
goto eadd;
|
||||
|
||||
@ -1796,9 +1804,7 @@ efinish:
|
||||
module_put(control->driver->owner);
|
||||
enodrv:
|
||||
eadddev:
|
||||
mutex_lock(&ici->clk_lock);
|
||||
ici->ops->clock_stop(ici);
|
||||
mutex_unlock(&ici->clk_lock);
|
||||
soc_camera_clock_stop(ici);
|
||||
}
|
||||
eadd:
|
||||
if (icd->vdev) {
|
||||
@ -1936,8 +1942,6 @@ int soc_camera_host_register(struct soc_camera_host *ici)
|
||||
((!ici->ops->init_videobuf ||
|
||||
!ici->ops->reqbufs) &&
|
||||
!ici->ops->init_videobuf2) ||
|
||||
!ici->ops->clock_start ||
|
||||
!ici->ops->clock_stop ||
|
||||
!ici->ops->poll ||
|
||||
!ici->v4l2_dev.dev)
|
||||
return -EINVAL;
|
||||
|
Loading…
Reference in New Issue
Block a user