gpio/rockchip: avoid division by zero

If the clk_get_rate return '0', it will happen division by zero.

Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Change-Id: I1d2c6b12b961a78629f22496fe8f8b685b27dc09
This commit is contained in:
Jianqun Xu
2022-06-16 16:52:52 +08:00
committed by Tao Huang
parent 498aa5fd36
commit 35a6ba5aa9

View File

@@ -199,8 +199,10 @@ static int rockchip_gpio_set_debounce(struct gpio_chip *gc,
if (bank->gpio_type == GPIO_TYPE_V2 && !IS_ERR(bank->db_clk)) {
div_debounce_support = true;
freq = clk_get_rate(bank->db_clk);
if (!freq)
return -EINVAL;
max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq;
if (debounce > max_debounce)
if ((unsigned long)debounce > max_debounce)
return -EINVAL;
div = debounce * freq;