On Fri, Aug 23, 2024 at 11:43:07AM +0800, Ye Zhang wrote: > div_reg may be < 0 if debounce is zero, causing the unsigned int to > overflow. ... > - if (bank->gpio_type == GPIO_TYPE_V2 && !IS_ERR(bank->db_clk)) { > - div_debounce_support = true; Wouldn't be cleaner (from the patch perspective) to simply move else branch here? else div_debounce_support = false; > + div_debounce_support = (bank->gpio_type == GPIO_TYPE_V2) && !IS_ERR(bank->db_clk); > + if (debounce && div_debounce_support) { > freq = clk_get_rate(bank->db_clk); > if (!freq) > return -EINVAL; > @@ -216,8 +216,6 @@ static int rockchip_gpio_set_debounce(struct gpio_chip *gc, > > div = (u64)debounce * freq; > div_reg = DIV_ROUND_CLOSEST_ULL(div, 2 * USEC_PER_SEC) - 1; > - } else { > - div_debounce_support = false; > } -- With Best Regards, Andy Shevchenko