public inbox for kernel-janitors@vger.kernel.org
 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, dan.carpenter@oracle.com,
	singhalsimran0@gmail.com, linux-media@vger.kernel.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 2/2] staging: atomisp: use local variable to reduce the number of reference
Date: Thu, 30 Mar 2017 07:19:20 +0000	[thread overview]
Message-ID: <58DCB178.6070909@bfs.de> (raw)
In-Reply-To: <20170330062517.GA25231@SEL-JYOUN-D1>



Am 30.03.2017 08:25, schrieb Daeseok Youn:
> Define new local variable to reduce the number of reference.
> The new local variable is added to save the addess of dfs
> and used in atomisp_freq_scaling() function.
> 
> Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
> ---
>  .../media/atomisp/pci/atomisp2/atomisp_cmd.c       | 37 ++++++++++++----------
>  1 file changed, 20 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
> index eebfccd..d76a95c 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
> @@ -251,6 +251,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
>  {
>  	/* FIXME! Only use subdev[0] status yet */
>  	struct atomisp_sub_device *asd = &isp->asd[0];
> +	const struct atomisp_dfs_config *dfs;
>  	unsigned int new_freq;
>  	struct atomisp_freq_scaling_rule curr_rules;
>  	int i, ret;
> @@ -268,20 +269,22 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
>  	    ATOMISP_USE_YUVPP(asd))
>  		isp->dfs = &dfs_config_cht_soc;
>  
> -	if (isp->dfs->lowest_freq = 0 || isp->dfs->max_freq_at_vmin = 0 ||
> -	    isp->dfs->highest_freq = 0 || isp->dfs->dfs_table_size = 0 ||
> -	    !isp->dfs->dfs_table) {
> +	dfs = isp->dfs;
> +
> +	if (dfs->lowest_freq = 0 || dfs->max_freq_at_vmin = 0 ||
> +	    dfs->highest_freq = 0 || dfs->dfs_table_size = 0 ||
> +	    !dfs->dfs_table) {
>  		dev_err(isp->dev, "DFS configuration is invalid.\n");
>  		return -EINVAL;
>  	}
>  
>  	if (mode = ATOMISP_DFS_MODE_LOW) {
> -		new_freq = isp->dfs->lowest_freq;
> +		new_freq = dfs->lowest_freq;
>  		goto done;
>  	}
>  
>  	if (mode = ATOMISP_DFS_MODE_MAX) {
> -		new_freq = isp->dfs->highest_freq;
> +		new_freq = dfs->highest_freq;
>  		goto done;
>  	}
>  
> @@ -307,26 +310,26 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
>  	}
>  
>  	/* search for the target frequency by looping freq rules*/
> -	for (i = 0; i < isp->dfs->dfs_table_size; i++) {
> -		if (curr_rules.width != isp->dfs->dfs_table[i].width &&
> -		    isp->dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
> +	for (i = 0; i < dfs->dfs_table_size; i++) {
> +		if (curr_rules.width != dfs->dfs_table[i].width &&
> +		    dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
>  			continue;
> -		if (curr_rules.height != isp->dfs->dfs_table[i].height &&
> -		    isp->dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
> +		if (curr_rules.height != dfs->dfs_table[i].height &&
> +		    dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
>  			continue;
> -		if (curr_rules.fps != isp->dfs->dfs_table[i].fps &&
> -		    isp->dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
> +		if (curr_rules.fps != dfs->dfs_table[i].fps &&
> +		    dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
>  			continue;
> -		if (curr_rules.run_mode != isp->dfs->dfs_table[i].run_mode &&
> -		    isp->dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
> +		if (curr_rules.run_mode != dfs->dfs_table[i].run_mode &&
> +		    dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
>  			continue;
>  		break;
>  	}

>  
> -	if (i = isp->dfs->dfs_table_size)
> -		new_freq = isp->dfs->max_freq_at_vmin;
> +	if (i = dfs->dfs_table_size)
> +		new_freq = dfs->max_freq_at_vmin;
>  	else
> -		new_freq = isp->dfs->dfs_table[i].isp_freq;
> +		new_freq = dfs->dfs_table[i].isp_freq;
>  

you can eliminate the last block by setting

 new_freq = dfs->max_freq_at_vmin;

  for(i=0;....) {
        ....
	new_freq = dfs->dfs_table[i].isp_freq;
	break;
}

unfortunately i have no good idea how to make the loop more readable.


re,
 wh


>  done:
>  	dev_dbg(isp->dev, "DFS target frequency=%d.\n", new_freq);

  reply	other threads:[~2017-03-30  7:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30  6:25 [PATCH 2/2] staging: atomisp: use local variable to reduce the number of reference Daeseok Youn
2017-03-30  7:19 ` walter harms [this message]
2017-03-30 10:26   ` 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=58DCB178.6070909@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