mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-10 07:44:23 +08:00
media: rcar-vin: Move pm_runtime_{get,put} out of helpers
The helpers rvin_power_{on,off} deal with both VIN and the parallel subdevice power. This makes it hard to merge the Gen2 and Gen3 open/release functions. Move the VIN power handling directly to the open/release functions to prepare for the merge. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
4e4ef86f52
commit
2a18fbec1d
@ -754,8 +754,6 @@ static int rvin_power_on(struct rvin_dev *vin)
|
|||||||
int ret;
|
int ret;
|
||||||
struct v4l2_subdev *sd = vin_to_source(vin);
|
struct v4l2_subdev *sd = vin_to_source(vin);
|
||||||
|
|
||||||
pm_runtime_get_sync(vin->v4l2_dev.dev);
|
|
||||||
|
|
||||||
ret = v4l2_subdev_call(sd, core, s_power, 1);
|
ret = v4l2_subdev_call(sd, core, s_power, 1);
|
||||||
if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
|
if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
|
||||||
return ret;
|
return ret;
|
||||||
@ -768,9 +766,6 @@ static int rvin_power_off(struct rvin_dev *vin)
|
|||||||
struct v4l2_subdev *sd = vin_to_source(vin);
|
struct v4l2_subdev *sd = vin_to_source(vin);
|
||||||
|
|
||||||
ret = v4l2_subdev_call(sd, core, s_power, 0);
|
ret = v4l2_subdev_call(sd, core, s_power, 0);
|
||||||
|
|
||||||
pm_runtime_put(vin->v4l2_dev.dev);
|
|
||||||
|
|
||||||
if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
|
if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -796,26 +791,36 @@ static int rvin_open(struct file *file)
|
|||||||
struct rvin_dev *vin = video_drvdata(file);
|
struct rvin_dev *vin = video_drvdata(file);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
ret = pm_runtime_get_sync(vin->dev);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
ret = mutex_lock_interruptible(&vin->lock);
|
ret = mutex_lock_interruptible(&vin->lock);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto err_pm;
|
||||||
|
|
||||||
file->private_data = vin;
|
file->private_data = vin;
|
||||||
|
|
||||||
ret = v4l2_fh_open(file);
|
ret = v4l2_fh_open(file);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto unlock;
|
goto err_unlock;
|
||||||
|
|
||||||
if (!v4l2_fh_is_singular_file(file))
|
if (v4l2_fh_is_singular_file(file)) {
|
||||||
goto unlock;
|
ret = rvin_initialize_device(file);
|
||||||
|
if (ret)
|
||||||
if (rvin_initialize_device(file)) {
|
goto err_open;
|
||||||
v4l2_fh_release(file);
|
|
||||||
ret = -ENODEV;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock:
|
|
||||||
mutex_unlock(&vin->lock);
|
mutex_unlock(&vin->lock);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
err_open:
|
||||||
|
v4l2_fh_release(file);
|
||||||
|
err_unlock:
|
||||||
|
mutex_unlock(&vin->lock);
|
||||||
|
err_pm:
|
||||||
|
pm_runtime_put(vin->dev);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -842,6 +847,8 @@ static int rvin_release(struct file *file)
|
|||||||
|
|
||||||
mutex_unlock(&vin->lock);
|
mutex_unlock(&vin->lock);
|
||||||
|
|
||||||
|
pm_runtime_put(vin->dev);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user