diff mbox series

[V2,4/9] genirq/timings: Use the min kernel macro

Message ID 20190524111615.4891-5-daniel.lezcano@linaro.org
State New
Headers show
Series genirq/timings: Fixes and selftests | expand

Commit Message

Daniel Lezcano May 24, 2019, 11:16 a.m. UTC
The' min' is available as a kernel macro. Use it instead of writing
the same code.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

---
 kernel/irq/timings.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

-- 
2.17.1

Comments

Andy Shevchenko May 24, 2019, 1:57 p.m. UTC | #1
On Fri, May 24, 2019 at 01:16:10PM +0200, Daniel Lezcano wrote:
> The' min' is available as a kernel macro. Use it instead of writing

> the same code.


While it's technically correct...

>  	/*

>  	 * 'count' will depends if the circular buffer wrapped or not

>  	 */

> -	count = irqs->count < IRQ_TIMINGS_SIZE ?

> -		irqs->count : IRQ_TIMINGS_SIZE;

> +	count = min_t(int, irqs->count,  IRQ_TIMINGS_SIZE);

>  

>  	start = irqs->count < IRQ_TIMINGS_SIZE ?

>  		0 : (irqs->count & IRQ_TIMINGS_MASK);


...looking to the context I would leave as is to have a pattern.

-- 
With Best Regards,
Andy Shevchenko
Daniel Lezcano May 24, 2019, 4:11 p.m. UTC | #2
On 24/05/2019 15:57, Andy Shevchenko wrote:
> On Fri, May 24, 2019 at 01:16:10PM +0200, Daniel Lezcano wrote:

>> The' min' is available as a kernel macro. Use it instead of writing

>> the same code.

> 

> While it's technically correct...

> 

>>  	/*

>>  	 * 'count' will depends if the circular buffer wrapped or not

>>  	 */

>> -	count = irqs->count < IRQ_TIMINGS_SIZE ?

>> -		irqs->count : IRQ_TIMINGS_SIZE;

>> +	count = min_t(int, irqs->count,  IRQ_TIMINGS_SIZE);

>>  

>>  	start = irqs->count < IRQ_TIMINGS_SIZE ?

>>  		0 : (irqs->count & IRQ_TIMINGS_MASK);

> 

> ...looking to the context I would leave as is to have a pattern.


Yes, you are right. I'll drop this patch.


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
diff mbox series

Patch

diff --git a/kernel/irq/timings.c b/kernel/irq/timings.c
index 06bde5253a7d..8928601b4b42 100644
--- a/kernel/irq/timings.c
+++ b/kernel/irq/timings.c
@@ -406,8 +406,7 @@  static u64 __irq_timings_next_event(struct irqt_stat *irqs, int irq, u64 now)
 	/*
 	 * 'count' will depends if the circular buffer wrapped or not
 	 */
-	count = irqs->count < IRQ_TIMINGS_SIZE ?
-		irqs->count : IRQ_TIMINGS_SIZE;
+	count = min_t(int, irqs->count,  IRQ_TIMINGS_SIZE);
 
 	start = irqs->count < IRQ_TIMINGS_SIZE ?
 		0 : (irqs->count & IRQ_TIMINGS_MASK);