ia64/xen-unstable

changeset 6357:2d3a7be68ba3

Use explicit functions with args instead of work_structs for callbacks.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Tue Aug 23 08:40:50 2005 +0000 (2005-08-23)
parents 827a3c3524b3 f51fe43c5d1c
children 5f4724c13040
files linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/include/asm-xen/gnttab.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Mon Aug 22 20:59:00 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Tue Aug 23 08:40:50 2005 +0000
     1.3 @@ -69,11 +69,13 @@ get_free_entry(
     1.4  
     1.5  static void do_free_callbacks(void)
     1.6  {
     1.7 -    struct gnttab_free_callback *callback = gnttab_free_callback_list;
     1.8 +    struct gnttab_free_callback *callback = gnttab_free_callback_list, *next;
     1.9      gnttab_free_callback_list = NULL;
    1.10      while (callback) {
    1.11 -	schedule_work(callback->work);
    1.12 -	callback = callback->next;
    1.13 +	next = callback->next;
    1.14 +	callback->next = NULL;
    1.15 +	callback->fn(callback->arg);
    1.16 +	callback = next;
    1.17      }
    1.18  }
    1.19  
    1.20 @@ -266,9 +268,12 @@ gnttab_release_grant_reference( grant_re
    1.21  
    1.22  void
    1.23  gnttab_request_free_callback(struct gnttab_free_callback *callback,
    1.24 -			     struct work_struct *work)
    1.25 +			     void (*fn)(void *), void *arg)
    1.26  {
    1.27 -    callback->work = work;
    1.28 +    if (callback->next)
    1.29 +	return;
    1.30 +    callback->fn = fn;
    1.31 +    callback->arg = arg;
    1.32      callback->next = gnttab_free_callback_list;
    1.33      gnttab_free_callback_list = callback;
    1.34  }
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Aug 22 20:59:00 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Tue Aug 23 08:40:50 2005 +0000
     2.3 @@ -157,11 +157,16 @@ static void blkif_restart_queue(void *ar
     2.4  {
     2.5  	struct blkfront_info *info = (struct blkfront_info *)arg;
     2.6  	spin_lock_irq(&blkif_io_lock);
     2.7 -	info->callback.work = NULL;
     2.8  	kick_pending_request_queues(info);
     2.9  	spin_unlock_irq(&blkif_io_lock);
    2.10  }
    2.11  
    2.12 +static void blkif_restart_queue_callback(void *arg)
    2.13 +{
    2.14 +	struct blkfront_info *info = (struct blkfront_info *)arg;
    2.15 +	schedule_work(&info->work);
    2.16 +}
    2.17 +
    2.18  int blkif_open(struct inode *inode, struct file *filep)
    2.19  {
    2.20  	// struct gendisk *gd = inode->i_bdev->bd_disk;
    2.21 @@ -239,10 +244,8 @@ static int blkif_queue_request(struct re
    2.22  
    2.23      if (gnttab_alloc_grant_references(BLKIF_MAX_SEGMENTS_PER_REQUEST,
    2.24  				      &gref_head, &gref_terminal) < 0) {
    2.25 -	    if (info->callback.work)
    2.26 -		    return 1;
    2.27 -	    INIT_WORK(&info->work, blkif_restart_queue, (void *)info);
    2.28 -	    gnttab_request_free_callback(&info->callback, &info->work);
    2.29 +	    gnttab_request_free_callback(&info->callback,
    2.30 +					 blkif_restart_queue_callback, info);
    2.31  	    return 1;
    2.32      }
    2.33  
    2.34 @@ -1242,6 +1245,7 @@ static int blkfront_probe(struct xenbus_
    2.35  	info->vdevice = vdevice;
    2.36  	info->connected = BLKIF_STATE_DISCONNECTED;
    2.37  	info->mi = NULL;
    2.38 +	INIT_WORK(&info->work, blkif_restart_queue, (void *)info);
    2.39  
    2.40  	/* Front end dir is a number, which is used as the id. */
    2.41  	info->handle = simple_strtoul(strrchr(dev->nodename,'/')+1, NULL, 0);
     3.1 --- a/linux-2.6-xen-sparse/include/asm-xen/gnttab.h	Mon Aug 22 20:59:00 2005 +0000
     3.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/gnttab.h	Tue Aug 23 08:40:50 2005 +0000
     3.3 @@ -25,7 +25,8 @@ struct work_struct;
     3.4  
     3.5  struct gnttab_free_callback {
     3.6      struct gnttab_free_callback *next;
     3.7 -    struct work_struct *work;
     3.8 +    void (*fn)(void *);
     3.9 +    void *arg;
    3.10  };
    3.11  
    3.12  int
    3.13 @@ -73,7 +74,7 @@ gnttab_release_grant_reference(
    3.14  
    3.15  void
    3.16  gnttab_request_free_callback(
    3.17 -    struct gnttab_free_callback *callback, struct work_struct *work );
    3.18 +    struct gnttab_free_callback *callback, void (*fn)(void *), void *arg);
    3.19  
    3.20  void
    3.21  gnttab_grant_foreign_access_ref(