mtdchar.c (c478d7e449508d924628b012e62dee6dddb6b9e9) | mtdchar.c (289c05222172b51401dbbb017115655f241d94ab) |
---|---|
1/* 2 * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * --- 72 unchanged lines hidden (view full) --- 81{ 82 int minor = iminor(inode); 83 int devnum = minor >> 1; 84 int ret = 0; 85 struct mtd_info *mtd; 86 struct mtd_file_info *mfi; 87 struct inode *mtd_ino; 88 | 1/* 2 * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * --- 72 unchanged lines hidden (view full) --- 81{ 82 int minor = iminor(inode); 83 int devnum = minor >> 1; 84 int ret = 0; 85 struct mtd_info *mtd; 86 struct mtd_file_info *mfi; 87 struct inode *mtd_ino; 88 |
89 DEBUG(MTD_DEBUG_LEVEL0, "MTD_open\n"); | 89 pr_debug("MTD_open\n"); |
90 91 /* You can't open the RO devices RW */ 92 if ((file->f_mode & FMODE_WRITE) && (minor & 1)) 93 return -EACCES; 94 95 mutex_lock(&mtd_mutex); 96 mtd = get_mtd_device(NULL, devnum); 97 --- 48 unchanged lines hidden (view full) --- 146 147/*====================================================================*/ 148 149static int mtd_close(struct inode *inode, struct file *file) 150{ 151 struct mtd_file_info *mfi = file->private_data; 152 struct mtd_info *mtd = mfi->mtd; 153 | 90 91 /* You can't open the RO devices RW */ 92 if ((file->f_mode & FMODE_WRITE) && (minor & 1)) 93 return -EACCES; 94 95 mutex_lock(&mtd_mutex); 96 mtd = get_mtd_device(NULL, devnum); 97 --- 48 unchanged lines hidden (view full) --- 146 147/*====================================================================*/ 148 149static int mtd_close(struct inode *inode, struct file *file) 150{ 151 struct mtd_file_info *mfi = file->private_data; 152 struct mtd_info *mtd = mfi->mtd; 153 |
154 DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n"); | 154 pr_debug("MTD_close\n"); |
155 156 /* Only sync if opened RW */ 157 if ((file->f_mode & FMODE_WRITE) && mtd->sync) 158 mtd->sync(mtd); 159 160 iput(mfi->ino); 161 162 put_mtd_device(mtd); --- 27 unchanged lines hidden (view full) --- 190 struct mtd_info *mtd = mfi->mtd; 191 size_t retlen=0; 192 size_t total_retlen=0; 193 int ret=0; 194 int len; 195 size_t size = count; 196 char *kbuf; 197 | 155 156 /* Only sync if opened RW */ 157 if ((file->f_mode & FMODE_WRITE) && mtd->sync) 158 mtd->sync(mtd); 159 160 iput(mfi->ino); 161 162 put_mtd_device(mtd); --- 27 unchanged lines hidden (view full) --- 190 struct mtd_info *mtd = mfi->mtd; 191 size_t retlen=0; 192 size_t total_retlen=0; 193 int ret=0; 194 int len; 195 size_t size = count; 196 char *kbuf; 197 |
198 DEBUG(MTD_DEBUG_LEVEL0,"MTD_read\n"); | 198 pr_debug("MTD_read\n"); |
199 200 if (*ppos + count > mtd->size) 201 count = mtd->size - *ppos; 202 203 if (!count) 204 return 0; 205 206 kbuf = mtd_kmalloc_up_to(mtd, &size); --- 66 unchanged lines hidden (view full) --- 273 struct mtd_info *mtd = mfi->mtd; 274 size_t size = count; 275 char *kbuf; 276 size_t retlen; 277 size_t total_retlen=0; 278 int ret=0; 279 int len; 280 | 199 200 if (*ppos + count > mtd->size) 201 count = mtd->size - *ppos; 202 203 if (!count) 204 return 0; 205 206 kbuf = mtd_kmalloc_up_to(mtd, &size); --- 66 unchanged lines hidden (view full) --- 273 struct mtd_info *mtd = mfi->mtd; 274 size_t size = count; 275 char *kbuf; 276 size_t retlen; 277 size_t total_retlen=0; 278 int ret=0; 279 int len; 280 |
281 DEBUG(MTD_DEBUG_LEVEL0,"MTD_write\n"); | 281 pr_debug("MTD_write\n"); |
282 283 if (*ppos == mtd->size) 284 return -ENOSPC; 285 286 if (*ppos + count > mtd->size) 287 count = mtd->size - *ppos; 288 289 if (!count) --- 275 unchanged lines hidden (view full) --- 565{ 566 struct mtd_file_info *mfi = file->private_data; 567 struct mtd_info *mtd = mfi->mtd; 568 void __user *argp = (void __user *)arg; 569 int ret = 0; 570 u_long size; 571 struct mtd_info_user info; 572 | 282 283 if (*ppos == mtd->size) 284 return -ENOSPC; 285 286 if (*ppos + count > mtd->size) 287 count = mtd->size - *ppos; 288 289 if (!count) --- 275 unchanged lines hidden (view full) --- 565{ 566 struct mtd_file_info *mfi = file->private_data; 567 struct mtd_info *mtd = mfi->mtd; 568 void __user *argp = (void __user *)arg; 569 int ret = 0; 570 u_long size; 571 struct mtd_info_user info; 572 |
573 DEBUG(MTD_DEBUG_LEVEL0, "MTD_ioctl\n"); | 573 pr_debug("MTD_ioctl\n"); |
574 575 size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; 576 if (cmd & IOC_IN) { 577 if (!access_ok(VERIFY_READ, argp, size)) 578 return -EFAULT; 579 } 580 if (cmd & IOC_OUT) { 581 if (!access_ok(VERIFY_WRITE, argp, size)) --- 644 unchanged lines hidden --- | 574 575 size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; 576 if (cmd & IOC_IN) { 577 if (!access_ok(VERIFY_READ, argp, size)) 578 return -EFAULT; 579 } 580 if (cmd & IOC_OUT) { 581 if (!access_ok(VERIFY_WRITE, argp, size)) --- 644 unchanged lines hidden --- |