mei: amthif: drop mei_amthif_read
authorAlexander Usyskin <alexander.usyskin@intel.com>
Mon, 25 Jul 2016 22:06:07 +0000 (01:06 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 Aug 2016 12:39:42 +0000 (14:39 +0200)
mei_amthif_read have only one difference from mei_read, it is not
calling mei_read_start().
Make mei_read_start return immediately for amthif client and drop the
special mei_amthif_read function.

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>
drivers/misc/mei/amthif.c
drivers/misc/mei/client.c
drivers/misc/mei/main.c
drivers/misc/mei/mei_dev.h

index e8029235504d9044addb1552fae9212e15f40d2d..2222b60e92083976de2a0b3209c197bac759d3ce 100644 (file)
@@ -84,106 +84,6 @@ int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
        return ret;
 }
 
-/**
- * mei_amthif_read - read data from AMTHIF client
- *
- * @dev: the device structure
- * @file: pointer to file object
- * @ubuf: pointer to user data in user space
- * @length: data length to read
- * @offset: data read offset
- *
- * Locking: called under "dev->device_lock" lock
- *
- * Return:
- *  returned data length on success,
- *  zero if no data to read,
- *  negative on failure.
- */
-int mei_amthif_read(struct mei_device *dev, struct file *file,
-              char __user *ubuf, size_t length, loff_t *offset)
-{
-       struct mei_cl *cl = file->private_data;
-       struct mei_cl_cb *cb;
-       int rets;
-       int wait_ret;
-
-       dev_dbg(dev->dev, "checking amthif data\n");
-       cb = mei_cl_read_cb(cl, file);
-
-       /* Check for if we can block or not*/
-       if (cb == NULL && file->f_flags & O_NONBLOCK)
-               return -EAGAIN;
-
-
-       dev_dbg(dev->dev, "waiting for amthif data\n");
-       while (cb == NULL) {
-               /* unlock the Mutex */
-               mutex_unlock(&dev->device_lock);
-
-               wait_ret = wait_event_interruptible(cl->rx_wait,
-                                       !list_empty(&cl->rd_completed) ||
-                                       !mei_cl_is_connected(cl));
-
-               /* Locking again the Mutex */
-               mutex_lock(&dev->device_lock);
-
-               if (wait_ret)
-                       return -ERESTARTSYS;
-
-               if (!mei_cl_is_connected(cl)) {
-                       rets = -ENODEV;
-                       goto out;
-               }
-
-               cb = mei_cl_read_cb(cl, file);
-       }
-
-       if (cb->status) {
-               rets = cb->status;
-               dev_dbg(dev->dev, "read operation failed %d\n", rets);
-               goto free;
-       }
-
-       dev_dbg(dev->dev, "Got amthif data\n");
-       /* if the whole message will fit remove it from the list */
-       if (cb->buf_idx >= *offset && length >= (cb->buf_idx - *offset))
-               list_del_init(&cb->list);
-       else if (cb->buf_idx <= *offset) {
-               /* end of the message has been reached */
-               list_del_init(&cb->list);
-               rets = 0;
-               goto free;
-       }
-               /* else means that not full buffer will be read and do not
-                * remove message from deletion list
-                */
-
-       dev_dbg(dev->dev, "amthif cb->buf.size - %zu cb->buf_idx - %zu\n",
-               cb->buf.size, cb->buf_idx);
-
-       /* length is being truncated to PAGE_SIZE, however,
-        * the buf_idx may point beyond */
-       length = min_t(size_t, length, (cb->buf_idx - *offset));
-
-       if (copy_to_user(ubuf, cb->buf.data + *offset, length)) {
-               dev_dbg(dev->dev, "failed to copy data to userland\n");
-               rets = -EFAULT;
-       } else {
-               rets = length;
-               if ((*offset + length) < cb->buf_idx) {
-                       *offset += length;
-                       goto out;
-               }
-       }
-free:
-       dev_dbg(dev->dev, "free amthif cb memory.\n");
-       *offset = 0;
-       mei_io_cb_free(cb);
-out:
-       return rets;
-}
-
 /**
  * mei_amthif_read_start - queue message for sending read credential
  *
index c924ba92c8341b39cf9b8ccf5748a70d9fc9141a..45a7652820cfd5928f2dc39db1398597158dc81d 100644 (file)
@@ -1462,7 +1462,7 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp)
                return  -ENOTTY;
        }
 
-       if (mei_cl_is_fixed_address(cl))
+       if (mei_cl_is_fixed_address(cl) || cl == &dev->iamthif_cl)
                return 0;
 
        /* HW currently supports only one pending read */
index 650061b6ab9b265b03d0c2b4385c719faa97e166..fa50635512e88985328849e216923785316ef79e 100644 (file)
@@ -164,11 +164,6 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
                goto out;
        }
 
-       if (cl == &dev->iamthif_cl) {
-               rets = mei_amthif_read(dev, file, ubuf, length, offset);
-               goto out;
-       }
-
        cb = mei_cl_read_cb(cl, file);
        if (cb)
                goto copy_buffer;
index 7c8fa8d70e11095592db0a13cb7c9bfb67efae4f..2ef1ad6c391a9c984cfc17590ac82128768f929e 100644 (file)
@@ -564,9 +564,6 @@ void mei_amthif_reset_params(struct mei_device *dev);
 
 int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl);
 
-int mei_amthif_read(struct mei_device *dev, struct file *file,
-               char __user *ubuf, size_t length, loff_t *offset);
-
 unsigned int mei_amthif_poll(struct file *file, poll_table *wait);
 
 int mei_amthif_release(struct mei_device *dev, struct file *file);