MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / mtd / mtdconcat.c
blob2b7a77d92106a47114a481323e8eb85aef12ddaf
1 /*
2 * MTD device concatenation layer
4 * (C) 2002 Robert Kaiser <rkaiser@sysgo.de>
6 * NAND support by Christian Gan <cgan@iders.ca>
8 * This code is GPL
10 * $Id: mtdconcat.c,v 1.9 2004/06/30 15:17:41 dbrown Exp $
13 #include <linux/module.h>
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/slab.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/concat.h>
22 * Our storage structure:
23 * Subdev points to an array of pointers to struct mtd_info objects
24 * which is allocated along with this structure
27 struct mtd_concat {
28 struct mtd_info mtd;
29 int num_subdev;
30 struct mtd_info **subdev;
34 * how to calculate the size required for the above structure,
35 * including the pointer array subdev points to:
37 #define SIZEOF_STRUCT_MTD_CONCAT(num_subdev) \
38 ((sizeof(struct mtd_concat) + (num_subdev) * sizeof(struct mtd_info *)))
41 * Given a pointer to the MTD object in the mtd_concat structure,
42 * we can retrieve the pointer to that structure with this macro.
44 #define CONCAT(x) ((struct mtd_concat *)(x))
46 /*
47 * MTD methods which look up the relevant subdevice, translate the
48 * effective address and pass through to the subdevice.
51 static int
52 concat_read(struct mtd_info *mtd, loff_t from, size_t len,
53 size_t * retlen, u_char * buf)
55 struct mtd_concat *concat = CONCAT(mtd);
56 int err = -EINVAL;
57 int i;
59 *retlen = 0;
61 for (i = 0; i < concat->num_subdev; i++) {
62 struct mtd_info *subdev = concat->subdev[i];
63 size_t size, retsize;
65 if (from >= subdev->size) {
66 /* Not destined for this subdev */
67 size = 0;
68 from -= subdev->size;
69 continue;
71 if (from + len > subdev->size)
72 /* First part goes into this subdev */
73 size = subdev->size - from;
74 else
75 /* Entire transaction goes into this subdev */
76 size = len;
78 err = subdev->read(subdev, from, size, &retsize, buf);
80 if (err)
81 break;
83 *retlen += retsize;
84 len -= size;
85 if (len == 0)
86 break;
88 err = -EINVAL;
89 buf += size;
90 from = 0;
92 return err;
95 static int
96 concat_write(struct mtd_info *mtd, loff_t to, size_t len,
97 size_t * retlen, const u_char * buf)
99 struct mtd_concat *concat = CONCAT(mtd);
100 int err = -EINVAL;
101 int i;
103 if (!(mtd->flags & MTD_WRITEABLE))
104 return -EROFS;
106 *retlen = 0;
108 for (i = 0; i < concat->num_subdev; i++) {
109 struct mtd_info *subdev = concat->subdev[i];
110 size_t size, retsize;
112 if (to >= subdev->size) {
113 size = 0;
114 to -= subdev->size;
115 continue;
117 if (to + len > subdev->size)
118 size = subdev->size - to;
119 else
120 size = len;
122 if (!(subdev->flags & MTD_WRITEABLE))
123 err = -EROFS;
124 else
125 err = subdev->write(subdev, to, size, &retsize, buf);
127 if (err)
128 break;
130 *retlen += retsize;
131 len -= size;
132 if (len == 0)
133 break;
135 err = -EINVAL;
136 buf += size;
137 to = 0;
139 return err;
142 static int
143 concat_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
144 size_t * retlen, u_char * buf, u_char * eccbuf,
145 struct nand_oobinfo *oobsel)
147 struct mtd_concat *concat = CONCAT(mtd);
148 int err = -EINVAL;
149 int i;
151 *retlen = 0;
153 for (i = 0; i < concat->num_subdev; i++) {
154 struct mtd_info *subdev = concat->subdev[i];
155 size_t size, retsize;
157 if (from >= subdev->size) {
158 /* Not destined for this subdev */
159 size = 0;
160 from -= subdev->size;
161 continue;
164 if (from + len > subdev->size)
165 /* First part goes into this subdev */
166 size = subdev->size - from;
167 else
168 /* Entire transaction goes into this subdev */
169 size = len;
171 if (subdev->read_ecc)
172 err = subdev->read_ecc(subdev, from, size,
173 &retsize, buf, eccbuf, oobsel);
174 else
175 err = -EINVAL;
177 if (err)
178 break;
180 *retlen += retsize;
181 len -= size;
182 if (len == 0)
183 break;
185 err = -EINVAL;
186 buf += size;
187 if (eccbuf) {
188 eccbuf += subdev->oobsize;
189 /* in nand.c at least, eccbufs are
190 tagged with 2 (int)eccstatus'; we
191 must account for these */
192 eccbuf += 2 * (sizeof (int));
194 from = 0;
196 return err;
199 static int
200 concat_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
201 size_t * retlen, const u_char * buf, u_char * eccbuf,
202 struct nand_oobinfo *oobsel)
204 struct mtd_concat *concat = CONCAT(mtd);
205 int err = -EINVAL;
206 int i;
208 if (!(mtd->flags & MTD_WRITEABLE))
209 return -EROFS;
211 *retlen = 0;
213 for (i = 0; i < concat->num_subdev; i++) {
214 struct mtd_info *subdev = concat->subdev[i];
215 size_t size, retsize;
217 if (to >= subdev->size) {
218 size = 0;
219 to -= subdev->size;
220 continue;
222 if (to + len > subdev->size)
223 size = subdev->size - to;
224 else
225 size = len;
227 if (!(subdev->flags & MTD_WRITEABLE))
228 err = -EROFS;
229 else if (subdev->write_ecc)
230 err = subdev->write_ecc(subdev, to, size,
231 &retsize, buf, eccbuf, oobsel);
232 else
233 err = -EINVAL;
235 if (err)
236 break;
238 *retlen += retsize;
239 len -= size;
240 if (len == 0)
241 break;
243 err = -EINVAL;
244 buf += size;
245 if (eccbuf)
246 eccbuf += subdev->oobsize;
247 to = 0;
249 return err;
252 static int
253 concat_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
254 size_t * retlen, u_char * buf)
256 struct mtd_concat *concat = CONCAT(mtd);
257 int err = -EINVAL;
258 int i;
260 *retlen = 0;
262 for (i = 0; i < concat->num_subdev; i++) {
263 struct mtd_info *subdev = concat->subdev[i];
264 size_t size, retsize;
266 if (from >= subdev->size) {
267 /* Not destined for this subdev */
268 size = 0;
269 from -= subdev->size;
270 continue;
272 if (from + len > subdev->size)
273 /* First part goes into this subdev */
274 size = subdev->size - from;
275 else
276 /* Entire transaction goes into this subdev */
277 size = len;
279 if (subdev->read_oob)
280 err = subdev->read_oob(subdev, from, size,
281 &retsize, buf);
282 else
283 err = -EINVAL;
285 if (err)
286 break;
288 *retlen += retsize;
289 len -= size;
290 if (len == 0)
291 break;
293 err = -EINVAL;
294 buf += size;
295 from = 0;
297 return err;
300 static int
301 concat_write_oob(struct mtd_info *mtd, loff_t to, size_t len,
302 size_t * retlen, const u_char * buf)
304 struct mtd_concat *concat = CONCAT(mtd);
305 int err = -EINVAL;
306 int i;
308 if (!(mtd->flags & MTD_WRITEABLE))
309 return -EROFS;
311 *retlen = 0;
313 for (i = 0; i < concat->num_subdev; i++) {
314 struct mtd_info *subdev = concat->subdev[i];
315 size_t size, retsize;
317 if (to >= subdev->size) {
318 size = 0;
319 to -= subdev->size;
320 continue;
322 if (to + len > subdev->size)
323 size = subdev->size - to;
324 else
325 size = len;
327 if (!(subdev->flags & MTD_WRITEABLE))
328 err = -EROFS;
329 else if (subdev->write_oob)
330 err = subdev->write_oob(subdev, to, size, &retsize,
331 buf);
332 else
333 err = -EINVAL;
335 if (err)
336 break;
338 *retlen += retsize;
339 len -= size;
340 if (len == 0)
341 break;
343 err = -EINVAL;
344 buf += size;
345 to = 0;
347 return err;
350 static void concat_erase_callback(struct erase_info *instr)
352 wake_up((wait_queue_head_t *) instr->priv);
355 static int concat_dev_erase(struct mtd_info *mtd, struct erase_info *erase)
357 int err;
358 wait_queue_head_t waitq;
359 DECLARE_WAITQUEUE(wait, current);
362 * This code was stol^H^H^H^Hinspired by mtdchar.c
364 init_waitqueue_head(&waitq);
366 erase->mtd = mtd;
367 erase->callback = concat_erase_callback;
368 erase->priv = (unsigned long) &waitq;
371 * FIXME: Allow INTERRUPTIBLE. Which means
372 * not having the wait_queue head on the stack.
374 err = mtd->erase(mtd, erase);
375 if (!err) {
376 #if 1 // mask by Victor Yu. 05-14-2007
377 set_current_state(TASK_UNINTERRUPTIBLE);
378 #endif
379 add_wait_queue(&waitq, &wait);
380 if (erase->state != MTD_ERASE_DONE
381 && erase->state != MTD_ERASE_FAILED)
382 schedule();
383 remove_wait_queue(&waitq, &wait);
384 #if 1 // mask by Victor Yu. 05-14-2007
385 set_current_state(TASK_RUNNING);
386 #endif
388 err = (erase->state == MTD_ERASE_FAILED) ? -EIO : 0;
390 return err;
393 static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)
395 struct mtd_concat *concat = CONCAT(mtd);
396 struct mtd_info *subdev;
397 int i, err;
398 u_int32_t length, offset = 0;
399 struct erase_info *erase;
401 if (!(mtd->flags & MTD_WRITEABLE))
402 return -EROFS;
404 if (instr->addr > concat->mtd.size)
405 return -EINVAL;
407 if (instr->len + instr->addr > concat->mtd.size)
408 return -EINVAL;
411 * Check for proper erase block alignment of the to-be-erased area.
412 * It is easier to do this based on the super device's erase
413 * region info rather than looking at each particular sub-device
414 * in turn.
416 if (!concat->mtd.numeraseregions) {
417 /* the easy case: device has uniform erase block size */
418 if (instr->addr & (concat->mtd.erasesize - 1))
419 return -EINVAL;
420 if (instr->len & (concat->mtd.erasesize - 1))
421 return -EINVAL;
422 } else {
423 /* device has variable erase size */
424 struct mtd_erase_region_info *erase_regions =
425 concat->mtd.eraseregions;
428 * Find the erase region where the to-be-erased area begins:
430 for (i = 0; i < concat->mtd.numeraseregions &&
431 instr->addr >= erase_regions[i].offset; i++) ;
432 --i;
435 * Now erase_regions[i] is the region in which the
436 * to-be-erased area begins. Verify that the starting
437 * offset is aligned to this region's erase size:
439 if (instr->addr & (erase_regions[i].erasesize - 1))
440 return -EINVAL;
443 * now find the erase region where the to-be-erased area ends:
445 for (; i < concat->mtd.numeraseregions &&
446 (instr->addr + instr->len) >= erase_regions[i].offset;
447 ++i) ;
448 --i;
450 * check if the ending offset is aligned to this region's erase size
452 if ((instr->addr + instr->len) & (erase_regions[i].erasesize -
454 return -EINVAL;
457 instr->fail_addr = 0xffffffff;
459 /* make a local copy of instr to avoid modifying the caller's struct */
460 erase = kmalloc(sizeof (struct erase_info), GFP_KERNEL);
462 if (!erase)
463 return -ENOMEM;
465 *erase = *instr;
466 length = instr->len;
469 * find the subdevice where the to-be-erased area begins, adjust
470 * starting offset to be relative to the subdevice start
472 for (i = 0; i < concat->num_subdev; i++) {
473 subdev = concat->subdev[i];
474 if (subdev->size <= erase->addr) {
475 erase->addr -= subdev->size;
476 offset += subdev->size;
477 } else {
478 break;
482 /* must never happen since size limit has been verified above */
483 if (i >= concat->num_subdev)
484 BUG();
486 /* now do the erase: */
487 err = 0;
488 for (; length > 0; i++) {
489 /* loop for all subdevices affected by this request */
490 subdev = concat->subdev[i]; /* get current subdevice */
492 /* limit length to subdevice's size: */
493 if (erase->addr + length > subdev->size)
494 erase->len = subdev->size - erase->addr;
495 else
496 erase->len = length;
498 if (!(subdev->flags & MTD_WRITEABLE)) {
499 err = -EROFS;
500 break;
502 length -= erase->len;
503 if ((err = concat_dev_erase(subdev, erase))) {
504 /* sanity check: should never happen since
505 * block alignment has been checked above */
506 if (err == -EINVAL)
507 BUG();
508 if (erase->fail_addr != 0xffffffff)
509 instr->fail_addr = erase->fail_addr + offset;
510 break;
513 * erase->addr specifies the offset of the area to be
514 * erased *within the current subdevice*. It can be
515 * non-zero only the first time through this loop, i.e.
516 * for the first subdevice where blocks need to be erased.
517 * All the following erases must begin at the start of the
518 * current subdevice, i.e. at offset zero.
520 erase->addr = 0;
521 offset += subdev->size;
523 instr->state = erase->state;
524 kfree(erase);
525 if (err)
526 return err;
528 if (instr->callback)
529 instr->callback(instr);
530 return 0;
533 static int concat_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
535 struct mtd_concat *concat = CONCAT(mtd);
536 int i, err = -EINVAL;
538 if ((len + ofs) > mtd->size)
539 return -EINVAL;
541 for (i = 0; i < concat->num_subdev; i++) {
542 struct mtd_info *subdev = concat->subdev[i];
543 size_t size;
545 if (ofs >= subdev->size) {
546 size = 0;
547 ofs -= subdev->size;
548 continue;
550 if (ofs + len > subdev->size)
551 size = subdev->size - ofs;
552 else
553 size = len;
555 err = subdev->lock(subdev, ofs, size);
557 if (err)
558 break;
560 len -= size;
561 if (len == 0)
562 break;
564 err = -EINVAL;
565 ofs = 0;
568 return err;
571 static int concat_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
573 struct mtd_concat *concat = CONCAT(mtd);
574 int i, err = 0;
576 if ((len + ofs) > mtd->size)
577 return -EINVAL;
579 for (i = 0; i < concat->num_subdev; i++) {
580 struct mtd_info *subdev = concat->subdev[i];
581 size_t size;
583 if (ofs >= subdev->size) {
584 size = 0;
585 ofs -= subdev->size;
586 continue;
588 if (ofs + len > subdev->size)
589 size = subdev->size - ofs;
590 else
591 size = len;
593 err = subdev->unlock(subdev, ofs, size);
595 if (err)
596 break;
598 len -= size;
599 if (len == 0)
600 break;
602 err = -EINVAL;
603 ofs = 0;
606 return err;
609 static void concat_sync(struct mtd_info *mtd)
611 struct mtd_concat *concat = CONCAT(mtd);
612 int i;
614 for (i = 0; i < concat->num_subdev; i++) {
615 struct mtd_info *subdev = concat->subdev[i];
616 subdev->sync(subdev);
620 static int concat_suspend(struct mtd_info *mtd)
622 struct mtd_concat *concat = CONCAT(mtd);
623 int i, rc = 0;
625 for (i = 0; i < concat->num_subdev; i++) {
626 struct mtd_info *subdev = concat->subdev[i];
627 if ((rc = subdev->suspend(subdev)) < 0)
628 return rc;
630 return rc;
633 static void concat_resume(struct mtd_info *mtd)
635 struct mtd_concat *concat = CONCAT(mtd);
636 int i;
638 for (i = 0; i < concat->num_subdev; i++) {
639 struct mtd_info *subdev = concat->subdev[i];
640 subdev->resume(subdev);
645 * This function constructs a virtual MTD device by concatenating
646 * num_devs MTD devices. A pointer to the new device object is
647 * stored to *new_dev upon success. This function does _not_
648 * register any devices: this is the caller's responsibility.
650 struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to concatenate */
651 int num_devs, /* number of subdevices */
652 char *name)
653 { /* name for the new device */
654 int i;
655 size_t size;
656 struct mtd_concat *concat;
657 u_int32_t max_erasesize, curr_erasesize;
658 int num_erase_region;
660 printk(KERN_NOTICE "Concatenating MTD devices:\n");
661 for (i = 0; i < num_devs; i++)
662 printk(KERN_NOTICE "(%d): \"%s\"\n", i, subdev[i]->name);
663 printk(KERN_NOTICE "into device \"%s\"\n", name);
665 /* allocate the device structure */
666 size = SIZEOF_STRUCT_MTD_CONCAT(num_devs);
667 concat = kmalloc(size, GFP_KERNEL);
668 if (!concat) {
669 printk
670 ("memory allocation error while creating concatenated device \"%s\"\n",
671 name);
672 return NULL;
674 memset(concat, 0, size);
675 concat->subdev = (struct mtd_info **) (concat + 1);
678 * Set up the new "super" device's MTD object structure, check for
679 * incompatibilites between the subdevices.
681 concat->mtd.type = subdev[0]->type;
682 concat->mtd.flags = subdev[0]->flags;
683 concat->mtd.size = subdev[0]->size;
684 concat->mtd.erasesize = subdev[0]->erasesize;
685 concat->mtd.oobblock = subdev[0]->oobblock;
686 concat->mtd.oobsize = subdev[0]->oobsize;
687 concat->mtd.ecctype = subdev[0]->ecctype;
688 concat->mtd.eccsize = subdev[0]->eccsize;
689 if (subdev[0]->read_ecc)
690 concat->mtd.read_ecc = concat_read_ecc;
691 if (subdev[0]->write_ecc)
692 concat->mtd.write_ecc = concat_write_ecc;
693 if (subdev[0]->read_oob)
694 concat->mtd.read_oob = concat_read_oob;
695 if (subdev[0]->write_oob)
696 concat->mtd.write_oob = concat_write_oob;
698 concat->subdev[0] = subdev[0];
700 for (i = 1; i < num_devs; i++) {
701 if (concat->mtd.type != subdev[i]->type) {
702 kfree(concat);
703 printk("Incompatible device type on \"%s\"\n",
704 subdev[i]->name);
705 return NULL;
707 if (concat->mtd.flags != subdev[i]->flags) {
709 * Expect all flags except MTD_WRITEABLE to be
710 * equal on all subdevices.
712 if ((concat->mtd.flags ^ subdev[i]->
713 flags) & ~MTD_WRITEABLE) {
714 kfree(concat);
715 printk("Incompatible device flags on \"%s\"\n",
716 subdev[i]->name);
717 return NULL;
718 } else
719 /* if writeable attribute differs,
720 make super device writeable */
721 concat->mtd.flags |=
722 subdev[i]->flags & MTD_WRITEABLE;
724 concat->mtd.size += subdev[i]->size;
725 if (concat->mtd.oobblock != subdev[i]->oobblock ||
726 concat->mtd.oobsize != subdev[i]->oobsize ||
727 concat->mtd.ecctype != subdev[i]->ecctype ||
728 concat->mtd.eccsize != subdev[i]->eccsize ||
729 !concat->mtd.read_ecc != !subdev[i]->read_ecc ||
730 !concat->mtd.write_ecc != !subdev[i]->write_ecc ||
731 !concat->mtd.read_oob != !subdev[i]->read_oob ||
732 !concat->mtd.write_oob != !subdev[i]->write_oob) {
733 kfree(concat);
734 printk("Incompatible OOB or ECC data on \"%s\"\n",
735 subdev[i]->name);
736 return NULL;
738 concat->subdev[i] = subdev[i];
742 concat->num_subdev = num_devs;
743 concat->mtd.name = name;
746 * NOTE: for now, we do not provide any readv()/writev() methods
747 * because they are messy to implement and they are not
748 * used to a great extent anyway.
750 concat->mtd.erase = concat_erase;
751 concat->mtd.read = concat_read;
752 concat->mtd.write = concat_write;
753 concat->mtd.sync = concat_sync;
754 concat->mtd.lock = concat_lock;
755 concat->mtd.unlock = concat_unlock;
756 concat->mtd.suspend = concat_suspend;
757 concat->mtd.resume = concat_resume;
760 * Combine the erase block size info of the subdevices:
762 * first, walk the map of the new device and see how
763 * many changes in erase size we have
765 max_erasesize = curr_erasesize = subdev[0]->erasesize;
766 num_erase_region = 1;
767 for (i = 0; i < num_devs; i++) {
768 if (subdev[i]->numeraseregions == 0) {
769 /* current subdevice has uniform erase size */
770 if (subdev[i]->erasesize != curr_erasesize) {
771 /* if it differs from the last subdevice's erase size, count it */
772 ++num_erase_region;
773 curr_erasesize = subdev[i]->erasesize;
774 if (curr_erasesize > max_erasesize)
775 max_erasesize = curr_erasesize;
777 } else {
778 /* current subdevice has variable erase size */
779 int j;
780 for (j = 0; j < subdev[i]->numeraseregions; j++) {
782 /* walk the list of erase regions, count any changes */
783 if (subdev[i]->eraseregions[j].erasesize !=
784 curr_erasesize) {
785 ++num_erase_region;
786 curr_erasesize =
787 subdev[i]->eraseregions[j].
788 erasesize;
789 if (curr_erasesize > max_erasesize)
790 max_erasesize = curr_erasesize;
796 if (num_erase_region == 1) {
798 * All subdevices have the same uniform erase size.
799 * This is easy:
801 concat->mtd.erasesize = curr_erasesize;
802 concat->mtd.numeraseregions = 0;
803 } else {
805 * erase block size varies across the subdevices: allocate
806 * space to store the data describing the variable erase regions
808 struct mtd_erase_region_info *erase_region_p;
809 u_int32_t begin, position;
811 concat->mtd.erasesize = max_erasesize;
812 concat->mtd.numeraseregions = num_erase_region;
813 concat->mtd.eraseregions = erase_region_p =
814 kmalloc(num_erase_region *
815 sizeof (struct mtd_erase_region_info), GFP_KERNEL);
816 if (!erase_region_p) {
817 kfree(concat);
818 printk
819 ("memory allocation error while creating erase region list"
820 " for device \"%s\"\n", name);
821 return NULL;
825 * walk the map of the new device once more and fill in
826 * in erase region info:
828 curr_erasesize = subdev[0]->erasesize;
829 begin = position = 0;
830 for (i = 0; i < num_devs; i++) {
831 if (subdev[i]->numeraseregions == 0) {
832 /* current subdevice has uniform erase size */
833 if (subdev[i]->erasesize != curr_erasesize) {
835 * fill in an mtd_erase_region_info structure for the area
836 * we have walked so far:
838 erase_region_p->offset = begin;
839 erase_region_p->erasesize =
840 curr_erasesize;
841 erase_region_p->numblocks =
842 (position - begin) / curr_erasesize;
843 begin = position;
845 curr_erasesize = subdev[i]->erasesize;
846 ++erase_region_p;
848 position += subdev[i]->size;
849 } else {
850 /* current subdevice has variable erase size */
851 int j;
852 for (j = 0; j < subdev[i]->numeraseregions; j++) {
853 /* walk the list of erase regions, count any changes */
854 if (subdev[i]->eraseregions[j].
855 erasesize != curr_erasesize) {
856 erase_region_p->offset = begin;
857 erase_region_p->erasesize =
858 curr_erasesize;
859 erase_region_p->numblocks =
860 (position -
861 begin) / curr_erasesize;
862 begin = position;
864 curr_erasesize =
865 subdev[i]->eraseregions[j].
866 erasesize;
867 ++erase_region_p;
869 position +=
870 subdev[i]->eraseregions[j].
871 numblocks * curr_erasesize;
875 /* Now write the final entry */
876 erase_region_p->offset = begin;
877 erase_region_p->erasesize = curr_erasesize;
878 erase_region_p->numblocks = (position - begin) / curr_erasesize;
881 return &concat->mtd;
885 * This function destroys an MTD object obtained from concat_mtd_devs()
888 void mtd_concat_destroy(struct mtd_info *mtd)
890 struct mtd_concat *concat = CONCAT(mtd);
891 if (concat->mtd.numeraseregions)
892 kfree(concat->mtd.eraseregions);
893 kfree(concat);
896 EXPORT_SYMBOL(mtd_concat_create);
897 EXPORT_SYMBOL(mtd_concat_destroy);
899 MODULE_LICENSE("GPL");
900 MODULE_AUTHOR("Robert Kaiser <rkaiser@sysgo.de>");
901 MODULE_DESCRIPTION("Generic support for concatenating of MTD devices");