direct-io.hg

changeset 10473:79ea1d8a5bb2

[LINUX][TPM] Use min_t/min instead of the #define'd MIN.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Jun 21 16:55:25 2006 +0100 (2006-06-21)
parents fc1c6dfd1807
children 12aaf4a2486b
files linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Wed Jun 21 16:54:09 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Wed Jun 21 16:55:25 2006 +0100
     1.3 @@ -71,8 +71,6 @@ static int packet_read_shmem(struct pack
     1.4  			     char *buffer, int isuserbuffer, u32 left);
     1.5  static int vtpm_queue_packet(struct packet *pak);
     1.6  
     1.7 -#define MIN(x,y)  (x) < (y) ? (x) : (y)
     1.8 -
     1.9  /***************************************************************
    1.10   Buffer copying fo user and kernel space buffes.
    1.11  ***************************************************************/
    1.12 @@ -309,7 +307,7 @@ int _packet_write(struct packet *pak,
    1.13  			return 0;
    1.14  		}
    1.15  
    1.16 -		tocopy = MIN(size - offset, PAGE_SIZE);
    1.17 +		tocopy = min_t(size_t, size - offset, PAGE_SIZE);
    1.18  
    1.19  		if (copy_from_buffer((void *)(MMAP_VADDR(tpmif, i) |
    1.20  					      (tx->addr & ~PAGE_MASK)),
    1.21 @@ -365,7 +363,7 @@ static int packet_read(struct packet *pa
    1.22  		u32 instance_no = htonl(pak->tpm_instance);
    1.23  		u32 last_read = pak->last_read;
    1.24  
    1.25 -		to_copy = MIN(4 - last_read, numbytes);
    1.26 +		to_copy = min_t(size_t, 4 - last_read, numbytes);
    1.27  
    1.28  		if (copy_to_buffer(&buffer[0],
    1.29  				   &(((u8 *) & instance_no)[last_read]),
    1.30 @@ -384,7 +382,7 @@ static int packet_read(struct packet *pa
    1.31  
    1.32  	if (room_left > 0) {
    1.33  		if (pak->data_buffer) {
    1.34 -			u32 to_copy = MIN(pak->data_len - offset, room_left);
    1.35 +			u32 to_copy = min_t(u32, pak->data_len - offset, room_left);
    1.36  			u32 last_read = pak->last_read - 4;
    1.37  
    1.38  			if (copy_to_buffer(&buffer[offset],
    1.39 @@ -424,7 +422,7 @@ static int packet_read_shmem(struct pack
    1.40  	 * and within that page at offset 'offset'.
    1.41  	 * Copy a maximum of 'room_left' bytes.
    1.42  	 */
    1.43 -	to_copy = MIN(PAGE_SIZE - pg_offset, room_left);
    1.44 +	to_copy = min_t(u32, PAGE_SIZE - pg_offset, room_left);
    1.45  	while (to_copy > 0) {
    1.46  		void *src;
    1.47  		struct gnttab_map_grant_ref map_op;
    1.48 @@ -451,7 +449,7 @@ static int packet_read_shmem(struct pack
    1.49  			/*
    1.50  			 * User requests more than what's available
    1.51  			 */
    1.52 -			to_copy = MIN(tx->size, to_copy);
    1.53 +			to_copy = min_t(u32, tx->size, to_copy);
    1.54  		}
    1.55  
    1.56  		DPRINTK("Copying from mapped memory at %08lx\n",
    1.57 @@ -483,7 +481,7 @@ static int packet_read_shmem(struct pack
    1.58  		last_read += to_copy;
    1.59  		room_left -= to_copy;
    1.60  
    1.61 -		to_copy = MIN(PAGE_SIZE, room_left);
    1.62 +		to_copy = min_t(u32, PAGE_SIZE, room_left);
    1.63  		i++;
    1.64  	}			/* while (to_copy > 0) */
    1.65  	/*
    1.66 @@ -545,7 +543,7 @@ static ssize_t vtpm_op_read(struct file 
    1.67  
    1.68  		DPRINTK("size given by app: %d, available: %d\n", size, left);
    1.69  
    1.70 -		ret_size = MIN(size, left);
    1.71 +		ret_size = min_t(size_t, size, left);
    1.72  
    1.73  		ret_size = packet_read(pak, ret_size, data, size, 1);
    1.74