Commit 2d5f4f85 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Marc Kleine-Budde

can: c_can: Cleanup irq enable/disable

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Tested-by: default avatarAlexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent d61d09de
...@@ -60,6 +60,8 @@ ...@@ -60,6 +60,8 @@
#define CONTROL_IE BIT(1) #define CONTROL_IE BIT(1)
#define CONTROL_INIT BIT(0) #define CONTROL_INIT BIT(0)
#define CONTROL_IRQMSK (CONTROL_EIE | CONTROL_IE | CONTROL_SIE)
/* test register */ /* test register */
#define TEST_RX BIT(7) #define TEST_RX BIT(7)
#define TEST_TX1 BIT(6) #define TEST_TX1 BIT(6)
...@@ -146,13 +148,6 @@ ...@@ -146,13 +148,6 @@
#define IF_RX 0 #define IF_RX 0
#define IF_TX 1 #define IF_TX 1
/* status interrupt */
#define STATUS_INTERRUPT 0x8000
/* global interrupt masks */
#define ENABLE_ALL_INTERRUPTS 1
#define DISABLE_ALL_INTERRUPTS 0
/* minimum timeout for checking BUSY status */ /* minimum timeout for checking BUSY status */
#define MIN_TIMEOUT_VALUE 6 #define MIN_TIMEOUT_VALUE 6
...@@ -246,18 +241,14 @@ static u32 c_can_read_reg32(struct c_can_priv *priv, enum reg index) ...@@ -246,18 +241,14 @@ static u32 c_can_read_reg32(struct c_can_priv *priv, enum reg index)
return val; return val;
} }
static void c_can_enable_all_interrupts(struct c_can_priv *priv, static void c_can_irq_control(struct c_can_priv *priv, bool enable)
int enable)
{ {
unsigned int cntrl_save = priv->read_reg(priv, u32 ctrl = priv->read_reg(priv, C_CAN_CTRL_REG) & ~CONTROL_IRQMSK;
C_CAN_CTRL_REG);
if (enable) if (enable)
cntrl_save |= (CONTROL_SIE | CONTROL_EIE | CONTROL_IE); ctrl |= CONTROL_IRQMSK;
else
cntrl_save &= ~(CONTROL_EIE | CONTROL_IE | CONTROL_SIE);
priv->write_reg(priv, C_CAN_CTRL_REG, cntrl_save); priv->write_reg(priv, C_CAN_CTRL_REG, ctrl);
} }
static inline int c_can_msg_obj_is_busy(struct c_can_priv *priv, int iface) static inline int c_can_msg_obj_is_busy(struct c_can_priv *priv, int iface)
...@@ -664,10 +655,7 @@ static void c_can_stop(struct net_device *dev) ...@@ -664,10 +655,7 @@ static void c_can_stop(struct net_device *dev)
{ {
struct c_can_priv *priv = netdev_priv(dev); struct c_can_priv *priv = netdev_priv(dev);
/* disable all interrupts */ c_can_irq_control(priv, false);
c_can_enable_all_interrupts(priv, DISABLE_ALL_INTERRUPTS);
/* set the state as STOPPED */
priv->can.state = CAN_STATE_STOPPED; priv->can.state = CAN_STATE_STOPPED;
} }
...@@ -682,8 +670,7 @@ static int c_can_set_mode(struct net_device *dev, enum can_mode mode) ...@@ -682,8 +670,7 @@ static int c_can_set_mode(struct net_device *dev, enum can_mode mode)
if (err) if (err)
return err; return err;
netif_wake_queue(dev); netif_wake_queue(dev);
/* enable status change, error and module interrupts */ c_can_irq_control(priv, true);
c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS);
break; break;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -1144,7 +1131,7 @@ static int c_can_poll(struct napi_struct *napi, int quota) ...@@ -1144,7 +1131,7 @@ static int c_can_poll(struct napi_struct *napi, int quota)
napi_complete(napi); napi_complete(napi);
/* enable all IRQs if we are not in bus off state */ /* enable all IRQs if we are not in bus off state */
if (priv->can.state != CAN_STATE_BUS_OFF) if (priv->can.state != CAN_STATE_BUS_OFF)
c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS); c_can_irq_control(priv, true);
} }
return work_done; return work_done;
...@@ -1159,7 +1146,7 @@ static irqreturn_t c_can_isr(int irq, void *dev_id) ...@@ -1159,7 +1146,7 @@ static irqreturn_t c_can_isr(int irq, void *dev_id)
return IRQ_NONE; return IRQ_NONE;
/* disable all interrupts and schedule the NAPI */ /* disable all interrupts and schedule the NAPI */
c_can_enable_all_interrupts(priv, DISABLE_ALL_INTERRUPTS); c_can_irq_control(priv, false);
napi_schedule(&priv->napi); napi_schedule(&priv->napi);
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -1197,7 +1184,7 @@ static int c_can_open(struct net_device *dev) ...@@ -1197,7 +1184,7 @@ static int c_can_open(struct net_device *dev)
napi_enable(&priv->napi); napi_enable(&priv->napi);
/* enable status change, error and module interrupts */ /* enable status change, error and module interrupts */
c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS); c_can_irq_control(priv, true);
netif_start_queue(dev); netif_start_queue(dev);
return 0; return 0;
...@@ -1324,7 +1311,7 @@ int c_can_power_up(struct net_device *dev) ...@@ -1324,7 +1311,7 @@ int c_can_power_up(struct net_device *dev)
ret = c_can_start(dev); ret = c_can_start(dev);
if (!ret) if (!ret)
c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS); c_can_irq_control(priv, true);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment