Skip to content

Commit 6d5eda6

Browse files
andy-shevjfvogel
authored andcommitted
ieee802154: ca8210: Use proper setters and getters for bitwise types
[ Upstream commit 169b2262205836a5d1213ff44dca2962276bece1 ] Sparse complains that the driver doesn't respect the bitwise types: drivers/net/ieee802154/ca8210.c:1796:27: warning: incorrect type in assignment (different base types) drivers/net/ieee802154/ca8210.c:1796:27: expected restricted __le16 [addressable] [assigned] [usertype] pan_id drivers/net/ieee802154/ca8210.c:1796:27: got unsigned short [usertype] drivers/net/ieee802154/ca8210.c:1801:25: warning: incorrect type in assignment (different base types) drivers/net/ieee802154/ca8210.c:1801:25: expected restricted __le16 [addressable] [assigned] [usertype] pan_id drivers/net/ieee802154/ca8210.c:1801:25: got unsigned short [usertype] drivers/net/ieee802154/ca8210.c:1928:28: warning: incorrect type in argument 3 (different base types) drivers/net/ieee802154/ca8210.c:1928:28: expected unsigned short [usertype] dst_pan_id drivers/net/ieee802154/ca8210.c:1928:28: got restricted __le16 [addressable] [usertype] pan_id Use proper setters and getters for bitwise types. Note, in accordance with [1] the protocol is little endian. Link: https://www.cascoda.com/wp-content/uploads/2018/11/CA-8210_datasheet_0418.pdf [1] Reviewed-by: Miquel Raynal <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Stefan Schmidt <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit a3642d2d73a97b39c50fcb6abb71c2488cda21ae) Signed-off-by: Jack Vogel <[email protected]>
1 parent 6288623 commit 6d5eda6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/net/ieee802154/ca8210.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,8 +1446,7 @@ static u8 mcps_data_request(
14461446
command.pdata.data_req.src_addr_mode = src_addr_mode;
14471447
command.pdata.data_req.dst.mode = dst_address_mode;
14481448
if (dst_address_mode != MAC_MODE_NO_ADDR) {
1449-
command.pdata.data_req.dst.pan_id[0] = LS_BYTE(dst_pan_id);
1450-
command.pdata.data_req.dst.pan_id[1] = MS_BYTE(dst_pan_id);
1449+
put_unaligned_le16(dst_pan_id, command.pdata.data_req.dst.pan_id);
14511450
if (dst_address_mode == MAC_MODE_SHORT_ADDR) {
14521451
command.pdata.data_req.dst.address[0] = LS_BYTE(
14531452
dst_addr->short_address
@@ -1795,12 +1794,12 @@ static int ca8210_skb_rx(
17951794
}
17961795
hdr.source.mode = data_ind[0];
17971796
dev_dbg(&priv->spi->dev, "srcAddrMode: %#03x\n", hdr.source.mode);
1798-
hdr.source.pan_id = *(u16 *)&data_ind[1];
1797+
hdr.source.pan_id = cpu_to_le16(get_unaligned_le16(&data_ind[1]));
17991798
dev_dbg(&priv->spi->dev, "srcPanId: %#06x\n", hdr.source.pan_id);
18001799
memcpy(&hdr.source.extended_addr, &data_ind[3], 8);
18011800
hdr.dest.mode = data_ind[11];
18021801
dev_dbg(&priv->spi->dev, "dstAddrMode: %#03x\n", hdr.dest.mode);
1803-
hdr.dest.pan_id = *(u16 *)&data_ind[12];
1802+
hdr.dest.pan_id = cpu_to_le16(get_unaligned_le16(&data_ind[12]));
18041803
dev_dbg(&priv->spi->dev, "dstPanId: %#06x\n", hdr.dest.pan_id);
18051804
memcpy(&hdr.dest.extended_addr, &data_ind[14], 8);
18061805

@@ -1927,7 +1926,7 @@ static int ca8210_skb_tx(
19271926
status = mcps_data_request(
19281927
header.source.mode,
19291928
header.dest.mode,
1930-
header.dest.pan_id,
1929+
le16_to_cpu(header.dest.pan_id),
19311930
(union macaddr *)&header.dest.extended_addr,
19321931
skb->len - mac_len,
19331932
&skb->data[mac_len],

0 commit comments

Comments
 (0)