aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/mei/main.c')
-rw-r--r--drivers/misc/mei/main.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 5e11b5b9b65d..173ff095be0d 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -625,24 +625,32 @@ static unsigned int mei_poll(struct file *file, poll_table *wait)
625 unsigned int mask = 0; 625 unsigned int mask = 0;
626 626
627 if (WARN_ON(!cl || !cl->dev)) 627 if (WARN_ON(!cl || !cl->dev))
628 return mask; 628 return POLLERR;
629 629
630 dev = cl->dev; 630 dev = cl->dev;
631 631
632 mutex_lock(&dev->device_lock); 632 mutex_lock(&dev->device_lock);
633 633
634 if (dev->dev_state != MEI_DEV_ENABLED) 634 if (!mei_cl_is_connected(cl)) {
635 goto out; 635 mask = POLLERR;
636
637
638 if (cl == &dev->iamthif_cl) {
639 mask = mei_amthif_poll(dev, file, wait);
640 goto out; 636 goto out;
641 } 637 }
642 638
643 mutex_unlock(&dev->device_lock); 639 mutex_unlock(&dev->device_lock);
640
641
642 if (cl == &dev->iamthif_cl)
643 return mei_amthif_poll(dev, file, wait);
644
644 poll_wait(file, &cl->tx_wait, wait); 645 poll_wait(file, &cl->tx_wait, wait);
646
645 mutex_lock(&dev->device_lock); 647 mutex_lock(&dev->device_lock);
648
649 if (!mei_cl_is_connected(cl)) {
650 mask = POLLERR;
651 goto out;
652 }
653
646 if (MEI_WRITE_COMPLETE == cl->writing_state) 654 if (MEI_WRITE_COMPLETE == cl->writing_state)
647 mask |= (POLLIN | POLLRDNORM); 655 mask |= (POLLIN | POLLRDNORM);
648 656