From: Tomas Winkler <tomas.winkler@intel.com>
To: gregkh@linuxfoundation.org
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org,
Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 11/14] mei: simplify handling of hbm client events
Date: Thu, 21 Aug 2014 14:29:20 +0300 [thread overview]
Message-ID: <1408620563-25834-11-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1408620563-25834-1-git-send-email-tomas.winkler@intel.com>
Add mei_hbm_cl_find_by_cmd handler to retrieve
the destination client
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/hbm.c | 74 +++++++++++++++++++++++++++++---------------------
1 file changed, 43 insertions(+), 31 deletions(-)
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index 2968b52..280befc 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -157,22 +157,43 @@ int mei_hbm_cl_write(struct mei_device *dev,
}
/**
- * mei_hbm_cl_addr_equal - tells if they have the same address
+ * mei_hbm_cl_addr_equal - check if the client's and
+ * the message address match
*
- * @cl: - client
- * @buf: buffer with cl header
+ * @cl: client
+ * @cmd: hbm client message
*
* returns true if addresses are the same
*/
static inline
-bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf)
+bool mei_hbm_cl_addr_equal(struct mei_cl *cl, struct mei_hbm_cl_cmd *cmd)
{
- struct mei_hbm_cl_cmd *cmd = buf;
return cl->host_client_id == cmd->host_addr &&
cl->me_client_id == cmd->me_addr;
}
/**
+ * mei_hbm_cl_find_by_cmd - find recipient client
+ *
+ * @dev: the device structure
+ * @buf: a buffer with hbm cl command
+ *
+ * returns the recipient client or NULL if not found
+ */
+static inline
+struct mei_cl *mei_hbm_cl_find_by_cmd(struct mei_device *dev, void *buf)
+{
+ struct mei_hbm_cl_cmd *cmd = (struct mei_hbm_cl_cmd *)buf;
+ struct mei_cl *cl;
+
+ list_for_each_entry(cl, &dev->file_list, link)
+ if (mei_hbm_cl_addr_equal(cl, cmd))
+ return cl;
+ return NULL;
+}
+
+
+/**
* mei_hbm_start_wait - wait for start response message.
*
* @dev: the device structure
@@ -449,7 +470,7 @@ static int mei_hbm_add_single_flow_creds(struct mei_device *dev,
* @flow_control: flow control response bus message
*/
static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
- struct hbm_flow_control *flow_control)
+ struct hbm_flow_control *flow_control)
{
struct mei_cl *cl;
@@ -459,15 +480,11 @@ static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
return;
}
- /* normal connection */
- list_for_each_entry(cl, &dev->file_list, link) {
- if (mei_hbm_cl_addr_equal(cl, flow_control)) {
- cl->mei_flow_ctrl_creds++;
- dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d creds %d.\n",
- flow_control->host_addr, flow_control->me_addr,
+ cl = mei_hbm_cl_find_by_cmd(dev, flow_control);
+ if (cl) {
+ cl->mei_flow_ctrl_creds++;
+ cl_dbg(dev, cl, "flow control creds = %d.\n",
cl->mei_flow_ctrl_creds);
- break;
- }
}
}
@@ -627,23 +644,18 @@ static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
struct mei_cl *cl;
struct mei_cl_cb *cb;
- list_for_each_entry(cl, &dev->file_list, link) {
- if (mei_hbm_cl_addr_equal(cl, disconnect_req)) {
- dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n",
- disconnect_req->host_addr,
- disconnect_req->me_addr);
- cl->state = MEI_FILE_DISCONNECTED;
- cl->timer_count = 0;
-
- cb = mei_io_cb_init(cl, NULL);
- if (!cb)
- return -ENOMEM;
- cb->fop_type = MEI_FOP_DISCONNECT_RSP;
- cl_dbg(dev, cl, "add disconnect response as first\n");
- list_add(&cb->list, &dev->ctrl_wr_list.list);
-
- break;
- }
+ cl = mei_hbm_cl_find_by_cmd(dev, disconnect_req);
+ if (cl) {
+ cl_dbg(dev, cl, "disconnect request received\n");
+ cl->state = MEI_FILE_DISCONNECTED;
+ cl->timer_count = 0;
+
+ cb = mei_io_cb_init(cl, NULL);
+ if (!cb)
+ return -ENOMEM;
+ cb->fop_type = MEI_FOP_DISCONNECT_RSP;
+ cl_dbg(dev, cl, "add disconnect response as first\n");
+ list_add(&cb->list, &dev->ctrl_wr_list.list);
}
return 0;
}
--
1.9.3
next prev parent reply other threads:[~2014-08-21 11:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-21 11:29 [char-misc-next 01/14] mei: use consistently me_addr in the hbm structures Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 02/14] mei: use wrapper for simple hbm client message Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 03/14] mei: me_client lookup function to return me_client object Tomas Winkler
2014-08-21 12:32 ` Josh Boyer
2014-08-21 13:14 ` Winkler, Tomas
2014-08-21 11:29 ` [char-misc-next 04/14] mei: use list for me clients book keeping Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 05/14] mei: add me client remove functions Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 06/14] mei: add mei_me_cl_by_uuid_id function Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 07/14] mei: add hbm commands return status values Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 08/14] mei: use disconnect name consistently Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 09/14] mei: revamp connect and disconnect response handling Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 10/14] mei: wait for hbm start non-interruptible Tomas Winkler
2014-08-21 11:29 ` Tomas Winkler [this message]
2014-08-21 11:29 ` [char-misc-next 12/14] mei: extract supported features from the hbm version Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 13/14] mei: enable adding more IOCTL handlers Tomas Winkler
2014-08-21 11:29 ` [char-misc-next 14/14] mei: use connect_data on the stack Tomas Winkler
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=1408620563-25834-11-git-send-email-tomas.winkler@intel.com \
--to=tomas.winkler@intel.com \
--cc=arnd@arndb.de \
--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®