diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2012-07-23 07:05:39 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-16 12:40:28 -0400 |
commit | 07b509b7943e5594f3f228e5b62a49cf6a033709 (patch) | |
tree | 6271fdff08b54ab605cbc666cdcc054d41d3e44a /drivers/misc/mei/init.c | |
parent | 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (diff) |
mei: revamp me client search function
me client search functions returns index
into me_client array according me client id
or me client uuid.
1. Add common prefix for the functions mei_me_cl_<>
2. create new function mei_me_cl_by_id that wraps open
coded loops scattered over the code
3. rename mei_find_me_client_index to mei_me_cl_by_uuid
4. rename mei_find_me_client_update_filext to
mei_me_cl_update_filext and updates its parameter names
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/init.c')
-rw-r--r-- | drivers/misc/mei/init.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c index e77f86e69fb5..58b3bf47c8eb 100644 --- a/drivers/misc/mei/init.c +++ b/drivers/misc/mei/init.c | |||
@@ -522,12 +522,12 @@ void mei_cl_init(struct mei_cl *priv, struct mei_device *dev) | |||
522 | priv->dev = dev; | 522 | priv->dev = dev; |
523 | } | 523 | } |
524 | 524 | ||
525 | int mei_find_me_client_index(const struct mei_device *dev, uuid_le cuuid) | 525 | int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *cuuid) |
526 | { | 526 | { |
527 | int i, res = -1; | 527 | int i, res = -ENOENT; |
528 | 528 | ||
529 | for (i = 0; i < dev->me_clients_num; ++i) | 529 | for (i = 0; i < dev->me_clients_num; ++i) |
530 | if (uuid_le_cmp(cuuid, | 530 | if (uuid_le_cmp(*cuuid, |
531 | dev->me_clients[i].props.protocol_name) == 0) { | 531 | dev->me_clients[i].props.protocol_name) == 0) { |
532 | res = i; | 532 | res = i; |
533 | break; | 533 | break; |
@@ -538,35 +538,35 @@ int mei_find_me_client_index(const struct mei_device *dev, uuid_le cuuid) | |||
538 | 538 | ||
539 | 539 | ||
540 | /** | 540 | /** |
541 | * mei_find_me_client_update_filext - searches for ME client guid | 541 | * mei_me_cl_update_filext - searches for ME client guid |
542 | * sets client_id in mei_file_private if found | 542 | * sets client_id in mei_file_private if found |
543 | * @dev: the device structure | 543 | * @dev: the device structure |
544 | * @priv: private file structure to set client_id in | 544 | * @cl: private file structure to set client_id in |
545 | * @cguid: searched guid of ME client | 545 | * @cuuid: searched uuid of ME client |
546 | * @client_id: id of host client to be set in file private structure | 546 | * @client_id: id of host client to be set in file private structure |
547 | * | 547 | * |
548 | * returns ME client index | 548 | * returns ME client index |
549 | */ | 549 | */ |
550 | u8 mei_find_me_client_update_filext(struct mei_device *dev, struct mei_cl *priv, | 550 | int mei_me_cl_update_filext(struct mei_device *dev, struct mei_cl *cl, |
551 | const uuid_le *cguid, u8 client_id) | 551 | const uuid_le *cuuid, u8 host_cl_id) |
552 | { | 552 | { |
553 | int i; | 553 | int i; |
554 | 554 | ||
555 | if (!dev || !priv || !cguid) | 555 | if (!dev || !cl || !cuuid) |
556 | return 0; | 556 | return -EINVAL; |
557 | 557 | ||
558 | /* check for valid client id */ | 558 | /* check for valid client id */ |
559 | i = mei_find_me_client_index(dev, *cguid); | 559 | i = mei_me_cl_by_uuid(dev, cuuid); |
560 | if (i >= 0) { | 560 | if (i >= 0) { |
561 | priv->me_client_id = dev->me_clients[i].client_id; | 561 | cl->me_client_id = dev->me_clients[i].client_id; |
562 | priv->state = MEI_FILE_CONNECTING; | 562 | cl->state = MEI_FILE_CONNECTING; |
563 | priv->host_client_id = client_id; | 563 | cl->host_client_id = host_cl_id; |
564 | 564 | ||
565 | list_add_tail(&priv->link, &dev->file_list); | 565 | list_add_tail(&cl->link, &dev->file_list); |
566 | return (u8)i; | 566 | return (u8)i; |
567 | } | 567 | } |
568 | 568 | ||
569 | return 0; | 569 | return -ENOENT; |
570 | } | 570 | } |
571 | 571 | ||
572 | /** | 572 | /** |
@@ -577,16 +577,16 @@ u8 mei_find_me_client_update_filext(struct mei_device *dev, struct mei_cl *priv, | |||
577 | */ | 577 | */ |
578 | void mei_host_init_iamthif(struct mei_device *dev) | 578 | void mei_host_init_iamthif(struct mei_device *dev) |
579 | { | 579 | { |
580 | u8 i; | 580 | int i; |
581 | unsigned char *msg_buf; | 581 | unsigned char *msg_buf; |
582 | 582 | ||
583 | mei_cl_init(&dev->iamthif_cl, dev); | 583 | mei_cl_init(&dev->iamthif_cl, dev); |
584 | dev->iamthif_cl.state = MEI_FILE_DISCONNECTED; | 584 | dev->iamthif_cl.state = MEI_FILE_DISCONNECTED; |
585 | 585 | ||
586 | /* find ME amthi client */ | 586 | /* find ME amthi client */ |
587 | i = mei_find_me_client_update_filext(dev, &dev->iamthif_cl, | 587 | i = mei_me_cl_update_filext(dev, &dev->iamthif_cl, |
588 | &mei_amthi_guid, MEI_IAMTHIF_HOST_CLIENT_ID); | 588 | &mei_amthi_guid, MEI_IAMTHIF_HOST_CLIENT_ID); |
589 | if (dev->iamthif_cl.state != MEI_FILE_CONNECTING) { | 589 | if (i < 0) { |
590 | dev_dbg(&dev->pdev->dev, "failed to find iamthif client.\n"); | 590 | dev_dbg(&dev->pdev->dev, "failed to find iamthif client.\n"); |
591 | return; | 591 | return; |
592 | } | 592 | } |