ia64/linux-2.6.18-xen.hg

annotate crypto/scatterwalk.h @ 854:950b9eb27661

usbback: fix urb interval value for interrupt urbs.

Signed-off-by: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Apr 06 13:51:20 2009 +0100 (2009-04-06)
parents 831230e53067
children
rev   line source
ian@0 1 /*
ian@0 2 * Cryptographic API.
ian@0 3 *
ian@0 4 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
ian@0 5 * Copyright (c) 2002 Adam J. Richter <adam@yggdrasil.com>
ian@0 6 * Copyright (c) 2004 Jean-Luc Cooke <jlcooke@certainkey.com>
ian@0 7 *
ian@0 8 * This program is free software; you can redistribute it and/or modify it
ian@0 9 * under the terms of the GNU General Public License as published by the Free
ian@0 10 * Software Foundation; either version 2 of the License, or (at your option)
ian@0 11 * any later version.
ian@0 12 *
ian@0 13 */
ian@0 14
ian@0 15 #ifndef _CRYPTO_SCATTERWALK_H
ian@0 16 #define _CRYPTO_SCATTERWALK_H
ian@0 17 #include <linux/mm.h>
ian@0 18 #include <asm/scatterlist.h>
ian@0 19
ian@0 20 struct scatter_walk {
ian@0 21 struct scatterlist *sg;
ian@0 22 struct page *page;
ian@0 23 void *data;
ian@0 24 unsigned int len_this_page;
ian@0 25 unsigned int len_this_segment;
ian@0 26 unsigned int offset;
ian@0 27 };
ian@0 28
ian@0 29 /* Define sg_next is an inline routine now in case we want to change
ian@0 30 scatterlist to a linked list later. */
ian@0 31 static inline struct scatterlist *sg_next(struct scatterlist *sg)
ian@0 32 {
ian@0 33 return sg + 1;
ian@0 34 }
ian@0 35
ian@0 36 static inline int scatterwalk_samebuf(struct scatter_walk *walk_in,
ian@0 37 struct scatter_walk *walk_out)
ian@0 38 {
ian@0 39 return walk_in->page == walk_out->page &&
ian@0 40 walk_in->offset == walk_out->offset;
ian@0 41 }
ian@0 42
ian@0 43 static inline unsigned int scatterwalk_clamp(struct scatter_walk *walk,
ian@0 44 unsigned int nbytes)
ian@0 45 {
ian@0 46 return nbytes > walk->len_this_page ? walk->len_this_page : nbytes;
ian@0 47 }
ian@0 48
ian@0 49 static inline void scatterwalk_advance(struct scatter_walk *walk,
ian@0 50 unsigned int nbytes)
ian@0 51 {
ian@0 52 walk->data += nbytes;
ian@0 53 walk->offset += nbytes;
ian@0 54 walk->len_this_page -= nbytes;
ian@0 55 walk->len_this_segment -= nbytes;
ian@0 56 }
ian@0 57
ian@0 58 static inline unsigned int scatterwalk_aligned(struct scatter_walk *walk,
ian@0 59 unsigned int alignmask)
ian@0 60 {
ian@0 61 return !(walk->offset & alignmask);
ian@0 62 }
ian@0 63
ian@0 64 void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg);
ian@0 65 int scatterwalk_copychunks(void *buf, struct scatter_walk *walk, size_t nbytes, int out);
ian@0 66 void scatterwalk_map(struct scatter_walk *walk, int out);
ian@0 67 void scatterwalk_done(struct scatter_walk *walk, int out, int more);
ian@0 68
ian@0 69 #endif /* _CRYPTO_SCATTERWALK_H */