mailbox: rockchip: modify the default time out value of scpi command from immediate
authorAiyoujun <ayj@rock-chips.com>
Fri, 15 May 2015 10:35:16 +0000 (18:35 +0800)
committerAiyoujun <ayj@rock-chips.com>
Fri, 15 May 2015 10:35:16 +0000 (18:35 +0800)
                   to a const define.
        If you would use another timeout value with your command, you shoul do it
        as below:
                   SCPI_SETUP_DBUF(sdata, mdata, SCPI_CL_CLOCKS,
                        SCPI_CMD_GET_CLOCK_VALUE, clk_id, buf);
                   sdata.timeout_ms = YOUR_CMD_DEFAULT_TIMEOUT_MS;

Signed-off-by: Aiyoujun <ayj@rock-chips.com>
drivers/mailbox/scpi_protocol.c

index 8313912ea8b9f91016b6998c518667d02a97fbf2..d906906fdbd71dc66f8705703281adf2a0e06f25 100644 (file)
@@ -41,6 +41,7 @@
        ((((cmd) & CMD_ID_MASK) << CMD_ID_SHIFT) |                      \
        (((sender) & CMD_SENDER_ID_MASK) << CMD_SENDER_ID_SHIFT) |      \
        (((txsz) & CMD_DATA_SIZE_MASK) << CMD_DATA_SIZE_SHIFT))
+#define SCPI_CMD_DEFAULT_TIMEOUT_MS  1000
 
 #define MAX_DVFS_DOMAINS       3
 #define MAX_DVFS_OPPS          8
@@ -51,6 +52,7 @@ struct scpi_data_buf {
        int client_id;
        struct rockchip_mbox_msg *data;
        struct completion complete;
+       int timeout_ms;
 };
 
 static int high_priority_cmds[] = {
@@ -112,6 +114,7 @@ static int send_scpi_cmd(struct scpi_data_buf *scpi_buf, bool high_priority)
        struct rockchip_mbox_msg *data = scpi_buf->data;
        u32 status;
        int ret;
+       int timeout = msecs_to_jiffies(scpi_buf->timeout_ms);
 
        if (!the_scpi_device) {
                pr_err("Scpi initializes unsuccessfully\n");
@@ -134,8 +137,7 @@ static int send_scpi_cmd(struct scpi_data_buf *scpi_buf, bool high_priority)
                goto free_channel;
        }
 
-       ret = wait_for_completion_timeout(&scpi_buf->complete,
-                                         msecs_to_jiffies(1000));
+       ret = wait_for_completion_timeout(&scpi_buf->complete, timeout);
        if (ret == 0) {
                status = SCPI_ERR_TIMEOUT;
                goto free_channel;
@@ -159,6 +161,7 @@ do {                                                \
        pdata->rx_size = sizeof(_rx_buf);       \
        scpi_buf.client_id = _client_id;        \
        scpi_buf.data = pdata;                  \
+       scpi_buf.timeout_ms = SCPI_CMD_DEFAULT_TIMEOUT_MS; \
 } while (0)
 
 static int scpi_execute_cmd(struct scpi_data_buf *scpi_buf)