Commit 5151e2b5 authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

mei: fix ssize_t to int assignment in read and write ops.

Use ssize_t for rets variables in mei_write(), mei_read(), and
mei_cl_write() as well as change the return type of mei_cl_write()
to ssize_t, to prevent assignment of possible 64bit size_t
to int 32 bit variable.

As by product also eliminate warning
drivers/misc/mei/client.c:1702:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 44c98df0
...@@ -1644,13 +1644,13 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, ...@@ -1644,13 +1644,13 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
* *
* Return: number of bytes sent on success, <0 on failure. * Return: number of bytes sent on success, <0 on failure.
*/ */
int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
{ {
struct mei_device *dev; struct mei_device *dev;
struct mei_msg_data *buf; struct mei_msg_data *buf;
struct mei_msg_hdr mei_hdr; struct mei_msg_hdr mei_hdr;
int size; size_t len;
int rets; ssize_t rets;
bool blocking; bool blocking;
if (WARN_ON(!cl || !cl->dev)) if (WARN_ON(!cl || !cl->dev))
...@@ -1662,15 +1662,15 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) ...@@ -1662,15 +1662,15 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
dev = cl->dev; dev = cl->dev;
buf = &cb->buf; buf = &cb->buf;
size = buf->size; len = buf->size;
blocking = cb->blocking; blocking = cb->blocking;
cl_dbg(dev, cl, "size=%d\n", size); cl_dbg(dev, cl, "len=%zd\n", len);
rets = pm_runtime_get(dev->dev); rets = pm_runtime_get(dev->dev);
if (rets < 0 && rets != -EINPROGRESS) { if (rets < 0 && rets != -EINPROGRESS) {
pm_runtime_put_noidle(dev->dev); pm_runtime_put_noidle(dev->dev);
cl_err(dev, cl, "rpm: get failed %d\n", rets); cl_err(dev, cl, "rpm: get failed %zd\n", rets);
goto free; goto free;
} }
...@@ -1689,21 +1689,21 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) ...@@ -1689,21 +1689,21 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
if (rets == 0) { if (rets == 0) {
cl_dbg(dev, cl, "No flow control credentials: not sending.\n"); cl_dbg(dev, cl, "No flow control credentials: not sending.\n");
rets = size; rets = len;
goto out; goto out;
} }
if (!mei_hbuf_acquire(dev)) { if (!mei_hbuf_acquire(dev)) {
cl_dbg(dev, cl, "Cannot acquire the host buffer: not sending.\n"); cl_dbg(dev, cl, "Cannot acquire the host buffer: not sending.\n");
rets = size; rets = len;
goto out; goto out;
} }
/* Check for a maximum length */ /* Check for a maximum length */
if (size > mei_hbuf_max_len(dev)) { if (len > mei_hbuf_max_len(dev)) {
mei_hdr.length = mei_hbuf_max_len(dev); mei_hdr.length = mei_hbuf_max_len(dev);
mei_hdr.msg_complete = 0; mei_hdr.msg_complete = 0;
} else { } else {
mei_hdr.length = size; mei_hdr.length = len;
mei_hdr.msg_complete = 1; mei_hdr.msg_complete = 1;
} }
...@@ -1745,7 +1745,7 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) ...@@ -1745,7 +1745,7 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
} }
} }
rets = size; rets = len;
err: err:
cl_dbg(dev, cl, "rpm: autosuspend\n"); cl_dbg(dev, cl, "rpm: autosuspend\n");
pm_runtime_mark_last_busy(dev->dev); pm_runtime_mark_last_busy(dev->dev);
......
...@@ -202,7 +202,7 @@ int mei_cl_connect(struct mei_cl *cl, struct mei_me_client *me_cl, ...@@ -202,7 +202,7 @@ int mei_cl_connect(struct mei_cl *cl, struct mei_me_client *me_cl,
int mei_cl_irq_connect(struct mei_cl *cl, struct mei_cl_cb *cb, int mei_cl_irq_connect(struct mei_cl *cl, struct mei_cl_cb *cb,
struct list_head *cmpl_list); struct list_head *cmpl_list);
int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp); int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp);
int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb); ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb);
int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
struct list_head *cmpl_list); struct list_head *cmpl_list);
......
...@@ -137,7 +137,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, ...@@ -137,7 +137,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
struct mei_device *dev; struct mei_device *dev;
struct mei_cl_cb *cb = NULL; struct mei_cl_cb *cb = NULL;
bool nonblock = !!(file->f_flags & O_NONBLOCK); bool nonblock = !!(file->f_flags & O_NONBLOCK);
int rets; ssize_t rets;
if (WARN_ON(!cl || !cl->dev)) if (WARN_ON(!cl || !cl->dev))
return -ENODEV; return -ENODEV;
...@@ -170,7 +170,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, ...@@ -170,7 +170,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
rets = mei_cl_read_start(cl, length, file); rets = mei_cl_read_start(cl, length, file);
if (rets && rets != -EBUSY) { if (rets && rets != -EBUSY) {
cl_dbg(dev, cl, "mei start read failure status = %d\n", rets); cl_dbg(dev, cl, "mei start read failure status = %zd\n", rets);
goto out; goto out;
} }
...@@ -204,7 +204,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, ...@@ -204,7 +204,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
/* now copy the data to user space */ /* now copy the data to user space */
if (cb->status) { if (cb->status) {
rets = cb->status; rets = cb->status;
cl_dbg(dev, cl, "read operation failed %d\n", rets); cl_dbg(dev, cl, "read operation failed %zd\n", rets);
goto free; goto free;
} }
...@@ -236,7 +236,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, ...@@ -236,7 +236,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
*offset = 0; *offset = 0;
out: out:
cl_dbg(dev, cl, "end mei read rets = %d\n", rets); cl_dbg(dev, cl, "end mei read rets = %zd\n", rets);
mutex_unlock(&dev->device_lock); mutex_unlock(&dev->device_lock);
return rets; return rets;
} }
...@@ -256,7 +256,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, ...@@ -256,7 +256,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
struct mei_cl *cl = file->private_data; struct mei_cl *cl = file->private_data;
struct mei_cl_cb *cb; struct mei_cl_cb *cb;
struct mei_device *dev; struct mei_device *dev;
int rets; ssize_t rets;
if (WARN_ON(!cl || !cl->dev)) if (WARN_ON(!cl || !cl->dev))
return -ENODEV; return -ENODEV;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment