Message ID | 20190516011417.10590-7-niklas.soderlund+renesas@ragnatech.se (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Kieran Bingham |
Headers | show |
Series | rcar-vin: Merge Gen2 and Gen3 file operations | expand |
> On May 16, 2019 at 3:14 AM Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> wrote: > > > The two power helpers are now only dealing with the parallel subdevice, > merge them into a single rvin_power_parallel() helper to reduce code > duplication. > > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> > --- > drivers/media/platform/rcar-vin/rcar-v4l2.c | 20 +++++--------------- > 1 file changed, 5 insertions(+), 15 deletions(-) > > diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c > index 5a9658b7d848fc86..7c8ba4b310706ceb 100644 > --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c > +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c > @@ -749,23 +749,13 @@ static const struct v4l2_ioctl_ops rvin_mc_ioctl_ops = { > * File Operations > */ > > -static int rvin_power_on(struct rvin_dev *vin) > +static int rvin_power_parallel(struct rvin_dev *vin, bool on) > { > - int ret; > struct v4l2_subdev *sd = vin_to_source(vin); > - > - ret = v4l2_subdev_call(sd, core, s_power, 1); > - if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) > - return ret; > - return 0; > -} > - > -static int rvin_power_off(struct rvin_dev *vin) > -{ > + int power = on ? 1 : 0; > int ret; > - 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, power); > if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) > return ret; > > @@ -777,7 +767,7 @@ static int rvin_initialize_device(struct file *file) > struct rvin_dev *vin = video_drvdata(file); > int ret; > > - ret = rvin_power_on(vin); > + ret = rvin_power_parallel(vin, true); > if (ret < 0) > return ret; > > @@ -844,7 +834,7 @@ static int rvin_release(struct file *file) > * Then de-initialize hw module. > */ > if (fh_singular) > - rvin_power_off(vin); > + rvin_power_parallel(vin, false); > > pm_runtime_put(vin->dev); > > -- > 2.21.0 > Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu> CU Uli
Hi Niklas, Thank you for the patch. On Thu, May 16, 2019 at 03:14:15AM +0200, Niklas Söderlund wrote: > The two power helpers are now only dealing with the parallel subdevice, > merge them into a single rvin_power_parallel() helper to reduce code > duplication. > > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> > --- > drivers/media/platform/rcar-vin/rcar-v4l2.c | 20 +++++--------------- > 1 file changed, 5 insertions(+), 15 deletions(-) > > diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c > index 5a9658b7d848fc86..7c8ba4b310706ceb 100644 > --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c > +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c > @@ -749,23 +749,13 @@ static const struct v4l2_ioctl_ops rvin_mc_ioctl_ops = { > * File Operations > */ > > -static int rvin_power_on(struct rvin_dev *vin) > +static int rvin_power_parallel(struct rvin_dev *vin, bool on) > { > - int ret; > struct v4l2_subdev *sd = vin_to_source(vin); > - > - ret = v4l2_subdev_call(sd, core, s_power, 1); > - if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) > - return ret; > - return 0; > -} > - > -static int rvin_power_off(struct rvin_dev *vin) > -{ > + int power = on ? 1 : 0; You could use on directly instead of going through a separate variable. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > int ret; > - 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, power); > if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) > return ret; > > @@ -777,7 +767,7 @@ static int rvin_initialize_device(struct file *file) > struct rvin_dev *vin = video_drvdata(file); > int ret; > > - ret = rvin_power_on(vin); > + ret = rvin_power_parallel(vin, true); > if (ret < 0) > return ret; > > @@ -844,7 +834,7 @@ static int rvin_release(struct file *file) > * Then de-initialize hw module. > */ > if (fh_singular) > - rvin_power_off(vin); > + rvin_power_parallel(vin, false); > > pm_runtime_put(vin->dev); >
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 5a9658b7d848fc86..7c8ba4b310706ceb 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -749,23 +749,13 @@ static const struct v4l2_ioctl_ops rvin_mc_ioctl_ops = { * File Operations */ -static int rvin_power_on(struct rvin_dev *vin) +static int rvin_power_parallel(struct rvin_dev *vin, bool on) { - int ret; struct v4l2_subdev *sd = vin_to_source(vin); - - ret = v4l2_subdev_call(sd, core, s_power, 1); - if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) - return ret; - return 0; -} - -static int rvin_power_off(struct rvin_dev *vin) -{ + int power = on ? 1 : 0; int ret; - 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, power); if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) return ret; @@ -777,7 +767,7 @@ static int rvin_initialize_device(struct file *file) struct rvin_dev *vin = video_drvdata(file); int ret; - ret = rvin_power_on(vin); + ret = rvin_power_parallel(vin, true); if (ret < 0) return ret; @@ -844,7 +834,7 @@ static int rvin_release(struct file *file) * Then de-initialize hw module. */ if (fh_singular) - rvin_power_off(vin); + rvin_power_parallel(vin, false); pm_runtime_put(vin->dev);
The two power helpers are now only dealing with the parallel subdevice, merge them into a single rvin_power_parallel() helper to reduce code duplication. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)