gluebi.c (5def48982b778aaebe201f85af7170b7d0a6619f) | gluebi.c (664addc248d2fed68d013d26ff2fc796d7134259) |
---|---|
1/* 2 * Copyright (c) International Business Machines Corp., 2006 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 * --- 201 unchanged lines hidden (view full) --- 210 */ 211static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len, 212 size_t *retlen, const u_char *buf) 213{ 214 int err = 0, lnum, offs, total_written; 215 struct gluebi_device *gluebi; 216 217 gluebi = container_of(mtd, struct gluebi_device, mtd); | 1/* 2 * Copyright (c) International Business Machines Corp., 2006 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 * --- 201 unchanged lines hidden (view full) --- 210 */ 211static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len, 212 size_t *retlen, const u_char *buf) 213{ 214 int err = 0, lnum, offs, total_written; 215 struct gluebi_device *gluebi; 216 217 gluebi = container_of(mtd, struct gluebi_device, mtd); |
218 219 if (!(mtd->flags & MTD_WRITEABLE)) 220 return -EROFS; 221 | |
222 lnum = div_u64_rem(to, mtd->erasesize, &offs); 223 224 if (len % mtd->writesize || offs % mtd->writesize) 225 return -EINVAL; 226 227 total_written = len; 228 while (total_written) { 229 size_t to_write = mtd->erasesize - offs; --- 28 unchanged lines hidden (view full) --- 258 int err, i, lnum, count; 259 struct gluebi_device *gluebi; 260 261 if (mtd_mod_by_ws(instr->addr, mtd) || mtd_mod_by_ws(instr->len, mtd)) 262 return -EINVAL; 263 264 lnum = mtd_div_by_eb(instr->addr, mtd); 265 count = mtd_div_by_eb(instr->len, mtd); | 218 lnum = div_u64_rem(to, mtd->erasesize, &offs); 219 220 if (len % mtd->writesize || offs % mtd->writesize) 221 return -EINVAL; 222 223 total_written = len; 224 while (total_written) { 225 size_t to_write = mtd->erasesize - offs; --- 28 unchanged lines hidden (view full) --- 254 int err, i, lnum, count; 255 struct gluebi_device *gluebi; 256 257 if (mtd_mod_by_ws(instr->addr, mtd) || mtd_mod_by_ws(instr->len, mtd)) 258 return -EINVAL; 259 260 lnum = mtd_div_by_eb(instr->addr, mtd); 261 count = mtd_div_by_eb(instr->len, mtd); |
266 | |
267 gluebi = container_of(mtd, struct gluebi_device, mtd); 268 | 262 gluebi = container_of(mtd, struct gluebi_device, mtd); 263 |
269 if (!(mtd->flags & MTD_WRITEABLE)) 270 return -EROFS; 271 | |
272 for (i = 0; i < count - 1; i++) { 273 err = ubi_leb_unmap(gluebi->desc, lnum + i); 274 if (err) 275 goto out_err; 276 } 277 /* 278 * MTD erase operations are synchronous, so we have to make sure the 279 * physical eraseblock is wiped out. --- 252 unchanged lines hidden --- | 264 for (i = 0; i < count - 1; i++) { 265 err = ubi_leb_unmap(gluebi->desc, lnum + i); 266 if (err) 267 goto out_err; 268 } 269 /* 270 * MTD erase operations are synchronous, so we have to make sure the 271 * physical eraseblock is wiped out. --- 252 unchanged lines hidden --- |