Commit d01a303e authored by Pontus Fuchs's avatar Pontus Fuchs Committed by John W. Linville

ar5523: Fix sparse endianness warnings

__be32 variables where used a little careless leading to sparse warnings.
Treat them a little more gentle.
Reported-by: default avatarFengguang Wu <fengguang.wu@intel.com>
Signed-off-by: default avatarPontus Fuchs <pontus.fuchs@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent f3ec3bf5
...@@ -50,18 +50,19 @@ static void ar5523_read_reply(struct ar5523 *ar, struct ar5523_cmd_hdr *hdr, ...@@ -50,18 +50,19 @@ static void ar5523_read_reply(struct ar5523 *ar, struct ar5523_cmd_hdr *hdr,
struct ar5523_tx_cmd *cmd) struct ar5523_tx_cmd *cmd)
{ {
int dlen, olen; int dlen, olen;
u32 *rp; __be32 *rp;
dlen = hdr->len - sizeof(*hdr); dlen = be32_to_cpu(hdr->len) - sizeof(*hdr);
if (dlen < 0) { if (dlen < 0) {
WARN_ON(1); WARN_ON(1);
goto out; goto out;
} }
ar5523_dbg(ar, "Code = %d len = %d\n", hdr->code & 0xff, dlen); ar5523_dbg(ar, "Code = %d len = %d\n", be32_to_cpu(hdr->code) & 0xff,
dlen);
rp = (u32 *)(hdr + 1); rp = (__be32 *)(hdr + 1);
if (dlen >= sizeof(u32)) { if (dlen >= sizeof(u32)) {
olen = be32_to_cpu(rp[0]); olen = be32_to_cpu(rp[0]);
dlen -= sizeof(u32); dlen -= sizeof(u32);
...@@ -95,6 +96,7 @@ static void ar5523_cmd_rx_cb(struct urb *urb) ...@@ -95,6 +96,7 @@ static void ar5523_cmd_rx_cb(struct urb *urb)
struct ar5523_tx_cmd *cmd = &ar->tx_cmd; struct ar5523_tx_cmd *cmd = &ar->tx_cmd;
struct ar5523_cmd_hdr *hdr = ar->rx_cmd_buf; struct ar5523_cmd_hdr *hdr = ar->rx_cmd_buf;
int dlen; int dlen;
u32 code, hdrlen;
if (urb->status) { if (urb->status) {
if (urb->status != -ESHUTDOWN) if (urb->status != -ESHUTDOWN)
...@@ -110,15 +112,15 @@ static void ar5523_cmd_rx_cb(struct urb *urb) ...@@ -110,15 +112,15 @@ static void ar5523_cmd_rx_cb(struct urb *urb)
ar5523_dbg(ar, "%s code %02x priv %d\n", __func__, ar5523_dbg(ar, "%s code %02x priv %d\n", __func__,
be32_to_cpu(hdr->code) & 0xff, hdr->priv); be32_to_cpu(hdr->code) & 0xff, hdr->priv);
hdr->code = be32_to_cpu(hdr->code); code = be32_to_cpu(hdr->code);
hdr->len = be32_to_cpu(hdr->len); hdrlen = be32_to_cpu(hdr->len);
switch (hdr->code & 0xff) { switch (code & 0xff) {
default: default:
/* reply to a read command */ /* reply to a read command */
if (hdr->priv != AR5523_CMD_ID) { if (hdr->priv != AR5523_CMD_ID) {
ar5523_err(ar, "Unexpected command id: %02x\n", ar5523_err(ar, "Unexpected command id: %02x\n",
hdr->code & 0xff); code & 0xff);
goto skip; goto skip;
} }
ar5523_read_reply(ar, hdr, cmd); ar5523_read_reply(ar, hdr, cmd);
...@@ -147,7 +149,7 @@ static void ar5523_cmd_rx_cb(struct urb *urb) ...@@ -147,7 +149,7 @@ static void ar5523_cmd_rx_cb(struct urb *urb)
case WDCMSG_TARGET_START: case WDCMSG_TARGET_START:
/* This command returns a bogus id so it needs special /* This command returns a bogus id so it needs special
handling */ handling */
dlen = hdr->len - sizeof(*hdr); dlen = hdrlen - sizeof(*hdr);
if (dlen != (int)sizeof(u32)) { if (dlen != (int)sizeof(u32)) {
ar5523_err(ar, "Invalid reply to WDCMSG_TARGET_START"); ar5523_err(ar, "Invalid reply to WDCMSG_TARGET_START");
return; return;
...@@ -303,7 +305,7 @@ static int ar5523_config(struct ar5523 *ar, u32 reg, u32 val) ...@@ -303,7 +305,7 @@ static int ar5523_config(struct ar5523 *ar, u32 reg, u32 val)
write.reg = cpu_to_be32(reg); write.reg = cpu_to_be32(reg);
write.len = cpu_to_be32(0); /* 0 = single write */ write.len = cpu_to_be32(0); /* 0 = single write */
*(u32 *)write.data = cpu_to_be32(val); *(__be32 *)write.data = cpu_to_be32(val);
error = ar5523_cmd_write(ar, WDCMSG_TARGET_SET_CONFIG, &write, error = ar5523_cmd_write(ar, WDCMSG_TARGET_SET_CONFIG, &write,
3 * sizeof(u32), 0); 3 * sizeof(u32), 0);
...@@ -335,29 +337,30 @@ static int ar5523_get_status(struct ar5523 *ar, u32 which, void *odata, ...@@ -335,29 +337,30 @@ static int ar5523_get_status(struct ar5523 *ar, u32 which, void *odata,
int olen) int olen)
{ {
int error; int error;
__be32 which_be;
which = cpu_to_be32(which); which_be = cpu_to_be32(which);
error = ar5523_cmd_read(ar, WDCMSG_TARGET_GET_STATUS, error = ar5523_cmd_read(ar, WDCMSG_TARGET_GET_STATUS,
&which, sizeof(which), odata, olen, AR5523_CMD_FLAG_MAGIC); &which_be, sizeof(which_be), odata, olen, AR5523_CMD_FLAG_MAGIC);
if (error != 0) if (error != 0)
ar5523_err(ar, "could not read EEPROM offset 0x%02x\n", ar5523_err(ar, "could not read EEPROM offset 0x%02x\n", which);
be32_to_cpu(which));
return error; return error;
} }
static int ar5523_get_capability(struct ar5523 *ar, u32 cap, u32 *val) static int ar5523_get_capability(struct ar5523 *ar, u32 cap, u32 *val)
{ {
int error; int error;
__be32 cap_be, val_be;
cap = cpu_to_be32(cap); cap_be = cpu_to_be32(cap);
error = ar5523_cmd_read(ar, WDCMSG_TARGET_GET_CAPABILITY, error = ar5523_cmd_read(ar, WDCMSG_TARGET_GET_CAPABILITY, &cap_be,
&cap, sizeof(cap), val, sizeof(u32), AR5523_CMD_FLAG_MAGIC); sizeof(cap_be), &val_be, sizeof(__be32),
AR5523_CMD_FLAG_MAGIC);
if (error != 0) { if (error != 0) {
ar5523_err(ar, "could not read capability %u\n", ar5523_err(ar, "could not read capability %u\n", cap);
be32_to_cpu(cap));
return error; return error;
} }
*val = be32_to_cpu(*val); *val = be32_to_cpu(val_be);
return error; return error;
} }
......
...@@ -161,7 +161,7 @@ struct ar5523_rx_desc { ...@@ -161,7 +161,7 @@ struct ar5523_rx_desc {
struct ar5523_tx_desc { struct ar5523_tx_desc {
__be32 msglen; __be32 msglen;
__be32 msgid; /* msg id (supplied by host) */ u32 msgid; /* msg id (supplied by host) */
__be32 type; /* opcode: WDMSG_SEND or WDCMSG_FLUSH */ __be32 type; /* opcode: WDMSG_SEND or WDCMSG_FLUSH */
__be32 txqid; /* tx queue id and flags */ __be32 txqid; /* tx queue id and flags */
#define UATH_TXQID_MASK 0x0f #define UATH_TXQID_MASK 0x0f
......
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