aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/mei/client.c')
-rw-r--r--drivers/misc/mei/client.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 539e861abc1e..3e62176a19a5 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -552,7 +552,8 @@ out:
552int mei_cl_flow_ctrl_creds(struct mei_cl *cl) 552int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
553{ 553{
554 struct mei_device *dev; 554 struct mei_device *dev;
555 int i; 555 struct mei_me_client *me_cl;
556 int id;
556 557
557 if (WARN_ON(!cl || !cl->dev)) 558 if (WARN_ON(!cl || !cl->dev))
558 return -EINVAL; 559 return -EINVAL;
@@ -565,19 +566,19 @@ int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
565 if (cl->mei_flow_ctrl_creds > 0) 566 if (cl->mei_flow_ctrl_creds > 0)
566 return 1; 567 return 1;
567 568
568 for (i = 0; i < dev->me_clients_num; i++) { 569 id = mei_me_cl_by_id(dev, cl->me_client_id);
569 struct mei_me_client *me_cl = &dev->me_clients[i]; 570 if (id < 0) {
570 if (me_cl->client_id == cl->me_client_id) { 571 cl_err(dev, cl, "no such me client %d\n", cl->me_client_id);
571 if (me_cl->mei_flow_ctrl_creds) { 572 return id;
572 if (WARN_ON(me_cl->props.single_recv_buf == 0))
573 return -EINVAL;
574 return 1;
575 } else {
576 return 0;
577 }
578 }
579 } 573 }
580 return -ENOENT; 574
575 me_cl = &dev->me_clients[id];
576 if (me_cl->mei_flow_ctrl_creds) {
577 if (WARN_ON(me_cl->props.single_recv_buf == 0))
578 return -EINVAL;
579 return 1;
580 }
581 return 0;
581} 582}
582 583
583/** 584/**
@@ -593,32 +594,31 @@ int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
593int mei_cl_flow_ctrl_reduce(struct mei_cl *cl) 594int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
594{ 595{
595 struct mei_device *dev; 596 struct mei_device *dev;
596 int i; 597 struct mei_me_client *me_cl;
598 int id;
597 599
598 if (WARN_ON(!cl || !cl->dev)) 600 if (WARN_ON(!cl || !cl->dev))
599 return -EINVAL; 601 return -EINVAL;
600 602
601 dev = cl->dev; 603 dev = cl->dev;
602 604
603 if (!dev->me_clients_num) 605 id = mei_me_cl_by_id(dev, cl->me_client_id);
604 return -ENOENT; 606 if (id < 0) {
607 cl_err(dev, cl, "no such me client %d\n", cl->me_client_id);
608 return id;
609 }
605 610
606 for (i = 0; i < dev->me_clients_num; i++) { 611 me_cl = &dev->me_clients[id];
607 struct mei_me_client *me_cl = &dev->me_clients[i]; 612 if (me_cl->props.single_recv_buf != 0) {
608 if (me_cl->client_id == cl->me_client_id) { 613 if (WARN_ON(me_cl->mei_flow_ctrl_creds <= 0))
609 if (me_cl->props.single_recv_buf != 0) { 614 return -EINVAL;
610 if (WARN_ON(me_cl->mei_flow_ctrl_creds <= 0)) 615 me_cl->mei_flow_ctrl_creds--;
611 return -EINVAL; 616 } else {
612 dev->me_clients[i].mei_flow_ctrl_creds--; 617 if (WARN_ON(cl->mei_flow_ctrl_creds <= 0))
613 } else { 618 return -EINVAL;
614 if (WARN_ON(cl->mei_flow_ctrl_creds <= 0)) 619 cl->mei_flow_ctrl_creds--;
615 return -EINVAL;
616 cl->mei_flow_ctrl_creds--;
617 }
618 return 0;
619 }
620 } 620 }
621 return -ENOENT; 621 return 0;
622} 622}
623 623
624/** 624/**