* drivers/gpio/gpio-rockchip.c:201:53: warning: Division by zero [clang-analyzer-core.DivideZero]
@ 2022-01-09 0:45 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-01-09 0:45 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 18128 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Jianqun Xu <jay.xu@rock-chips.com>
CC: Linus Walleij <linus.walleij@linaro.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d1587f7bfe9a0f97a75d42ac1489aeda551106bc
commit: 3bcbd1a85b68e5f864029fd6f0bb0bcc8e2f1082 gpio/rockchip: support next version gpio controller
date: 5 months ago
:::::: branch date: 25 hours ago
:::::: commit date: 5 months ago
config: mips-randconfig-c004-20220107 (https://download.01.org/0day-ci/archive/20220109/202201090830.dSQuR0Hf-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 32167bfe64a4c5dd4eb3f7a58e24f4cba76f5ac2)
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
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3bcbd1a85b68e5f864029fd6f0bb0bcc8e2f1082
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 3bcbd1a85b68e5f864029fd6f0bb0bcc8e2f1082
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
^
include/linux/list.h:628:2: note: expanded from macro 'list_for_each_entry'
for (pos = list_first_entry(head, typeof(*pos), member); \
^
drivers/firewire/core-topology.c:328:15: note: Assuming 'i' is >= field 'port_count'
for (i = 0; i < node->port_count; i++) {
^~~~~~~~~~~~~~~~~~~~
drivers/firewire/core-topology.c:328:3: note: Loop condition is false. Execution continues on line 340
for (i = 0; i < node->port_count; i++) {
^
drivers/firewire/core-topology.c:340:3: note: Calling 'report_lost_node'
callback(card, node, parent);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firewire/core-topology.c:351:2: note: Calling 'fw_node_put'
fw_node_put(node);
^~~~~~~~~~~~~~~~~
drivers/firewire/core.h:206:2: note: Taking true branch
if (refcount_dec_and_test(&node->ref_count))
^
drivers/firewire/core.h:207:3: note: Memory is released
kfree(node);
^~~~~~~~~~~
drivers/firewire/core-topology.c:351:2: note: Returning; memory was released
fw_node_put(node);
^~~~~~~~~~~~~~~~~
drivers/firewire/core-topology.c:340:3: note: Returning; memory was released
callback(card, node, parent);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firewire/core-topology.c:325:2: note: Use of memory after it is freed
list_for_each_entry(node, &list, link) {
^
include/linux/list.h:630:13: note: expanded from macro 'list_for_each_entry'
pos = list_next_entry(pos, member))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:555:2: note: expanded from macro 'list_next_entry'
list_entry((pos)->member.next, typeof(*(pos)), member)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:494:25: note: expanded from macro 'container_of'
void *__mptr = (void *)(ptr); \
^~~~~
drivers/firewire/core-topology.c:494:20: warning: Access to field 'node_id' results in a dereference of a null pointer (loaded from field 'root_node') [clang-analyzer-core.NullDereference]
int node_count = (card->root_node->node_id & 0x3f) + 1;
^
drivers/firewire/core-topology.c:518:56: note: Left side of '&&' is false
if (!is_next_generation(generation, card->generation) &&
^
drivers/firewire/core-topology.c:524:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(&card->lock, flags);
^
include/linux/spinlock.h:384:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:250:2: note: expanded from macro 'raw_spin_lock_irqsave'
do { \
^
drivers/firewire/core-topology.c:524:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(&card->lock, flags);
^
include/linux/spinlock.h:382:43: note: expanded from macro 'spin_lock_irqsave'
#define spin_lock_irqsave(lock, flags) \
^
drivers/firewire/core-topology.c:539:15: note: Calling 'build_tree'
local_node = build_tree(card, self_ids, self_id_count);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firewire/core-topology.c:182:2: note: Null pointer value stored to 'node'
node = NULL;
^~~~~~~~~~~
drivers/firewire/core-topology.c:191:2: note: Loop condition is false. Execution continues on line 301
while (sid < end) {
^
drivers/firewire/core-topology.c:301:2: note: Null pointer value stored to field 'root_node'
card->root_node = node;
^~~~~~~~~~~~~~~~~~~~~~
drivers/firewire/core-topology.c:539:15: note: Returning from 'build_tree'
local_node = build_tree(card, self_ids, self_id_count);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firewire/core-topology.c:541:2: note: Calling 'update_topology_map'
update_topology_map(card, self_ids, self_id_count);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firewire/core-topology.c:494:20: note: Access to field 'node_id' results in a dereference of a null pointer (loaded from field 'root_node')
int node_count = (card->root_node->node_id & 0x3f) + 1;
^ ~~~~~~~~~
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
2 warnings generated.
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
drivers/gpio/gpio-pcf857x.c:237:23: warning: Value stored to 'np' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct device_node *np = client->dev.of_node;
^~ ~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-pcf857x.c:237:23: note: Value stored to 'np' during its initialization is never read
struct device_node *np = client->dev.of_node;
^~ ~~~~~~~~~~~~~~~~~~~
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
>> drivers/gpio/gpio-rockchip.c:201:53: warning: Division by zero [clang-analyzer-core.DivideZero]
max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq;
^
drivers/gpio/gpio-rockchip.c:272:2: note: Control jumps to 'case PIN_CONFIG_INPUT_DEBOUNCE:' at line 273
switch (param) {
^
drivers/gpio/gpio-rockchip.c:274:3: note: Calling 'rockchip_gpio_set_debounce'
rockchip_gpio_set_debounce(gc, offset, true);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:198:7: note: Calling 'IS_ERR'
if (!IS_ERR(bank->db_clk)) {
^~~~~~~~~~~~~~~~~~~~
include/linux/err.h:36:9: note: Assuming the condition is false
return IS_ERR_VALUE((unsigned long)ptr);
^
include/linux/err.h:22:34: note: expanded from macro 'IS_ERR_VALUE'
#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
^
include/linux/err.h:36:2: note: Returning zero, which participates in a condition later
return IS_ERR_VALUE((unsigned long)ptr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:198:7: note: Returning from 'IS_ERR'
if (!IS_ERR(bank->db_clk)) {
^~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:198:2: note: Taking true branch
if (!IS_ERR(bank->db_clk)) {
^
drivers/gpio/gpio-rockchip.c:200:10: note: Calling 'clk_get_rate'
freq = clk_get_rate(bank->db_clk);
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/clk.h:882:2: note: Returning zero
return 0;
^~~~~~~~
drivers/gpio/gpio-rockchip.c:200:10: note: Returning from 'clk_get_rate'
freq = clk_get_rate(bank->db_clk);
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:200:3: note: The value 0 is assigned to 'freq'
freq = clk_get_rate(bank->db_clk);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:201:53: note: Division by zero
max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
16 warnings generated.
fs/io_uring.c:1293:10: warning: Access to field 'io_wq' results in a dereference of a null pointer (loaded from variable 'tctx') [clang-analyzer-core.NullDereference]
BUG_ON(!tctx->io_wq);
^
fs/io_uring.c:8869:2: note: Calling 'io_ring_ctx_wait_and_kill'
io_ring_ctx_wait_and_kill(ctx);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/io_uring.c:8842:6: note: Assuming field 'rings' is null
if (ctx->rings)
^~~~~~~~~~
fs/io_uring.c:8842:2: note: Taking false branch
if (ctx->rings)
^
fs/io_uring.c:8844:2: note: Loop condition is false. Execution continues on line 8846
xa_for_each(&ctx->personalities, index, creds)
^
include/linux/xarray.h:499:2: note: expanded from macro 'xa_for_each'
xa_for_each_start(xa, index, entry, 0)
^
include/linux/xarray.h:475:2: note: expanded from macro 'xa_for_each_start'
xa_for_each_range(xa, index, entry, start, ULONG_MAX)
^
include/linux/xarray.h:446:2: note: expanded from macro 'xa_for_each_range'
for (index = start, \
^
fs/io_uring.c:8852:2: note: Calling 'io_iopoll_try_reap_events'
io_iopoll_try_reap_events(ctx);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/io_uring.c:2301:6: note: Assuming the condition is false
if (!(ctx->flags & IORING_SETUP_IOPOLL))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/io_uring.c:2301:2: note: Taking false branch
if (!(ctx->flags & IORING_SETUP_IOPOLL))
^
fs/io_uring.c:2305:2: note: Loop condition is true. Entering loop body
while (!list_empty(&ctx->iopoll_list)) {
^
fs/io_uring.c:2308:3: note: Calling 'io_do_iopoll'
io_do_iopoll(ctx, &nr_events, 0);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/io_uring.c:2258:9: note: Assuming field 'poll_multi_queue' is false
spin = !ctx->poll_multi_queue && *nr_events < min;
^~~~~~~~~~~~~~~~~~~~~~
fs/io_uring.c:2258:9: note: Left side of '&&' is true
fs/io_uring.c:2261:2: note: Left side of '&&' is false
list_for_each_entry_safe(req, tmp, &ctx->iopoll_list, inflight_entry) {
^
include/linux/list.h:715:13: note: expanded from macro 'list_for_each_entry_safe'
for (pos = list_first_entry(head, typeof(*pos), member), \
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
vim +201 drivers/gpio/gpio-rockchip.c
936ee2675eee1f Jianqun Xu 2021-08-16 186
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 187 static int rockchip_gpio_set_debounce(struct gpio_chip *gc,
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 188 unsigned int offset,
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 189 unsigned int debounce)
936ee2675eee1f Jianqun Xu 2021-08-16 190 {
936ee2675eee1f Jianqun Xu 2021-08-16 191 struct rockchip_pin_bank *bank = gpiochip_get_data(gc);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 192 const struct rockchip_gpio_regs *reg = bank->gpio_regs;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 193 unsigned long flags, div_reg, freq, max_debounce;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 194 bool div_debounce_support;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 195 unsigned int cur_div_reg;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 196 u64 div;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 197
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 198 if (!IS_ERR(bank->db_clk)) {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 199 div_debounce_support = true;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 200 freq = clk_get_rate(bank->db_clk);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 @201 max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 202 if (debounce > max_debounce)
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 203 return -EINVAL;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 204
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 205 div = debounce * freq;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 206 div_reg = DIV_ROUND_CLOSEST_ULL(div, 2 * USEC_PER_SEC) - 1;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 207 } else {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 208 div_debounce_support = false;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 209 }
936ee2675eee1f Jianqun Xu 2021-08-16 210
936ee2675eee1f Jianqun Xu 2021-08-16 211 raw_spin_lock_irqsave(&bank->slock, flags);
936ee2675eee1f Jianqun Xu 2021-08-16 212
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 213 /* Only the v1 needs to configure div_en and div_con for dbclk */
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 214 if (debounce) {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 215 if (div_debounce_support) {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 216 /* Configure the max debounce from consumers */
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 217 cur_div_reg = readl(bank->reg_base +
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 218 reg->dbclk_div_con);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 219 if (cur_div_reg < div_reg)
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 220 writel(div_reg, bank->reg_base +
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 221 reg->dbclk_div_con);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 222 rockchip_gpio_writel_bit(bank, offset, 1,
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 223 reg->dbclk_div_en);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 224 }
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 225
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 226 rockchip_gpio_writel_bit(bank, offset, 1, reg->debounce);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 227 } else {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 228 if (div_debounce_support)
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 229 rockchip_gpio_writel_bit(bank, offset, 0,
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 230 reg->dbclk_div_en);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 231
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 232 rockchip_gpio_writel_bit(bank, offset, 0, reg->debounce);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 233 }
936ee2675eee1f Jianqun Xu 2021-08-16 234
936ee2675eee1f Jianqun Xu 2021-08-16 235 raw_spin_unlock_irqrestore(&bank->slock, flags);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 236
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 237 /* Enable or disable dbclk at last */
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 238 if (div_debounce_support) {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 239 if (debounce)
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 240 clk_prepare_enable(bank->db_clk);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 241 else
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 242 clk_disable_unprepare(bank->db_clk);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 243 }
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 244
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 245 return 0;
936ee2675eee1f Jianqun Xu 2021-08-16 246 }
936ee2675eee1f Jianqun Xu 2021-08-16 247
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* drivers/gpio/gpio-rockchip.c:201:53: warning: Division by zero [clang-analyzer-core.DivideZero]
@ 2022-03-21 6:57 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-03-21 6:57 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 18686 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Jianqun Xu <jay.xu@rock-chips.com>
CC: Linus Walleij <linus.walleij@linaro.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f443e374ae131c168a065ea1748feac6b2e76613
commit: 3bcbd1a85b68e5f864029fd6f0bb0bcc8e2f1082 gpio/rockchip: support next version gpio controller
date: 7 months ago
:::::: branch date: 11 hours ago
:::::: commit date: 7 months ago
config: arm-randconfig-c002-20220312 (https://download.01.org/0day-ci/archive/20220321/202203211417.w5bsTTg6-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 276ca87382b8f16a65bddac700202924228982f6)
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
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3bcbd1a85b68e5f864029fd6f0bb0bcc8e2f1082
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 3bcbd1a85b68e5f864029fd6f0bb0bcc8e2f1082
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
8 warnings generated.
block/partitions/acorn.c:285:4: warning: Value stored to 'slot' is never read [clang-analyzer-deadcode.DeadStores]
slot = riscix_partition(state, start_sect, slot,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
block/partitions/acorn.c:285:4: note: Value stored to 'slot' is never read
slot = riscix_partition(state, start_sect, slot,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
block/partitions/acorn.c:291:4: warning: Value stored to 'slot' is never read [clang-analyzer-deadcode.DeadStores]
slot = linux_partition(state, start_sect, slot,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
block/partitions/acorn.c:291:4: note: Value stored to 'slot' is never read
slot = linux_partition(state, start_sect, slot,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
8 warnings generated.
drivers/misc/cardreader/rtsx_pcr.c:1254:7: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage [clang-analyzer-core.uninitialized.Assign]
val &= ~(1<<9);
~~~ ^
drivers/misc/cardreader/rtsx_pcr.c:1250:2: note: 'val' declared without an initial value
u16 val;
^~~~~~~
drivers/misc/cardreader/rtsx_pcr.c:1252:7: note: Assuming field 'device' is not equal to PID_525A
if ((PCI_PID(pcr) != PID_525A) && (PCI_PID(pcr) != PID_5260)) {
^
include/linux/rtsx_pci.h:1277:24: note: expanded from macro 'PCI_PID'
#define PCI_PID(pcr) ((pcr)->pci->device)
^
drivers/misc/cardreader/rtsx_pcr.c:1252:6: note: Left side of '&&' is true
if ((PCI_PID(pcr) != PID_525A) && (PCI_PID(pcr) != PID_5260)) {
^
drivers/misc/cardreader/rtsx_pcr.c:1252:37: note: Assuming field 'device' is not equal to PID_5260
if ((PCI_PID(pcr) != PID_525A) && (PCI_PID(pcr) != PID_5260)) {
^
include/linux/rtsx_pci.h:1277:24: note: expanded from macro 'PCI_PID'
#define PCI_PID(pcr) ((pcr)->pci->device)
^
drivers/misc/cardreader/rtsx_pcr.c:1252:2: note: Taking true branch
if ((PCI_PID(pcr) != PID_525A) && (PCI_PID(pcr) != PID_5260)) {
^
drivers/misc/cardreader/rtsx_pcr.c:1253:3: note: Calling 'rtsx_pci_read_phy_register'
rtsx_pci_read_phy_register(pcr, 0x01, &val);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/cardreader/rtsx_pcr.c:291:6: note: Assuming field 'read_phy' is null
if (pcr->ops->read_phy)
^~~~~~~~~~~~~~~~~~
drivers/misc/cardreader/rtsx_pcr.c:291:2: note: Taking false branch
if (pcr->ops->read_phy)
^
drivers/misc/cardreader/rtsx_pcr.c:294:9: note: Calling '__rtsx_pci_read_phy_register'
return __rtsx_pci_read_phy_register(pcr, addr, val);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/cardreader/rtsx_pcr.c:265:2: note: Loop condition is true. Entering loop body
for (i = 0; i < 100000; i++) {
^
drivers/misc/cardreader/rtsx_pcr.c:267:7: note: Assuming 'err' is < 0
if (err < 0)
^~~~~~~
drivers/misc/cardreader/rtsx_pcr.c:267:3: note: Taking true branch
if (err < 0)
^
drivers/misc/cardreader/rtsx_pcr.c:268:4: note: Returning without writing to '*val'
return err;
^
drivers/misc/cardreader/rtsx_pcr.c:294:9: note: Returning from '__rtsx_pci_read_phy_register'
return __rtsx_pci_read_phy_register(pcr, addr, val);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/cardreader/rtsx_pcr.c:294:2: note: Returning without writing to '*'
return __rtsx_pci_read_phy_register(pcr, addr, val);
^
drivers/misc/cardreader/rtsx_pcr.c:1253:3: note: Returning from 'rtsx_pci_read_phy_register'
rtsx_pci_read_phy_register(pcr, 0x01, &val);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/cardreader/rtsx_pcr.c:1254:7: note: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage
val &= ~(1<<9);
~~~ ^
drivers/misc/cardreader/rtsx_pcr.c:1305:3: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
err = rtsx_pci_write_register(pcr, RTS5261_FW_CFG1,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/cardreader/rtsx_pcr.c:1305:3: note: Value stored to 'err' is never read
err = rtsx_pci_write_register(pcr, RTS5261_FW_CFG1,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
1 warning generated.
>> drivers/gpio/gpio-rockchip.c:201:53: warning: Division by zero [clang-analyzer-core.DivideZero]
max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
drivers/gpio/gpio-rockchip.c:198:7: note: Calling 'IS_ERR'
if (!IS_ERR(bank->db_clk)) {
^~~~~~~~~~~~~~~~~~~~
include/linux/err.h:36:9: note: Assuming the condition is false
return IS_ERR_VALUE((unsigned long)ptr);
^
include/linux/err.h:22:34: note: expanded from macro 'IS_ERR_VALUE'
#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
^
include/linux/err.h:36:2: note: Returning zero, which participates in a condition later
return IS_ERR_VALUE((unsigned long)ptr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:198:7: note: Returning from 'IS_ERR'
if (!IS_ERR(bank->db_clk)) {
^~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:198:2: note: Taking true branch
if (!IS_ERR(bank->db_clk)) {
^
drivers/gpio/gpio-rockchip.c:200:10: note: Calling 'clk_get_rate'
freq = clk_get_rate(bank->db_clk);
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/clk.h:882:2: note: Returning zero
return 0;
^~~~~~~~
drivers/gpio/gpio-rockchip.c:200:10: note: Returning from 'clk_get_rate'
freq = clk_get_rate(bank->db_clk);
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:200:3: note: The value 0 is assigned to 'freq'
freq = clk_get_rate(bank->db_clk);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:201:53: note: Division by zero
max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
10 warnings generated.
drivers/scsi/mvumi.c:516:2: warning: Value stored to 'ob_write' is never read [clang-analyzer-deadcode.DeadStores]
ob_write = ioread32(regs->outb_read_pointer);
^
drivers/scsi/mvumi.c:516:2: note: Value stored to 'ob_write' is never read
drivers/scsi/mvumi.c:863:3: warning: Value stored to 'hs_page3' is never read [clang-analyzer-deadcode.DeadStores]
hs_page3 = (struct mvumi_hs_page3 *) hs_header;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/mvumi.c:863:3: note: Value stored to 'hs_page3' is never read
hs_page3 = (struct mvumi_hs_page3 *) hs_header;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:135:13: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
__list_del(entry->prev, entry->next);
^
drivers/scsi/mvumi.c:2538:6: note: Assuming field 'dm_thread' is null
if (mhba->dm_thread) {
^~~~~~~~~~~~~~~
drivers/scsi/mvumi.c:2538:2: note: Taking false branch
if (mhba->dm_thread) {
^
drivers/scsi/mvumi.c:2550:2: note: Calling 'mvumi_release_fw'
mvumi_release_fw(mhba);
^~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/mvumi.c:757:2: note: Calling 'mvumi_free_cmds'
mvumi_free_cmds(mhba);
^~~~~~~~~~~~~~~~~~~~~
drivers/scsi/mvumi.c:350:2: note: Loop condition is true. Entering loop body
while (!list_empty(&mhba->cmd_pool)) {
^
drivers/scsi/mvumi.c:351:9: note: Left side of '&&' is false
cmd = list_first_entry(&mhba->cmd_pool, struct mvumi_cmd,
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/scsi/mvumi.c:351:9: note: Taking false branch
cmd = list_first_entry(&mhba->cmd_pool, struct mvumi_cmd,
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
vim +201 drivers/gpio/gpio-rockchip.c
936ee2675eee1f Jianqun Xu 2021-08-16 186
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 187 static int rockchip_gpio_set_debounce(struct gpio_chip *gc,
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 188 unsigned int offset,
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 189 unsigned int debounce)
936ee2675eee1f Jianqun Xu 2021-08-16 190 {
936ee2675eee1f Jianqun Xu 2021-08-16 191 struct rockchip_pin_bank *bank = gpiochip_get_data(gc);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 192 const struct rockchip_gpio_regs *reg = bank->gpio_regs;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 193 unsigned long flags, div_reg, freq, max_debounce;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 194 bool div_debounce_support;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 195 unsigned int cur_div_reg;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 196 u64 div;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 197
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 198 if (!IS_ERR(bank->db_clk)) {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 199 div_debounce_support = true;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 200 freq = clk_get_rate(bank->db_clk);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 @201 max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 202 if (debounce > max_debounce)
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 203 return -EINVAL;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 204
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 205 div = debounce * freq;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 206 div_reg = DIV_ROUND_CLOSEST_ULL(div, 2 * USEC_PER_SEC) - 1;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 207 } else {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 208 div_debounce_support = false;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 209 }
936ee2675eee1f Jianqun Xu 2021-08-16 210
936ee2675eee1f Jianqun Xu 2021-08-16 211 raw_spin_lock_irqsave(&bank->slock, flags);
936ee2675eee1f Jianqun Xu 2021-08-16 212
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 213 /* Only the v1 needs to configure div_en and div_con for dbclk */
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 214 if (debounce) {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 215 if (div_debounce_support) {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 216 /* Configure the max debounce from consumers */
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 217 cur_div_reg = readl(bank->reg_base +
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 218 reg->dbclk_div_con);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 219 if (cur_div_reg < div_reg)
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 220 writel(div_reg, bank->reg_base +
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 221 reg->dbclk_div_con);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 222 rockchip_gpio_writel_bit(bank, offset, 1,
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 223 reg->dbclk_div_en);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 224 }
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 225
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 226 rockchip_gpio_writel_bit(bank, offset, 1, reg->debounce);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 227 } else {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 228 if (div_debounce_support)
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 229 rockchip_gpio_writel_bit(bank, offset, 0,
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 230 reg->dbclk_div_en);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 231
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 232 rockchip_gpio_writel_bit(bank, offset, 0, reg->debounce);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 233 }
936ee2675eee1f Jianqun Xu 2021-08-16 234
936ee2675eee1f Jianqun Xu 2021-08-16 235 raw_spin_unlock_irqrestore(&bank->slock, flags);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 236
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 237 /* Enable or disable dbclk at last */
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 238 if (div_debounce_support) {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 239 if (debounce)
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 240 clk_prepare_enable(bank->db_clk);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 241 else
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 242 clk_disable_unprepare(bank->db_clk);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 243 }
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 244
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 245 return 0;
936ee2675eee1f Jianqun Xu 2021-08-16 246 }
936ee2675eee1f Jianqun Xu 2021-08-16 247
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 3+ messages in thread
* drivers/gpio/gpio-rockchip.c:201:53: warning: Division by zero [clang-analyzer-core.DivideZero]
@ 2022-04-07 4:59 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-04-07 4:59 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 19286 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Jianqun Xu <jay.xu@rock-chips.com>
CC: Linus Walleij <linus.walleij@linaro.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 3e732ebf7316ac83e8562db7e64cc68aec390a18
commit: 3bcbd1a85b68e5f864029fd6f0bb0bcc8e2f1082 gpio/rockchip: support next version gpio controller
date: 8 months ago
:::::: branch date: 35 hours ago
:::::: commit date: 8 months ago
config: mips-randconfig-c004-20220404 (https://download.01.org/0day-ci/archive/20220407/202204071238.S37Lu57T-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c4a1b07d0979e7ff20d7d541af666d822d66b566)
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
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3bcbd1a85b68e5f864029fd6f0bb0bcc8e2f1082
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 3bcbd1a85b68e5f864029fd6f0bb0bcc8e2f1082
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
^~~~~~~~~~
include/linux/uaccess.h:192:7: note: Returning from '_copy_from_user'
n = _copy_from_user(to, from, n);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:193:2: note: Returning without writing to 'to->rlim_cur'
return n;
^
include/linux/uaccess.h:193:2: note: Returning zero (loaded from 'n'), which participates in a condition later
return n;
^~~~~~~~
kernel/sys.c:1691:6: note: Returning from 'copy_from_user'
if (copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/sys.c:1691:2: note: Taking false branch
if (copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
^
kernel/sys.c:1693:9: note: Calling 'do_prlimit'
return do_prlimit(current, resource, &new_rlim, NULL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/sys.c:1567:6: note: Assuming 'resource' is < RLIM_NLIMITS
if (resource >= RLIM_NLIMITS)
^~~~~~~~~~~~~~~~~~~~~~~~
kernel/sys.c:1567:2: note: Taking false branch
if (resource >= RLIM_NLIMITS)
^
kernel/sys.c:1569:6: note: 'new_rlim' is non-null
if (new_rlim) {
^~~~~~~~
kernel/sys.c:1569:2: note: Taking true branch
if (new_rlim) {
^
kernel/sys.c:1570:26: note: The left operand of '>' is a garbage value
if (new_rlim->rlim_cur > new_rlim->rlim_max)
~~~~~~~~~~~~~~~~~~ ^
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
9 warnings generated.
fs/iomap/buffered-io.c:1039:6: warning: Value stored to 'start' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
u64 start = bio->bi_iter.bi_sector;
^~~~~ ~~~~~~~~~~~~~~~~~~~~~~
fs/iomap/buffered-io.c:1039:6: note: Value stored to 'start' during its initialization is never read
u64 start = bio->bi_iter.bi_sector;
^~~~~ ~~~~~~~~~~~~~~~~~~~~~~
fs/iomap/buffered-io.c:1040:9: warning: Value stored to 'offset' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
loff_t offset = ioend->io_offset;
^~~~~~ ~~~~~~~~~~~~~~~~
fs/iomap/buffered-io.c:1040:9: note: Value stored to 'offset' during its initialization is never read
loff_t offset = ioend->io_offset;
^~~~~~ ~~~~~~~~~~~~~~~~
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
7 warnings generated.
Suppressed 7 warnings (7 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
>> drivers/gpio/gpio-rockchip.c:201:53: warning: Division by zero [clang-analyzer-core.DivideZero]
max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq;
^
drivers/gpio/gpio-rockchip.c:272:2: note: Control jumps to 'case PIN_CONFIG_INPUT_DEBOUNCE:' at line 273
switch (param) {
^
drivers/gpio/gpio-rockchip.c:274:3: note: Calling 'rockchip_gpio_set_debounce'
rockchip_gpio_set_debounce(gc, offset, true);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:198:7: note: Calling 'IS_ERR'
if (!IS_ERR(bank->db_clk)) {
^~~~~~~~~~~~~~~~~~~~
include/linux/err.h:36:9: note: Assuming the condition is false
return IS_ERR_VALUE((unsigned long)ptr);
^
include/linux/err.h:22:34: note: expanded from macro 'IS_ERR_VALUE'
#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
^
include/linux/err.h:36:2: note: Returning zero, which participates in a condition later
return IS_ERR_VALUE((unsigned long)ptr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:198:7: note: Returning from 'IS_ERR'
if (!IS_ERR(bank->db_clk)) {
^~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:198:2: note: Taking true branch
if (!IS_ERR(bank->db_clk)) {
^
drivers/gpio/gpio-rockchip.c:200:10: note: Calling 'clk_get_rate'
freq = clk_get_rate(bank->db_clk);
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/clk.h:882:2: note: Returning zero
return 0;
^~~~~~~~
drivers/gpio/gpio-rockchip.c:200:10: note: Returning from 'clk_get_rate'
freq = clk_get_rate(bank->db_clk);
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:200:3: note: The value 0 is assigned to 'freq'
freq = clk_get_rate(bank->db_clk);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:201:53: note: Division by zero
max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
8 warnings generated.
Suppressed 8 warnings (5 in non-user code, 3 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
8 warnings generated.
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
12 warnings generated.
Suppressed 12 warnings (11 in non-user code, 1 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
10 warnings generated.
Suppressed 10 warnings (10 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (5 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
vim +201 drivers/gpio/gpio-rockchip.c
936ee2675eee1f Jianqun Xu 2021-08-16 186
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 187 static int rockchip_gpio_set_debounce(struct gpio_chip *gc,
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 188 unsigned int offset,
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 189 unsigned int debounce)
936ee2675eee1f Jianqun Xu 2021-08-16 190 {
936ee2675eee1f Jianqun Xu 2021-08-16 191 struct rockchip_pin_bank *bank = gpiochip_get_data(gc);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 192 const struct rockchip_gpio_regs *reg = bank->gpio_regs;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 193 unsigned long flags, div_reg, freq, max_debounce;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 194 bool div_debounce_support;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 195 unsigned int cur_div_reg;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 196 u64 div;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 197
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 198 if (!IS_ERR(bank->db_clk)) {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 199 div_debounce_support = true;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 200 freq = clk_get_rate(bank->db_clk);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 @201 max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 202 if (debounce > max_debounce)
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 203 return -EINVAL;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 204
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 205 div = debounce * freq;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 206 div_reg = DIV_ROUND_CLOSEST_ULL(div, 2 * USEC_PER_SEC) - 1;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 207 } else {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 208 div_debounce_support = false;
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 209 }
936ee2675eee1f Jianqun Xu 2021-08-16 210
936ee2675eee1f Jianqun Xu 2021-08-16 211 raw_spin_lock_irqsave(&bank->slock, flags);
936ee2675eee1f Jianqun Xu 2021-08-16 212
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 213 /* Only the v1 needs to configure div_en and div_con for dbclk */
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 214 if (debounce) {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 215 if (div_debounce_support) {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 216 /* Configure the max debounce from consumers */
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 217 cur_div_reg = readl(bank->reg_base +
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 218 reg->dbclk_div_con);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 219 if (cur_div_reg < div_reg)
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 220 writel(div_reg, bank->reg_base +
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 221 reg->dbclk_div_con);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 222 rockchip_gpio_writel_bit(bank, offset, 1,
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 223 reg->dbclk_div_en);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 224 }
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 225
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 226 rockchip_gpio_writel_bit(bank, offset, 1, reg->debounce);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 227 } else {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 228 if (div_debounce_support)
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 229 rockchip_gpio_writel_bit(bank, offset, 0,
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 230 reg->dbclk_div_en);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 231
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 232 rockchip_gpio_writel_bit(bank, offset, 0, reg->debounce);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 233 }
936ee2675eee1f Jianqun Xu 2021-08-16 234
936ee2675eee1f Jianqun Xu 2021-08-16 235 raw_spin_unlock_irqrestore(&bank->slock, flags);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 236
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 237 /* Enable or disable dbclk at last */
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 238 if (div_debounce_support) {
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 239 if (debounce)
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 240 clk_prepare_enable(bank->db_clk);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 241 else
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 242 clk_disable_unprepare(bank->db_clk);
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 243 }
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 244
3bcbd1a85b68e5 Jianqun Xu 2021-08-16 245 return 0;
936ee2675eee1f Jianqun Xu 2021-08-16 246 }
936ee2675eee1f Jianqun Xu 2021-08-16 247
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-07 4:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-09 0:45 drivers/gpio/gpio-rockchip.c:201:53: warning: Division by zero [clang-analyzer-core.DivideZero] kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2022-03-21 6:57 kernel test robot
2022-04-07 4:59 kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.