Skip to content

Commit 9dd2d6c

Browse files
arndbdavem330
authored andcommitted
netcp: add more __le32 annotations
The handling of epib and psdata remains a bit unclear in the driver, as we access the same fields both as CPU-endian and through DMA from the device. Sparse warns about this: ti/netcp_core.c:1147:21: warning: incorrect type in assignment (different base types) ti/netcp_core.c:1147:21: expected unsigned int [usertype] *[assigned] epib ti/netcp_core.c:1147:21: got restricted __le32 *<noident> This uses __le32 types in a few places and uses __force where the code looks fishy. The previous patch should really have produced the correct behavior, but this second patch is needed to shut up the warnings about it. Ideally it would be slightly rewritten to not need those casts, but I don't dare do that without access to the hardware for proper testing. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8990777 commit 9dd2d6c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

drivers/net/ethernet/ti/netcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct netcp_intf {
113113
#define NETCP_PSDATA_LEN KNAV_DMA_NUM_PS_WORDS
114114
struct netcp_packet {
115115
struct sk_buff *skb;
116-
u32 *epib;
116+
__le32 *epib;
117117
u32 *psdata;
118118
unsigned int psdata_len;
119119
struct netcp_intf *netcp;

drivers/net/ethernet/ti/netcp_core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,8 +1145,8 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp,
11451145
p_info.ts_context = NULL;
11461146
p_info.txtstamp_complete = NULL;
11471147
p_info.epib = desc->epib;
1148-
p_info.psdata = desc->psdata;
1149-
memset(p_info.epib, 0, KNAV_DMA_NUM_EPIB_WORDS * sizeof(u32));
1148+
p_info.psdata = (u32 __force *)desc->psdata;
1149+
memset(p_info.epib, 0, KNAV_DMA_NUM_EPIB_WORDS * sizeof(__le32));
11501150

11511151
/* Find out where to inject the packet for transmission */
11521152
list_for_each_entry(tx_hook, &netcp->txhook_list_head, list) {
@@ -1170,11 +1170,12 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp,
11701170

11711171
/* update descriptor */
11721172
if (p_info.psdata_len) {
1173-
u32 *psdata = p_info.psdata;
1173+
/* psdata points to both native-endian and device-endian data */
1174+
__le32 *psdata = (void __force *)p_info.psdata;
11741175

11751176
memmove(p_info.psdata, p_info.psdata + p_info.psdata_len,
11761177
p_info.psdata_len);
1177-
set_words(psdata, p_info.psdata_len, psdata);
1178+
set_words(p_info.psdata, p_info.psdata_len, psdata);
11781179
tmp |= (p_info.psdata_len & KNAV_DMA_DESC_PSLEN_MASK) <<
11791180
KNAV_DMA_DESC_PSLEN_SHIFT;
11801181
}

0 commit comments

Comments
 (0)