linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Daeseok Youn <daeseok.youn@gmail.com>
Cc: mchehab@kernel.org, gregkh@linuxfoundation.org,
	alan@linux.intel.com, singhalsimran0@gmail.com,
	dan.carpenter@oracle.com, linux-media@vger.kernel.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 2/4] staging: atomisp: simplify if statement in atomisp_get_sensor_fps()
Date: Mon, 20 Mar 2017 13:04:49 +0100	[thread overview]
Message-ID: <58CFC561.8090104@bfs.de> (raw)
In-Reply-To: <20170320105940.GA17472@SEL-JYOUN-D1>



Am 20.03.2017 11:59, schrieb Daeseok Youn:
> If v4l2_subdev_call() gets the global frame interval values,
> it returned 0 and it could be checked whether numerator is zero or not.
> 
> If the numerator is not zero, the fps could be calculated in this function.
> If not, it just returns 0.
> 
> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
> ---
>  .../media/atomisp/pci/atomisp2/atomisp_cmd.c       | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
> index 8bdb224..6bdd19e 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
> @@ -153,20 +153,18 @@ struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct video_device *dev)
>  
>  static unsigned short atomisp_get_sensor_fps(struct atomisp_sub_device *asd)
>  {
> -	struct v4l2_subdev_frame_interval frame_interval;
> +	struct v4l2_subdev_frame_interval fi;
>  	struct atomisp_device *isp = asd->isp;
> -	unsigned short fps;
>  
> -	if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
> -	    video, g_frame_interval, &frame_interval)) {
> -		fps = 0;
> -	} else {
> -		if (frame_interval.interval.numerator)
> -			fps = frame_interval.interval.denominator /
> -			    frame_interval.interval.numerator;
> -		else
> -			fps = 0;
> -	}
> +	unsigned short fps = 0;
> +	int ret;
> +
> +	ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
> +			       video, g_frame_interval, &fi);
> +
> +	if (!ret && fi.interval.numerator)
> +		fps = fi.interval.denominator / fi.interval.numerator;
> +
>  	return fps;
>  }



do you need to check ret at all ? if an error occurs can fi.interval.numerator
be something else than 0 ?

if ret is an ERRNO it would be wise to return ret not fps, but this may require
changes at other places also.

re,
 wh

>  

  reply	other threads:[~2017-03-20 12:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-20 10:59 [PATCH 2/4] staging: atomisp: simplify if statement in atomisp_get_sensor_fps() Daeseok Youn
2017-03-20 12:04 ` walter harms [this message]
2017-03-20 12:51   ` DaeSeok Youn
2017-03-20 13:11     ` walter harms
2017-03-21  1:43       ` DaeSeok Youn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58CFC561.8090104@bfs.de \
    --to=wharms@bfs.de \
    --cc=alan@linux.intel.com \
    --cc=daeseok.youn@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=singhalsimran0@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).