diff options
author | Alexander Usyskin <alexander.usyskin@intel.com> | 2014-02-19 17:35:49 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-28 15:15:57 -0800 |
commit | 7ca96aa278f8b9983184e318b06a0ed9ad0297b8 (patch) | |
tree | b01220d624e9fbf70258a96890be25b56405c11e /drivers/misc/mei/client.c | |
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/mei/client.c')
-rw-r--r-- | drivers/misc/mei/client.c | 26 |
1 files changed, 14 insertions, 12 deletions
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) i = mei_me_cl_by_id(dev, cl->me_client_id); if (i < 0) { cl_err(dev, cl, "no such me client %d\n", cl->me_client_id); - return -ENODEV; + return -ENOTTY; } 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) cl->writing_state = MEI_WRITING; cb->buf_idx = mei_hdr.length; - rets = buf->size; out: if (mei_hdr.msg_complete) { - if (mei_cl_flow_ctrl_reduce(cl)) { - rets = -ENODEV; + rets = mei_cl_flow_ctrl_reduce(cl); + if (rets < 0) goto err; - } + list_add_tail(&cb->list, &dev->write_waiting_list.list); } else { list_add_tail(&cb->list, &dev->write_list.list); @@ -868,15 +867,18 @@ out: if (blocking && cl->writing_state != MEI_WRITE_COMPLETE) { mutex_unlock(&dev->device_lock); - if (wait_event_interruptible(cl->tx_wait, - cl->writing_state == MEI_WRITE_COMPLETE)) { - if (signal_pending(current)) - rets = -EINTR; - else - rets = -ERESTARTSYS; - } + rets = wait_event_interruptible(cl->tx_wait, + cl->writing_state == MEI_WRITE_COMPLETE); mutex_lock(&dev->device_lock); + /* wait_event_interruptible returns -ERESTARTSYS */ + if (rets) { + if (signal_pending(current)) + rets = -EINTR; + goto err; + } } + + rets = buf->size; err: return rets; } |