From patchwork Wed Apr 12 18:20:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cox X-Patchwork-Id: 40766 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cyMsE-0003nu-Vp; Wed, 12 Apr 2017 18:20:11 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.84_2/mailfrontend-6) with esmtp id 1cyMsC-0004mS-4Y; Wed, 12 Apr 2017 20:20:10 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754767AbdDLSUG (ORCPT + 1 other); Wed, 12 Apr 2017 14:20:06 -0400 Received: from mga01.intel.com ([192.55.52.88]:58763 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754745AbdDLSUG (ORCPT ); Wed, 12 Apr 2017 14:20:06 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Apr 2017 11:20:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,191,1488873600"; d="scan'208";a="1118702180" Received: from acox1-desk1.ger.corp.intel.com ([10.252.16.134]) by orsmga001.jf.intel.com with ESMTP; 12 Apr 2017 11:20:03 -0700 Subject: [PATCH 01/14] staging: atomisp: use local variable to reduce number of references From: Alan Cox To: greg@kroah.com, linux-media@vger.kernel.org Date: Wed, 12 Apr 2017 19:20:01 +0100 Message-ID: <149202119790.16615.4841216953457109397.stgit@acox1-desk1.ger.corp.intel.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2017.4.12.180915 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, MSGID_ADDED_BY_MTA 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, NO_URI_HTTPS 0, __ANY_URI 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __HAS_FROM 0, __HAS_LIST_ID 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_VERSION 0, __NO_HTML_TAG_RAW 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' From: 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 Signed-off-by: Alan Cox --- .../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 94bc793..9ad5146 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; @@ -265,20 +266,22 @@ int atomisp_freq_scaling(struct atomisp_device *isp, ATOMISP_PCI_DEVICE_SOC_CHT && 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; } @@ -304,26 +307,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; done: dev_dbg(isp->dev, "DFS target frequency=%d.\n", new_freq);