From: Tomas Winkler <tomas.winkler@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alexander Usyskin <alexander.usyskin@intel.com>,
linux-kernel@vger.kernel.org,
Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 11/12] mei: amthif: drop mei_amthif_read
Date: Fri, 22 Jul 2016 15:56:28 +0300 [thread overview]
Message-ID: <1469192189-29042-12-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1469192189-29042-1-git-send-email-tomas.winkler@intel.com>
From: Alexander Usyskin <alexander.usyskin@intel.com>
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>
---
drivers/misc/mei/amthif.c | 100 ---------------------------------------------
drivers/misc/mei/client.c | 2 +-
drivers/misc/mei/main.c | 5 ---
drivers/misc/mei/mei_dev.h | 3 --
4 files changed, 1 insertion(+), 109 deletions(-)
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index e8029235504d..2222b60e9208 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -85,106 +85,6 @@ int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
}
/**
- * 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
*
* @cl: host client
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index c924ba92c834..45a7652820cf 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -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 */
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 650061b6ab9b..fa50635512e8 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -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;
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 7c8fa8d70e11..2ef1ad6c391a 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -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);
--
2.7.4
next prev parent reply other threads:[~2016-07-22 12:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-22 12:56 [char-misc-next 00/12] mei: rx enhancements Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 01/12] mei: move read cb to complete queue if not connected Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 02/12] mei: add file pointer to the host client structure Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 03/12] mei: add read callback on demand for fixed_address clients Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 04/12] mei: amthif: drop mei_clear_lists function Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 05/12] mei: drop redundant krealloc and checks in irq read Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 06/12] mei: prepare read cb for fixed address clients on the receive path only Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 07/12] mei: rx flow control counter Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 08/12] mei: use consistent naming for TX control flow credits Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 09/12] mei: add wrapper for queuing control commands Tomas Winkler
2016-07-22 12:56 ` [char-misc-next 10/12] mei: enqueue consecutive reads Tomas Winkler
2016-07-22 12:56 ` Tomas Winkler [this message]
2016-07-22 12:56 ` [char-misc-next 12/12] mei: drop unused file transaction states Tomas Winkler
2016-07-24 22:52 ` [char-misc-next 00/12] mei: rx enhancements Winkler, Tomas
2016-07-24 23:28 ` Greg Kroah-Hartman
2016-07-25 21:49 ` Winkler, Tomas
2016-08-29 21:27 ` Winkler, Tomas
2016-08-30 6:11 ` 'Greg Kroah-Hartman'
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1469192189-29042-12-git-send-email-tomas.winkler@intel.com \
--to=tomas.winkler@intel.com \
--cc=alexander.usyskin@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®