lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250826025131.112900-1-zhao.xichao@vivo.com>
Date: Tue, 26 Aug 2025 10:51:31 +0800
From: Xichao Zhao <zhao.xichao@...o.com>
To: rcsekar@...sung.com,
	mkl@...gutronix.de,
	mailhol.vincent@...adoo.fr,
	Markus.Elfring@....de
Cc: linux-can@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Xichao Zhao <zhao.xichao@...o.com>
Subject: [PATCH v2] can: m_can: use us_to_ktime() in m_can_set_coalesce()

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@...o.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ