Revert "Driver core: convert SPI code to use struct device"
[linux-2.6/mini2440.git] / fs / 9p / vfs_addr.c
blobcc24abf232d5818c375836b744759916b88f24ac
1 /*
2 * linux/fs/9p/vfs_addr.c
4 * This file contians vfs address (mmap) ops for 9P2000.
6 * Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com>
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to:
20 * Free Software Foundation
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02111-1301 USA
26 #include <linux/module.h>
27 #include <linux/errno.h>
28 #include <linux/fs.h>
29 #include <linux/file.h>
30 #include <linux/stat.h>
31 #include <linux/string.h>
32 #include <linux/smp_lock.h>
33 #include <linux/inet.h>
34 #include <linux/pagemap.h>
35 #include <linux/idr.h>
37 #include "debug.h"
38 #include "v9fs.h"
39 #include "9p.h"
40 #include "v9fs_vfs.h"
41 #include "fid.h"
43 /**
44 * v9fs_vfs_readpage - read an entire page in from 9P
46 * @file: file being read
47 * @page: structure to page
51 static int v9fs_vfs_readpage(struct file *filp, struct page *page)
53 char *buffer = NULL;
54 int retval = -EIO;
55 loff_t offset = page_offset(page);
56 int count = PAGE_CACHE_SIZE;
57 struct inode *inode = filp->f_path.dentry->d_inode;
58 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode);
59 int rsize = v9ses->maxdata - V9FS_IOHDRSZ;
60 struct v9fs_fid *v9f = filp->private_data;
61 struct v9fs_fcall *fcall = NULL;
62 int fid = v9f->fid;
63 int total = 0;
64 int result = 0;
66 buffer = kmap(page);
67 do {
68 if (count < rsize)
69 rsize = count;
71 result = v9fs_t_read(v9ses, fid, offset, rsize, &fcall);
73 if (result < 0) {
74 printk(KERN_ERR "v9fs_t_read returned %d\n",
75 result);
77 kfree(fcall);
78 goto UnmapAndUnlock;
79 } else
80 offset += result;
82 memcpy(buffer, fcall->params.rread.data, result);
84 count -= result;
85 buffer += result;
86 total += result;
88 kfree(fcall);
90 if (result < rsize)
91 break;
92 } while (count);
94 memset(buffer, 0, count);
95 flush_dcache_page(page);
96 SetPageUptodate(page);
97 retval = 0;
99 UnmapAndUnlock:
100 kunmap(page);
101 unlock_page(page);
102 return retval;
105 const struct address_space_operations v9fs_addr_operations = {
106 .readpage = v9fs_vfs_readpage,