aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/c_can
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-04-11 04:13:17 -0400
committerMarc Kleine-Budde <mkl@pengutronix.de>2014-04-24 16:09:00 -0400
commit2d5f4f85695623fab5fac7db19fd0290ef54eca8 (patch)
tree59ffc08ad5d4f503bc99580d9ff6ad9b07ededfc /drivers/net/can/c_can
parentd61d09de023320b95a536eb4d31941e67002a93c (diff)
can: c_can: Cleanup irq enable/disable
Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/c_can')
-rw-r--r--drivers/net/can/c_can/c_can.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 5d43c5a0e2d9..562faef29896 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -60,6 +60,8 @@
60#define CONTROL_IE BIT(1) 60#define CONTROL_IE BIT(1)
61#define CONTROL_INIT BIT(0) 61#define CONTROL_INIT BIT(0)
62 62
63#define CONTROL_IRQMSK (CONTROL_EIE | CONTROL_IE | CONTROL_SIE)
64
63/* test register */ 65/* test register */
64#define TEST_RX BIT(7) 66#define TEST_RX BIT(7)
65#define TEST_TX1 BIT(6) 67#define TEST_TX1 BIT(6)
@@ -146,13 +148,6 @@
146#define IF_RX 0 148#define IF_RX 0
147#define IF_TX 1 149#define IF_TX 1
148 150
149/* status interrupt */
150#define STATUS_INTERRUPT 0x8000
151
152/* global interrupt masks */
153#define ENABLE_ALL_INTERRUPTS 1
154#define DISABLE_ALL_INTERRUPTS 0
155
156/* minimum timeout for checking BUSY status */ 151/* minimum timeout for checking BUSY status */
157#define MIN_TIMEOUT_VALUE 6 152#define MIN_TIMEOUT_VALUE 6
158 153
@@ -246,18 +241,14 @@ static u32 c_can_read_reg32(struct c_can_priv *priv, enum reg index)
246 return val; 241 return val;
247} 242}
248 243
249static void c_can_enable_all_interrupts(struct c_can_priv *priv, 244static void c_can_irq_control(struct c_can_priv *priv, bool enable)
250 int enable)
251{ 245{
252 unsigned int cntrl_save = priv->read_reg(priv, 246 u32 ctrl = priv->read_reg(priv, C_CAN_CTRL_REG) & ~CONTROL_IRQMSK;
253 C_CAN_CTRL_REG);
254 247
255 if (enable) 248 if (enable)
256 cntrl_save |= (CONTROL_SIE | CONTROL_EIE | CONTROL_IE); 249 ctrl |= CONTROL_IRQMSK;
257 else
258 cntrl_save &= ~(CONTROL_EIE | CONTROL_IE | CONTROL_SIE);
259 250
260 priv->write_reg(priv, C_CAN_CTRL_REG, cntrl_save); 251 priv->write_reg(priv, C_CAN_CTRL_REG, ctrl);
261} 252}
262 253
263static inline int c_can_msg_obj_is_busy(struct c_can_priv *priv, int iface) 254static 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{ 655{
665 struct c_can_priv *priv = netdev_priv(dev); 656 struct c_can_priv *priv = netdev_priv(dev);
666 657
667 /* disable all interrupts */ 658 c_can_irq_control(priv, false);
668 c_can_enable_all_interrupts(priv, DISABLE_ALL_INTERRUPTS);
669
670 /* set the state as STOPPED */
671 priv->can.state = CAN_STATE_STOPPED; 659 priv->can.state = CAN_STATE_STOPPED;
672} 660}
673 661
@@ -682,8 +670,7 @@ static int c_can_set_mode(struct net_device *dev, enum can_mode mode)
682 if (err) 670 if (err)
683 return err; 671 return err;
684 netif_wake_queue(dev); 672 netif_wake_queue(dev);
685 /* enable status change, error and module interrupts */ 673 c_can_irq_control(priv, true);
686 c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS);
687 break; 674 break;
688 default: 675 default:
689 return -EOPNOTSUPP; 676 return -EOPNOTSUPP;
@@ -1144,7 +1131,7 @@ end:
1144 napi_complete(napi); 1131 napi_complete(napi);
1145 /* enable all IRQs if we are not in bus off state */ 1132 /* enable all IRQs if we are not in bus off state */
1146 if (priv->can.state != CAN_STATE_BUS_OFF) 1133 if (priv->can.state != CAN_STATE_BUS_OFF)
1147 c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS); 1134 c_can_irq_control(priv, true);
1148 } 1135 }
1149 1136
1150 return work_done; 1137 return work_done;
@@ -1159,7 +1146,7 @@ static irqreturn_t c_can_isr(int irq, void *dev_id)
1159 return IRQ_NONE; 1146 return IRQ_NONE;
1160 1147
1161 /* disable all interrupts and schedule the NAPI */ 1148 /* disable all interrupts and schedule the NAPI */
1162 c_can_enable_all_interrupts(priv, DISABLE_ALL_INTERRUPTS); 1149 c_can_irq_control(priv, false);
1163 napi_schedule(&priv->napi); 1150 napi_schedule(&priv->napi);
1164 1151
1165 return IRQ_HANDLED; 1152 return IRQ_HANDLED;
@@ -1197,7 +1184,7 @@ static int c_can_open(struct net_device *dev)
1197 1184
1198 napi_enable(&priv->napi); 1185 napi_enable(&priv->napi);
1199 /* enable status change, error and module interrupts */ 1186 /* enable status change, error and module interrupts */
1200 c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS); 1187 c_can_irq_control(priv, true);
1201 netif_start_queue(dev); 1188 netif_start_queue(dev);
1202 1189
1203 return 0; 1190 return 0;
@@ -1324,7 +1311,7 @@ int c_can_power_up(struct net_device *dev)
1324 1311
1325 ret = c_can_start(dev); 1312 ret = c_can_start(dev);
1326 if (!ret) 1313 if (!ret)
1327 c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS); 1314 c_can_irq_control(priv, true);
1328 1315
1329 return ret; 1316 return ret;
1330} 1317}