mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
gpio: rockchip: Prevent underflow unsigned variables.
Signed-off-by: Ye Zhang <ye.zhang@rock-chips.com> Change-Id: I2910fe7c57683bbd175cbc4b28584ff84f037d07
This commit is contained in:
@@ -209,11 +209,12 @@ static int rockchip_gpio_set_debounce(struct gpio_chip *gc,
|
||||
unsigned int cur_div_reg;
|
||||
u64 div;
|
||||
|
||||
if (bank->gpio_type >= GPIO_TYPE_V2 && !IS_ERR(bank->db_clk)) {
|
||||
div_debounce_support = true;
|
||||
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;
|
||||
|
||||
div = (u64)(GENMASK(23, 0) + 1) * 1000000;
|
||||
if (bank->gpio_type == GPIO_TYPE_V2)
|
||||
max_debounce = DIV_ROUND_CLOSEST_ULL(div, freq);
|
||||
@@ -227,8 +228,6 @@ static int rockchip_gpio_set_debounce(struct gpio_chip *gc,
|
||||
div_reg = DIV_ROUND_CLOSEST_ULL(div, USEC_PER_SEC) - 1;
|
||||
else
|
||||
div_reg = DIV_ROUND_CLOSEST_ULL(div, USEC_PER_SEC / 2) - 1;
|
||||
} else {
|
||||
div_debounce_support = false;
|
||||
}
|
||||
|
||||
raw_spin_lock_irqsave(&bank->slock, flags);
|
||||
|
||||
Reference in New Issue
Block a user