Skip to content

Commit 7469cd3

Browse files
daeseokyoungregkh
authored andcommitted
staging: atomisp: use local variable to reduce number of references
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 <[email protected]> Signed-off-by: Alan Cox <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d317d05 commit 7469cd3

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
251251
{
252252
/* FIXME! Only use subdev[0] status yet */
253253
struct atomisp_sub_device *asd = &isp->asd[0];
254+
const struct atomisp_dfs_config *dfs;
254255
unsigned int new_freq;
255256
struct atomisp_freq_scaling_rule curr_rules;
256257
int i, ret;
@@ -265,20 +266,22 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
265266
ATOMISP_PCI_DEVICE_SOC_CHT && ATOMISP_USE_YUVPP(asd))
266267
isp->dfs = &dfs_config_cht_soc;
267268

268-
if (isp->dfs->lowest_freq == 0 || isp->dfs->max_freq_at_vmin == 0 ||
269-
isp->dfs->highest_freq == 0 || isp->dfs->dfs_table_size == 0 ||
270-
!isp->dfs->dfs_table) {
269+
dfs = isp->dfs;
270+
271+
if (dfs->lowest_freq == 0 || dfs->max_freq_at_vmin == 0 ||
272+
dfs->highest_freq == 0 || dfs->dfs_table_size == 0 ||
273+
!dfs->dfs_table) {
271274
dev_err(isp->dev, "DFS configuration is invalid.\n");
272275
return -EINVAL;
273276
}
274277

275278
if (mode == ATOMISP_DFS_MODE_LOW) {
276-
new_freq = isp->dfs->lowest_freq;
279+
new_freq = dfs->lowest_freq;
277280
goto done;
278281
}
279282

280283
if (mode == ATOMISP_DFS_MODE_MAX) {
281-
new_freq = isp->dfs->highest_freq;
284+
new_freq = dfs->highest_freq;
282285
goto done;
283286
}
284287

@@ -304,26 +307,26 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
304307
}
305308

306309
/* search for the target frequency by looping freq rules*/
307-
for (i = 0; i < isp->dfs->dfs_table_size; i++) {
308-
if (curr_rules.width != isp->dfs->dfs_table[i].width &&
309-
isp->dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
310+
for (i = 0; i < dfs->dfs_table_size; i++) {
311+
if (curr_rules.width != dfs->dfs_table[i].width &&
312+
dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
310313
continue;
311-
if (curr_rules.height != isp->dfs->dfs_table[i].height &&
312-
isp->dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
314+
if (curr_rules.height != dfs->dfs_table[i].height &&
315+
dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
313316
continue;
314-
if (curr_rules.fps != isp->dfs->dfs_table[i].fps &&
315-
isp->dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
317+
if (curr_rules.fps != dfs->dfs_table[i].fps &&
318+
dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
316319
continue;
317-
if (curr_rules.run_mode != isp->dfs->dfs_table[i].run_mode &&
318-
isp->dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
320+
if (curr_rules.run_mode != dfs->dfs_table[i].run_mode &&
321+
dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
319322
continue;
320323
break;
321324
}
322325

323-
if (i == isp->dfs->dfs_table_size)
324-
new_freq = isp->dfs->max_freq_at_vmin;
326+
if (i == dfs->dfs_table_size)
327+
new_freq = dfs->max_freq_at_vmin;
325328
else
326-
new_freq = isp->dfs->dfs_table[i].isp_freq;
329+
new_freq = dfs->dfs_table[i].isp_freq;
327330

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

0 commit comments

Comments
 (0)