diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2014-04-11 04:13:21 -0400 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2014-04-24 16:09:01 -0400 |
commit | d48071be6cb94912cf3c3ac0b4d520438fab4778 (patch) | |
tree | fb45ee82298a136ffed5b1f108095084bdb2c327 /drivers/net/can/c_can | |
parent | 23ef0a895dd3f115909ca70958aeb3d04f374b0d (diff) |
can: c_can: Use proper u32 variables in c_can_write_msg_object()
Instead of obfuscating the code by artificial 16 bit splits use the
proper 32 bit assignments and split the result when writing to the
interface.
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.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index 7c60e6affe7a..61fde414bb1f 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c | |||
@@ -135,9 +135,9 @@ | |||
135 | #define IF_COMM_INVAL (IF_COMM_ARB | IF_COMM_CONTROL) | 135 | #define IF_COMM_INVAL (IF_COMM_ARB | IF_COMM_CONTROL) |
136 | 136 | ||
137 | /* IFx arbitration */ | 137 | /* IFx arbitration */ |
138 | #define IF_ARB_MSGVAL BIT(15) | 138 | #define IF_ARB_MSGVAL BIT(31) |
139 | #define IF_ARB_MSGXTD BIT(14) | 139 | #define IF_ARB_MSGXTD BIT(30) |
140 | #define IF_ARB_TRANSMIT BIT(13) | 140 | #define IF_ARB_TRANSMIT BIT(29) |
141 | 141 | ||
142 | /* IFx message control */ | 142 | /* IFx message control */ |
143 | #define IF_MCONT_NEWDAT BIT(15) | 143 | #define IF_MCONT_NEWDAT BIT(15) |
@@ -299,18 +299,18 @@ static void c_can_write_msg_object(struct net_device *dev, int iface, | |||
299 | { | 299 | { |
300 | struct c_can_priv *priv = netdev_priv(dev); | 300 | struct c_can_priv *priv = netdev_priv(dev); |
301 | u16 ctrl = IF_MCONT_TX | frame->can_dlc; | 301 | u16 ctrl = IF_MCONT_TX | frame->can_dlc; |
302 | u32 arb = IF_ARB_MSGVAL << 16; | 302 | u32 arb = IF_ARB_MSGVAL; |
303 | int i; | 303 | int i; |
304 | 304 | ||
305 | if (frame->can_id & CAN_EFF_FLAG) { | 305 | if (frame->can_id & CAN_EFF_FLAG) { |
306 | arb |= frame->can_id & CAN_EFF_MASK; | 306 | arb |= frame->can_id & CAN_EFF_MASK; |
307 | arb |= IF_ARB_MSGXTD << 16; | 307 | arb |= IF_ARB_MSGXTD; |
308 | } else { | 308 | } else { |
309 | arb |= (frame->can_id & CAN_SFF_MASK) << 18; | 309 | arb |= (frame->can_id & CAN_SFF_MASK) << 18; |
310 | } | 310 | } |
311 | 311 | ||
312 | if (!(frame->can_id & CAN_RTR_FLAG)) | 312 | if (!(frame->can_id & CAN_RTR_FLAG)) |
313 | arb |= IF_ARB_TRANSMIT << 16; | 313 | arb |= IF_ARB_TRANSMIT; |
314 | 314 | ||
315 | priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), arb); | 315 | priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), arb); |
316 | priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), arb >> 16); | 316 | priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), arb >> 16); |
@@ -380,12 +380,12 @@ static int c_can_read_msg_object(struct net_device *dev, int iface, u32 ctrl) | |||
380 | arb = priv->read_reg(priv, C_CAN_IFACE(ARB1_REG, iface)); | 380 | arb = priv->read_reg(priv, C_CAN_IFACE(ARB1_REG, iface)); |
381 | arb |= priv->read_reg(priv, C_CAN_IFACE(ARB2_REG, iface)) << 16; | 381 | arb |= priv->read_reg(priv, C_CAN_IFACE(ARB2_REG, iface)) << 16; |
382 | 382 | ||
383 | if (arb & (IF_ARB_MSGXTD << 16)) | 383 | if (arb & IF_ARB_MSGXTD) |
384 | frame->can_id = (arb & CAN_EFF_MASK) | CAN_EFF_FLAG; | 384 | frame->can_id = (arb & CAN_EFF_MASK) | CAN_EFF_FLAG; |
385 | else | 385 | else |
386 | frame->can_id = (arb >> 18) & CAN_SFF_MASK; | 386 | frame->can_id = (arb >> 18) & CAN_SFF_MASK; |
387 | 387 | ||
388 | if (arb & (IF_ARB_TRANSMIT << 16)) { | 388 | if (arb & IF_ARB_TRANSMIT) { |
389 | frame->can_id |= CAN_RTR_FLAG; | 389 | frame->can_id |= CAN_RTR_FLAG; |
390 | } else { | 390 | } else { |
391 | int i, dreg = C_CAN_IFACE(DATA1_REG, iface); | 391 | int i, dreg = C_CAN_IFACE(DATA1_REG, iface); |
@@ -413,7 +413,7 @@ static void c_can_setup_receive_object(struct net_device *dev, int iface, | |||
413 | priv->write_reg(priv, C_CAN_IFACE(MASK1_REG, iface), mask); | 413 | priv->write_reg(priv, C_CAN_IFACE(MASK1_REG, iface), mask); |
414 | priv->write_reg(priv, C_CAN_IFACE(MASK2_REG, iface), mask >> 16); | 414 | priv->write_reg(priv, C_CAN_IFACE(MASK2_REG, iface), mask >> 16); |
415 | 415 | ||
416 | id |= IF_ARB_MSGVAL << 16; | 416 | id |= IF_ARB_MSGVAL; |
417 | priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), id); | 417 | priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), id); |
418 | priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), id >> 16); | 418 | priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), id >> 16); |
419 | 419 | ||