mtdpart.c (5def48982b778aaebe201f85af7170b7d0a6619f) mtdpart.c (664addc248d2fed68d013d26ff2fc796d7134259)
1/*
2 * Simple MTD partitioning layer
3 *
4 * Copyright © 2000 Nicolas Pitre <nico@fluxnic.net>
5 * Copyright © 2002 Thomas Gleixner <gleixner@linutronix.de>
6 * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org>
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 158 unchanged lines hidden (view full) ---

167 struct mtd_part *part = PART(mtd);
168 return mtd_get_fact_prot_info(part->master, buf, len);
169}
170
171static int part_write(struct mtd_info *mtd, loff_t to, size_t len,
172 size_t *retlen, const u_char *buf)
173{
174 struct mtd_part *part = PART(mtd);
1/*
2 * Simple MTD partitioning layer
3 *
4 * Copyright © 2000 Nicolas Pitre <nico@fluxnic.net>
5 * Copyright © 2002 Thomas Gleixner <gleixner@linutronix.de>
6 * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org>
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 158 unchanged lines hidden (view full) ---

167 struct mtd_part *part = PART(mtd);
168 return mtd_get_fact_prot_info(part->master, buf, len);
169}
170
171static int part_write(struct mtd_info *mtd, loff_t to, size_t len,
172 size_t *retlen, const u_char *buf)
173{
174 struct mtd_part *part = PART(mtd);
175 if (!(mtd->flags & MTD_WRITEABLE))
176 return -EROFS;
177 return mtd_write(part->master, to + part->offset, len, retlen, buf);
178}
179
180static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
181 size_t *retlen, const u_char *buf)
182{
183 struct mtd_part *part = PART(mtd);
175 return mtd_write(part->master, to + part->offset, len, retlen, buf);
176}
177
178static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
179 size_t *retlen, const u_char *buf)
180{
181 struct mtd_part *part = PART(mtd);
184 if (!(mtd->flags & MTD_WRITEABLE))
185 return -EROFS;
186 return mtd_panic_write(part->master, to + part->offset, len, retlen,
187 buf);
188}
189
190static int part_write_oob(struct mtd_info *mtd, loff_t to,
191 struct mtd_oob_ops *ops)
192{
193 struct mtd_part *part = PART(mtd);
194
182 return mtd_panic_write(part->master, to + part->offset, len, retlen,
183 buf);
184}
185
186static int part_write_oob(struct mtd_info *mtd, loff_t to,
187 struct mtd_oob_ops *ops)
188{
189 struct mtd_part *part = PART(mtd);
190
195 if (!(mtd->flags & MTD_WRITEABLE))
196 return -EROFS;
197
198 if (to >= mtd->size)
199 return -EINVAL;
200 if (ops->datbuf && to + ops->len > mtd->size)
201 return -EINVAL;
202 return mtd_write_oob(part->master, to + part->offset, ops);
203}
204
205static int part_write_user_prot_reg(struct mtd_info *mtd, loff_t from,

--- 9 unchanged lines hidden (view full) ---

215 struct mtd_part *part = PART(mtd);
216 return mtd_lock_user_prot_reg(part->master, from, len);
217}
218
219static int part_writev(struct mtd_info *mtd, const struct kvec *vecs,
220 unsigned long count, loff_t to, size_t *retlen)
221{
222 struct mtd_part *part = PART(mtd);
191 if (to >= mtd->size)
192 return -EINVAL;
193 if (ops->datbuf && to + ops->len > mtd->size)
194 return -EINVAL;
195 return mtd_write_oob(part->master, to + part->offset, ops);
196}
197
198static int part_write_user_prot_reg(struct mtd_info *mtd, loff_t from,

--- 9 unchanged lines hidden (view full) ---

208 struct mtd_part *part = PART(mtd);
209 return mtd_lock_user_prot_reg(part->master, from, len);
210}
211
212static int part_writev(struct mtd_info *mtd, const struct kvec *vecs,
213 unsigned long count, loff_t to, size_t *retlen)
214{
215 struct mtd_part *part = PART(mtd);
223 if (!(mtd->flags & MTD_WRITEABLE))
224 return -EROFS;
225 return mtd_writev(part->master, vecs, count, to + part->offset,
226 retlen);
227}
228
229static int part_erase(struct mtd_info *mtd, struct erase_info *instr)
230{
231 struct mtd_part *part = PART(mtd);
232 int ret;
216 return mtd_writev(part->master, vecs, count, to + part->offset,
217 retlen);
218}
219
220static int part_erase(struct mtd_info *mtd, struct erase_info *instr)
221{
222 struct mtd_part *part = PART(mtd);
223 int ret;
233 if (!(mtd->flags & MTD_WRITEABLE))
234 return -EROFS;
224
235 instr->addr += part->offset;
236 ret = mtd_erase(part->master, instr);
237 if (ret) {
238 if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
239 instr->fail_addr -= part->offset;
240 instr->addr -= part->offset;
241 }
242 return ret;

--- 56 unchanged lines hidden (view full) ---

299 return mtd_block_isbad(part->master, ofs);
300}
301
302static int part_block_markbad(struct mtd_info *mtd, loff_t ofs)
303{
304 struct mtd_part *part = PART(mtd);
305 int res;
306
225 instr->addr += part->offset;
226 ret = mtd_erase(part->master, instr);
227 if (ret) {
228 if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
229 instr->fail_addr -= part->offset;
230 instr->addr -= part->offset;
231 }
232 return ret;

--- 56 unchanged lines hidden (view full) ---

289 return mtd_block_isbad(part->master, ofs);
290}
291
292static int part_block_markbad(struct mtd_info *mtd, loff_t ofs)
293{
294 struct mtd_part *part = PART(mtd);
295 int res;
296
307 if (!(mtd->flags & MTD_WRITEABLE))
308 return -EROFS;
309 ofs += part->offset;
310 res = mtd_block_markbad(part->master, ofs);
311 if (!res)
312 mtd->ecc_stats.badblocks++;
313 return res;
314}
315
316static inline void free_partition(struct mtd_part *p)

--- 449 unchanged lines hidden ---
297 ofs += part->offset;
298 res = mtd_block_markbad(part->master, ofs);
299 if (!res)
300 mtd->ecc_stats.badblocks++;
301 return res;
302}
303
304static inline void free_partition(struct mtd_part *p)

--- 449 unchanged lines hidden ---