Thread (29 messages) 29 messages, 7 authors, 2024-08-23

Re: [PATCH v2] gpio: rockchip: avoid division by zero

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2024-08-23 14:46:01
Also in: linux-gpio, linux-rockchip, lkml

On Fri, Aug 23, 2024 at 11:43:04AM +0800, Ye Zhang wrote:
If the clk_get_rate return '0', it will happen division by zero.
At the abstraction level this is good to avoid 0 division and return an error,
but...
 		freq = clk_get_rate(bank->db_clk);
+		if (!freq)
+			return -EINVAL;
...do you this the absence of debounce here is a fatal error?
(Yes, I see it's a fatal when it's bigger than maximum.)
 		max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq;
 		if (debounce > max_debounce)
 			return -EINVAL;
-- 
With Best Regards,
Andy Shevchenko


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help