can: m_can: Start/Cancel polling timer together with interrupts
Interrupts are enabled/disabled in more places than just m_can_start()
and m_can_stop(). Couple the polling timer with enabling/disabling of
all interrupts to achieve equivalent behavior.
Cc: Judith Mendez <jm@ti.com>
Fixes: b382380c0d
("can: m_can: Add hrtimer to generate software interrupt")
Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/all/20240207093220.2681425-2-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
dbd86e47fd
commit
a163c57610
1 changed files with 12 additions and 11 deletions
|
@ -418,6 +418,13 @@ static void m_can_config_endisable(struct m_can_classdev *cdev, bool enable)
|
||||||
|
|
||||||
static inline void m_can_enable_all_interrupts(struct m_can_classdev *cdev)
|
static inline void m_can_enable_all_interrupts(struct m_can_classdev *cdev)
|
||||||
{
|
{
|
||||||
|
if (!cdev->net->irq) {
|
||||||
|
dev_dbg(cdev->dev, "Start hrtimer\n");
|
||||||
|
hrtimer_start(&cdev->hrtimer,
|
||||||
|
ms_to_ktime(HRTIMER_POLL_INTERVAL_MS),
|
||||||
|
HRTIMER_MODE_REL_PINNED);
|
||||||
|
}
|
||||||
|
|
||||||
/* Only interrupt line 0 is used in this driver */
|
/* Only interrupt line 0 is used in this driver */
|
||||||
m_can_write(cdev, M_CAN_ILE, ILE_EINT0);
|
m_can_write(cdev, M_CAN_ILE, ILE_EINT0);
|
||||||
}
|
}
|
||||||
|
@ -425,6 +432,11 @@ static inline void m_can_enable_all_interrupts(struct m_can_classdev *cdev)
|
||||||
static inline void m_can_disable_all_interrupts(struct m_can_classdev *cdev)
|
static inline void m_can_disable_all_interrupts(struct m_can_classdev *cdev)
|
||||||
{
|
{
|
||||||
m_can_write(cdev, M_CAN_ILE, 0x0);
|
m_can_write(cdev, M_CAN_ILE, 0x0);
|
||||||
|
|
||||||
|
if (!cdev->net->irq) {
|
||||||
|
dev_dbg(cdev->dev, "Stop hrtimer\n");
|
||||||
|
hrtimer_cancel(&cdev->hrtimer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Retrieve internal timestamp counter from TSCV.TSC, and shift it to 32-bit
|
/* Retrieve internal timestamp counter from TSCV.TSC, and shift it to 32-bit
|
||||||
|
@ -1417,12 +1429,6 @@ static int m_can_start(struct net_device *dev)
|
||||||
|
|
||||||
m_can_enable_all_interrupts(cdev);
|
m_can_enable_all_interrupts(cdev);
|
||||||
|
|
||||||
if (!dev->irq) {
|
|
||||||
dev_dbg(cdev->dev, "Start hrtimer\n");
|
|
||||||
hrtimer_start(&cdev->hrtimer, ms_to_ktime(HRTIMER_POLL_INTERVAL_MS),
|
|
||||||
HRTIMER_MODE_REL_PINNED);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1577,11 +1583,6 @@ static void m_can_stop(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct m_can_classdev *cdev = netdev_priv(dev);
|
struct m_can_classdev *cdev = netdev_priv(dev);
|
||||||
|
|
||||||
if (!dev->irq) {
|
|
||||||
dev_dbg(cdev->dev, "Stop hrtimer\n");
|
|
||||||
hrtimer_cancel(&cdev->hrtimer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* disable all interrupts */
|
/* disable all interrupts */
|
||||||
m_can_disable_all_interrupts(cdev);
|
m_can_disable_all_interrupts(cdev);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue