aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/gluebi.c
diff options
context:
space:
mode:
authorAdrian Hunter <ext-adrian.hunter@nokia.com>2008-12-10 08:37:21 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2008-12-10 08:37:21 -0500
commit69423d99fc182a81f3c5db3eb5c140acc6fc64be (patch)
tree5f1818e6fb69388f0da276152646bf0597e318c0 /drivers/mtd/ubi/gluebi.c
parent8a4c2495b142fe612b291a810d9e695f269c26db (diff)
[MTD] update internal API to support 64-bit device size
MTD internal API presently uses 32-bit values to represent device size. This patch updates them to 64-bits but leaves the external API unchanged. Extending the external API is a separate issue for several reasons. First, no one needs it at the moment. Secondly, whether the implementation is done with IOCTLs, sysfs or both is still debated. Thirdly external API changes require the internal API to be accepted first. Note that although the MTD API will be able to support 64-bit device sizes, existing drivers do not and are not required to do so, although NAND base has been updated. In general, changing from 32-bit to 64-bit values cause little or no changes to the majority of the code with the following exceptions: - printk message formats - division and modulus of 64-bit values - NAND base support - 32-bit local variables used by mtdpart and mtdconcat - naughtily assuming one structure maps to another in MEMERASE ioctl Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/ubi/gluebi.c')
-rw-r--r--drivers/mtd/ubi/gluebi.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c
index 605812bb0b1a..6dd4f5e77f82 100644
--- a/drivers/mtd/ubi/gluebi.c
+++ b/drivers/mtd/ubi/gluebi.c
@@ -215,7 +215,8 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)
215 struct ubi_volume *vol; 215 struct ubi_volume *vol;
216 struct ubi_device *ubi; 216 struct ubi_device *ubi;
217 217
218 dbg_gen("erase %u bytes at offset %u", instr->len, instr->addr); 218 dbg_gen("erase %llu bytes at offset %llu", (unsigned long long)instr->len,
219 (unsigned long long)instr->addr);
219 220
220 if (instr->addr < 0 || instr->addr > mtd->size - mtd->erasesize) 221 if (instr->addr < 0 || instr->addr > mtd->size - mtd->erasesize)
221 return -EINVAL; 222 return -EINVAL;
@@ -223,11 +224,11 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)
223 if (instr->len < 0 || instr->addr + instr->len > mtd->size) 224 if (instr->len < 0 || instr->addr + instr->len > mtd->size)
224 return -EINVAL; 225 return -EINVAL;
225 226
226 if (instr->addr % mtd->writesize || instr->len % mtd->writesize) 227 if (mtd_mod_by_ws(instr->addr, mtd) || mtd_mod_by_ws(instr->len, mtd))
227 return -EINVAL; 228 return -EINVAL;
228 229
229 lnum = instr->addr / mtd->erasesize; 230 lnum = mtd_div_by_eb(instr->addr, mtd);
230 count = instr->len / mtd->erasesize; 231 count = mtd_div_by_eb(instr->len, mtd);
231 232
232 vol = container_of(mtd, struct ubi_volume, gluebi_mtd); 233 vol = container_of(mtd, struct ubi_volume, gluebi_mtd);
233 ubi = vol->ubi; 234 ubi = vol->ubi;
@@ -255,7 +256,7 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)
255 256
256out_err: 257out_err:
257 instr->state = MTD_ERASE_FAILED; 258 instr->state = MTD_ERASE_FAILED;
258 instr->fail_addr = lnum * mtd->erasesize; 259 instr->fail_addr = (long long)lnum * mtd->erasesize;
259 return err; 260 return err;
260} 261}
261 262
@@ -294,7 +295,7 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol)
294 * bytes. 295 * bytes.
295 */ 296 */
296 if (vol->vol_type == UBI_DYNAMIC_VOLUME) 297 if (vol->vol_type == UBI_DYNAMIC_VOLUME)
297 mtd->size = vol->usable_leb_size * vol->reserved_pebs; 298 mtd->size = (long long)vol->usable_leb_size * vol->reserved_pebs;
298 else 299 else
299 mtd->size = vol->used_bytes; 300 mtd->size = vol->used_bytes;
300 301
@@ -304,8 +305,8 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol)
304 return -ENFILE; 305 return -ENFILE;
305 } 306 }
306 307
307 dbg_gen("added mtd%d (\"%s\"), size %u, EB size %u", 308 dbg_gen("added mtd%d (\"%s\"), size %llu, EB size %u",
308 mtd->index, mtd->name, mtd->size, mtd->erasesize); 309 mtd->index, mtd->name, (unsigned long long)mtd->size, mtd->erasesize);
309 return 0; 310 return 0;
310} 311}
311 312