aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1271_cmd.c
diff options
context:
space:
mode:
authorJuuso Oikarinen <juuso.oikarinen@nokia.com>2009-11-02 13:22:10 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-11-02 15:43:32 -0500
commit3b775b4b27818130291e7716f3ce1e24664004c9 (patch)
tree75232beef2e18edc233aab2fcea2133275814479 /drivers/net/wireless/wl12xx/wl1271_cmd.c
parent605351e2220bd7960a55d6d7903f87f11f419f4e (diff)
wl1271: Check result code of commands
Check the result code of all commands, and return an error code if the firmware reports an error in execution. Previously this error would go ignored in most cases. Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com> Reviewed-by: Luciano Coelho <luciano.coelho@nokia.com> Signed-off-by: Luciano Coelho <luciano.coelho@nokia.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_cmd.c')
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_cmd.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.c b/drivers/net/wireless/wl12xx/wl1271_cmd.c
index 0666328ce9ab..46e5ea48651b 100644
--- a/drivers/net/wireless/wl12xx/wl1271_cmd.c
+++ b/drivers/net/wireless/wl12xx/wl1271_cmd.c
@@ -74,6 +74,15 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len)
74 intr = wl1271_spi_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); 74 intr = wl1271_spi_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR);
75 } 75 }
76 76
77 /* read back the status code of the command */
78 wl1271_spi_read(wl, wl->cmd_box_addr, cmd,
79 sizeof(struct wl1271_cmd_header), false);
80
81 if (cmd->status != CMD_STATUS_SUCCESS) {
82 wl1271_error("command execute failure %d", cmd->status);
83 ret = -EIO;
84 }
85
77 wl1271_spi_write32(wl, ACX_REG_INTERRUPT_ACK, 86 wl1271_spi_write32(wl, ACX_REG_INTERRUPT_ACK,
78 WL1271_ACX_INTR_CMD_COMPLETE); 87 WL1271_ACX_INTR_CMD_COMPLETE);
79 88
@@ -306,7 +315,6 @@ int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer)
306 315
307 if (answer) { 316 if (answer) {
308 struct wl1271_command *cmd_answer; 317 struct wl1271_command *cmd_answer;
309 u16 status;
310 318
311 /* 319 /*
312 * The test command got in, we can read the answer. 320 * The test command got in, we can read the answer.
@@ -316,10 +324,6 @@ int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer)
316 wl1271_spi_read(wl, wl->cmd_box_addr, buf, buf_len, false); 324 wl1271_spi_read(wl, wl->cmd_box_addr, buf, buf_len, false);
317 325
318 cmd_answer = buf; 326 cmd_answer = buf;
319 status = le16_to_cpu(cmd_answer->header.status);
320
321 if (status != CMD_STATUS_SUCCESS)
322 wl1271_error("TEST command answer error: %d", status);
323 } 327 }
324 328
325 return 0; 329 return 0;
@@ -354,11 +358,6 @@ int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len)
354 /* the interrogate command got in, we can read the answer */ 358 /* the interrogate command got in, we can read the answer */
355 wl1271_spi_read(wl, wl->cmd_box_addr, buf, len, false); 359 wl1271_spi_read(wl, wl->cmd_box_addr, buf, len, false);
356 360
357 acx = buf;
358 if (le16_to_cpu(acx->cmd.status) != CMD_STATUS_SUCCESS)
359 wl1271_error("INTERROGATE command error: %d",
360 le16_to_cpu(acx->cmd.status));
361
362out: 361out:
363 return ret; 362 return ret;
364} 363}
@@ -507,11 +506,6 @@ int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
507 506
508 /* the read command got in, we can now read the answer */ 507 /* the read command got in, we can now read the answer */
509 wl1271_spi_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd), false); 508 wl1271_spi_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd), false);
510
511 if (le16_to_cpu(cmd->header.status) != CMD_STATUS_SUCCESS)
512 wl1271_error("error in read command result: %d",
513 le16_to_cpu(cmd->header.status));
514
515 memcpy(answer, cmd->value, len); 509 memcpy(answer, cmd->value, len);
516 510
517out: 511out:
@@ -639,17 +633,7 @@ int wl1271_cmd_scan(struct wl1271 *wl, u8 *ssid, size_t len,
639 ret = wl1271_cmd_send(wl, CMD_SCAN, params, sizeof(*params)); 633 ret = wl1271_cmd_send(wl, CMD_SCAN, params, sizeof(*params));
640 if (ret < 0) { 634 if (ret < 0) {
641 wl1271_error("SCAN failed"); 635 wl1271_error("SCAN failed");
642 goto out;
643 }
644
645 wl1271_spi_read(wl, wl->cmd_box_addr, params, sizeof(*params),
646 false);
647
648 if (le16_to_cpu(params->header.status) != CMD_STATUS_SUCCESS) {
649 wl1271_error("Scan command error: %d",
650 le16_to_cpu(params->header.status));
651 wl->scanning = false; 636 wl->scanning = false;
652 ret = -EIO;
653 goto out; 637 goto out;
654 } 638 }
655 639