Commit 4fb6dccd authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Marc Kleine-Budde

can: c_can: Cleanup c_can_read_msg_object()

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 2d5f4f85
...@@ -380,15 +380,13 @@ static int c_can_handle_lost_msg_obj(struct net_device *dev, ...@@ -380,15 +380,13 @@ static int c_can_handle_lost_msg_obj(struct net_device *dev,
return 1; return 1;
} }
static int c_can_read_msg_object(struct net_device *dev, int iface, int ctrl) static int c_can_read_msg_object(struct net_device *dev, int iface, u32 ctrl)
{ {
u16 flags, data;
int i;
unsigned int val;
struct c_can_priv *priv = netdev_priv(dev);
struct net_device_stats *stats = &dev->stats; struct net_device_stats *stats = &dev->stats;
struct sk_buff *skb; struct c_can_priv *priv = netdev_priv(dev);
struct can_frame *frame; struct can_frame *frame;
struct sk_buff *skb;
u32 arb, data;
skb = alloc_can_skb(dev, &frame); skb = alloc_can_skb(dev, &frame);
if (!skb) { if (!skb) {
...@@ -398,21 +396,21 @@ static int c_can_read_msg_object(struct net_device *dev, int iface, int ctrl) ...@@ -398,21 +396,21 @@ static int c_can_read_msg_object(struct net_device *dev, int iface, int ctrl)
frame->can_dlc = get_can_dlc(ctrl & 0x0F); frame->can_dlc = get_can_dlc(ctrl & 0x0F);
flags = priv->read_reg(priv, C_CAN_IFACE(ARB2_REG, iface)); arb = priv->read_reg(priv, C_CAN_IFACE(ARB1_REG, iface));
val = priv->read_reg(priv, C_CAN_IFACE(ARB1_REG, iface)) | arb |= priv->read_reg(priv, C_CAN_IFACE(ARB2_REG, iface)) << 16;
(flags << 16);
if (flags & IF_ARB_MSGXTD) if (arb & (IF_ARB_MSGXTD << 16))
frame->can_id = (val & CAN_EFF_MASK) | CAN_EFF_FLAG; frame->can_id = (arb & CAN_EFF_MASK) | CAN_EFF_FLAG;
else else
frame->can_id = (val >> 18) & CAN_SFF_MASK; frame->can_id = (arb >> 18) & CAN_SFF_MASK;
if (flags & IF_ARB_TRANSMIT) if (arb & (IF_ARB_TRANSMIT << 16)) {
frame->can_id |= CAN_RTR_FLAG; frame->can_id |= CAN_RTR_FLAG;
else { } else {
for (i = 0; i < frame->can_dlc; i += 2) { int i, dreg = C_CAN_IFACE(DATA1_REG, iface);
data = priv->read_reg(priv,
C_CAN_IFACE(DATA1_REG, iface) + i / 2); for (i = 0; i < frame->can_dlc; i += 2, dreg ++) {
data = priv->read_reg(priv, dreg);
frame->data[i] = data; frame->data[i] = data;
frame->data[i + 1] = data >> 8; frame->data[i + 1] = data >> 8;
} }
......
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