Skip to content

Commit 5775793

Browse files
scosumarckleinebudde
authored andcommitted
can: m_can: Avoid reading irqstatus twice
For peripheral devices the m_can_rx_handler is called directly after setting cdev->irqstatus. This means we don't have to read the irqstatus again in m_can_rx_handler. Avoid this by adding a parameter that is false for direct calls. Signed-off-by: Markus Schneider-Pargmann <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent c1eaf8b commit 5775793

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/net/can/m_can/m_can.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -905,14 +905,13 @@ static int m_can_handle_bus_errors(struct net_device *dev, u32 irqstatus,
905905
return work_done;
906906
}
907907

908-
static int m_can_rx_handler(struct net_device *dev, int quota)
908+
static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus)
909909
{
910910
struct m_can_classdev *cdev = netdev_priv(dev);
911911
int rx_work_or_err;
912912
int work_done = 0;
913-
u32 irqstatus, psr;
913+
u32 psr;
914914

915-
irqstatus = cdev->irqstatus | m_can_read(cdev, M_CAN_IR);
916915
if (!irqstatus)
917916
goto end;
918917

@@ -956,12 +955,12 @@ static int m_can_rx_handler(struct net_device *dev, int quota)
956955
return work_done;
957956
}
958957

959-
static int m_can_rx_peripheral(struct net_device *dev)
958+
static int m_can_rx_peripheral(struct net_device *dev, u32 irqstatus)
960959
{
961960
struct m_can_classdev *cdev = netdev_priv(dev);
962961
int work_done;
963962

964-
work_done = m_can_rx_handler(dev, NAPI_POLL_WEIGHT);
963+
work_done = m_can_rx_handler(dev, NAPI_POLL_WEIGHT, irqstatus);
965964

966965
/* Don't re-enable interrupts if the driver had a fatal error
967966
* (e.g., FIFO read failure).
@@ -977,8 +976,11 @@ static int m_can_poll(struct napi_struct *napi, int quota)
977976
struct net_device *dev = napi->dev;
978977
struct m_can_classdev *cdev = netdev_priv(dev);
979978
int work_done;
979+
u32 irqstatus;
980+
981+
irqstatus = cdev->irqstatus | m_can_read(cdev, M_CAN_IR);
980982

981-
work_done = m_can_rx_handler(dev, quota);
983+
work_done = m_can_rx_handler(dev, quota, irqstatus);
982984

983985
/* Don't re-enable interrupts if the driver had a fatal error
984986
* (e.g., FIFO read failure).
@@ -1088,7 +1090,7 @@ static irqreturn_t m_can_isr(int irq, void *dev_id)
10881090
m_can_disable_all_interrupts(cdev);
10891091
if (!cdev->is_peripheral)
10901092
napi_schedule(&cdev->napi);
1091-
else if (m_can_rx_peripheral(dev) < 0)
1093+
else if (m_can_rx_peripheral(dev, ir) < 0)
10921094
goto out_fail;
10931095
}
10941096

0 commit comments

Comments
 (0)