diff options
Diffstat (limited to 'drivers/mtd')
| -rw-r--r-- | drivers/mtd/Makefile | 2 | ||||
| -rw-r--r-- | drivers/mtd/internal.h | 17 | ||||
| -rw-r--r-- | drivers/mtd/mtdbdi.c | 43 | ||||
| -rw-r--r-- | drivers/mtd/mtdcore.c | 79 | ||||
| -rw-r--r-- | drivers/mtd/mtdsuper.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/nand/orion_nand.c | 8 |
6 files changed, 84 insertions, 67 deletions
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile index 82d1e4de475b..4521b1ecce45 100644 --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | # Core functionality. | 5 | # Core functionality. |
| 6 | obj-$(CONFIG_MTD) += mtd.o | 6 | obj-$(CONFIG_MTD) += mtd.o |
| 7 | mtd-y := mtdcore.o mtdsuper.o mtdbdi.o | 7 | mtd-y := mtdcore.o mtdsuper.o |
| 8 | mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart.o | 8 | mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart.o |
| 9 | 9 | ||
| 10 | obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o | 10 | obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o |
diff --git a/drivers/mtd/internal.h b/drivers/mtd/internal.h deleted file mode 100644 index c658fe7216b5..000000000000 --- a/drivers/mtd/internal.h +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | /* Internal MTD definitions | ||
| 2 | * | ||
| 3 | * Copyright © 2006 Red Hat, Inc. All Rights Reserved. | ||
| 4 | * Written by David Howells (dhowells@redhat.com) | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public License | ||
| 8 | * as published by the Free Software Foundation; either version | ||
| 9 | * 2 of the License, or (at your option) any later version. | ||
| 10 | */ | ||
| 11 | |||
| 12 | /* | ||
| 13 | * mtdbdi.c | ||
| 14 | */ | ||
| 15 | extern struct backing_dev_info mtd_bdi_unmappable; | ||
| 16 | extern struct backing_dev_info mtd_bdi_ro_mappable; | ||
| 17 | extern struct backing_dev_info mtd_bdi_rw_mappable; | ||
diff --git a/drivers/mtd/mtdbdi.c b/drivers/mtd/mtdbdi.c deleted file mode 100644 index 5ca5aed0b225..000000000000 --- a/drivers/mtd/mtdbdi.c +++ /dev/null | |||
| @@ -1,43 +0,0 @@ | |||
| 1 | /* MTD backing device capabilities | ||
| 2 | * | ||
| 3 | * Copyright © 2006 Red Hat, Inc. All Rights Reserved. | ||
| 4 | * Written by David Howells (dhowells@redhat.com) | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public License | ||
| 8 | * as published by the Free Software Foundation; either version | ||
| 9 | * 2 of the License, or (at your option) any later version. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/backing-dev.h> | ||
| 13 | #include <linux/mtd/mtd.h> | ||
| 14 | #include "internal.h" | ||
| 15 | |||
| 16 | /* | ||
| 17 | * backing device capabilities for non-mappable devices (such as NAND flash) | ||
| 18 | * - permits private mappings, copies are taken of the data | ||
| 19 | */ | ||
| 20 | struct backing_dev_info mtd_bdi_unmappable = { | ||
| 21 | .capabilities = BDI_CAP_MAP_COPY, | ||
| 22 | }; | ||
| 23 | |||
| 24 | /* | ||
| 25 | * backing device capabilities for R/O mappable devices (such as ROM) | ||
| 26 | * - permits private mappings, copies are taken of the data | ||
| 27 | * - permits non-writable shared mappings | ||
| 28 | */ | ||
| 29 | struct backing_dev_info mtd_bdi_ro_mappable = { | ||
| 30 | .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT | | ||
| 31 | BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP), | ||
| 32 | }; | ||
| 33 | |||
| 34 | /* | ||
| 35 | * backing device capabilities for writable mappable devices (such as RAM) | ||
| 36 | * - permits private mappings, copies are taken of the data | ||
| 37 | * - permits non-writable shared mappings | ||
| 38 | */ | ||
| 39 | struct backing_dev_info mtd_bdi_rw_mappable = { | ||
| 40 | .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT | | ||
| 41 | BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP | | ||
| 42 | BDI_CAP_WRITE_MAP), | ||
| 43 | }; | ||
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 5b38b17d2229..b177e750efc3 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | * Core registration and callback routines for MTD | 2 | * Core registration and callback routines for MTD |
| 3 | * drivers and users. | 3 | * drivers and users. |
| 4 | * | 4 | * |
| 5 | * bdi bits are: | ||
| 6 | * Copyright © 2006 Red Hat, Inc. All Rights Reserved. | ||
| 7 | * Written by David Howells (dhowells@redhat.com) | ||
| 5 | */ | 8 | */ |
| 6 | 9 | ||
| 7 | #include <linux/module.h> | 10 | #include <linux/module.h> |
| @@ -16,11 +19,39 @@ | |||
| 16 | #include <linux/init.h> | 19 | #include <linux/init.h> |
| 17 | #include <linux/mtd/compatmac.h> | 20 | #include <linux/mtd/compatmac.h> |
| 18 | #include <linux/proc_fs.h> | 21 | #include <linux/proc_fs.h> |
| 22 | #include <linux/backing-dev.h> | ||
| 19 | 23 | ||
| 20 | #include <linux/mtd/mtd.h> | 24 | #include <linux/mtd/mtd.h> |
| 21 | #include "internal.h" | ||
| 22 | 25 | ||
| 23 | #include "mtdcore.h" | 26 | #include "mtdcore.h" |
| 27 | /* | ||
| 28 | * backing device capabilities for non-mappable devices (such as NAND flash) | ||
| 29 | * - permits private mappings, copies are taken of the data | ||
| 30 | */ | ||
| 31 | struct backing_dev_info mtd_bdi_unmappable = { | ||
| 32 | .capabilities = BDI_CAP_MAP_COPY, | ||
| 33 | }; | ||
| 34 | |||
| 35 | /* | ||
| 36 | * backing device capabilities for R/O mappable devices (such as ROM) | ||
| 37 | * - permits private mappings, copies are taken of the data | ||
| 38 | * - permits non-writable shared mappings | ||
| 39 | */ | ||
| 40 | struct backing_dev_info mtd_bdi_ro_mappable = { | ||
| 41 | .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT | | ||
| 42 | BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP), | ||
| 43 | }; | ||
| 44 | |||
| 45 | /* | ||
| 46 | * backing device capabilities for writable mappable devices (such as RAM) | ||
| 47 | * - permits private mappings, copies are taken of the data | ||
| 48 | * - permits non-writable shared mappings | ||
| 49 | */ | ||
| 50 | struct backing_dev_info mtd_bdi_rw_mappable = { | ||
| 51 | .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT | | ||
| 52 | BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP | | ||
| 53 | BDI_CAP_WRITE_MAP), | ||
| 54 | }; | ||
| 24 | 55 | ||
| 25 | static int mtd_cls_suspend(struct device *dev, pm_message_t state); | 56 | static int mtd_cls_suspend(struct device *dev, pm_message_t state); |
| 26 | static int mtd_cls_resume(struct device *dev); | 57 | static int mtd_cls_resume(struct device *dev); |
| @@ -628,20 +659,55 @@ done: | |||
| 628 | /*====================================================================*/ | 659 | /*====================================================================*/ |
| 629 | /* Init code */ | 660 | /* Init code */ |
| 630 | 661 | ||
| 662 | static int __init mtd_bdi_init(struct backing_dev_info *bdi, const char *name) | ||
| 663 | { | ||
| 664 | int ret; | ||
| 665 | |||
| 666 | ret = bdi_init(bdi); | ||
| 667 | if (!ret) | ||
| 668 | ret = bdi_register(bdi, NULL, name); | ||
| 669 | |||
| 670 | if (ret) | ||
| 671 | bdi_destroy(bdi); | ||
| 672 | |||
| 673 | return ret; | ||
| 674 | } | ||
| 675 | |||
| 631 | static int __init init_mtd(void) | 676 | static int __init init_mtd(void) |
| 632 | { | 677 | { |
| 633 | int ret; | 678 | int ret; |
| 679 | |||
| 634 | ret = class_register(&mtd_class); | 680 | ret = class_register(&mtd_class); |
| 681 | if (ret) | ||
| 682 | goto err_reg; | ||
| 683 | |||
| 684 | ret = mtd_bdi_init(&mtd_bdi_unmappable, "mtd-unmap"); | ||
| 685 | if (ret) | ||
| 686 | goto err_bdi1; | ||
| 687 | |||
| 688 | ret = mtd_bdi_init(&mtd_bdi_ro_mappable, "mtd-romap"); | ||
| 689 | if (ret) | ||
| 690 | goto err_bdi2; | ||
| 691 | |||
| 692 | ret = mtd_bdi_init(&mtd_bdi_rw_mappable, "mtd-rwmap"); | ||
| 693 | if (ret) | ||
| 694 | goto err_bdi3; | ||
| 635 | 695 | ||
| 636 | if (ret) { | ||
| 637 | pr_err("Error registering mtd class: %d\n", ret); | ||
| 638 | return ret; | ||
| 639 | } | ||
| 640 | #ifdef CONFIG_PROC_FS | 696 | #ifdef CONFIG_PROC_FS |
| 641 | if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) | 697 | if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) |
| 642 | proc_mtd->read_proc = mtd_read_proc; | 698 | proc_mtd->read_proc = mtd_read_proc; |
| 643 | #endif /* CONFIG_PROC_FS */ | 699 | #endif /* CONFIG_PROC_FS */ |
| 644 | return 0; | 700 | return 0; |
| 701 | |||
| 702 | err_bdi3: | ||
| 703 | bdi_destroy(&mtd_bdi_ro_mappable); | ||
| 704 | err_bdi2: | ||
| 705 | bdi_destroy(&mtd_bdi_unmappable); | ||
| 706 | err_bdi1: | ||
| 707 | class_unregister(&mtd_class); | ||
| 708 | err_reg: | ||
| 709 | pr_err("Error registering mtd class or bdi: %d\n", ret); | ||
| 710 | return ret; | ||
| 645 | } | 711 | } |
| 646 | 712 | ||
| 647 | static void __exit cleanup_mtd(void) | 713 | static void __exit cleanup_mtd(void) |
| @@ -651,6 +717,9 @@ static void __exit cleanup_mtd(void) | |||
| 651 | remove_proc_entry( "mtd", NULL); | 717 | remove_proc_entry( "mtd", NULL); |
| 652 | #endif /* CONFIG_PROC_FS */ | 718 | #endif /* CONFIG_PROC_FS */ |
| 653 | class_unregister(&mtd_class); | 719 | class_unregister(&mtd_class); |
| 720 | bdi_destroy(&mtd_bdi_unmappable); | ||
| 721 | bdi_destroy(&mtd_bdi_ro_mappable); | ||
| 722 | bdi_destroy(&mtd_bdi_rw_mappable); | ||
| 654 | } | 723 | } |
| 655 | 724 | ||
| 656 | module_init(init_mtd); | 725 | module_init(init_mtd); |
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c index af8b42e0a55b..7c003191fca4 100644 --- a/drivers/mtd/mtdsuper.c +++ b/drivers/mtd/mtdsuper.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <linux/mtd/super.h> | 13 | #include <linux/mtd/super.h> |
| 14 | #include <linux/namei.h> | 14 | #include <linux/namei.h> |
| 15 | #include <linux/ctype.h> | 15 | #include <linux/ctype.h> |
| 16 | #include <linux/slab.h> | ||
| 16 | 17 | ||
| 17 | /* | 18 | /* |
| 18 | * compare superblocks to see if they're equivalent | 19 | * compare superblocks to see if they're equivalent |
| @@ -44,6 +45,7 @@ static int get_sb_mtd_set(struct super_block *sb, void *_mtd) | |||
| 44 | 45 | ||
| 45 | sb->s_mtd = mtd; | 46 | sb->s_mtd = mtd; |
| 46 | sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index); | 47 | sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index); |
| 48 | sb->s_bdi = mtd->backing_dev_info; | ||
| 47 | return 0; | 49 | return 0; |
| 48 | } | 50 | } |
| 49 | 51 | ||
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c index f59c07427af3..d60fc5719fef 100644 --- a/drivers/mtd/nand/orion_nand.c +++ b/drivers/mtd/nand/orion_nand.c | |||
| @@ -60,7 +60,13 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) | |||
| 60 | } | 60 | } |
| 61 | buf64 = (uint64_t *)buf; | 61 | buf64 = (uint64_t *)buf; |
| 62 | while (i < len/8) { | 62 | while (i < len/8) { |
| 63 | uint64_t x; | 63 | /* |
| 64 | * Since GCC has no proper constraint (PR 43518) | ||
| 65 | * force x variable to r2/r3 registers as ldrd instruction | ||
| 66 | * requires first register to be even. | ||
| 67 | */ | ||
| 68 | register uint64_t x asm ("r2"); | ||
| 69 | |||
| 64 | asm volatile ("ldrd\t%0, [%1]" : "=&r" (x) : "r" (io_base)); | 70 | asm volatile ("ldrd\t%0, [%1]" : "=&r" (x) : "r" (io_base)); |
| 65 | buf64[i++] = x; | 71 | buf64[i++] = x; |
| 66 | } | 72 | } |
