Re: [PATCH] can: m_can: use us_to_ktime() where appropriate
From: 赵西超
Date: Mon Aug 25 2025 - 22:54:11 EST
> [You don't often get email from markus.elfring@xxxxxx. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
>> The tx_coalesce_usecs_irq are more suitable for using the
>> us_to_ktime(). This can make the code more concise and
>> enhance readability.
> Wording suggestion:
> The data structure members “rx_coalesce_usecs_irq” and
> “tx_coalesce_usecs_irq” are more suitable for using us_to_ktime()
> instead of calling ns_to_ktime().
> Thus make the code more concise and enhance readability.
>
>
> Should the information “where appropriate” be replaced by the hint
> “in m_can_set_coalesce()” for the summary phrase?
>
>
> …
>> +++ b/drivers/net/can/m_can/m_can.c
>> @@ -2214,10 +2214,10 @@ static int m_can_set_coalesce(struct net_device *dev,
>>
>> if (cdev->rx_coalesce_usecs_irq)
>> cdev->irq_timer_wait =
>> - ns_to_ktime(cdev->rx_coalesce_usecs_irq * NSEC_PER_USEC);
>> + us_to_ktime(cdev->rx_coalesce_usecs_irq);
>> else
>> cdev->irq_timer_wait =
>> - ns_to_ktime(cdev->tx_coalesce_usecs_irq * NSEC_PER_USEC);
>> + us_to_ktime(cdev->tx_coalesce_usecs_irq);
> …
>
> How do you think about to apply the following source code variant instead?
>
> cdev->irq_timer_wait = us_to_ktime(cdev->rx_coalesce_usecs_irq
> ? cdev->rx_coalesce_usecs_irq
> : cdev->tx_coalesce_usecs_irq);
>
>
> Regards,
> Markus
Thank you for your suggestions. I have incorporated them and sent the
second version of the patch.
Regards,
Xichao Zhao