mei: propagate error from write routines instead of ENODEV
authorTomas Winkler <tomas.winkler@intel.com>
Mon, 16 Sep 2013 20:44:43 +0000 (23:44 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Sep 2013 15:42:02 +0000 (08:42 -0700)
ENODEV will cause application to try to reconnect since
it assumes that device went through the reset
write errors are not always fatal it can happen due to
resource contention

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/amthif.c
drivers/misc/mei/client.c
drivers/misc/mei/hbm.c
drivers/misc/mei/interrupt.c

index d0fdc134068a05ed9967fe98ca7d9a6d6429e710..718f3a14c1ca4b6f06265deef880381501be74c9 100644 (file)
@@ -312,13 +312,13 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)
                mei_hdr.me_addr = dev->iamthif_cl.me_client_id;
                mei_hdr.reserved = 0;
                dev->iamthif_msg_buf_index += mei_hdr.length;
-               if (mei_write_message(dev, &mei_hdr,
-                                       (unsigned char *)dev->iamthif_msg_buf))
-                       return -ENODEV;
+               ret = mei_write_message(dev, &mei_hdr, dev->iamthif_msg_buf);
+               if (ret)
+                       return ret;
 
                if (mei_hdr.msg_complete) {
                        if (mei_cl_flow_ctrl_reduce(&dev->iamthif_cl))
-                               return -ENODEV;
+                               return -EIO;
                        dev->iamthif_flow_control_pending = true;
                        dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
                        dev_dbg(&dev->pdev->dev, "add amthif cb to write waiting list\n");
@@ -458,6 +458,7 @@ int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
        struct mei_msg_hdr mei_hdr;
        size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index;
        u32 msg_slots = mei_data2slots(len);
+       int rets;
 
        mei_hdr.host_addr = cl->host_client_id;
        mei_hdr.me_addr = cl->me_client_id;
@@ -480,16 +481,17 @@ int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
        dev_dbg(&dev->pdev->dev, MEI_HDR_FMT,  MEI_HDR_PRM(&mei_hdr));
 
        *slots -=  msg_slots;
-       if (mei_write_message(dev, &mei_hdr,
-               dev->iamthif_msg_buf + dev->iamthif_msg_buf_index)) {
-                       dev->iamthif_state = MEI_IAMTHIF_IDLE;
-                       cl->status = -ENODEV;
-                       list_del(&cb->list);
-                       return -ENODEV;
+       rets = mei_write_message(dev, &mei_hdr,
+                       dev->iamthif_msg_buf + dev->iamthif_msg_buf_index);
+       if (rets) {
+               dev->iamthif_state = MEI_IAMTHIF_IDLE;
+               cl->status = rets;
+               list_del(&cb->list);
+               return rets;
        }
 
        if (mei_cl_flow_ctrl_reduce(cl))
-               return -ENODEV;
+               return -EIO;
 
        dev->iamthif_msg_buf_index += mei_hdr.length;
        cl->status = 0;
index bccc3164ea4ca8fd1334c7071070a3d611650573..1a53d961302a7e1e3d7d474dfed74afad22bb4eb 100644 (file)
@@ -706,6 +706,7 @@ int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
        struct mei_msg_hdr mei_hdr;
        size_t len = cb->request_buffer.size - cb->buf_idx;
        u32 msg_slots = mei_data2slots(len);
+       int rets;
 
        mei_hdr.host_addr = cl->host_client_id;
        mei_hdr.me_addr = cl->me_client_id;
@@ -729,11 +730,12 @@ int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
                        cb->request_buffer.size, cb->buf_idx);
 
        *slots -=  msg_slots;
-       if (mei_write_message(dev, &mei_hdr,
-                       cb->request_buffer.data + cb->buf_idx)) {
-               cl->status = -ENODEV;
+       rets = mei_write_message(dev, &mei_hdr,
+                       cb->request_buffer.data + cb->buf_idx);
+       if (rets) {
+               cl->status = rets;
                list_move_tail(&cb->list, &cmpl_list->list);
-               return -ENODEV;
+               return rets;
        }
 
        cl->status = 0;
@@ -742,7 +744,7 @@ int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,
 
        if (mei_hdr.msg_complete) {
                if (mei_cl_flow_ctrl_reduce(cl))
-                       return -ENODEV;
+                       return -EIO;
                list_move_tail(&cb->list, &dev->write_waiting_list.list);
        }
 
@@ -811,10 +813,9 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking)
        mei_hdr.reserved = 0;
 
 
-       if (mei_write_message(dev, &mei_hdr, buf->data)) {
-               rets = -EIO;
+       rets = mei_write_message(dev, &mei_hdr, buf->data);
+       if (rets)
                goto err;
-       }
 
        cl->writing_state = MEI_WRITING;
        cb->buf_idx = mei_hdr.length;
index f706fe8a3286940b2e145e3bb8ee3476a1d6126f..f1c974a0bc0d3bd5b6a8b7d9f261833b77027e75 100644 (file)
@@ -170,7 +170,7 @@ int mei_hbm_start_req(struct mei_device *dev)
                dev_err(&dev->pdev->dev, "version message write failed\n");
                dev->dev_state = MEI_DEV_RESETTING;
                mei_reset(dev, 1);
-               return -ENODEV;
+               return -EIO;
        }
        dev->hbm_state = MEI_HBM_START;
        dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
index be42c700b15ad6d03926cbeb3695884a931b3eca..e4bb9aee40a1f8e7b83d771d96e72e9f8b8058ac 100644 (file)
@@ -216,9 +216,11 @@ static int mei_cl_irq_read(struct mei_cl *cl, struct mei_cl_cb *cb,
                           s32 *slots, struct mei_cl_cb *cmpl_list)
 {
        struct mei_device *dev = cl->dev;
-
        u32 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control));
 
+       int ret;
+
+
        if (*slots < msg_slots) {
                /* return the cancel routine */
                list_del(&cb->list);
@@ -227,12 +229,14 @@ static int mei_cl_irq_read(struct mei_cl *cl, struct mei_cl_cb *cb,
 
        *slots -= msg_slots;
 
-       if (mei_hbm_cl_flow_control_req(dev, cl)) {
-               cl->status = -ENODEV;
+       ret = mei_hbm_cl_flow_control_req(dev, cl);
+       if (ret) {
+               cl->status = ret;
                cb->buf_idx = 0;
                list_move_tail(&cb->list, &cmpl_list->list);
-               return -ENODEV;
+               return ret;
        }
+
        list_move_tail(&cb->list, &dev->read_list.list);
 
        return 0;
@@ -254,6 +258,7 @@ static int mei_cl_irq_ioctl(struct mei_cl *cl, struct mei_cl_cb *cb,
                           s32 *slots, struct mei_cl_cb *cmpl_list)
 {
        struct mei_device *dev = cl->dev;
+       int ret;
 
        u32 msg_slots =
                mei_data2slots(sizeof(struct hbm_client_connect_request));
@@ -268,11 +273,12 @@ static int mei_cl_irq_ioctl(struct mei_cl *cl, struct mei_cl_cb *cb,
 
        cl->state = MEI_FILE_CONNECTING;
 
-       if (mei_hbm_cl_connect_req(dev, cl)) {
-               cl->status = -ENODEV;
+       ret = mei_hbm_cl_connect_req(dev, cl);
+       if (ret) {
+               cl->status = ret;
                cb->buf_idx = 0;
                list_del(&cb->list);
-               return -ENODEV;
+               return ret;
        }
 
        list_move_tail(&cb->list, &dev->ctrl_rd_list.list);