ia64/xen-unstable

changeset 7344:801ffcaa450b

This patch implements select() functionality on /dev/vtpm and fixes some
other problems.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Oct 12 09:33:03 2005 +0100 (2005-10-12)
parents 1fd8bd359118
children e89a7279d602
files linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Wed Oct 12 09:31:53 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Wed Oct 12 09:33:03 2005 +0100
     1.3 @@ -17,6 +17,7 @@
     1.4  #include <linux/types.h>
     1.5  #include <linux/list.h>
     1.6  #include <linux/miscdevice.h>
     1.7 +#include <linux/poll.h>
     1.8  #include <asm/uaccess.h>
     1.9  #include <asm-xen/xenbus.h>
    1.10  #include <asm-xen/xen-public/grant_table.h>
    1.11 @@ -680,9 +681,14 @@ vtpm_op_release(struct inode *inode, str
    1.12  }
    1.13  
    1.14  static unsigned int
    1.15 -vtpm_op_poll(struct file *file, struct poll_table_struct *pst)
    1.16 +vtpm_op_poll(struct file *file, struct poll_table_struct *pts)
    1.17  {
    1.18 -	return 0;
    1.19 +	unsigned int flags = POLLOUT | POLLWRNORM;
    1.20 +	poll_wait(file, &dataex.wait_queue, pts);
    1.21 +	if (!list_empty(&dataex.pending_pak)) {
    1.22 +		flags |= POLLIN | POLLRDNORM;
    1.23 +	}
    1.24 +	return flags;
    1.25  }
    1.26  
    1.27  static struct file_operations vtpm_ops = {
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Wed Oct 12 09:31:53 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Wed Oct 12 09:33:03 2005 +0100
     2.3 @@ -39,6 +39,7 @@
     2.4  #include <linux/interrupt.h>
     2.5  #include <linux/init.h>
     2.6  #include <linux/tpmfe.h>
     2.7 +#include <linux/err.h>
     2.8  
     2.9  #include <asm/semaphore.h>
    2.10  #include <asm/io.h>
    2.11 @@ -372,7 +373,7 @@ again:
    2.12  	info->watch.callback = watch_for_status;
    2.13  	err = register_xenbus_watch(&info->watch);
    2.14  	if (err) {
    2.15 -		message = "registering watch on backend";
    2.16 +		xenbus_dev_error(dev, err, "registering watch on backend");
    2.17  		goto destroy_tpmring;
    2.18  	}
    2.19  
    2.20 @@ -398,6 +399,8 @@ static int tpmfront_probe(struct xenbus_
    2.21  	int err;
    2.22  	struct tpmfront_info *info;
    2.23  	int handle;
    2.24 +	int len = max(XS_WATCH_PATH, XS_WATCH_TOKEN) + 1;
    2.25 +	const char *vec[len];
    2.26  
    2.27  	err = xenbus_scanf(NULL, dev->nodename,
    2.28  	                   "handle", "%i", &handle);
    2.29 @@ -427,6 +430,10 @@ static int tpmfront_probe(struct xenbus_
    2.30  		return err;
    2.31  	}
    2.32  
    2.33 +	vec[XS_WATCH_PATH]  = info->watch.node;
    2.34 +	vec[XS_WATCH_TOKEN] = NULL;
    2.35 +	watch_for_status(&info->watch, vec, len);
    2.36 +
    2.37  	return 0;
    2.38  }
    2.39