blob: a3d44c3416b4f2bef8a1932976b2825a1e230609 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Simple MTD partitioning layer
3 *
David Woodhousea1452a32010-08-08 20:58:20 +01004 * Copyright © 2000 Nicolas Pitre <nico@fluxnic.net>
5 * Copyright © 2002 Thomas Gleixner <gleixner@linutronix.de>
6 * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
David Woodhousea1452a32010-08-08 20:58:20 +01008 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 *
David Woodhousea1452a32010-08-08 20:58:20 +010013 * 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.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 *
Thomas Gleixner97894cd2005-11-07 11:15:26 +000022 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24#include <linux/module.h>
25#include <linux/types.h>
26#include <linux/kernel.h>
27#include <linux/slab.h>
28#include <linux/list.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/kmod.h>
30#include <linux/mtd/mtd.h>
31#include <linux/mtd/partitions.h>
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +030032#include <linux/err.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Jamie Ileseea72d52011-05-23 10:23:42 +010034#include "mtdcore.h"
35
Linus Torvalds1da177e2005-04-16 15:20:36 -070036/* Our partition linked list */
37static LIST_HEAD(mtd_partitions);
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +030038static DEFINE_MUTEX(mtd_partitions_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* Our partition node structure */
41struct mtd_part {
42 struct mtd_info mtd;
43 struct mtd_info *master;
Adrian Hunter69423d92008-12-10 13:37:21 +000044 uint64_t offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 struct list_head list;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046};
47
48/*
49 * Given a pointer to the MTD object in the mtd_part structure, we can retrieve
50 * the pointer to that structure with this macro.
51 */
52#define PART(x) ((struct mtd_part *)(x))
53
Thomas Gleixner97894cd2005-11-07 11:15:26 +000054
55/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 * MTD methods which simply translate the effective address and pass through
57 * to the _real_ device.
58 */
59
Atsushi Nemotob33a2882008-07-19 01:00:33 +090060static int part_read(struct mtd_info *mtd, loff_t from, size_t len,
61 size_t *retlen, u_char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062{
63 struct mtd_part *part = PART(mtd);
Yauhen Kharuzhyd8877f12009-03-27 00:41:09 +020064 struct mtd_ecc_stats stats;
Thomas Gleixnerf1a28c02006-05-30 00:37:34 +020065 int res;
66
Yauhen Kharuzhyd8877f12009-03-27 00:41:09 +020067 stats = part->master->ecc_stats;
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 if (from >= mtd->size)
70 len = 0;
71 else if (from + len > mtd->size)
72 len = mtd->size - from;
Artem Bityutskiy329ad392011-12-23 17:30:16 +020073 res = mtd_read(part->master, from + part->offset, len, retlen, buf);
Thomas Gleixnerf1a28c02006-05-30 00:37:34 +020074 if (unlikely(res)) {
Brian Norrisd57f40542011-09-20 18:34:25 -070075 if (mtd_is_bitflip(res))
Yauhen Kharuzhyd8877f12009-03-27 00:41:09 +020076 mtd->ecc_stats.corrected += part->master->ecc_stats.corrected - stats.corrected;
Brian Norrisd57f40542011-09-20 18:34:25 -070077 if (mtd_is_eccerr(res))
Yauhen Kharuzhyd8877f12009-03-27 00:41:09 +020078 mtd->ecc_stats.failed += part->master->ecc_stats.failed - stats.failed;
Thomas Gleixnerf1a28c02006-05-30 00:37:34 +020079 }
80 return res;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081}
82
Atsushi Nemotob33a2882008-07-19 01:00:33 +090083static int part_point(struct mtd_info *mtd, loff_t from, size_t len,
84 size_t *retlen, void **virt, resource_size_t *phys)
Linus Torvalds1da177e2005-04-16 15:20:36 -070085{
86 struct mtd_part *part = PART(mtd);
87 if (from >= mtd->size)
88 len = 0;
89 else if (from + len > mtd->size)
90 len = mtd->size - from;
Artem Bityutskiyd35ea202011-12-23 17:00:37 +020091 return mtd_point(part->master, from + part->offset, len, retlen,
92 virt, phys);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
Thomas Gleixner9223a452006-05-23 17:21:03 +020094
Jared Hulberta98889f2008-04-29 23:26:49 -070095static void part_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
97 struct mtd_part *part = PART(mtd);
98
Artem Bityutskiy72197782011-12-23 17:05:52 +020099 mtd_unpoint(part->master, from + part->offset, len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100}
101
David Howells402d3262009-02-12 10:40:00 +0000102static unsigned long part_get_unmapped_area(struct mtd_info *mtd,
103 unsigned long len,
104 unsigned long offset,
105 unsigned long flags)
106{
107 struct mtd_part *part = PART(mtd);
108
109 offset += part->offset;
Artem Bityutskiy04c601b2011-12-23 17:10:15 +0200110 return mtd_get_unmapped_area(part->master, len, offset, flags);
David Howells402d3262009-02-12 10:40:00 +0000111}
112
Thomas Gleixner8593fbc2006-05-29 03:26:58 +0200113static int part_read_oob(struct mtd_info *mtd, loff_t from,
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900114 struct mtd_oob_ops *ops)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115{
116 struct mtd_part *part = PART(mtd);
Thomas Gleixnerf1a28c02006-05-30 00:37:34 +0200117 int res;
Thomas Gleixner8593fbc2006-05-29 03:26:58 +0200118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 if (from >= mtd->size)
Thomas Gleixner8593fbc2006-05-29 03:26:58 +0200120 return -EINVAL;
Vitaly Wool70145682006-11-03 18:20:38 +0300121 if (ops->datbuf && from + ops->len > mtd->size)
Thomas Gleixner8593fbc2006-05-29 03:26:58 +0200122 return -EINVAL;
Thomas Gleixnerf1a28c02006-05-30 00:37:34 +0200123
Artem Bityutskiy154bf892011-01-16 17:50:54 +0200124 /*
125 * If OOB is also requested, make sure that we do not read past the end
126 * of this partition.
127 */
128 if (ops->oobbuf) {
129 size_t len, pages;
130
Brian Norris0612b9d2011-08-30 18:45:40 -0700131 if (ops->mode == MTD_OPS_AUTO_OOB)
Artem Bityutskiy154bf892011-01-16 17:50:54 +0200132 len = mtd->oobavail;
133 else
134 len = mtd->oobsize;
135 pages = mtd_div_by_ws(mtd->size, mtd);
136 pages -= mtd_div_by_ws(from, mtd);
137 if (ops->ooboffs + ops->ooblen > pages * len)
138 return -EINVAL;
139 }
140
Artem Bityutskiyfd2819b2011-12-23 18:27:05 +0200141 res = mtd_read_oob(part->master, from + part->offset, ops);
Thomas Gleixnerf1a28c02006-05-30 00:37:34 +0200142 if (unlikely(res)) {
Brian Norrisd57f40542011-09-20 18:34:25 -0700143 if (mtd_is_bitflip(res))
Thomas Gleixnerf1a28c02006-05-30 00:37:34 +0200144 mtd->ecc_stats.corrected++;
Brian Norrisd57f40542011-09-20 18:34:25 -0700145 if (mtd_is_eccerr(res))
Thomas Gleixnerf1a28c02006-05-30 00:37:34 +0200146 mtd->ecc_stats.failed++;
147 }
148 return res;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149}
150
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900151static int part_read_user_prot_reg(struct mtd_info *mtd, loff_t from,
152 size_t len, size_t *retlen, u_char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153{
154 struct mtd_part *part = PART(mtd);
Artem Bityutskiy4ea1cab2011-12-23 18:47:59 +0200155 return mtd_read_user_prot_reg(part->master, from, len, retlen, buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156}
157
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900158static int part_get_user_prot_info(struct mtd_info *mtd,
159 struct otp_info *buf, size_t len)
Nicolas Pitref77814d2005-02-08 17:11:19 +0000160{
161 struct mtd_part *part = PART(mtd);
Artem Bityutskiy855e5d82011-12-23 18:45:11 +0200162 return mtd_get_user_prot_info(part->master, buf, len);
Nicolas Pitref77814d2005-02-08 17:11:19 +0000163}
164
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900165static int part_read_fact_prot_reg(struct mtd_info *mtd, loff_t from,
166 size_t len, size_t *retlen, u_char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167{
168 struct mtd_part *part = PART(mtd);
Artem Bityutskiyd264f722011-12-23 18:40:06 +0200169 return mtd_read_fact_prot_reg(part->master, from, len, retlen, buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170}
171
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900172static int part_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf,
173 size_t len)
Nicolas Pitref77814d2005-02-08 17:11:19 +0000174{
175 struct mtd_part *part = PART(mtd);
Artem Bityutskiya750b5c2011-12-23 18:33:28 +0200176 return mtd_get_fact_prot_info(part->master, buf, len);
Nicolas Pitref77814d2005-02-08 17:11:19 +0000177}
178
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900179static int part_write(struct mtd_info *mtd, loff_t to, size_t len,
180 size_t *retlen, const u_char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181{
182 struct mtd_part *part = PART(mtd);
183 if (!(mtd->flags & MTD_WRITEABLE))
184 return -EROFS;
185 if (to >= mtd->size)
186 len = 0;
187 else if (to + len > mtd->size)
188 len = mtd->size - to;
Artem Bityutskiyeda95cb2011-12-23 17:35:41 +0200189 return mtd_write(part->master, to + part->offset, len, retlen, buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190}
191
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900192static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
193 size_t *retlen, const u_char *buf)
Richard Purdie388bbb02008-02-06 10:17:15 +0000194{
195 struct mtd_part *part = PART(mtd);
196 if (!(mtd->flags & MTD_WRITEABLE))
197 return -EROFS;
198 if (to >= mtd->size)
199 len = 0;
200 else if (to + len > mtd->size)
201 len = mtd->size - to;
Artem Bityutskiy7ae79d72011-12-23 18:03:17 +0200202 return mtd_panic_write(part->master, to + part->offset, len, retlen,
203 buf);
Richard Purdie388bbb02008-02-06 10:17:15 +0000204}
205
Thomas Gleixner8593fbc2006-05-29 03:26:58 +0200206static int part_write_oob(struct mtd_info *mtd, loff_t to,
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900207 struct mtd_oob_ops *ops)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208{
209 struct mtd_part *part = PART(mtd);
Thomas Gleixner8593fbc2006-05-29 03:26:58 +0200210
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 if (!(mtd->flags & MTD_WRITEABLE))
212 return -EROFS;
Thomas Gleixner8593fbc2006-05-29 03:26:58 +0200213
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 if (to >= mtd->size)
Thomas Gleixner8593fbc2006-05-29 03:26:58 +0200215 return -EINVAL;
Vitaly Wool70145682006-11-03 18:20:38 +0300216 if (ops->datbuf && to + ops->len > mtd->size)
Thomas Gleixner8593fbc2006-05-29 03:26:58 +0200217 return -EINVAL;
Artem Bityutskiya2cc5ba2011-12-23 18:29:55 +0200218 return mtd_write_oob(part->master, to + part->offset, ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219}
220
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900221static int part_write_user_prot_reg(struct mtd_info *mtd, loff_t from,
222 size_t len, size_t *retlen, u_char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223{
224 struct mtd_part *part = PART(mtd);
Artem Bityutskiy482b43a2011-12-23 18:50:04 +0200225 return mtd_write_user_prot_reg(part->master, from, len, retlen, buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226}
227
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900228static int part_lock_user_prot_reg(struct mtd_info *mtd, loff_t from,
229 size_t len)
Nicolas Pitref77814d2005-02-08 17:11:19 +0000230{
231 struct mtd_part *part = PART(mtd);
Artem Bityutskiy4403dbfb2011-12-23 18:55:49 +0200232 return mtd_lock_user_prot_reg(part->master, from, len);
Nicolas Pitref77814d2005-02-08 17:11:19 +0000233}
234
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900235static int part_writev(struct mtd_info *mtd, const struct kvec *vecs,
236 unsigned long count, loff_t to, size_t *retlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237{
238 struct mtd_part *part = PART(mtd);
239 if (!(mtd->flags & MTD_WRITEABLE))
240 return -EROFS;
Artem Bityutskiyb0a31f72011-12-23 18:59:12 +0200241 return mtd_writev(part->master, vecs, count, to + part->offset,
242 retlen);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243}
244
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900245static int part_erase(struct mtd_info *mtd, struct erase_info *instr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246{
247 struct mtd_part *part = PART(mtd);
248 int ret;
249 if (!(mtd->flags & MTD_WRITEABLE))
250 return -EROFS;
251 if (instr->addr >= mtd->size)
252 return -EINVAL;
253 instr->addr += part->offset;
Artem Bityutskiy7e1f0dc2011-12-23 15:25:39 +0200254 ret = mtd_erase(part->master, instr);
Adrian Hunter74641d72007-03-08 12:20:12 +0200255 if (ret) {
Adrian Hunterbb0eb212008-08-12 12:40:50 +0300256 if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
Adrian Hunter74641d72007-03-08 12:20:12 +0200257 instr->fail_addr -= part->offset;
258 instr->addr -= part->offset;
259 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 return ret;
261}
262
263void mtd_erase_callback(struct erase_info *instr)
264{
265 if (instr->mtd->erase == part_erase) {
266 struct mtd_part *part = PART(instr->mtd);
267
Adrian Hunterbb0eb212008-08-12 12:40:50 +0300268 if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 instr->fail_addr -= part->offset;
270 instr->addr -= part->offset;
271 }
272 if (instr->callback)
273 instr->callback(instr);
274}
275EXPORT_SYMBOL_GPL(mtd_erase_callback);
276
Adrian Hunter69423d92008-12-10 13:37:21 +0000277static int part_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278{
279 struct mtd_part *part = PART(mtd);
Thomas Gleixner97894cd2005-11-07 11:15:26 +0000280 if ((len + ofs) > mtd->size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 return -EINVAL;
Artem Bityutskiy7799f9a2011-12-23 19:15:39 +0200282 return mtd_lock(part->master, ofs + part->offset, len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283}
284
Adrian Hunter69423d92008-12-10 13:37:21 +0000285static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286{
287 struct mtd_part *part = PART(mtd);
Thomas Gleixner97894cd2005-11-07 11:15:26 +0000288 if ((len + ofs) > mtd->size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 return -EINVAL;
Artem Bityutskiyb66005c2011-12-23 19:18:22 +0200290 return mtd_unlock(part->master, ofs + part->offset, len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291}
292
Richard Cochran99384242010-06-14 18:10:33 +0200293static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
294{
295 struct mtd_part *part = PART(mtd);
296 if ((len + ofs) > mtd->size)
297 return -EINVAL;
Artem Bityutskiye95e9782011-12-23 19:21:16 +0200298 return mtd_is_locked(part->master, ofs + part->offset, len);
Richard Cochran99384242010-06-14 18:10:33 +0200299}
300
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301static void part_sync(struct mtd_info *mtd)
302{
303 struct mtd_part *part = PART(mtd);
Artem Bityutskiy85f2f2a2011-12-23 19:03:12 +0200304 mtd_sync(part->master);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305}
306
307static int part_suspend(struct mtd_info *mtd)
308{
309 struct mtd_part *part = PART(mtd);
Artem Bityutskiy3fe4bae2011-12-23 19:25:16 +0200310 return mtd_suspend(part->master);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311}
312
313static void part_resume(struct mtd_info *mtd)
314{
315 struct mtd_part *part = PART(mtd);
Artem Bityutskiyead995f2011-12-23 19:31:25 +0200316 mtd_resume(part->master);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317}
318
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900319static int part_block_isbad(struct mtd_info *mtd, loff_t ofs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320{
321 struct mtd_part *part = PART(mtd);
322 if (ofs >= mtd->size)
323 return -EINVAL;
324 ofs += part->offset;
Artem Bityutskiy7086c192011-12-23 19:35:30 +0200325 return mtd_block_isbad(part->master, ofs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326}
327
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900328static int part_block_markbad(struct mtd_info *mtd, loff_t ofs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329{
330 struct mtd_part *part = PART(mtd);
Thomas Gleixnerf1a28c02006-05-30 00:37:34 +0200331 int res;
332
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 if (!(mtd->flags & MTD_WRITEABLE))
334 return -EROFS;
335 if (ofs >= mtd->size)
336 return -EINVAL;
337 ofs += part->offset;
Artem Bityutskiy5942ddb2011-12-23 19:37:38 +0200338 res = mtd_block_markbad(part->master, ofs);
Thomas Gleixnerf1a28c02006-05-30 00:37:34 +0200339 if (!res)
340 mtd->ecc_stats.badblocks++;
341 return res;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342}
343
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300344static inline void free_partition(struct mtd_part *p)
345{
346 kfree(p->mtd.name);
347 kfree(p);
348}
349
Thomas Gleixner97894cd2005-11-07 11:15:26 +0000350/*
351 * This function unregisters and destroy all slave MTD objects which are
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 * attached to the given master MTD object.
353 */
354
355int del_mtd_partitions(struct mtd_info *master)
356{
Chris Malley71a928c2008-05-19 20:11:50 +0100357 struct mtd_part *slave, *next;
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300358 int ret, err = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300360 mutex_lock(&mtd_partitions_mutex);
Chris Malley71a928c2008-05-19 20:11:50 +0100361 list_for_each_entry_safe(slave, next, &mtd_partitions, list)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 if (slave->master == master) {
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300363 ret = del_mtd_device(&slave->mtd);
364 if (ret < 0) {
365 err = ret;
366 continue;
367 }
Chris Malley71a928c2008-05-19 20:11:50 +0100368 list_del(&slave->list);
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300369 free_partition(slave);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 }
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300371 mutex_unlock(&mtd_partitions_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300373 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374}
375
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300376static struct mtd_part *allocate_partition(struct mtd_info *master,
377 const struct mtd_partition *part, int partno,
378 uint64_t cur_offset)
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900379{
380 struct mtd_part *slave;
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300381 char *name;
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900382
383 /* allocate the partition structure */
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900384 slave = kzalloc(sizeof(*slave), GFP_KERNEL);
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300385 name = kstrdup(part->name, GFP_KERNEL);
386 if (!name || !slave) {
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900387 printk(KERN_ERR"memory allocation error while creating partitions for \"%s\"\n",
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300388 master->name);
389 kfree(name);
390 kfree(slave);
391 return ERR_PTR(-ENOMEM);
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900392 }
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900393
394 /* set up the MTD object for this partition */
395 slave->mtd.type = master->type;
396 slave->mtd.flags = master->flags & ~part->mask_flags;
397 slave->mtd.size = part->size;
398 slave->mtd.writesize = master->writesize;
Anatolij Gustschin7fa33ac2010-12-16 23:42:18 +0100399 slave->mtd.writebufsize = master->writebufsize;
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900400 slave->mtd.oobsize = master->oobsize;
401 slave->mtd.oobavail = master->oobavail;
402 slave->mtd.subpage_sft = master->subpage_sft;
403
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300404 slave->mtd.name = name;
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900405 slave->mtd.owner = master->owner;
David Howells402d3262009-02-12 10:40:00 +0000406 slave->mtd.backing_dev_info = master->backing_dev_info;
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900407
David Brownell1f24b5a2009-03-26 00:42:41 -0700408 /* NOTE: we don't arrange MTDs as a tree; it'd be error-prone
409 * to have the same data be in two different partitions.
410 */
411 slave->mtd.dev.parent = master->dev.parent;
412
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900413 slave->mtd.read = part_read;
414 slave->mtd.write = part_write;
415
416 if (master->panic_write)
417 slave->mtd.panic_write = part_panic_write;
418
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900419 if (master->point && master->unpoint) {
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900420 slave->mtd.point = part_point;
421 slave->mtd.unpoint = part_unpoint;
422 }
423
David Howells402d3262009-02-12 10:40:00 +0000424 if (master->get_unmapped_area)
425 slave->mtd.get_unmapped_area = part_get_unmapped_area;
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900426 if (master->read_oob)
427 slave->mtd.read_oob = part_read_oob;
428 if (master->write_oob)
429 slave->mtd.write_oob = part_write_oob;
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900430 if (master->read_user_prot_reg)
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900431 slave->mtd.read_user_prot_reg = part_read_user_prot_reg;
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900432 if (master->read_fact_prot_reg)
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900433 slave->mtd.read_fact_prot_reg = part_read_fact_prot_reg;
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900434 if (master->write_user_prot_reg)
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900435 slave->mtd.write_user_prot_reg = part_write_user_prot_reg;
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900436 if (master->lock_user_prot_reg)
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900437 slave->mtd.lock_user_prot_reg = part_lock_user_prot_reg;
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900438 if (master->get_user_prot_info)
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900439 slave->mtd.get_user_prot_info = part_get_user_prot_info;
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900440 if (master->get_fact_prot_info)
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900441 slave->mtd.get_fact_prot_info = part_get_fact_prot_info;
442 if (master->sync)
443 slave->mtd.sync = part_sync;
David Woodhouse4704a782009-04-05 07:56:23 -0700444 if (!partno && !master->dev.class && master->suspend && master->resume) {
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900445 slave->mtd.suspend = part_suspend;
446 slave->mtd.resume = part_resume;
447 }
448 if (master->writev)
449 slave->mtd.writev = part_writev;
450 if (master->lock)
451 slave->mtd.lock = part_lock;
452 if (master->unlock)
453 slave->mtd.unlock = part_unlock;
Richard Cochran99384242010-06-14 18:10:33 +0200454 if (master->is_locked)
455 slave->mtd.is_locked = part_is_locked;
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900456 if (master->block_isbad)
457 slave->mtd.block_isbad = part_block_isbad;
458 if (master->block_markbad)
459 slave->mtd.block_markbad = part_block_markbad;
460 slave->mtd.erase = part_erase;
461 slave->master = master;
462 slave->offset = part->offset;
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900463
464 if (slave->offset == MTDPART_OFS_APPEND)
465 slave->offset = cur_offset;
466 if (slave->offset == MTDPART_OFS_NXTBLK) {
467 slave->offset = cur_offset;
Adrian Hunter69423d92008-12-10 13:37:21 +0000468 if (mtd_mod_by_eb(cur_offset, master) != 0) {
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900469 /* Round up to next erasesize */
Adrian Hunter69423d92008-12-10 13:37:21 +0000470 slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize;
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900471 printk(KERN_NOTICE "Moving partition %d: "
Adrian Hunter69423d92008-12-10 13:37:21 +0000472 "0x%012llx -> 0x%012llx\n", partno,
473 (unsigned long long)cur_offset, (unsigned long long)slave->offset);
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900474 }
475 }
Dmitry Eremin-Solenikov1a313682011-06-06 18:04:14 +0400476 if (slave->offset == MTDPART_OFS_RETAIN) {
477 slave->offset = cur_offset;
478 if (master->size - slave->offset >= slave->mtd.size) {
479 slave->mtd.size = master->size - slave->offset
480 - slave->mtd.size;
481 } else {
482 printk(KERN_ERR "mtd partition \"%s\" doesn't have enough space: %#llx < %#llx, disabled\n",
483 part->name, master->size - slave->offset,
484 slave->mtd.size);
485 /* register to preserve ordering */
486 goto out_register;
487 }
488 }
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900489 if (slave->mtd.size == MTDPART_SIZ_FULL)
490 slave->mtd.size = master->size - slave->offset;
491
Adrian Hunter69423d92008-12-10 13:37:21 +0000492 printk(KERN_NOTICE "0x%012llx-0x%012llx : \"%s\"\n", (unsigned long long)slave->offset,
493 (unsigned long long)(slave->offset + slave->mtd.size), slave->mtd.name);
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900494
495 /* let's do some sanity checks */
496 if (slave->offset >= master->size) {
Atsushi Nemotof636ffb2008-07-19 01:01:22 +0900497 /* let's register it anyway to preserve ordering */
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900498 slave->offset = 0;
499 slave->mtd.size = 0;
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900500 printk(KERN_ERR"mtd: partition \"%s\" is out of reach -- disabled\n",
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900501 part->name);
Atsushi Nemotof636ffb2008-07-19 01:01:22 +0900502 goto out_register;
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900503 }
504 if (slave->offset + slave->mtd.size > master->size) {
505 slave->mtd.size = master->size - slave->offset;
Adrian Hunter69423d92008-12-10 13:37:21 +0000506 printk(KERN_WARNING"mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#llx\n",
507 part->name, master->name, (unsigned long long)slave->mtd.size);
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900508 }
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900509 if (master->numeraseregions > 1) {
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900510 /* Deal with variable erase size stuff */
Atsushi Nemoto6910c132008-07-19 01:00:57 +0900511 int i, max = master->numeraseregions;
Adrian Hunter69423d92008-12-10 13:37:21 +0000512 u64 end = slave->offset + slave->mtd.size;
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900513 struct mtd_erase_region_info *regions = master->eraseregions;
514
Atsushi Nemoto6910c132008-07-19 01:00:57 +0900515 /* Find the first erase regions which is part of this
516 * partition. */
517 for (i = 0; i < max && regions[i].offset <= slave->offset; i++)
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900518 ;
Atsushi Nemoto6910c132008-07-19 01:00:57 +0900519 /* The loop searched for the region _behind_ the first one */
Roel Kluina57ca042009-09-18 12:51:50 -0700520 if (i > 0)
521 i--;
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900522
Atsushi Nemoto6910c132008-07-19 01:00:57 +0900523 /* Pick biggest erasesize */
524 for (; i < max && regions[i].offset < end; i++) {
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900525 if (slave->mtd.erasesize < regions[i].erasesize) {
526 slave->mtd.erasesize = regions[i].erasesize;
527 }
528 }
Atsushi Nemoto6910c132008-07-19 01:00:57 +0900529 BUG_ON(slave->mtd.erasesize == 0);
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900530 } else {
531 /* Single erase size */
532 slave->mtd.erasesize = master->erasesize;
533 }
534
535 if ((slave->mtd.flags & MTD_WRITEABLE) &&
Adrian Hunter69423d92008-12-10 13:37:21 +0000536 mtd_mod_by_eb(slave->offset, &slave->mtd)) {
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900537 /* Doesn't start on a boundary of major erase size */
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900538 /* FIXME: Let it be writable if it is on a boundary of
539 * _minor_ erase size though */
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900540 slave->mtd.flags &= ~MTD_WRITEABLE;
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900541 printk(KERN_WARNING"mtd: partition \"%s\" doesn't start on an erase block boundary -- force read-only\n",
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900542 part->name);
543 }
544 if ((slave->mtd.flags & MTD_WRITEABLE) &&
Adrian Hunter69423d92008-12-10 13:37:21 +0000545 mtd_mod_by_eb(slave->mtd.size, &slave->mtd)) {
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900546 slave->mtd.flags &= ~MTD_WRITEABLE;
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900547 printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n",
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900548 part->name);
549 }
550
551 slave->mtd.ecclayout = master->ecclayout;
552 if (master->block_isbad) {
Adrian Hunter69423d92008-12-10 13:37:21 +0000553 uint64_t offs = 0;
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900554
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900555 while (offs < slave->mtd.size) {
Artem Bityutskiy7086c192011-12-23 19:35:30 +0200556 if (mtd_block_isbad(master, offs + slave->offset))
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900557 slave->mtd.ecc_stats.badblocks++;
558 offs += slave->mtd.erasesize;
559 }
560 }
561
Atsushi Nemotof636ffb2008-07-19 01:01:22 +0900562out_register:
Atsushi Nemoto7788ba72008-07-19 01:00:18 +0900563 return slave;
564}
565
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300566int mtd_add_partition(struct mtd_info *master, char *name,
567 long long offset, long long length)
568{
569 struct mtd_partition part;
570 struct mtd_part *p, *new;
571 uint64_t start, end;
572 int ret = 0;
573
574 /* the direct offset is expected */
575 if (offset == MTDPART_OFS_APPEND ||
576 offset == MTDPART_OFS_NXTBLK)
577 return -EINVAL;
578
579 if (length == MTDPART_SIZ_FULL)
580 length = master->size - offset;
581
582 if (length <= 0)
583 return -EINVAL;
584
585 part.name = name;
586 part.size = length;
587 part.offset = offset;
588 part.mask_flags = 0;
589 part.ecclayout = NULL;
590
591 new = allocate_partition(master, &part, -1, offset);
592 if (IS_ERR(new))
593 return PTR_ERR(new);
594
595 start = offset;
596 end = offset + length;
597
598 mutex_lock(&mtd_partitions_mutex);
599 list_for_each_entry(p, &mtd_partitions, list)
600 if (p->master == master) {
601 if ((start >= p->offset) &&
602 (start < (p->offset + p->mtd.size)))
603 goto err_inv;
604
605 if ((end >= p->offset) &&
606 (end < (p->offset + p->mtd.size)))
607 goto err_inv;
608 }
609
610 list_add(&new->list, &mtd_partitions);
611 mutex_unlock(&mtd_partitions_mutex);
612
613 add_mtd_device(&new->mtd);
614
615 return ret;
616err_inv:
617 mutex_unlock(&mtd_partitions_mutex);
618 free_partition(new);
619 return -EINVAL;
620}
621EXPORT_SYMBOL_GPL(mtd_add_partition);
622
623int mtd_del_partition(struct mtd_info *master, int partno)
624{
625 struct mtd_part *slave, *next;
626 int ret = -EINVAL;
627
628 mutex_lock(&mtd_partitions_mutex);
629 list_for_each_entry_safe(slave, next, &mtd_partitions, list)
630 if ((slave->master == master) &&
631 (slave->mtd.index == partno)) {
632 ret = del_mtd_device(&slave->mtd);
633 if (ret < 0)
634 break;
635
636 list_del(&slave->list);
637 free_partition(slave);
638 break;
639 }
640 mutex_unlock(&mtd_partitions_mutex);
641
642 return ret;
643}
644EXPORT_SYMBOL_GPL(mtd_del_partition);
645
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646/*
647 * This function, given a master MTD object and a partition table, creates
648 * and registers slave MTD objects which are bound to the master according to
649 * the partition definitions.
David Brownell1f24b5a2009-03-26 00:42:41 -0700650 *
651 * We don't register the master, or expect the caller to have done so,
652 * for reasons of data integrity.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 */
654
Thomas Gleixner97894cd2005-11-07 11:15:26 +0000655int add_mtd_partitions(struct mtd_info *master,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 const struct mtd_partition *parts,
657 int nbparts)
658{
659 struct mtd_part *slave;
Adrian Hunter69423d92008-12-10 13:37:21 +0000660 uint64_t cur_offset = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 int i;
662
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900663 printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664
665 for (i = 0; i < nbparts; i++) {
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300666 slave = allocate_partition(master, parts + i, i, cur_offset);
667 if (IS_ERR(slave))
668 return PTR_ERR(slave);
669
670 mutex_lock(&mtd_partitions_mutex);
671 list_add(&slave->list, &mtd_partitions);
672 mutex_unlock(&mtd_partitions_mutex);
673
674 add_mtd_device(&slave->mtd);
675
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 cur_offset = slave->offset + slave->mtd.size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 }
678
679 return 0;
680}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681
682static DEFINE_SPINLOCK(part_parser_lock);
683static LIST_HEAD(part_parsers);
684
685static struct mtd_part_parser *get_partition_parser(const char *name)
686{
Chris Malley71a928c2008-05-19 20:11:50 +0100687 struct mtd_part_parser *p, *ret = NULL;
688
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 spin_lock(&part_parser_lock);
690
Chris Malley71a928c2008-05-19 20:11:50 +0100691 list_for_each_entry(p, &part_parsers, list)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 if (!strcmp(p->name, name) && try_module_get(p->owner)) {
693 ret = p;
694 break;
695 }
Chris Malley71a928c2008-05-19 20:11:50 +0100696
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 spin_unlock(&part_parser_lock);
698
699 return ret;
700}
701
Dmitry Eremin-Solenikov953b3bd2011-06-23 15:26:14 +0400702#define put_partition_parser(p) do { module_put((p)->owner); } while (0)
703
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704int register_mtd_parser(struct mtd_part_parser *p)
705{
706 spin_lock(&part_parser_lock);
707 list_add(&p->list, &part_parsers);
708 spin_unlock(&part_parser_lock);
709
710 return 0;
711}
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900712EXPORT_SYMBOL_GPL(register_mtd_parser);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713
714int deregister_mtd_parser(struct mtd_part_parser *p)
715{
716 spin_lock(&part_parser_lock);
717 list_del(&p->list);
718 spin_unlock(&part_parser_lock);
719 return 0;
720}
Atsushi Nemotob33a2882008-07-19 01:00:33 +0900721EXPORT_SYMBOL_GPL(deregister_mtd_parser);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722
Artem Bityutskiyad274ce2011-06-08 11:42:27 +0300723/*
724 * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you
725 * are changing this array!
726 */
Dmitry Eremin-Solenikovd26c87d2011-05-29 21:32:33 +0400727static const char *default_mtd_part_types[] = {
728 "cmdlinepart",
729 "ofpart",
730 NULL
731};
Dmitry Eremin-Solenikov5c4eefb2011-06-02 18:51:16 +0400732
Artem Bityutskiyad274ce2011-06-08 11:42:27 +0300733/**
734 * parse_mtd_partitions - parse MTD partitions
735 * @master: the master partition (describes whole MTD device)
736 * @types: names of partition parsers to try or %NULL
737 * @pparts: array of partitions found is returned here
Dmitry Eremin-Solenikovc7975332011-06-10 18:18:28 +0400738 * @data: MTD partition parser-specific data
Artem Bityutskiyad274ce2011-06-08 11:42:27 +0300739 *
740 * This function tries to find partition on MTD device @master. It uses MTD
741 * partition parsers, specified in @types. However, if @types is %NULL, then
742 * the default list of parsers is used. The default list contains only the
Dmitry Eremin-Solenikovd26c87d2011-05-29 21:32:33 +0400743 * "cmdlinepart" and "ofpart" parsers ATM.
Artem Bityutskiyad274ce2011-06-08 11:42:27 +0300744 *
745 * This function may return:
746 * o a negative error code in case of failure
747 * o zero if no partitions were found
748 * o a positive number of found partitions, in which case on exit @pparts will
749 * point to an array containing this number of &struct mtd_info objects.
750 */
Thomas Gleixner97894cd2005-11-07 11:15:26 +0000751int parse_mtd_partitions(struct mtd_info *master, const char **types,
Dmitry Eremin-Solenikovc7975332011-06-10 18:18:28 +0400752 struct mtd_partition **pparts,
753 struct mtd_part_parser_data *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754{
755 struct mtd_part_parser *parser;
756 int ret = 0;
Thomas Gleixner97894cd2005-11-07 11:15:26 +0000757
Dmitry Eremin-Solenikov5c4eefb2011-06-02 18:51:16 +0400758 if (!types)
759 types = default_mtd_part_types;
760
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 for ( ; ret <= 0 && *types; types++) {
762 parser = get_partition_parser(*types);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 if (!parser && !request_module("%s", *types))
764 parser = get_partition_parser(*types);
Artem Bityutskiy7c802fb2011-05-17 11:13:17 +0300765 if (!parser)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 continue;
Dmitry Eremin-Solenikovc7975332011-06-10 18:18:28 +0400767 ret = (*parser->parse_fn)(master, pparts, data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 if (ret > 0) {
Thomas Gleixner97894cd2005-11-07 11:15:26 +0000769 printk(KERN_NOTICE "%d %s partitions found on MTD device %s\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 ret, parser->name, master->name);
771 }
772 put_partition_parser(parser);
773 }
774 return ret;
775}
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300776
Roman Tereshonkova7e93dc2010-11-23 14:17:17 +0200777int mtd_is_partition(struct mtd_info *mtd)
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300778{
779 struct mtd_part *part;
Roman Tereshonkova7e93dc2010-11-23 14:17:17 +0200780 int ispart = 0;
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300781
782 mutex_lock(&mtd_partitions_mutex);
783 list_for_each_entry(part, &mtd_partitions, list)
784 if (&part->mtd == mtd) {
Roman Tereshonkova7e93dc2010-11-23 14:17:17 +0200785 ispart = 1;
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300786 break;
787 }
788 mutex_unlock(&mtd_partitions_mutex);
789
Roman Tereshonkova7e93dc2010-11-23 14:17:17 +0200790 return ispart;
Roman Tereshonkov5daa7b22010-09-17 13:31:41 +0300791}
Roman Tereshonkova7e93dc2010-11-23 14:17:17 +0200792EXPORT_SYMBOL_GPL(mtd_is_partition);