linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] can: m_can: use us_to_ktime() in m_can_set_coalesce()
@ 2025-08-26  2:51 Xichao Zhao
  2025-08-26  5:43 ` Markus Elfring
  0 siblings, 1 reply; 4+ messages in thread
From: Xichao Zhao @ 2025-08-26  2:51 UTC (permalink / raw)
  To: rcsekar, mkl, mailhol.vincent, Markus.Elfring
  Cc: linux-can, linux-kernel, Xichao Zhao

Replace the if-else statement with a ternary operator to
set cdev->irq_timer_wait. Use us_to_ktime() instead of
ns_to_ktime() with NSEC_PER_USEC multiplication. Simplify
the assignment of cdev->irq_timer_wait by combining
conditional checks into a single line.

Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
---
v2: Simplify code. Modify title and content.
---
 drivers/net/can/m_can/m_can.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index fe74dbd2c966..d4621346e76a 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -2211,13 +2211,9 @@ static int m_can_set_coalesce(struct net_device *dev,
 	cdev->tx_max_coalesced_frames = ec->tx_max_coalesced_frames;
 	cdev->tx_max_coalesced_frames_irq = ec->tx_max_coalesced_frames_irq;
 	cdev->tx_coalesce_usecs_irq = ec->tx_coalesce_usecs_irq;
-
-	if (cdev->rx_coalesce_usecs_irq)
-		cdev->irq_timer_wait =
-			ns_to_ktime(cdev->rx_coalesce_usecs_irq * NSEC_PER_USEC);
-	else
-		cdev->irq_timer_wait =
-			ns_to_ktime(cdev->tx_coalesce_usecs_irq * NSEC_PER_USEC);
+	cdev->irq_timer_wait = us_to_ktime(cdev->rx_coalesce_usecs_irq ?
+					   cdev->rx_coalesce_usecs_irq :
+					   cdev->tx_coalesce_usecs_irq);
 
 	return 0;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-27  7:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-26  2:51 [PATCH v2] can: m_can: use us_to_ktime() in m_can_set_coalesce() Xichao Zhao
2025-08-26  5:43 ` Markus Elfring
2025-08-26  8:38   ` Vincent Mailhol
2025-08-26  8:44     ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).