drivers/clk/at91/clk-sam9x60-pll.c:334:13: warning: variable 'best_div' set but not used

From: kernel test robot
Date: Sun Aug 16 2020 - 09:45:45 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4b6c093e21d36bede0fd88fd0aeb3b03647260e4
commit: 43b1bb4a9b3e183af12225f56c27164c10d06223 clk: at91: clk-sam9x60-pll: re-factor to support plls with multiple outputs
date: 3 weeks ago
config: arm-at91_dt_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 43b1bb4a9b3e183af12225f56c27164c10d06223
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

drivers/clk/at91/clk-sam9x60-pll.c: In function 'sam9x60_div_pll_compute_div':
>> drivers/clk/at91/clk-sam9x60-pll.c:334:13: warning: variable 'best_div' set but not used [-Wunused-but-set-variable]
334 | u32 divid, best_div;
| ^~~~~~~~

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=43b1bb4a9b3e183af12225f56c27164c10d06223
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 43b1bb4a9b3e183af12225f56c27164c10d06223
vim +/best_div +334 drivers/clk/at91/clk-sam9x60-pll.c

324
325 static long sam9x60_div_pll_compute_div(struct sam9x60_pll_core *core,
326 unsigned long *parent_rate,
327 unsigned long rate)
328 {
329 const struct clk_pll_characteristics *characteristics =
330 core->characteristics;
331 struct clk_hw *parent = clk_hw_get_parent(&core->hw);
332 unsigned long tmp_rate, tmp_parent_rate, tmp_diff;
333 long best_diff = -1, best_rate = -EINVAL;
> 334 u32 divid, best_div;
335
336 if (!rate)
337 return 0;
338
339 if (rate < characteristics->output[0].min ||
340 rate > characteristics->output[0].max)
341 return -ERANGE;
342
343 for (divid = 1; divid < core->layout->div_mask; divid++) {
344 tmp_parent_rate = clk_hw_round_rate(parent, rate * divid);
345 if (!tmp_parent_rate)
346 continue;
347
348 tmp_rate = DIV_ROUND_CLOSEST_ULL(tmp_parent_rate, divid);
349 tmp_diff = abs(rate - tmp_rate);
350
351 if (best_diff < 0 || best_diff > tmp_diff) {
352 *parent_rate = tmp_parent_rate;
353 best_rate = tmp_rate;
354 best_diff = tmp_diff;
355 best_div = divid;
356 }
357
358 if (!best_diff)
359 break;
360 }
361
362 if (best_rate < characteristics->output[0].min ||
363 best_rate > characteristics->output[0].max)
364 return -ERANGE;
365
366 return best_rate;
367 }
368

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip