Skip to contentSkip to conversation

ems_usb: Fix byte order issues on big endian machines

PATCH New Sebastian Haas 1 participant 1 message Nov 4, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ems_usb: Fix byte order issues on big endian machines

CPC-USB is using a ARM7 core with little endian byte order. The "id" field in can_msg needs byte order conversion from/to CPU byte order.

---

 drivers/net/can/usb/ems_usb.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/can/usb/ems_usb.c +4 -1
index 9012e0a..abdbd9c 100644
@@ -319,7 +319,7 @@ static void ems_usb_rx_can_msg(struct ems_usb *dev, struct ems_cpc_msg *msg)
 
 	cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
 
-	cf->can_id = msg->msg.can_msg.id;
+	cf->can_id = le32_to_cpu(msg->msg.can_msg.id);
 	cf->can_dlc = min_t(u8, msg->msg.can_msg.length, 8);
 
 	if (msg->type == CPC_MSG_TYPE_EXT_CAN_FRAME
@@ -813,6 +813,9 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne
 		msg->length = CPC_CAN_MSG_MIN_SIZE + cf->can_dlc;
 	}
 
+	/* Respect byte order */
+	msg->msg.can_msg.id = cpu_to_le32(msg->msg.can_msg.id);
+
 	for (i = 0; i < MAX_TX_URBS; i++) {
 		if (dev->tx_contexts[i].echo_index == MAX_TX_URBS) {
 			context = &dev->tx_contexts[i];
Signature · 7 lines
EMS Dr. Thomas Wuensche e.K.
Sonnenhang 3
85304 Ilmmuenster
HRA Neuburg a.d. Donau, HR-Nr. 70.106
Phone: +49-8441-490260
Fax  : +49-8441-81860
http://www.ems-wuensche.com