mei: use helper function to find me client by id
We already have a helper to find me client by id, let's use it in all relevant places. 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>
This commit is contained in:
parent
a27a76d3c0
commit
12d0066526
2 changed files with 56 additions and 48 deletions
|
@ -552,7 +552,8 @@ out:
|
||||||
int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
|
int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
|
||||||
{
|
{
|
||||||
struct mei_device *dev;
|
struct mei_device *dev;
|
||||||
int i;
|
struct mei_me_client *me_cl;
|
||||||
|
int id;
|
||||||
|
|
||||||
if (WARN_ON(!cl || !cl->dev))
|
if (WARN_ON(!cl || !cl->dev))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -565,20 +566,20 @@ int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
|
||||||
if (cl->mei_flow_ctrl_creds > 0)
|
if (cl->mei_flow_ctrl_creds > 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (i = 0; i < dev->me_clients_num; i++) {
|
id = mei_me_cl_by_id(dev, cl->me_client_id);
|
||||||
struct mei_me_client *me_cl = &dev->me_clients[i];
|
if (id < 0) {
|
||||||
if (me_cl->client_id == cl->me_client_id) {
|
cl_err(dev, cl, "no such me client %d\n", cl->me_client_id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
me_cl = &dev->me_clients[id];
|
||||||
if (me_cl->mei_flow_ctrl_creds) {
|
if (me_cl->mei_flow_ctrl_creds) {
|
||||||
if (WARN_ON(me_cl->props.single_recv_buf == 0))
|
if (WARN_ON(me_cl->props.single_recv_buf == 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return -ENOENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mei_cl_flow_ctrl_reduce - reduces flow_control.
|
* mei_cl_flow_ctrl_reduce - reduces flow_control.
|
||||||
|
@ -593,23 +594,25 @@ int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
|
||||||
int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
|
int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
|
||||||
{
|
{
|
||||||
struct mei_device *dev;
|
struct mei_device *dev;
|
||||||
int i;
|
struct mei_me_client *me_cl;
|
||||||
|
int id;
|
||||||
|
|
||||||
if (WARN_ON(!cl || !cl->dev))
|
if (WARN_ON(!cl || !cl->dev))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
dev = cl->dev;
|
dev = cl->dev;
|
||||||
|
|
||||||
if (!dev->me_clients_num)
|
id = mei_me_cl_by_id(dev, cl->me_client_id);
|
||||||
return -ENOENT;
|
if (id < 0) {
|
||||||
|
cl_err(dev, cl, "no such me client %d\n", cl->me_client_id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < dev->me_clients_num; i++) {
|
me_cl = &dev->me_clients[id];
|
||||||
struct mei_me_client *me_cl = &dev->me_clients[i];
|
|
||||||
if (me_cl->client_id == cl->me_client_id) {
|
|
||||||
if (me_cl->props.single_recv_buf != 0) {
|
if (me_cl->props.single_recv_buf != 0) {
|
||||||
if (WARN_ON(me_cl->mei_flow_ctrl_creds <= 0))
|
if (WARN_ON(me_cl->mei_flow_ctrl_creds <= 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
dev->me_clients[i].mei_flow_ctrl_creds--;
|
me_cl->mei_flow_ctrl_creds--;
|
||||||
} else {
|
} else {
|
||||||
if (WARN_ON(cl->mei_flow_ctrl_creds <= 0))
|
if (WARN_ON(cl->mei_flow_ctrl_creds <= 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -617,9 +620,6 @@ int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -ENOENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mei_cl_read_start - the start read client message function.
|
* mei_cl_read_start - the start read client message function.
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "mei_dev.h"
|
#include "mei_dev.h"
|
||||||
#include "hbm.h"
|
#include "hbm.h"
|
||||||
#include "hw-me.h"
|
#include "hw-me.h"
|
||||||
|
#include "client.h"
|
||||||
|
|
||||||
static const char *mei_cl_conn_status_str(enum mei_cl_connect_status status)
|
static const char *mei_cl_conn_status_str(enum mei_cl_connect_status status)
|
||||||
{
|
{
|
||||||
|
@ -340,27 +341,34 @@ int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
|
||||||
*
|
*
|
||||||
* @dev: the device structure
|
* @dev: the device structure
|
||||||
* @flow: flow control.
|
* @flow: flow control.
|
||||||
|
*
|
||||||
|
* return 0 on success, < 0 otherwise
|
||||||
*/
|
*/
|
||||||
static void mei_hbm_add_single_flow_creds(struct mei_device *dev,
|
static int mei_hbm_add_single_flow_creds(struct mei_device *dev,
|
||||||
struct hbm_flow_control *flow)
|
struct hbm_flow_control *flow)
|
||||||
{
|
{
|
||||||
struct mei_me_client *client;
|
struct mei_me_client *me_cl;
|
||||||
int i;
|
int id;
|
||||||
|
|
||||||
for (i = 0; i < dev->me_clients_num; i++) {
|
id = mei_me_cl_by_id(dev, flow->me_addr);
|
||||||
client = &dev->me_clients[i];
|
if (id < 0) {
|
||||||
if (client && flow->me_addr == client->client_id) {
|
dev_err(&dev->pdev->dev, "no such me client %d\n",
|
||||||
if (client->props.single_recv_buf) {
|
flow->me_addr);
|
||||||
client->mei_flow_ctrl_creds++;
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
me_cl = &dev->me_clients[id];
|
||||||
|
if (me_cl->props.single_recv_buf) {
|
||||||
|
me_cl->mei_flow_ctrl_creds++;
|
||||||
dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n",
|
dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n",
|
||||||
flow->me_addr);
|
flow->me_addr);
|
||||||
dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n",
|
dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n",
|
||||||
client->mei_flow_ctrl_creds);
|
me_cl->mei_flow_ctrl_creds);
|
||||||
} else {
|
} else {
|
||||||
BUG(); /* error in flow control */
|
BUG(); /* error in flow control */
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue