2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-23 12:43:55 +08:00

can: ti_hecc: fix endianness related sparse warning

This patch fixes the following sparse warning, which occurs in casts when
accessing the data in the CAN frames (struct can_frame) in the RX and TX
routines:

drivers/net/can/ti_hecc.c:521:17: warning: cast to restricted __be32
drivers/net/can/ti_hecc.c:521:17: warning: cast to restricted __be32
drivers/net/can/ti_hecc.c:521:17: warning: cast to restricted __be32
drivers/net/can/ti_hecc.c:521:17: warning: cast to restricted __be32
drivers/net/can/ti_hecc.c:521:17: warning: cast to restricted __be32
drivers/net/can/ti_hecc.c:521:17: warning: cast to restricted __be32
drivers/net/can/ti_hecc.c:524:25: warning: cast to restricted __be32
drivers/net/can/ti_hecc.c:524:25: warning: cast to restricted __be32
drivers/net/can/ti_hecc.c:524:25: warning: cast to restricted __be32
drivers/net/can/ti_hecc.c:524:25: warning: cast to restricted __be32
drivers/net/can/ti_hecc.c:524:25: warning: cast to restricted __be32
drivers/net/can/ti_hecc.c:524:25: warning: cast to restricted __be32
drivers/net/can/ti_hecc.c:572:28: warning: incorrect type in assignment (different base types)
drivers/net/can/ti_hecc.c:572:28:    expected unsigned int [unsigned] [usertype] <noident>
drivers/net/can/ti_hecc.c:572:28:    got restricted __be32 [usertype] <noident>
drivers/net/can/ti_hecc.c:575:40: warning: incorrect type in assignment (different base types)
drivers/net/can/ti_hecc.c:575:40:    expected unsigned int [unsigned] [usertype] <noident>
drivers/net/can/ti_hecc.c:575:40:    got restricted __be32 [usertype] <noident>

As the data is indeed big endian, use "__be32" instead of "u32", when casting
it.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
Marc Kleine-Budde 2014-01-11 19:11:24 +01:00
parent 40d451181a
commit ea79c1c185

View File

@ -518,10 +518,10 @@ static netdev_tx_t ti_hecc_xmit(struct sk_buff *skb, struct net_device *ndev)
data = (cf->can_id & CAN_SFF_MASK) << 18; data = (cf->can_id & CAN_SFF_MASK) << 18;
hecc_write_mbx(priv, mbxno, HECC_CANMID, data); hecc_write_mbx(priv, mbxno, HECC_CANMID, data);
hecc_write_mbx(priv, mbxno, HECC_CANMDL, hecc_write_mbx(priv, mbxno, HECC_CANMDL,
be32_to_cpu(*(u32 *)(cf->data))); be32_to_cpu(*(__be32 *)(cf->data)));
if (cf->can_dlc > 4) if (cf->can_dlc > 4)
hecc_write_mbx(priv, mbxno, HECC_CANMDH, hecc_write_mbx(priv, mbxno, HECC_CANMDH,
be32_to_cpu(*(u32 *)(cf->data + 4))); be32_to_cpu(*(__be32 *)(cf->data + 4)));
else else
*(u32 *)(cf->data + 4) = 0; *(u32 *)(cf->data + 4) = 0;
can_put_echo_skb(skb, ndev, mbxno); can_put_echo_skb(skb, ndev, mbxno);
@ -569,12 +569,10 @@ static int ti_hecc_rx_pkt(struct ti_hecc_priv *priv, int mbxno)
cf->can_id |= CAN_RTR_FLAG; cf->can_id |= CAN_RTR_FLAG;
cf->can_dlc = get_can_dlc(data & 0xF); cf->can_dlc = get_can_dlc(data & 0xF);
data = hecc_read_mbx(priv, mbxno, HECC_CANMDL); data = hecc_read_mbx(priv, mbxno, HECC_CANMDL);
*(u32 *)(cf->data) = cpu_to_be32(data); *(__be32 *)(cf->data) = cpu_to_be32(data);
if (cf->can_dlc > 4) { if (cf->can_dlc > 4) {
data = hecc_read_mbx(priv, mbxno, HECC_CANMDH); data = hecc_read_mbx(priv, mbxno, HECC_CANMDH);
*(u32 *)(cf->data + 4) = cpu_to_be32(data); *(__be32 *)(cf->data + 4) = cpu_to_be32(data);
} else {
*(u32 *)(cf->data + 4) = 0;
} }
spin_lock_irqsave(&priv->mbx_lock, flags); spin_lock_irqsave(&priv->mbx_lock, flags);
hecc_clear_bit(priv, HECC_CANME, mbx_mask); hecc_clear_bit(priv, HECC_CANME, mbx_mask);