mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user