diff options
author | Alexander Usyskin <alexander.usyskin@intel.com> | 2014-02-19 10:35:49 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-28 18:15:57 -0500 |
commit | 7ca96aa278f8b9983184e318b06a0ed9ad0297b8 (patch) | |
tree | b01220d624e9fbf70258a96890be25b56405c11e /drivers/misc | |
parent | 9d098192c3d45ab6dd90ae87d649950a9ef70ccb (diff) |
mei: make return values consistent across the driver
1. Propagate ENOTTY to user space if the client is not present
in the system
2. Use ETIME consistently on timeouts
3. Return EIO on write failures
4. Return ENODEV on recoverable device failures such as resets
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/mei/amthif.c | 12 | ||||
-rw-r--r-- | drivers/misc/mei/client.c | 26 | ||||
-rw-r--r-- | drivers/misc/mei/hbm.c | 2 | ||||
-rw-r--r-- | drivers/misc/mei/hw-me.c | 8 | ||||
-rw-r--r-- | drivers/misc/mei/interrupt.c | 4 | ||||
-rw-r--r-- | drivers/misc/mei/main.c | 2 | ||||
-rw-r--r-- | drivers/misc/mei/nfc.c | 6 | ||||
-rw-r--r-- | drivers/misc/mei/wd.c | 6 |
8 files changed, 33 insertions, 33 deletions
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c index bff9a07f1af5..f05d54d15e2f 100644 --- a/drivers/misc/mei/amthif.c +++ b/drivers/misc/mei/amthif.c | |||
@@ -78,10 +78,9 @@ int mei_amthif_host_init(struct mei_device *dev) | |||
78 | 78 | ||
79 | i = mei_me_cl_by_uuid(dev, &mei_amthif_guid); | 79 | i = mei_me_cl_by_uuid(dev, &mei_amthif_guid); |
80 | if (i < 0) { | 80 | if (i < 0) { |
81 | ret = i; | ||
82 | dev_info(&dev->pdev->dev, | 81 | dev_info(&dev->pdev->dev, |
83 | "amthif: failed to find the client %d\n", ret); | 82 | "amthif: failed to find the client %d\n", i); |
84 | return ret; | 83 | return -ENOTTY; |
85 | } | 84 | } |
86 | 85 | ||
87 | cl->me_client_id = dev->me_clients[i].client_id; | 86 | cl->me_client_id = dev->me_clients[i].client_id; |
@@ -174,14 +173,13 @@ int mei_amthif_read(struct mei_device *dev, struct file *file, | |||
174 | /* Only possible if we are in timeout */ | 173 | /* Only possible if we are in timeout */ |
175 | if (!cl || cl != &dev->iamthif_cl) { | 174 | if (!cl || cl != &dev->iamthif_cl) { |
176 | dev_dbg(&dev->pdev->dev, "bad file ext.\n"); | 175 | dev_dbg(&dev->pdev->dev, "bad file ext.\n"); |
177 | return -ETIMEDOUT; | 176 | return -ETIME; |
178 | } | 177 | } |
179 | 178 | ||
180 | i = mei_me_cl_by_id(dev, dev->iamthif_cl.me_client_id); | 179 | i = mei_me_cl_by_id(dev, dev->iamthif_cl.me_client_id); |
181 | |||
182 | if (i < 0) { | 180 | if (i < 0) { |
183 | dev_dbg(&dev->pdev->dev, "amthif client not found.\n"); | 181 | dev_dbg(&dev->pdev->dev, "amthif client not found.\n"); |
184 | return -ENODEV; | 182 | return -ENOTTY; |
185 | } | 183 | } |
186 | dev_dbg(&dev->pdev->dev, "checking amthif data\n"); | 184 | dev_dbg(&dev->pdev->dev, "checking amthif data\n"); |
187 | cb = mei_amthif_find_read_list_entry(dev, file); | 185 | cb = mei_amthif_find_read_list_entry(dev, file); |
@@ -222,7 +220,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file, | |||
222 | dev_dbg(&dev->pdev->dev, "amthif Time out\n"); | 220 | dev_dbg(&dev->pdev->dev, "amthif Time out\n"); |
223 | /* 15 sec for the message has expired */ | 221 | /* 15 sec for the message has expired */ |
224 | list_del(&cb->list); | 222 | list_del(&cb->list); |
225 | rets = -ETIMEDOUT; | 223 | rets = -ETIME; |
226 | goto free; | 224 | goto free; |
227 | } | 225 | } |
228 | } | 226 | } |
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index 2b0f99955ba6..753608185b77 100644 --- a/drivers/misc/mei/client.c +++ b/drivers/misc/mei/client.c | |||
@@ -664,7 +664,7 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length) | |||
664 | i = mei_me_cl_by_id(dev, cl->me_client_id); | 664 | i = mei_me_cl_by_id(dev, cl->me_client_id); |
665 | if (i < 0) { | 665 | if (i < 0) { |
666 | cl_err(dev, cl, "no such me client %d\n", cl->me_client_id); | 666 | cl_err(dev, cl, "no such me client %d\n", cl->me_client_id); |
667 | return -ENODEV; | 667 | return -ENOTTY; |
668 | } | 668 | } |
669 | 669 | ||
670 | cb = mei_io_cb_init(cl, NULL); | 670 | cb = mei_io_cb_init(cl, NULL); |
@@ -852,13 +852,12 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking) | |||
852 | cl->writing_state = MEI_WRITING; | 852 | cl->writing_state = MEI_WRITING; |
853 | cb->buf_idx = mei_hdr.length; | 853 | cb->buf_idx = mei_hdr.length; |
854 | 854 | ||
855 | rets = buf->size; | ||
856 | out: | 855 | out: |
857 | if (mei_hdr.msg_complete) { | 856 | if (mei_hdr.msg_complete) { |
858 | if (mei_cl_flow_ctrl_reduce(cl)) { | 857 | rets = mei_cl_flow_ctrl_reduce(cl); |
859 | rets = -ENODEV; | 858 | if (rets < 0) |
860 | goto err; | 859 | goto err; |
861 | } | 860 | |
862 | list_add_tail(&cb->list, &dev->write_waiting_list.list); | 861 | list_add_tail(&cb->list, &dev->write_waiting_list.list); |
863 | } else { | 862 | } else { |
864 | list_add_tail(&cb->list, &dev->write_list.list); | 863 | list_add_tail(&cb->list, &dev->write_list.list); |
@@ -868,15 +867,18 @@ out: | |||
868 | if (blocking && cl->writing_state != MEI_WRITE_COMPLETE) { | 867 | if (blocking && cl->writing_state != MEI_WRITE_COMPLETE) { |
869 | 868 | ||
870 | mutex_unlock(&dev->device_lock); | 869 | mutex_unlock(&dev->device_lock); |
871 | if (wait_event_interruptible(cl->tx_wait, | 870 | rets = wait_event_interruptible(cl->tx_wait, |
872 | cl->writing_state == MEI_WRITE_COMPLETE)) { | 871 | cl->writing_state == MEI_WRITE_COMPLETE); |
873 | if (signal_pending(current)) | ||
874 | rets = -EINTR; | ||
875 | else | ||
876 | rets = -ERESTARTSYS; | ||
877 | } | ||
878 | mutex_lock(&dev->device_lock); | 872 | mutex_lock(&dev->device_lock); |
873 | /* wait_event_interruptible returns -ERESTARTSYS */ | ||
874 | if (rets) { | ||
875 | if (signal_pending(current)) | ||
876 | rets = -EINTR; | ||
877 | goto err; | ||
878 | } | ||
879 | } | 879 | } |
880 | |||
881 | rets = buf->size; | ||
880 | err: | 882 | err: |
881 | return rets; | 883 | return rets; |
882 | } | 884 | } |
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c index a28cc928fb02..9555791c010b 100644 --- a/drivers/misc/mei/hbm.c +++ b/drivers/misc/mei/hbm.c | |||
@@ -161,7 +161,7 @@ int mei_hbm_start_wait(struct mei_device *dev) | |||
161 | if (ret <= 0 && (dev->hbm_state <= MEI_HBM_START)) { | 161 | if (ret <= 0 && (dev->hbm_state <= MEI_HBM_START)) { |
162 | dev->hbm_state = MEI_HBM_IDLE; | 162 | dev->hbm_state = MEI_HBM_IDLE; |
163 | dev_err(&dev->pdev->dev, "waiting for mei start failed\n"); | 163 | dev_err(&dev->pdev->dev, "waiting for mei start failed\n"); |
164 | return -ETIMEDOUT; | 164 | return -ETIME; |
165 | } | 165 | } |
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c index 84165cce57d2..7e769c59a420 100644 --- a/drivers/misc/mei/hw-me.c +++ b/drivers/misc/mei/hw-me.c | |||
@@ -244,7 +244,7 @@ static int mei_me_hw_ready_wait(struct mei_device *dev) | |||
244 | mutex_lock(&dev->device_lock); | 244 | mutex_lock(&dev->device_lock); |
245 | if (!err && !dev->recvd_hw_ready) { | 245 | if (!err && !dev->recvd_hw_ready) { |
246 | if (!err) | 246 | if (!err) |
247 | err = -ETIMEDOUT; | 247 | err = -ETIME; |
248 | dev_err(&dev->pdev->dev, | 248 | dev_err(&dev->pdev->dev, |
249 | "wait hw ready failed. status = %d\n", err); | 249 | "wait hw ready failed. status = %d\n", err); |
250 | return err; | 250 | return err; |
@@ -303,7 +303,7 @@ static bool mei_me_hbuf_is_empty(struct mei_device *dev) | |||
303 | * | 303 | * |
304 | * @dev: the device structure | 304 | * @dev: the device structure |
305 | * | 305 | * |
306 | * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise empty slots count | 306 | * returns -EOVERFLOW if overflow, otherwise empty slots count |
307 | */ | 307 | */ |
308 | static int mei_me_hbuf_empty_slots(struct mei_device *dev) | 308 | static int mei_me_hbuf_empty_slots(struct mei_device *dev) |
309 | { | 309 | { |
@@ -326,7 +326,7 @@ static size_t mei_me_hbuf_max_len(const struct mei_device *dev) | |||
326 | 326 | ||
327 | 327 | ||
328 | /** | 328 | /** |
329 | * mei_write_message - writes a message to mei device. | 329 | * mei_me_write_message - writes a message to mei device. |
330 | * | 330 | * |
331 | * @dev: the device structure | 331 | * @dev: the device structure |
332 | * @header: mei HECI header of message | 332 | * @header: mei HECI header of message |
@@ -381,7 +381,7 @@ static int mei_me_write_message(struct mei_device *dev, | |||
381 | * | 381 | * |
382 | * @dev: the device structure | 382 | * @dev: the device structure |
383 | * | 383 | * |
384 | * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise filled slots count | 384 | * returns -EOVERFLOW if overflow, otherwise filled slots count |
385 | */ | 385 | */ |
386 | static int mei_me_count_full_read_slots(struct mei_device *dev) | 386 | static int mei_me_count_full_read_slots(struct mei_device *dev) |
387 | { | 387 | { |
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c index e6151e2dac48..31cb3452b9d7 100644 --- a/drivers/misc/mei/interrupt.c +++ b/drivers/misc/mei/interrupt.c | |||
@@ -350,7 +350,7 @@ int mei_irq_read_handler(struct mei_device *dev, | |||
350 | dev_err(&dev->pdev->dev, "less data available than length=%08x.\n", | 350 | dev_err(&dev->pdev->dev, "less data available than length=%08x.\n", |
351 | *slots); | 351 | *slots); |
352 | /* we can't read the message */ | 352 | /* we can't read the message */ |
353 | ret = -ERANGE; | 353 | ret = -EBADMSG; |
354 | goto end; | 354 | goto end; |
355 | } | 355 | } |
356 | 356 | ||
@@ -483,7 +483,7 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list) | |||
483 | if (mei_wd_send(dev)) | 483 | if (mei_wd_send(dev)) |
484 | dev_dbg(&dev->pdev->dev, "wd send failed.\n"); | 484 | dev_dbg(&dev->pdev->dev, "wd send failed.\n"); |
485 | else if (mei_cl_flow_ctrl_reduce(&dev->wd_cl)) | 485 | else if (mei_cl_flow_ctrl_reduce(&dev->wd_cl)) |
486 | return -ENODEV; | 486 | return -EIO; |
487 | dev->wd_pending = false; | 487 | dev->wd_pending = false; |
488 | } | 488 | } |
489 | } | 489 | } |
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index 434242bada89..49e3bb8a724a 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c | |||
@@ -340,7 +340,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, | |||
340 | 340 | ||
341 | id = mei_me_cl_by_id(dev, cl->me_client_id); | 341 | id = mei_me_cl_by_id(dev, cl->me_client_id); |
342 | if (id < 0) { | 342 | if (id < 0) { |
343 | rets = -ENODEV; | 343 | rets = -ENOTTY; |
344 | goto out; | 344 | goto out; |
345 | } | 345 | } |
346 | 346 | ||
diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c index 7626dde5e1f5..3095fc514a65 100644 --- a/drivers/misc/mei/nfc.c +++ b/drivers/misc/mei/nfc.c | |||
@@ -364,7 +364,7 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length) | |||
364 | if (!wait_event_interruptible_timeout(ndev->send_wq, | 364 | if (!wait_event_interruptible_timeout(ndev->send_wq, |
365 | ndev->recv_req_id == ndev->req_id, HZ)) { | 365 | ndev->recv_req_id == ndev->req_id, HZ)) { |
366 | dev_err(&dev->pdev->dev, "NFC MEI command timeout\n"); | 366 | dev_err(&dev->pdev->dev, "NFC MEI command timeout\n"); |
367 | err = -ETIMEDOUT; | 367 | err = -ETIME; |
368 | } else { | 368 | } else { |
369 | ndev->req_id++; | 369 | ndev->req_id++; |
370 | } | 370 | } |
@@ -502,7 +502,7 @@ int mei_nfc_host_init(struct mei_device *dev) | |||
502 | i = mei_me_cl_by_uuid(dev, &mei_nfc_info_guid); | 502 | i = mei_me_cl_by_uuid(dev, &mei_nfc_info_guid); |
503 | if (i < 0) { | 503 | if (i < 0) { |
504 | dev_info(&dev->pdev->dev, "nfc: failed to find the client\n"); | 504 | dev_info(&dev->pdev->dev, "nfc: failed to find the client\n"); |
505 | ret = -ENOENT; | 505 | ret = -ENOTTY; |
506 | goto err; | 506 | goto err; |
507 | } | 507 | } |
508 | 508 | ||
@@ -520,7 +520,7 @@ int mei_nfc_host_init(struct mei_device *dev) | |||
520 | i = mei_me_cl_by_uuid(dev, &mei_nfc_guid); | 520 | i = mei_me_cl_by_uuid(dev, &mei_nfc_guid); |
521 | if (i < 0) { | 521 | if (i < 0) { |
522 | dev_info(&dev->pdev->dev, "nfc: failed to find the client\n"); | 522 | dev_info(&dev->pdev->dev, "nfc: failed to find the client\n"); |
523 | ret = -ENOENT; | 523 | ret = -ENOTTY; |
524 | goto err; | 524 | goto err; |
525 | } | 525 | } |
526 | 526 | ||
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c index afe976a18586..4644b62e9055 100644 --- a/drivers/misc/mei/wd.c +++ b/drivers/misc/mei/wd.c | |||
@@ -53,7 +53,7 @@ static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout) | |||
53 | * | 53 | * |
54 | * @dev: the device structure | 54 | * @dev: the device structure |
55 | * | 55 | * |
56 | * returns -ENENT if wd client cannot be found | 56 | * returns -ENOTTY if wd client cannot be found |
57 | * -EIO if write has failed | 57 | * -EIO if write has failed |
58 | * 0 on success | 58 | * 0 on success |
59 | */ | 59 | */ |
@@ -73,7 +73,7 @@ int mei_wd_host_init(struct mei_device *dev) | |||
73 | id = mei_me_cl_by_uuid(dev, &mei_wd_guid); | 73 | id = mei_me_cl_by_uuid(dev, &mei_wd_guid); |
74 | if (id < 0) { | 74 | if (id < 0) { |
75 | dev_info(&dev->pdev->dev, "wd: failed to find the client\n"); | 75 | dev_info(&dev->pdev->dev, "wd: failed to find the client\n"); |
76 | return id; | 76 | return -ENOTTY; |
77 | } | 77 | } |
78 | 78 | ||
79 | cl->me_client_id = dev->me_clients[id].client_id; | 79 | cl->me_client_id = dev->me_clients[id].client_id; |
@@ -185,7 +185,7 @@ int mei_wd_stop(struct mei_device *dev) | |||
185 | ret = 0; | 185 | ret = 0; |
186 | } else { | 186 | } else { |
187 | if (!ret) | 187 | if (!ret) |
188 | ret = -ETIMEDOUT; | 188 | ret = -ETIME; |
189 | dev_warn(&dev->pdev->dev, | 189 | dev_warn(&dev->pdev->dev, |
190 | "wd: stop failed to complete ret=%d.\n", ret); | 190 | "wd: stop failed to complete ret=%d.\n", ret); |
191 | } | 191 | } |