aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/main.c
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2013-01-08 16:07:15 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-08 19:40:45 -0500
commit9f81abdac3629629a246fdc9e2a7c01ffd52ce8a (patch)
tree4593dab5bdf44e200efe1fa72f3badb517cc8a12 /drivers/misc/mei/main.c
parent90e0b5f18569bdd03c5ddd1d8c99946f42af77b8 (diff)
mei: implement mei_cl_connect function
Implement mei_cl_connect that warps host client parts of the connection and leave the ioctl specifics in the mei_ioctl_connect_client function. Move mei_ioctl_connect_client to main.c where it belongs Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/main.c')
-rw-r--r--drivers/misc/mei/main.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 95f05d97a115..8d3c134314c6 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -562,6 +562,103 @@ err:
562 return rets; 562 return rets;
563} 563}
564 564
565/**
566 * mei_ioctl_connect_client - the connect to fw client IOCTL function
567 *
568 * @dev: the device structure
569 * @data: IOCTL connect data, input and output parameters
570 * @file: private data of the file object
571 *
572 * Locking: called under "dev->device_lock" lock
573 *
574 * returns 0 on success, <0 on failure.
575 */
576static int mei_ioctl_connect_client(struct file *file,
577 struct mei_connect_client_data *data)
578{
579 struct mei_device *dev;
580 struct mei_client *client;
581 struct mei_cl *cl;
582 int i;
583 int rets;
584
585 cl = file->private_data;
586 if (WARN_ON(!cl || !cl->dev))
587 return -ENODEV;
588
589 dev = cl->dev;
590
591 if (dev->dev_state != MEI_DEV_ENABLED) {
592 rets = -ENODEV;
593 goto end;
594 }
595
596 if (cl->state != MEI_FILE_INITIALIZING &&
597 cl->state != MEI_FILE_DISCONNECTED) {
598 rets = -EBUSY;
599 goto end;
600 }
601
602 /* find ME client we're trying to connect to */
603 i = mei_me_cl_by_uuid(dev, &data->in_client_uuid);
604 if (i >= 0 && !dev->me_clients[i].props.fixed_address) {
605 cl->me_client_id = dev->me_clients[i].client_id;
606 cl->state = MEI_FILE_CONNECTING;
607 }
608
609 dev_dbg(&dev->pdev->dev, "Connect to FW Client ID = %d\n",
610 cl->me_client_id);
611 dev_dbg(&dev->pdev->dev, "FW Client - Protocol Version = %d\n",
612 dev->me_clients[i].props.protocol_version);
613 dev_dbg(&dev->pdev->dev, "FW Client - Max Msg Len = %d\n",
614 dev->me_clients[i].props.max_msg_length);
615
616 /* if we're connecting to amthi client then we will use the
617 * existing connection
618 */
619 if (uuid_le_cmp(data->in_client_uuid, mei_amthi_guid) == 0) {
620 dev_dbg(&dev->pdev->dev, "FW Client is amthi\n");
621 if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) {
622 rets = -ENODEV;
623 goto end;
624 }
625 clear_bit(cl->host_client_id, dev->host_clients_map);
626 mei_cl_unlink(cl);
627
628 kfree(cl);
629 cl = NULL;
630 file->private_data = &dev->iamthif_cl;
631
632 client = &data->out_client_properties;
633 client->max_msg_length =
634 dev->me_clients[i].props.max_msg_length;
635 client->protocol_version =
636 dev->me_clients[i].props.protocol_version;
637 rets = dev->iamthif_cl.status;
638
639 goto end;
640 }
641
642 if (cl->state != MEI_FILE_CONNECTING) {
643 rets = -ENODEV;
644 goto end;
645 }
646
647
648 /* prepare the output buffer */
649 client = &data->out_client_properties;
650 client->max_msg_length = dev->me_clients[i].props.max_msg_length;
651 client->protocol_version = dev->me_clients[i].props.protocol_version;
652 dev_dbg(&dev->pdev->dev, "Can connect?\n");
653
654
655 rets = mei_cl_connect(cl, file);
656
657end:
658 dev_dbg(&dev->pdev->dev, "free connect cb memory.");
659 return rets;
660}
661
565 662
566/** 663/**
567 * mei_ioctl - the IOCTL function 664 * mei_ioctl - the IOCTL function
@@ -610,6 +707,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
610 rets = -EFAULT; 707 rets = -EFAULT;
611 goto out; 708 goto out;
612 } 709 }
710
613 rets = mei_ioctl_connect_client(file, connect_data); 711 rets = mei_ioctl_connect_client(file, connect_data);
614 712
615 /* if all is ok, copying the data back to user. */ 713 /* if all is ok, copying the data back to user. */