direct-io.hg

changeset 10305:afdb70b16a53

[LINUX] Use structs not typedefs, remove trailing whitespaces, place symbol
EXPORTs with functions, order includes, eliminate unsed macros, don't
initialize static data to NULL, etc. Cleanups from patchqueue.

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
author kaf24@firebug.cl.cam.ac.uk
date Fri Jun 09 14:13:18 2006 +0100 (2006-06-09)
parents 2dea01abfbfe
children db8ec1e48414
files linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Fri Jun 09 14:10:32 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Fri Jun 09 14:13:18 2006 +0100
     1.3 @@ -1,27 +1,27 @@
     1.4  /******************************************************************************
     1.5   * gnttab.c
     1.6 - * 
     1.7 + *
     1.8   * Granting foreign access to our memory reservation.
     1.9 - * 
    1.10 + *
    1.11   * Copyright (c) 2005, Christopher Clark
    1.12   * Copyright (c) 2004-2005, K A Fraser
    1.13 - * 
    1.14 + *
    1.15   * This program is free software; you can redistribute it and/or
    1.16   * modify it under the terms of the GNU General Public License version 2
    1.17   * as published by the Free Software Foundation; or, when distributed
    1.18   * separately from the Linux kernel or incorporated into other
    1.19   * software packages, subject to the following license:
    1.20 - * 
    1.21 + *
    1.22   * Permission is hereby granted, free of charge, to any person obtaining a copy
    1.23   * of this source file (the "Software"), to deal in the Software without
    1.24   * restriction, including without limitation the rights to use, copy, modify,
    1.25   * merge, publish, distribute, sublicense, and/or sell copies of the Software,
    1.26   * and to permit persons to whom the Software is furnished to do so, subject to
    1.27   * the following conditions:
    1.28 - * 
    1.29 + *
    1.30   * The above copyright notice and this permission notice shall be included in
    1.31   * all copies or substantial portions of the Software.
    1.32 - * 
    1.33 + *
    1.34   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    1.35   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    1.36   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    1.37 @@ -36,45 +36,17 @@
    1.38  #include <linux/sched.h>
    1.39  #include <linux/mm.h>
    1.40  #include <linux/vmalloc.h>
    1.41 -#include <asm/pgtable.h>
    1.42  #include <xen/interface/xen.h>
    1.43 +#include <xen/gnttab.h>
    1.44 +#include <asm/pgtable.h>
    1.45  #include <asm/uaccess.h>
    1.46 -#include <xen/gnttab.h>
    1.47  #include <asm/synch_bitops.h>
    1.48  
    1.49 -#if 1
    1.50 -#define ASSERT(_p)							      \
    1.51 -	if (!(_p)) { printk(KERN_ALERT"Assertion '%s': line %d, file %s\n",   \
    1.52 -	#_p , __LINE__, __FILE__); *(int*)0=0; }
    1.53 -#else
    1.54 -#define ASSERT(_p) ((void)0)
    1.55 -#endif
    1.56 -
    1.57 -#define WPRINTK(fmt, args...)				\
    1.58 -	printk(KERN_WARNING "xen_grant: " fmt, ##args)
    1.59 -
    1.60 -
    1.61 -EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access);
    1.62 -EXPORT_SYMBOL_GPL(gnttab_end_foreign_access_ref);
    1.63 -EXPORT_SYMBOL_GPL(gnttab_end_foreign_access);
    1.64 -EXPORT_SYMBOL_GPL(gnttab_query_foreign_access);
    1.65 -EXPORT_SYMBOL_GPL(gnttab_grant_foreign_transfer);
    1.66 -EXPORT_SYMBOL_GPL(gnttab_end_foreign_transfer_ref);
    1.67 -EXPORT_SYMBOL_GPL(gnttab_end_foreign_transfer);
    1.68 -EXPORT_SYMBOL_GPL(gnttab_alloc_grant_references);
    1.69 -EXPORT_SYMBOL_GPL(gnttab_free_grant_references);
    1.70 -EXPORT_SYMBOL_GPL(gnttab_free_grant_reference);
    1.71 -EXPORT_SYMBOL_GPL(gnttab_empty_grant_references);
    1.72 -EXPORT_SYMBOL_GPL(gnttab_claim_grant_reference);
    1.73 -EXPORT_SYMBOL_GPL(gnttab_release_grant_reference);
    1.74 -EXPORT_SYMBOL_GPL(gnttab_request_free_callback);
    1.75 -EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access_ref);
    1.76 -EXPORT_SYMBOL_GPL(gnttab_grant_foreign_transfer_ref);
    1.77 -
    1.78  /* External tools reserve first few grant table entries. */
    1.79  #define NR_RESERVED_ENTRIES 8
    1.80  
    1.81 -#define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
    1.82 +#define NR_GRANT_ENTRIES \
    1.83 +	(NR_GRANT_FRAMES * PAGE_SIZE / sizeof(struct grant_entry))
    1.84  #define GNTTAB_LIST_END (NR_GRANT_ENTRIES + 1)
    1.85  
    1.86  static grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
    1.87 @@ -82,12 +54,11 @@ static int gnttab_free_count;
    1.88  static grant_ref_t gnttab_free_head;
    1.89  static DEFINE_SPINLOCK(gnttab_list_lock);
    1.90  
    1.91 -static grant_entry_t *shared = NULL;
    1.92 +static struct grant_entry *shared;
    1.93  
    1.94 -static struct gnttab_free_callback *gnttab_free_callback_list = NULL;
    1.95 +static struct gnttab_free_callback *gnttab_free_callback_list;
    1.96  
    1.97 -static int
    1.98 -get_free_entries(int count)
    1.99 +static int get_free_entries(int count)
   1.100  {
   1.101  	unsigned long flags;
   1.102  	int ref;
   1.103 @@ -109,8 +80,7 @@ get_free_entries(int count)
   1.104  
   1.105  #define get_free_entry() get_free_entries(1)
   1.106  
   1.107 -static void
   1.108 -do_free_callbacks(void)
   1.109 +static void do_free_callbacks(void)
   1.110  {
   1.111  	struct gnttab_free_callback *callback, *next;
   1.112  
   1.113 @@ -130,15 +100,13 @@ do_free_callbacks(void)
   1.114  	}
   1.115  }
   1.116  
   1.117 -static inline void
   1.118 -check_free_callbacks(void)
   1.119 +static inline void check_free_callbacks(void)
   1.120  {
   1.121  	if (unlikely(gnttab_free_callback_list))
   1.122  		do_free_callbacks();
   1.123  }
   1.124  
   1.125 -static void
   1.126 -put_free_entry(grant_ref_t ref)
   1.127 +static void put_free_entry(grant_ref_t ref)
   1.128  {
   1.129  	unsigned long flags;
   1.130  	spin_lock_irqsave(&gnttab_list_lock, flags);
   1.131 @@ -153,8 +121,8 @@ put_free_entry(grant_ref_t ref)
   1.132   * Public grant-issuing interface functions
   1.133   */
   1.134  
   1.135 -int
   1.136 -gnttab_grant_foreign_access(domid_t domid, unsigned long frame, int readonly)
   1.137 +int gnttab_grant_foreign_access(domid_t domid, unsigned long frame,
   1.138 +				int readonly)
   1.139  {
   1.140  	int ref;
   1.141  
   1.142 @@ -168,20 +136,20 @@ gnttab_grant_foreign_access(domid_t domi
   1.143  
   1.144  	return ref;
   1.145  }
   1.146 +EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access);
   1.147  
   1.148 -void
   1.149 -gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid,
   1.150 -				unsigned long frame, int readonly)
   1.151 +void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid,
   1.152 +				     unsigned long frame, int readonly)
   1.153  {
   1.154  	shared[ref].frame = frame;
   1.155  	shared[ref].domid = domid;
   1.156  	wmb();
   1.157  	shared[ref].flags = GTF_permit_access | (readonly ? GTF_readonly : 0);
   1.158  }
   1.159 +EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access_ref);
   1.160  
   1.161  
   1.162 -int
   1.163 -gnttab_query_foreign_access(grant_ref_t ref)
   1.164 +int gnttab_query_foreign_access(grant_ref_t ref)
   1.165  {
   1.166  	u16 nflags;
   1.167  
   1.168 @@ -189,9 +157,9 @@ gnttab_query_foreign_access(grant_ref_t 
   1.169  
   1.170  	return (nflags & (GTF_reading|GTF_writing));
   1.171  }
   1.172 +EXPORT_SYMBOL_GPL(gnttab_query_foreign_access);
   1.173  
   1.174 -int
   1.175 -gnttab_end_foreign_access_ref(grant_ref_t ref, int readonly)
   1.176 +int gnttab_end_foreign_access_ref(grant_ref_t ref, int readonly)
   1.177  {
   1.178  	u16 flags, nflags;
   1.179  
   1.180 @@ -206,15 +174,15 @@ gnttab_end_foreign_access_ref(grant_ref_
   1.181  
   1.182  	return 1;
   1.183  }
   1.184 +EXPORT_SYMBOL_GPL(gnttab_end_foreign_access_ref);
   1.185  
   1.186 -void
   1.187 -gnttab_end_foreign_access(grant_ref_t ref, int readonly, unsigned long page)
   1.188 +void gnttab_end_foreign_access(grant_ref_t ref, int readonly,
   1.189 +			       unsigned long page)
   1.190  {
   1.191  	if (gnttab_end_foreign_access_ref(ref, readonly)) {
   1.192  		put_free_entry(ref);
   1.193 -		if (page != 0) {
   1.194 +		if (page != 0)
   1.195  			free_page(page);
   1.196 -		}
   1.197  	} else {
   1.198  		/* XXX This needs to be fixed so that the ref and page are
   1.199  		   placed on a list to be freed up later. */
   1.200 @@ -222,9 +190,9 @@ gnttab_end_foreign_access(grant_ref_t re
   1.201  		       "WARNING: leaking g.e. and page still in use!\n");
   1.202  	}
   1.203  }
   1.204 +EXPORT_SYMBOL_GPL(gnttab_end_foreign_access);
   1.205  
   1.206 -int
   1.207 -gnttab_grant_foreign_transfer(domid_t domid, unsigned long pfn)
   1.208 +int gnttab_grant_foreign_transfer(domid_t domid, unsigned long pfn)
   1.209  {
   1.210  	int ref;
   1.211  
   1.212 @@ -234,19 +202,19 @@ gnttab_grant_foreign_transfer(domid_t do
   1.213  
   1.214  	return ref;
   1.215  }
   1.216 +EXPORT_SYMBOL_GPL(gnttab_grant_foreign_transfer);
   1.217  
   1.218 -void
   1.219 -gnttab_grant_foreign_transfer_ref(grant_ref_t ref, domid_t domid,
   1.220 -				  unsigned long pfn)
   1.221 +void gnttab_grant_foreign_transfer_ref(grant_ref_t ref, domid_t domid,
   1.222 +				       unsigned long pfn)
   1.223  {
   1.224  	shared[ref].frame = pfn;
   1.225  	shared[ref].domid = domid;
   1.226  	wmb();
   1.227  	shared[ref].flags = GTF_accept_transfer;
   1.228  }
   1.229 +EXPORT_SYMBOL_GPL(gnttab_grant_foreign_transfer_ref);
   1.230  
   1.231 -unsigned long
   1.232 -gnttab_end_foreign_transfer_ref(grant_ref_t ref)
   1.233 +unsigned long gnttab_end_foreign_transfer_ref(grant_ref_t ref)
   1.234  {
   1.235  	unsigned long frame;
   1.236  	u16           flags;
   1.237 @@ -274,24 +242,23 @@ gnttab_end_foreign_transfer_ref(grant_re
   1.238  
   1.239  	return frame;
   1.240  }
   1.241 +EXPORT_SYMBOL_GPL(gnttab_end_foreign_transfer_ref);
   1.242  
   1.243 -unsigned long
   1.244 -gnttab_end_foreign_transfer(grant_ref_t ref)
   1.245 +unsigned long gnttab_end_foreign_transfer(grant_ref_t ref)
   1.246  {
   1.247  	unsigned long frame = gnttab_end_foreign_transfer_ref(ref);
   1.248  	put_free_entry(ref);
   1.249  	return frame;
   1.250  }
   1.251 +EXPORT_SYMBOL_GPL(gnttab_end_foreign_transfer);
   1.252  
   1.253 -void
   1.254 -gnttab_free_grant_reference(grant_ref_t ref)
   1.255 +void gnttab_free_grant_reference(grant_ref_t ref)
   1.256  {
   1.257 -
   1.258  	put_free_entry(ref);
   1.259  }
   1.260 +EXPORT_SYMBOL_GPL(gnttab_free_grant_reference);
   1.261  
   1.262 -void
   1.263 -gnttab_free_grant_references(grant_ref_t head)
   1.264 +void gnttab_free_grant_references(grant_ref_t head)
   1.265  {
   1.266  	grant_ref_t ref;
   1.267  	unsigned long flags;
   1.268 @@ -310,9 +277,9 @@ gnttab_free_grant_references(grant_ref_t
   1.269  	check_free_callbacks();
   1.270  	spin_unlock_irqrestore(&gnttab_list_lock, flags);
   1.271  }
   1.272 +EXPORT_SYMBOL_GPL(gnttab_free_grant_references);
   1.273  
   1.274 -int
   1.275 -gnttab_alloc_grant_references(u16 count, grant_ref_t *head)
   1.276 +int gnttab_alloc_grant_references(u16 count, grant_ref_t *head)
   1.277  {
   1.278  	int h = get_free_entries(count);
   1.279  
   1.280 @@ -323,15 +290,15 @@ gnttab_alloc_grant_references(u16 count,
   1.281  
   1.282  	return 0;
   1.283  }
   1.284 +EXPORT_SYMBOL_GPL(gnttab_alloc_grant_references);
   1.285  
   1.286 -int
   1.287 -gnttab_empty_grant_references(const grant_ref_t *private_head)
   1.288 +int gnttab_empty_grant_references(const grant_ref_t *private_head)
   1.289  {
   1.290  	return (*private_head == GNTTAB_LIST_END);
   1.291  }
   1.292 +EXPORT_SYMBOL_GPL(gnttab_empty_grant_references);
   1.293  
   1.294 -int
   1.295 -gnttab_claim_grant_reference(grant_ref_t *private_head)
   1.296 +int gnttab_claim_grant_reference(grant_ref_t *private_head)
   1.297  {
   1.298  	grant_ref_t g = *private_head;
   1.299  	if (unlikely(g == GNTTAB_LIST_END))
   1.300 @@ -339,17 +306,18 @@ gnttab_claim_grant_reference(grant_ref_t
   1.301  	*private_head = gnttab_list[g];
   1.302  	return g;
   1.303  }
   1.304 +EXPORT_SYMBOL_GPL(gnttab_claim_grant_reference);
   1.305  
   1.306 -void
   1.307 -gnttab_release_grant_reference(grant_ref_t *private_head, grant_ref_t  release)
   1.308 +void gnttab_release_grant_reference(grant_ref_t *private_head,
   1.309 +				    grant_ref_t release)
   1.310  {
   1.311  	gnttab_list[release] = *private_head;
   1.312  	*private_head = release;
   1.313  }
   1.314 +EXPORT_SYMBOL_GPL(gnttab_release_grant_reference);
   1.315  
   1.316 -void
   1.317 -gnttab_request_free_callback(struct gnttab_free_callback *callback,
   1.318 -			     void (*fn)(void *), void *arg, u16 count)
   1.319 +void gnttab_request_free_callback(struct gnttab_free_callback *callback,
   1.320 +				  void (*fn)(void *), void *arg, u16 count)
   1.321  {
   1.322  	unsigned long flags;
   1.323  	spin_lock_irqsave(&gnttab_list_lock, flags);
   1.324 @@ -361,9 +329,10 @@ gnttab_request_free_callback(struct gntt
   1.325  	callback->next = gnttab_free_callback_list;
   1.326  	gnttab_free_callback_list = callback;
   1.327  	check_free_callbacks();
   1.328 - out:
   1.329 +out:
   1.330  	spin_unlock_irqrestore(&gnttab_list_lock, flags);
   1.331  }
   1.332 +EXPORT_SYMBOL_GPL(gnttab_request_free_callback);
   1.333  
   1.334  #ifndef __ia64__
   1.335  static int map_pte_fn(pte_t *pte, struct page *pmd_page,
   1.336 @@ -377,7 +346,7 @@ static int map_pte_fn(pte_t *pte, struct
   1.337  }
   1.338  
   1.339  static int unmap_pte_fn(pte_t *pte, struct page *pmd_page,
   1.340 -		      unsigned long addr, void *data)
   1.341 +			unsigned long addr, void *data)
   1.342  {
   1.343  
   1.344  	set_pte_at(&init_mm, addr, pte, __pte(0));
   1.345 @@ -385,10 +354,9 @@ static int unmap_pte_fn(pte_t *pte, stru
   1.346  }
   1.347  #endif
   1.348  
   1.349 -int
   1.350 -gnttab_resume(void)
   1.351 +int gnttab_resume(void)
   1.352  {
   1.353 -	gnttab_setup_table_t setup;
   1.354 +	struct gnttab_setup_table setup;
   1.355  	unsigned long frames[NR_GRANT_FRAMES];
   1.356  	int rc;
   1.357  #ifndef __ia64__
   1.358 @@ -424,8 +392,7 @@ gnttab_resume(void)
   1.359  	return 0;
   1.360  }
   1.361  
   1.362 -int
   1.363 -gnttab_suspend(void)
   1.364 +int gnttab_suspend(void)
   1.365  {
   1.366  
   1.367  #ifndef __ia64__
   1.368 @@ -437,8 +404,7 @@ gnttab_suspend(void)
   1.369  	return 0;
   1.370  }
   1.371  
   1.372 -static int __init
   1.373 -gnttab_init(void)
   1.374 +static int __init gnttab_init(void)
   1.375  {
   1.376  	int i;
   1.377