2007-12-27 18:59:39

by Jason Lunz

[permalink] [raw]
Subject: [PATCH] allow use of mtd and jffs2 on uml


Allow parts of drivers/mtd to compile on uml by pushing the HAS_IOMEM
dependencies down closer to the parts of mtd that actually need it. This
allows enough of mtd to build to let jffs2 be used on uml.

Signed-off-by: Jason Lunz <[email protected]>

---

arch/um/Kconfig | 4 +---
drivers/mtd/Kconfig | 12 +++++++-----
drivers/mtd/chips/Kconfig | 11 ++++++++---
drivers/mtd/devices/Kconfig | 7 +++++++
4 files changed, 23 insertions(+), 11 deletions(-)

Index: linux-2.6.23.1-uml/arch/um/Kconfig
===================================================================
--- linux-2.6.23.1-uml.orig/arch/um/Kconfig
+++ linux-2.6.23.1-uml/arch/um/Kconfig
@@ -326,9 +326,7 @@

source "drivers/md/Kconfig"

-if BROKEN
- source "drivers/mtd/Kconfig"
-endif
+source "drivers/mtd/Kconfig"

#This is just to shut up some Kconfig warnings, so no prompt.
config INPUT
Index: linux-2.6.23.1-uml/drivers/mtd/devices/Kconfig
===================================================================
--- linux-2.6.23.1-uml.orig/drivers/mtd/devices/Kconfig
+++ linux-2.6.23.1-uml/drivers/mtd/devices/Kconfig
@@ -78,6 +78,7 @@

config MTD_SLRAM
tristate "Uncached system RAM"
+ depends on HAS_IOMEM
help
If your CPU cannot cache all of the physical memory in your machine,
you can still use it for storage or swap by using this driver to
@@ -85,6 +86,7 @@

config MTD_PHRAM
tristate "Physical system RAM"
+ depends on HAS_IOMEM
help
This is a re-implementation of the slram driver above.

@@ -151,10 +153,13 @@
Testing MTD users (eg JFFS2) on large media and media that might
be removed during a write (using the floppy drive).

+if HAS_IOMEM
comment "Disk-On-Chip Device Drivers"
+endif

config MTD_DOC2000
tristate "M-Systems Disk-On-Chip 2000 and Millennium (DEPRECATED)"
+ depends on HAS_IOMEM
select MTD_DOCPROBE
select MTD_NAND_IDS
---help---
@@ -177,6 +182,7 @@

config MTD_DOC2001
tristate "M-Systems Disk-On-Chip Millennium-only alternative driver (DEPRECATED)"
+ depends on HAS_IOMEM
select MTD_DOCPROBE
select MTD_NAND_IDS
---help---
@@ -198,6 +204,7 @@

config MTD_DOC2001PLUS
tristate "M-Systems Disk-On-Chip Millennium Plus"
+ depends on HAS_IOMEM
select MTD_DOCPROBE
select MTD_NAND_IDS
---help---
Index: linux-2.6.23.1-uml/drivers/mtd/Kconfig
===================================================================
--- linux-2.6.23.1-uml.orig/drivers/mtd/Kconfig
+++ linux-2.6.23.1-uml/drivers/mtd/Kconfig
@@ -2,7 +2,6 @@

menuconfig MTD
tristate "Memory Technology Device (MTD) support"
- depends on HAS_IOMEM
help
Memory Technology Devices are flash, RAM and similar chips, often
used for solid state file systems on embedded devices. This option
@@ -278,15 +277,18 @@
This enables read only access to SmartMedia formatted NAND
flash. You can mount it with FAT file system.

-source "drivers/mtd/chips/Kconfig"

-source "drivers/mtd/maps/Kconfig"
+if HAS_IOMEM
+ source "drivers/mtd/chips/Kconfig"
+ source "drivers/mtd/maps/Kconfig"
+endif

source "drivers/mtd/devices/Kconfig"

-source "drivers/mtd/nand/Kconfig"
-
-source "drivers/mtd/onenand/Kconfig"
+if HAS_IOMEM
+ source "drivers/mtd/nand/Kconfig"
+ source "drivers/mtd/onenand/Kconfig"
+endif

source "drivers/mtd/ubi/Kconfig"

Index: linux-2.6.23.1-uml/drivers/mtd/Makefile
===================================================================
--- linux-2.6.23.1-uml.orig/drivers/mtd/Makefile
+++ linux-2.6.23.1-uml/drivers/mtd/Makefile
@@ -26,6 +26,9 @@
nftl-objs := nftlcore.o nftlmount.o
inftl-objs := inftlcore.o inftlmount.o

-obj-y += chips/ maps/ devices/ nand/ onenand/
+obj-y += devices/
+ifdef CONFIG_HAS_IOMEM
+obj-y += chips/ maps/ nand/ onenand/
+endif

obj-$(CONFIG_MTD_UBI) += ubi/


2007-12-28 17:49:17

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH] allow use of mtd and jffs2 on uml

On Thu, Dec 27, 2007 at 01:15:25PM -0500, Jason Lunz wrote:
>
> Allow parts of drivers/mtd to compile on uml by pushing the HAS_IOMEM
> dependencies down closer to the parts of mtd that actually need it. This
> allows enough of mtd to build to let jffs2 be used on uml.
>
> Signed-off-by: Jason Lunz <[email protected]>
>
> ---
>
> arch/um/Kconfig | 4 +---
> drivers/mtd/Kconfig | 12 +++++++-----
> drivers/mtd/chips/Kconfig | 11 ++++++++---
> drivers/mtd/devices/Kconfig | 7 +++++++
> 4 files changed, 23 insertions(+), 11 deletions(-)
>
> Index: linux-2.6.23.1-uml/arch/um/Kconfig
> ===================================================================
> --- linux-2.6.23.1-uml.orig/arch/um/Kconfig
> +++ linux-2.6.23.1-uml/arch/um/Kconfig
> @@ -326,9 +326,7 @@
>
> source "drivers/md/Kconfig"
>
> -if BROKEN
> - source "drivers/mtd/Kconfig"
> -endif
> +source "drivers/mtd/Kconfig"
>
> #This is just to shut up some Kconfig warnings, so no prompt.
> config INPUT
> Index: linux-2.6.23.1-uml/drivers/mtd/devices/Kconfig
> ===================================================================
> --- linux-2.6.23.1-uml.orig/drivers/mtd/devices/Kconfig
> +++ linux-2.6.23.1-uml/drivers/mtd/devices/Kconfig
> @@ -78,6 +78,7 @@
>
> config MTD_SLRAM
> tristate "Uncached system RAM"
> + depends on HAS_IOMEM
> help
> If your CPU cannot cache all of the physical memory in your machine,
> you can still use it for storage or swap by using this driver to
> @@ -85,6 +86,7 @@
>
> config MTD_PHRAM
> tristate "Physical system RAM"
> + depends on HAS_IOMEM
> help
> This is a re-implementation of the slram driver above.
>
> @@ -151,10 +153,13 @@
> Testing MTD users (eg JFFS2) on large media and media that might
> be removed during a write (using the floppy drive).
>
> +if HAS_IOMEM
> comment "Disk-On-Chip Device Drivers"
> +endif

You can expand the if above to include the config symols..
>
> config MTD_DOC2000
> tristate "M-Systems Disk-On-Chip 2000 and Millennium (DEPRECATED)"
> + depends on HAS_IOMEM
> select MTD_DOCPROBE
> select MTD_NAND_IDS
> ---help---
> @@ -177,6 +182,7 @@
>
> config MTD_DOC2001
> tristate "M-Systems Disk-On-Chip Millennium-only alternative driver (DEPRECATED)"
> + depends on HAS_IOMEM
> select MTD_DOCPROBE
> select MTD_NAND_IDS
> ---help---
> @@ -198,6 +204,7 @@
>
> config MTD_DOC2001PLUS
> tristate "M-Systems Disk-On-Chip Millennium Plus"
> + depends on HAS_IOMEM
> select MTD_DOCPROBE
> select MTD_NAND_IDS
> ---help---
.. so if the endif was placed here you did not have to specify
the "depends on". Assumng btw that no other symbols inbetween
exists.

> Index: linux-2.6.23.1-uml/drivers/mtd/Kconfig
> ===================================================================
> --- linux-2.6.23.1-uml.orig/drivers/mtd/Kconfig
> +++ linux-2.6.23.1-uml/drivers/mtd/Kconfig
> @@ -2,7 +2,6 @@
>
> menuconfig MTD
> tristate "Memory Technology Device (MTD) support"
> - depends on HAS_IOMEM
> help
> Memory Technology Devices are flash, RAM and similar chips, often
> used for solid state file systems on embedded devices. This option
> @@ -278,15 +277,18 @@
> This enables read only access to SmartMedia formatted NAND
> flash. You can mount it with FAT file system.
>
> -source "drivers/mtd/chips/Kconfig"
>
> -source "drivers/mtd/maps/Kconfig"
> +if HAS_IOMEM
> + source "drivers/mtd/chips/Kconfig"
> + source "drivers/mtd/maps/Kconfig"
> +endif

This "if" should be pushed down in the kconfig file
so it is obvoious we have this dependency.
>
> source "drivers/mtd/devices/Kconfig"
>
> -source "drivers/mtd/nand/Kconfig"
> -
> -source "drivers/mtd/onenand/Kconfig"
> +if HAS_IOMEM
> + source "drivers/mtd/nand/Kconfig"
> + source "drivers/mtd/onenand/Kconfig"
> +endif
Same for this one - let it be explicit in the Kconfig file.

>
> source "drivers/mtd/ubi/Kconfig"
>
> Index: linux-2.6.23.1-uml/drivers/mtd/Makefile
> ===================================================================
> --- linux-2.6.23.1-uml.orig/drivers/mtd/Makefile
> +++ linux-2.6.23.1-uml/drivers/mtd/Makefile
> @@ -26,6 +26,9 @@
> nftl-objs := nftlcore.o nftlmount.o
> inftl-objs := inftlcore.o inftlmount.o
>
> -obj-y += chips/ maps/ devices/ nand/ onenand/
> +obj-y += devices/
> +ifdef CONFIG_HAS_IOMEM
> +obj-y += chips/ maps/ nand/ onenand/
> +endif

The ifdef for CONFIG_HAS_IOMEM looks strange.
Let kbuild visit the directories and then figure out nothing
needs to be done.
If you insist on the HAS_IOMEM dependency then use:
obj-$(CONFIG_HAS_IOMEM) += chips/ maps/ nand/ o


Sam

2010-12-07 07:50:40

by Jason Lunz

[permalink] [raw]
Subject: [PATCH] mtd: allow mtd and jffs2 when ARCH=um


Allow parts of drivers/mtd to compile on uml by pushing the HAS_IOMEM
dependencies down closer to the parts of mtd that actually need it.
This allows enough of mtd to build to let jffs2 be used on uml.

Signed-off-by: Jason Lunz <[email protected]>
---
arch/um/Kconfig.rest | 4 +---
drivers/mtd/Kconfig | 1 -
drivers/mtd/Makefile | 3 ++-
drivers/mtd/chips/Kconfig | 4 ++++
drivers/mtd/devices/Kconfig | 8 ++++++++
drivers/mtd/maps/Kconfig | 4 ++++
drivers/mtd/mtdchar.c | 4 ++++
drivers/mtd/nand/Kconfig | 3 +++
drivers/mtd/onenand/Kconfig | 3 +++
include/linux/mtd/map.h | 2 ++
10 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/arch/um/Kconfig.rest b/arch/um/Kconfig.rest
index 0ccad0f..e34f399 100644
--- a/arch/um/Kconfig.rest
+++ b/arch/um/Kconfig.rest
@@ -28,9 +28,7 @@ source "drivers/scsi/Kconfig"

source "drivers/md/Kconfig"

-if BROKEN
- source "drivers/mtd/Kconfig"
-endif
+source "drivers/mtd/Kconfig"

source "drivers/leds/Kconfig"

diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 1e2cbf5..a0e2a28 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -1,6 +1,5 @@
menuconfig MTD
tristate "Memory Technology Device (MTD) support"
- depends on HAS_IOMEM
help
Memory Technology Devices are flash, RAM and similar chips, often
used for solid state file systems on embedded devices. This option
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index 760abc5..ffa2e15 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_MTD_OOPS) += mtdoops.o
nftl-objs := nftlcore.o nftlmount.o
inftl-objs := inftlcore.o inftlmount.o

-obj-y += chips/ lpddr/ maps/ devices/ nand/ onenand/ tests/
+obj-y += maps/ devices/ nand/ onenand/ tests/
+obj-$(CONFIG_HAS_IOMEM) += chips/ lpddr/

obj-$(CONFIG_MTD_UBI) += ubi/
diff --git a/drivers/mtd/chips/Kconfig b/drivers/mtd/chips/Kconfig
index 35c6a23..27382c9 100644
--- a/drivers/mtd/chips/Kconfig
+++ b/drivers/mtd/chips/Kconfig
@@ -1,3 +1,5 @@
+if HAS_IOMEM
+
menu "RAM/ROM/Flash chip drivers"
depends on MTD!=n

@@ -240,3 +242,5 @@ config MTD_XIP
then say N.

endmenu
+
+endif # HAS_IOMEM
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index 35081ce..8f6d85d 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -112,6 +112,8 @@ config MTD_SST25L
Set up your spi devices with the right board-specific platform data,
if you want to specify device partitioning.

+if HAS_IOMEM
+
config MTD_SLRAM
tristate "Uncached system RAM"
help
@@ -128,6 +130,8 @@ config MTD_PHRAM
doesn't have access to, memory beyond the mem=xxx limit, nvram,
memory on the video card, etc...

+endif # HAS_IOMEM
+
config MTD_LART
tristate "28F160xx flash driver for LART"
depends on SA1100_LART
@@ -187,6 +191,8 @@ config MTD_BLOCK2MTD
Testing MTD users (eg JFFS2) on large media and media that might
be removed during a write (using the floppy drive).

+if HAS_IOMEM
+
comment "Disk-On-Chip Device Drivers"

config MTD_DOC2000
@@ -249,6 +255,8 @@ config MTD_DOC2001PLUS
under "NAND Flash Device Drivers" (currently that driver does not
support all Millennium Plus devices).

+endif # HAS_IOMEM
+
config MTD_DOCPROBE
tristate
select MTD_DOCECC
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index a0dd7bb..e793b29 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -1,3 +1,5 @@
+if HAS_IOMEM
+
menu "Mapping drivers for chip access"
depends on MTD!=n

@@ -553,3 +555,5 @@ config MTD_PISMO
When built as a module, it will be called pismo.ko

endmenu
+
+endif # HAS_IOMEM
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 4759d82..a434354 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1075,6 +1075,7 @@ static unsigned long mtd_get_unmapped_area(struct file *file,
/*
* set up a mapping for shared memory segments
*/
+#ifdef CONFIG_HAS_IOMEM
static int mtd_mmap(struct file *file, struct vm_area_struct *vma)
{
#ifdef CONFIG_MMU
@@ -1113,6 +1114,7 @@ static int mtd_mmap(struct file *file, struct vm_area_struct *vma)
return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS;
#endif
}
+#endif

static const struct file_operations mtd_fops = {
.owner = THIS_MODULE,
@@ -1125,7 +1127,9 @@ static const struct file_operations mtd_fops = {
#endif
.open = mtd_open,
.release = mtd_close,
+#ifdef CONFIG_HAS_IOMEM
.mmap = mtd_mmap,
+#endif
#ifndef CONFIG_MMU
.get_unmapped_area = mtd_get_unmapped_area,
#endif
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 8229802..8bdd465 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -10,6 +10,8 @@ config MTD_NAND_ECC_SMC
The original Linux implementation had byte 0 and 1 swapped.


+if HAS_IOMEM
+
menuconfig MTD_NAND
tristate "NAND Device Support"
depends on MTD
@@ -533,3 +535,4 @@ config MTD_NAND_FSMC
Flexible Static Memory Controller (FSMC)

endif # MTD_NAND
+endif # HAS_IOMEM
diff --git a/drivers/mtd/onenand/Kconfig b/drivers/mtd/onenand/Kconfig
index 4dbd0f5..166aa18 100644
--- a/drivers/mtd/onenand/Kconfig
+++ b/drivers/mtd/onenand/Kconfig
@@ -1,3 +1,5 @@
+if HAS_IOMEM
+
menuconfig MTD_ONENAND
tristate "OneNAND Device Support"
depends on MTD
@@ -75,3 +77,4 @@ config MTD_ONENAND_SIM
OneNAND MTD layer.

endif # MTD_ONENAND
+endif # HAS_IOMEM
diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
index a9e6ba4..c7233ba 100644
--- a/include/linux/mtd/map.h
+++ b/include/linux/mtd/map.h
@@ -388,6 +388,7 @@ static inline map_word map_word_ff(struct map_info *map)
return r;
}

+#ifdef CONFIG_HAS_IOMEM
static inline map_word inline_map_read(struct map_info *map, unsigned long ofs)
{
map_word r;
@@ -439,6 +440,7 @@ static inline void inline_map_copy_to(struct map_info *map, unsigned long to, co
{
memcpy_toio(map->virt + to, from, len);
}
+#endif /* CONFIG_HAS_IOMEM */

#ifdef CONFIG_MTD_COMPLEX_MAPPINGS
#define map_read(map, ofs) (map)->read(map, ofs)
--
1.7.2.3

2010-12-07 09:39:44

by Richard Weinberger

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Tue, Dec 7, 2010 at 8:29 AM, Jason Lunz <[email protected]> wrote:
>
> Allow parts of drivers/mtd to compile on uml by pushing the HAS_IOMEM
> dependencies down closer to the parts of mtd that actually need it.
> This allows enough of mtd to build to let jffs2 be used on uml.
>
> Signed-off-by: Jason Lunz <[email protected]>
> ---
> ?arch/um/Kconfig.rest ? ? ? ?| ? ?4 +---
> ?drivers/mtd/Kconfig ? ? ? ? | ? ?1 -
> ?drivers/mtd/Makefile ? ? ? ?| ? ?3 ++-
> ?drivers/mtd/chips/Kconfig ? | ? ?4 ++++
> ?drivers/mtd/devices/Kconfig | ? ?8 ++++++++
> ?drivers/mtd/maps/Kconfig ? ?| ? ?4 ++++
> ?drivers/mtd/mtdchar.c ? ? ? | ? ?4 ++++
> ?drivers/mtd/nand/Kconfig ? ?| ? ?3 +++
> ?drivers/mtd/onenand/Kconfig | ? ?3 +++
> ?include/linux/mtd/map.h ? ? | ? ?2 ++
> ?10 files changed, 31 insertions(+), 5 deletions(-)
>
> diff --git a/arch/um/Kconfig.rest b/arch/um/Kconfig.rest
> index 0ccad0f..e34f399 100644
> --- a/arch/um/Kconfig.rest
> +++ b/arch/um/Kconfig.rest
> @@ -28,9 +28,7 @@ source "drivers/scsi/Kconfig"
>
> ?source "drivers/md/Kconfig"
>
> -if BROKEN
> - ? ? ? source "drivers/mtd/Kconfig"
> -endif
> +source "drivers/mtd/Kconfig"

drivers/mtd was already marked as broken when we moved over to git (2.6.12-rc2).

Do you exactly know why it was marked and fixes this patch all issues?

> ?source "drivers/leds/Kconfig"
>
> diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
> index 1e2cbf5..a0e2a28 100644
> --- a/drivers/mtd/Kconfig
> +++ b/drivers/mtd/Kconfig
> @@ -1,6 +1,5 @@
> ?menuconfig MTD
> ? ? ? ?tristate "Memory Technology Device (MTD) support"
> - ? ? ? depends on HAS_IOMEM
> ? ? ? ?help
> ? ? ? ? ?Memory Technology Devices are flash, RAM and similar chips, often
> ? ? ? ? ?used for solid state file systems on embedded devices. This option
> diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
> index 760abc5..ffa2e15 100644
> --- a/drivers/mtd/Makefile
> +++ b/drivers/mtd/Makefile
> @@ -30,6 +30,7 @@ obj-$(CONFIG_MTD_OOPS) ? ? ? ? ? ? ? ?+= mtdoops.o
> ?nftl-objs ? ? ? ? ? ? ?:= nftlcore.o nftlmount.o
> ?inftl-objs ? ? ? ? ? ? := inftlcore.o inftlmount.o
>
> -obj-y ? ? ? ? ?+= chips/ lpddr/ maps/ devices/ nand/ onenand/ tests/
> +obj-y ? ? ? ? ? ? ? ? ?+= maps/ devices/ nand/ onenand/ tests/
> +obj-$(CONFIG_HAS_IOMEM) ? ? ? ?+= chips/ lpddr/
>
> ?obj-$(CONFIG_MTD_UBI) ? ? ? ? ?+= ubi/
> diff --git a/drivers/mtd/chips/Kconfig b/drivers/mtd/chips/Kconfig
> index 35c6a23..27382c9 100644
> --- a/drivers/mtd/chips/Kconfig
> +++ b/drivers/mtd/chips/Kconfig
> @@ -1,3 +1,5 @@
> +if HAS_IOMEM
> +
> ?menu "RAM/ROM/Flash chip drivers"
> ? ? ? ?depends on MTD!=n
>
> @@ -240,3 +242,5 @@ config MTD_XIP
> ? ? ? ? ?then say N.
>
> ?endmenu
> +
> +endif # HAS_IOMEM
> diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
> index 35081ce..8f6d85d 100644
> --- a/drivers/mtd/devices/Kconfig
> +++ b/drivers/mtd/devices/Kconfig
> @@ -112,6 +112,8 @@ config MTD_SST25L
> ? ? ? ? ?Set up your spi devices with the right board-specific platform data,
> ? ? ? ? ?if you want to specify device partitioning.
>
> +if HAS_IOMEM
> +
> ?config MTD_SLRAM
> ? ? ? ?tristate "Uncached system RAM"
> ? ? ? ?help
> @@ -128,6 +130,8 @@ config MTD_PHRAM
> ? ? ? ? ?doesn't have access to, memory beyond the mem=xxx limit, nvram,
> ? ? ? ? ?memory on the video card, etc...
>
> +endif # HAS_IOMEM
> +
> ?config MTD_LART
> ? ? ? ?tristate "28F160xx flash driver for LART"
> ? ? ? ?depends on SA1100_LART
> @@ -187,6 +191,8 @@ config MTD_BLOCK2MTD
> ? ? ? ? ?Testing MTD users (eg JFFS2) on large media and media that might
> ? ? ? ? ?be removed during a write (using the floppy drive).
>
> +if HAS_IOMEM
> +
> ?comment "Disk-On-Chip Device Drivers"
>
> ?config MTD_DOC2000
> @@ -249,6 +255,8 @@ config MTD_DOC2001PLUS
> ? ? ? ? ?under "NAND Flash Device Drivers" (currently that driver does not
> ? ? ? ? ?support all Millennium Plus devices).
>
> +endif # HAS_IOMEM
> +
> ?config MTD_DOCPROBE
> ? ? ? ?tristate
> ? ? ? ?select MTD_DOCECC
> diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
> index a0dd7bb..e793b29 100644
> --- a/drivers/mtd/maps/Kconfig
> +++ b/drivers/mtd/maps/Kconfig
> @@ -1,3 +1,5 @@
> +if HAS_IOMEM
> +
> ?menu "Mapping drivers for chip access"
> ? ? ? ?depends on MTD!=n
>
> @@ -553,3 +555,5 @@ config MTD_PISMO
> ? ? ? ? ?When built as a module, it will be called pismo.ko
>
> ?endmenu
> +
> +endif # HAS_IOMEM
> diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
> index 4759d82..a434354 100644
> --- a/drivers/mtd/mtdchar.c
> +++ b/drivers/mtd/mtdchar.c
> @@ -1075,6 +1075,7 @@ static unsigned long mtd_get_unmapped_area(struct file *file,
> ?/*
> ?* set up a mapping for shared memory segments
> ?*/
> +#ifdef CONFIG_HAS_IOMEM
> ?static int mtd_mmap(struct file *file, struct vm_area_struct *vma)
> ?{
> ?#ifdef CONFIG_MMU
> @@ -1113,6 +1114,7 @@ static int mtd_mmap(struct file *file, struct vm_area_struct *vma)
> ? ? ? ?return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS;
> ?#endif
> ?}
> +#endif
>
> ?static const struct file_operations mtd_fops = {
> ? ? ? ?.owner ? ? ? ? ?= THIS_MODULE,
> @@ -1125,7 +1127,9 @@ static const struct file_operations mtd_fops = {
> ?#endif
> ? ? ? ?.open ? ? ? ? ? = mtd_open,
> ? ? ? ?.release ? ? ? ?= mtd_close,
> +#ifdef CONFIG_HAS_IOMEM
> ? ? ? ?.mmap ? ? ? ? ? = mtd_mmap,
> +#endif
> ?#ifndef CONFIG_MMU
> ? ? ? ?.get_unmapped_area = mtd_get_unmapped_area,
> ?#endif
> diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
> index 8229802..8bdd465 100644
> --- a/drivers/mtd/nand/Kconfig
> +++ b/drivers/mtd/nand/Kconfig
> @@ -10,6 +10,8 @@ config MTD_NAND_ECC_SMC
> ? ? ? ? ?The original Linux implementation had byte 0 and 1 swapped.
>
>
> +if HAS_IOMEM
> +
> ?menuconfig MTD_NAND
> ? ? ? ?tristate "NAND Device Support"
> ? ? ? ?depends on MTD
> @@ -533,3 +535,4 @@ config MTD_NAND_FSMC
> ? ? ? ? ?Flexible Static Memory Controller (FSMC)
>
> ?endif # MTD_NAND
> +endif # HAS_IOMEM
> diff --git a/drivers/mtd/onenand/Kconfig b/drivers/mtd/onenand/Kconfig
> index 4dbd0f5..166aa18 100644
> --- a/drivers/mtd/onenand/Kconfig
> +++ b/drivers/mtd/onenand/Kconfig
> @@ -1,3 +1,5 @@
> +if HAS_IOMEM
> +
> ?menuconfig MTD_ONENAND
> ? ? ? ?tristate "OneNAND Device Support"
> ? ? ? ?depends on MTD
> @@ -75,3 +77,4 @@ config MTD_ONENAND_SIM
> ? ? ? ? ?OneNAND MTD layer.
>
> ?endif # MTD_ONENAND
> +endif # HAS_IOMEM
> diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
> index a9e6ba4..c7233ba 100644
> --- a/include/linux/mtd/map.h
> +++ b/include/linux/mtd/map.h
> @@ -388,6 +388,7 @@ static inline map_word map_word_ff(struct map_info *map)
> ? ? ? ?return r;
> ?}
>
> +#ifdef CONFIG_HAS_IOMEM
> ?static inline map_word inline_map_read(struct map_info *map, unsigned long ofs)
> ?{
> ? ? ? ?map_word r;
> @@ -439,6 +440,7 @@ static inline void inline_map_copy_to(struct map_info *map, unsigned long to, co
> ?{
> ? ? ? ?memcpy_toio(map->virt + to, from, len);
> ?}
> +#endif /* CONFIG_HAS_IOMEM */
>
> ?#ifdef CONFIG_MTD_COMPLEX_MAPPINGS
> ?#define map_read(map, ofs) (map)->read(map, ofs)
> --
> 1.7.2.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at ?http://www.tux.org/lkml/
>



--
Thanks,
//richard

2010-12-07 18:20:48

by Jason Lunz

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Tue, Dec 07, 2010 at 10:39:41AM +0100, richard -rw- weinberger wrote:
> On Tue, Dec 7, 2010 at 8:29 AM, Jason Lunz <[email protected]> wrote:
> >
> > Allow parts of drivers/mtd to compile on uml by pushing the HAS_IOMEM
> > dependencies down closer to the parts of mtd that actually need it.
> > This allows enough of mtd to build to let jffs2 be used on uml.
> >
> > Signed-off-by: Jason Lunz <[email protected]>
> > ---
> > ?arch/um/Kconfig.rest ? ? ? ?| ? ?4 +---
> > ?drivers/mtd/Kconfig ? ? ? ? | ? ?1 -
> > ?drivers/mtd/Makefile ? ? ? ?| ? ?3 ++-
> > ?drivers/mtd/chips/Kconfig ? | ? ?4 ++++
> > ?drivers/mtd/devices/Kconfig | ? ?8 ++++++++
> > ?drivers/mtd/maps/Kconfig ? ?| ? ?4 ++++
> > ?drivers/mtd/mtdchar.c ? ? ? | ? ?4 ++++
> > ?drivers/mtd/nand/Kconfig ? ?| ? ?3 +++
> > ?drivers/mtd/onenand/Kconfig | ? ?3 +++
> > ?include/linux/mtd/map.h ? ? | ? ?2 ++
> > ?10 files changed, 31 insertions(+), 5 deletions(-)
> >
> > diff --git a/arch/um/Kconfig.rest b/arch/um/Kconfig.rest
> > index 0ccad0f..e34f399 100644
> > --- a/arch/um/Kconfig.rest
> > +++ b/arch/um/Kconfig.rest
> > @@ -28,9 +28,7 @@ source "drivers/scsi/Kconfig"
> >
> > ?source "drivers/md/Kconfig"
> >
> > -if BROKEN
> > - ? ? ? source "drivers/mtd/Kconfig"
> > -endif
> > +source "drivers/mtd/Kconfig"
>
> drivers/mtd was already marked as broken when we moved over to git (2.6.12-rc2).
>
> Do you exactly know why it was marked and fixes this patch all issues?

I don't know exactly why it was originally marked BROKEN. I imagine it
was because most of the low-level mtd drivers need readb/writeb and
friends, which don't exist on uml. But now that mtd has virtual ram- and
blockdev-backed drivers, that's no longer sufficient reason to omit the
whole subsystem.

I can't claim that this fixes all possible issues of course, but I've
privately been using this patch to run block2mtd under uml for years. My
original motivation was to allow the use of jffs2 in a uml-based test
environment and for that it's worked very well.

Jason

2010-12-14 16:25:29

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Tue, 2010-12-07 at 10:20 -0800, Jason Lunz wrote:
> On Tue, Dec 07, 2010 at 10:39:41AM +0100, richard -rw- weinberger wrote:
> > On Tue, Dec 7, 2010 at 8:29 AM, Jason Lunz <[email protected]> wrote:
> > >
> > > Allow parts of drivers/mtd to compile on uml by pushing the HAS_IOMEM
> > > dependencies down closer to the parts of mtd that actually need it.
> > > This allows enough of mtd to build to let jffs2 be used on uml.
> > >
> > > Signed-off-by: Jason Lunz <[email protected]>
> > > ---
> > > arch/um/Kconfig.rest | 4 +---
> > > drivers/mtd/Kconfig | 1 -
> > > drivers/mtd/Makefile | 3 ++-
> > > drivers/mtd/chips/Kconfig | 4 ++++
> > > drivers/mtd/devices/Kconfig | 8 ++++++++
> > > drivers/mtd/maps/Kconfig | 4 ++++
> > > drivers/mtd/mtdchar.c | 4 ++++
> > > drivers/mtd/nand/Kconfig | 3 +++
> > > drivers/mtd/onenand/Kconfig | 3 +++
> > > include/linux/mtd/map.h | 2 ++
> > > 10 files changed, 31 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/arch/um/Kconfig.rest b/arch/um/Kconfig.rest
> > > index 0ccad0f..e34f399 100644
> > > --- a/arch/um/Kconfig.rest
> > > +++ b/arch/um/Kconfig.rest
> > > @@ -28,9 +28,7 @@ source "drivers/scsi/Kconfig"
> > >
> > > source "drivers/md/Kconfig"
> > >
> > > -if BROKEN
> > > - source "drivers/mtd/Kconfig"
> > > -endif
> > > +source "drivers/mtd/Kconfig"
> >
> > drivers/mtd was already marked as broken when we moved over to git (2.6.12-rc2).
> >
> > Do you exactly know why it was marked and fixes this patch all issues?
>
> I don't know exactly why it was originally marked BROKEN. I imagine it
> was because most of the low-level mtd drivers need readb/writeb and
> friends, which don't exist on uml. But now that mtd has virtual ram- and
> blockdev-backed drivers, that's no longer sufficient reason to omit the
> whole subsystem.
>
> I can't claim that this fixes all possible issues of course, but I've
> privately been using this patch to run block2mtd under uml for years. My
> original motivation was to allow the use of jffs2 in a uml-based test
> environment and for that it's worked very well.

But I think your solution is a bit dirty, because it adds a great deal
of little 'if HAS_IOMEM' and '#ifdef CONFIG_HAS_IOMEM' to many places.
This is error-prone.

Instead, you should solve this problem in UML code. I do not know how,
but may be you can add readb/writeb there which actually do nothing or
print a scary warning, or do BUG(), and let things which use them just
fail run-time.

Anyway, please, think about a solution which needs few changes in UML
code instead of myriads of small little changes in many places.

Thanks!

--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

2010-12-14 19:52:17

by Jason Lunz

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um


On Tue, Dec 14, 2010 at 06:24:38PM +0200, Artem Bityutskiy wrote:
> But I think your solution is a bit dirty, because it adds a great deal
> of little 'if HAS_IOMEM' and '#ifdef CONFIG_HAS_IOMEM' to many places.
> This is error-prone.

The intent of that patch was to allow as much of the mtd subsystem to
compile as possible. My thinking was to try and rectify the fact that
uml has gone without mtd (and hence jffs2) support for years even though
much of it works just fine. I think the entire subsystem being marked
BROKEN in kconfig kept anyone from experimenting with it.

The patch I sent was actually a reaction to feedback I got from Sam
Ravnborg on my last attempt (um, three years ago :/ ) in which he
suggested pushing down the ifdefs closer to their points of use. But I
agree, the minimal version has a much smaller footprint.

The version below still meets the goal of allowing jffs2-on-block2mtd
usage under uml but is much smaller because only the mtd core is
included. Compile-tested on i386, x86_64, um/i386, and um/x86_64.

> Instead, you should solve this problem in UML code. I do not know how,
> but may be you can add readb/writeb there which actually do nothing or
> print a scary warning, or do BUG(), and let things which use them just
> fail run-time.

Something like this could work, but it would be error-prone for anyone
else who attempts using iomem-requiring drivers on uml. Instead of
getting obvious compile failures we'd have broken drivers that BUG() or
emit scary warnings. That doesn't seem to me like an improvement.

Jason

--

Allow parts of drivers/mtd to compile on uml by pushing the HAS_IOMEM
dependencies down closer to the parts of mtd that actually need it.
This allows enough of mtd to build to let jffs2 be used on uml.

Signed-off-by: Jason Lunz <[email protected]>
---
arch/um/Kconfig.rest | 4 +---
drivers/mtd/Kconfig | 7 +++++--
drivers/mtd/Makefile | 3 ++-
drivers/mtd/mtdchar.c | 4 ++++
include/linux/mtd/map.h | 18 +++++++++---------
5 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/arch/um/Kconfig.rest b/arch/um/Kconfig.rest
index 0ccad0f..e34f399 100644
--- a/arch/um/Kconfig.rest
+++ b/arch/um/Kconfig.rest
@@ -28,9 +28,7 @@ source "drivers/scsi/Kconfig"

source "drivers/md/Kconfig"

-if BROKEN
- source "drivers/mtd/Kconfig"
-endif
+source "drivers/mtd/Kconfig"

source "drivers/leds/Kconfig"

diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 1e2cbf5..7537654 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -1,6 +1,5 @@
menuconfig MTD
tristate "Memory Technology Device (MTD) support"
- depends on HAS_IOMEM
help
Memory Technology Devices are flash, RAM and similar chips, often
used for solid state file systems on embedded devices. This option
@@ -307,7 +306,7 @@ config SSFDC

config SM_FTL
tristate "SmartMedia/xD new translation layer"
- depends on EXPERIMENTAL && BLOCK
+ depends on EXPERIMENTAL && BLOCK && HAS_IOMEM
select MTD_BLKDEVS
select MTD_NAND_ECC
help
@@ -330,6 +329,8 @@ config MTD_OOPS
To use, add console=ttyMTDx to the kernel command line,
where x is the MTD device number to use.

+if HAS_IOMEM
+
source "drivers/mtd/chips/Kconfig"

source "drivers/mtd/maps/Kconfig"
@@ -342,6 +343,8 @@ source "drivers/mtd/onenand/Kconfig"

source "drivers/mtd/lpddr/Kconfig"

+endif # HAS_IOMEM
+
source "drivers/mtd/ubi/Kconfig"

endif # MTD
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index 760abc5..74a03bd 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_MTD_OOPS) += mtdoops.o
nftl-objs := nftlcore.o nftlmount.o
inftl-objs := inftlcore.o inftlmount.o

-obj-y += chips/ lpddr/ maps/ devices/ nand/ onenand/ tests/
+obj-y += tests/
+obj-$(CONFIG_HAS_IOMEM) += chips/ lpddr/ maps/ devices/ nand/ onenand/

obj-$(CONFIG_MTD_UBI) += ubi/
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 4759d82..a434354 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1075,6 +1075,7 @@ static unsigned long mtd_get_unmapped_area(struct file *file,
/*
* set up a mapping for shared memory segments
*/
+#ifdef CONFIG_HAS_IOMEM
static int mtd_mmap(struct file *file, struct vm_area_struct *vma)
{
#ifdef CONFIG_MMU
@@ -1113,6 +1114,7 @@ static int mtd_mmap(struct file *file, struct vm_area_struct *vma)
return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS;
#endif
}
+#endif

static const struct file_operations mtd_fops = {
.owner = THIS_MODULE,
@@ -1125,7 +1127,9 @@ static const struct file_operations mtd_fops = {
#endif
.open = mtd_open,
.release = mtd_close,
+#ifdef CONFIG_HAS_IOMEM
.mmap = mtd_mmap,
+#endif
#ifndef CONFIG_MMU
.get_unmapped_area = mtd_get_unmapped_area,
#endif
diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
index a9e6ba4..3d9f7e0 100644
--- a/include/linux/mtd/map.h
+++ b/include/linux/mtd/map.h
@@ -388,6 +388,15 @@ static inline map_word map_word_ff(struct map_info *map)
return r;
}

+#ifdef CONFIG_MTD_COMPLEX_MAPPINGS
+#define map_read(map, ofs) (map)->read(map, ofs)
+#define map_copy_from(map, to, from, len) (map)->copy_from(map, to, from, len)
+#define map_write(map, datum, ofs) (map)->write(map, datum, ofs)
+#define map_copy_to(map, to, from, len) (map)->copy_to(map, to, from, len)
+
+extern void simple_map_init(struct map_info *);
+#define map_is_linear(map) (map->phys != NO_XIP)
+
static inline map_word inline_map_read(struct map_info *map, unsigned long ofs)
{
map_word r;
@@ -440,15 +449,6 @@ static inline void inline_map_copy_to(struct map_info *map, unsigned long to, co
memcpy_toio(map->virt + to, from, len);
}

-#ifdef CONFIG_MTD_COMPLEX_MAPPINGS
-#define map_read(map, ofs) (map)->read(map, ofs)
-#define map_copy_from(map, to, from, len) (map)->copy_from(map, to, from, len)
-#define map_write(map, datum, ofs) (map)->write(map, datum, ofs)
-#define map_copy_to(map, to, from, len) (map)->copy_to(map, to, from, len)
-
-extern void simple_map_init(struct map_info *);
-#define map_is_linear(map) (map->phys != NO_XIP)
-
#else
#define map_read(map, ofs) inline_map_read(map, ofs)
#define map_copy_from(map, to, from, len) inline_map_copy_from(map, to, from, len)
--
1.7.2.3

2010-12-14 20:01:40

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Tue, 2010-12-14 at 11:51 -0800, Jason Lunz wrote:
> On Tue, Dec 14, 2010 at 06:24:38PM +0200, Artem Bityutskiy wrote:
> > But I think your solution is a bit dirty, because it adds a great deal
> > of little 'if HAS_IOMEM' and '#ifdef CONFIG_HAS_IOMEM' to many places.
> > This is error-prone.
>
> The intent of that patch was to allow as much of the mtd subsystem to
> compile as possible. My thinking was to try and rectify the fact that
> uml has gone without mtd (and hence jffs2) support for years even though
> much of it works just fine. I think the entire subsystem being marked
> BROKEN in kconfig kept anyone from experimenting with it.
>
> The patch I sent was actually a reaction to feedback I got from Sam
> Ravnborg on my last attempt (um, three years ago :/ ) in which he
> suggested pushing down the ifdefs closer to their points of use. But I
> agree, the minimal version has a much smaller footprint.
>
> The version below still meets the goal of allowing jffs2-on-block2mtd
> usage under uml but is much smaller because only the mtd core is
> included. Compile-tested on i386, x86_64, um/i386, and um/x86_64.
>
> > Instead, you should solve this problem in UML code. I do not know how,
> > but may be you can add readb/writeb there which actually do nothing or
> > print a scary warning, or do BUG(), and let things which use them just
> > fail run-time.
>
> Something like this could work, but it would be error-prone for anyone
> else who attempts using iomem-requiring drivers on uml. Instead of
> getting obvious compile failures we'd have broken drivers that BUG() or
> emit scary warnings. That doesn't seem to me like an improvement.

This problem does not seem to be mtd-specific, right? So my point was
that it would be nicer to come up with a general solution.

--
Best Regards,
Artem Bityutskiy (Битюцкий Артём)

2010-12-14 21:12:32

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Tue, Dec 14, 2010 at 21:01, Artem Bityutskiy <[email protected]> wrote:
> On Tue, 2010-12-14 at 11:51 -0800, Jason Lunz wrote:
>> On Tue, Dec 14, 2010 at 06:24:38PM +0200, Artem Bityutskiy wrote:
>> > But I think your solution is a bit dirty, because it adds a great deal
>> > of little 'if HAS_IOMEM' and '#ifdef CONFIG_HAS_IOMEM' to many places.
>> > This is error-prone.
>>
>> The intent of that patch was to allow as much of the mtd subsystem to
>> compile as possible. My thinking was to try and rectify the fact that
>> uml has gone without mtd (and hence jffs2) support for years even though
>> much of it works just fine. I think the entire subsystem being marked
>> BROKEN in kconfig kept anyone from experimenting with it.
>>
>> The patch I sent was actually a reaction to feedback I got from Sam
>> Ravnborg on my last attempt (um, three years ago :/ ) in which he
>> suggested pushing down the ifdefs closer to their points of use. But I
>> agree, the minimal version has a much smaller footprint.
>>
>> The version below still meets the goal of allowing jffs2-on-block2mtd
>> usage under uml but is much smaller because only the mtd core is
>> included. Compile-tested on i386, x86_64, um/i386, and um/x86_64.
>>
>> > Instead, you should solve this problem in UML code. I do not know how,
>> > but may be you can add readb/writeb there which actually do nothing or
>> > print a scary warning, or do BUG(), and let things which use them just
>> > fail run-time.
>>
>> Something like this could work, but it would be error-prone for anyone
>> else who attempts using iomem-requiring drivers on uml. Instead of
>> getting obvious compile failures we'd have broken drivers that BUG() or
>> emit scary warnings. That doesn't seem to me like an improvement.
>
> This problem does not seem to be mtd-specific, right? So my point was
> that it would be nicer to come up with a general solution.

The generic solution for stuff that needs I/O operations is to mark it
"depends on HAS_IOMEM".

I used a similar patch in the past, IIRC to try axfs on UML.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

2010-12-14 21:24:16

by Jason Lunz

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um


On one hand you've got uml, which simply doesn't have mmio. On the other
there's mtd, which began as a method for accessing hardware devices that
are often accessed using mmio. But then the mtd subsystem developed
emulations of that hardware that are software based and thus don't
require mmio. It's mainly these emulated backends I'm interested in
exposing.

Nothing is going to change so that it makes sense to have any real
mmio-using hardware driver run on uml. The question you raise is, are
there other classes of driver with a software-only subset that can be
exposed on uml? And if so, would adding stub implementations of
readb/writeb and friends actually be enough to make those work? I'm not
aware of any, so at present I don't think the argument for implementing
this in uml arch code is very strong. Or in other words, I don't think a
"general solution" would be very general.

Jason

On Tue, Dec 14, 2010 at 10:01:33PM +0200, Artem Bityutskiy wrote:
> This problem does not seem to be mtd-specific, right? So my point was
> that it would be nicer to come up with a general solution.

2010-12-15 00:40:32

by Rob Landley

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Tuesday 14 December 2010 15:23:49 Jason Lunz wrote:
> On one hand you've got uml, which simply doesn't have mmio. On the other
> there's mtd, which began as a method for accessing hardware devices that
> are often accessed using mmio. But then the mtd subsystem developed
> emulations of that hardware that are software based and thus don't
> require mmio. It's mainly these emulated backends I'm interested in
> exposing.
>
> Nothing is going to change so that it makes sense to have any real
> mmio-using hardware driver run on uml. The question you raise is, are
> there other classes of driver with a software-only subset that can be
> exposed on uml? And if so, would adding stub implementations of
> readb/writeb and friends actually be enough to make those work? I'm not
> aware of any, so at present I don't think the argument for implementing
> this in uml arch code is very strong. Or in other words, I don't think a
> "general solution" would be very general.

For what it's worth, QEMU had replaced all my use cases for UML in the past
few years. If I wanted to play with loopback mounting jffs2 I'd build a kernel
to run under QEMU, and have that emulate the flash.

Rob
--
GPLv3: as worthy a successor as The Phantom Menace, as timely as Duke Nukem
Forever, and as welcome as New Coke.

2010-12-15 00:49:08

by Rob Landley

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Tuesday 14 December 2010 14:01:33 Artem Bityutskiy wrote:
> > > Instead, you should solve this problem in UML code. I do not know how,
> > > but may be you can add readb/writeb there which actually do nothing or
> > > print a scary warning, or do BUG(), and let things which use them just
> > > fail run-time.
> >
> > Something like this could work, but it would be error-prone for anyone
> > else who attempts using iomem-requiring drivers on uml. Instead of
> > getting obvious compile failures we'd have broken drivers that BUG() or
> > emit scary warnings. That doesn't seem to me like an improvement.
>
> This problem does not seem to be mtd-specific, right? So my point was
> that it would be nicer to come up with a general solution.

The problem is that jffs2 is a filesystem, and thus something people would
really like to be able to loopback mount, but it's hardwired to assume it's
only ever stored on a certain type of hardware, and thus requies incestuous
knowledge of the erase granularity of the flash layer in order to function.

It would be really nice to have either the loopback driver or jffs2 be able to
fake the mtd thing with some kind of "granularity=262144" option to let it
know "you're not on flash right now, but the flash you'll eventually be on is
X". This might require padding the image at the beginning and being mounted
with an offset if the filesystem doesn't start at the beginning of an erase
block when copied to the final hardware, but losetup already supports offsets.

What any of this has to do with UML is an open question. I don't want to
require UML to loopback mount a jffs2 image, I want to be able to do it from my
host. From my perspective, you're solving the wrong problem.

Rob
--
GPLv3: as worthy a successor as The Phantom Menace, as timely as Duke Nukem
Forever, and as welcome as New Coke.

2010-12-15 01:19:44

by Jason Lunz

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Tue, Dec 14, 2010 at 06:49:02PM -0600, Rob Landley wrote:
> The problem is that jffs2 is a filesystem, and thus something people would
> really like to be able to loopback mount, but it's hardwired to assume it's
> only ever stored on a certain type of hardware, and thus requies incestuous
> knowledge of the erase granularity of the flash layer in order to function.

I assume you can turn your jffs2 image file into a block dev using
losetup, then turn the corresponding loop device into an mtd device
using block2mtd, at which point you ought to be able to mount it with
jffs2. I've never tried it.

> What any of this has to do with UML is an open question. I don't want to
> require UML to loopback mount a jffs2 image, I want to be able to do it from my
> host. From my perspective, you're solving the wrong problem.

There's more than just loopback-mounting jffs2 images. I use this to
make entire uml+jffs2 virtual machines for testing purposes.

Jason

2010-12-15 06:31:30

by Rob Landley

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Tuesday 14 December 2010 19:19:05 Jason Lunz wrote:
> On Tue, Dec 14, 2010 at 06:49:02PM -0600, Rob Landley wrote:
> > The problem is that jffs2 is a filesystem, and thus something people
> > would really like to be able to loopback mount, but it's hardwired to
> > assume it's only ever stored on a certain type of hardware, and thus
> > requies incestuous knowledge of the erase granularity of the flash layer
> > in order to function.
>
> I assume you can turn your jffs2 image file into a block dev using
> losetup, then turn the corresponding loop device into an mtd device
> using block2mtd, at which point you ought to be able to mount it with
> jffs2. I've never tried it.

That is awesome and I'm not finding any documentation on it... Ah:

http://wiki.maemo.org/Modifying_the_root_image#Block_device_emulating_an_MTD_device

Wow that's awkward. Let's see, that says...

mknod /tmp/mtdblock0 b 31 0
modprobe loop
losetup /dev/loop0 rootfs.jffs2
modprobe mtdblock
modprobe block2mtd
# Note the ,128KiB is needed (on 2.6.26 at least) to set the
# eraseblock size.
echo "/dev/loop0,128KiB" > /sys/module/block2mtd/parameters/block2mtd
modprobe jffs2
mount -t jffs2 /tmp/mtdblock0 /media/jffs2

So the system isn't automatically loading mtdblock, udev isn't creating any
/dev nodes for it even thought it is for loop, the associations are created by
writing strings into a filesystem with a _notoriously_ unstable API (and it
expects a three letter mixed case suffix to specify units), and despite
"mtdblock0" I have no idea how that echo syntax would specify more than one
association at a time.

I'm trying to figure out whether creating a shell script for this or trying to
modify the busybox mount command would be a better approach to beating some
sort of usability out of doing this.

Hmmm, mkfs.jffs2 is named as a mkfs but acts a a generator ala genext2fs. How
about...

mkdir empty
mkfs.jffs2 -r empty -o rootfs.jffs2 -e 128 -l -n

And it created an empty (zero byte) file. That's nice. If I touch a file in
"empty" now 116 bytes. Adding -p makes it one erase block, but adding "-p
2048" doesn't specify a multiple of the erase block size, it instead rounded
rounded it _down_ to that many bytes. But --pad=$((2048*1024*1024)) was
apparently ignored...? How do I specify a _size_ for this thing so it has
empty space I can write into after the fact? (The man page says pad with
0xFF. Am I going to have to do this by hand?)

mkdir empty
touch empty/hello
mkfs.jffs2 -r empty -o temp.jffs2 -e 128 -l -n -p
python -c "import sys; sys.stdout.write(131072*63*chr(0xff))" >> temp.jffs2
losetup /dev/loop0 temp.jffs2
echo "/dev/loop0,128KiB" > /sys/module/block2mtd/parameters/block2mtd
mount -t jffs2 mtdblock0 empty

Yay! I have a filesystem! And df claims it's 8 megabytes.

Woot.

> > What any of this has to do with UML is an open question. I don't want to
> > require UML to loopback mount a jffs2 image, I want to be able to do it
> > from my host. From my perspective, you're solving the wrong problem.
>
> There's more than just loopback-mounting jffs2 images. I use this to
> make entire uml+jffs2 virtual machines for testing purposes.

As I said, I'm almost exclusively using qemu/kvm these days, but this is
fun...

> Jason

Rob
--
GPLv3: as worthy a successor as The Phantom Menace, as timely as Duke Nukem
Forever, and as welcome as New Coke.

2010-12-15 08:18:36

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Wed, Dec 15, 2010 at 02:19, Jason Lunz <[email protected]> wrote:
> On Tue, Dec 14, 2010 at 06:49:02PM -0600, Rob Landley wrote:
>> The problem is that jffs2 is a filesystem, and thus something people would
>> really like to be able to loopback mount, but it's hardwired to assume it's
>> only ever stored on a certain type of hardware, and thus requies incestuous
>> knowledge of the erase granularity of the flash layer in order to function.
>
> I assume you can turn your jffs2 image file into a block dev using
> losetup, then turn the corresponding loop device into an mtd device
> using block2mtd, at which point you ought to be able to mount it with
> jffs2. I've never tried it.

And block2mtd is part of mtd, so you have to get mtd compiled first.

BTW, the patch I used in the past was less intrusive than yours.
I attached it, as I can't send it inline from here.
Note that it was against 2.6.31-rc4.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds


Attachments:
uml-mtd.diff (3.02 kB)

2010-12-16 15:19:10

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Wed, 2010-12-15 at 00:31 -0600, Rob Landley wrote:
> That is awesome and I'm not finding any documentation on it... Ah:
>
> http://wiki.maemo.org/Modifying_the_root_image#Block_device_emulating_an_MTD_device
>
> Wow that's awkward. Let's see, that says...
>
> mknod /tmp/mtdblock0 b 31 0
> modprobe loop
> losetup /dev/loop0 rootfs.jffs2
> modprobe mtdblock
> modprobe block2mtd
> # Note the ,128KiB is needed (on 2.6.26 at least) to set the
> # eraseblock size.
> echo "/dev/loop0,128KiB" > /sys/module/block2mtd/parameters/block2mtd
> modprobe jffs2
> mount -t jffs2 /tmp/mtdblock0 /media/jffs2

You should not need mtdblock in modern kernels, it is legacy. You should
be abole to mount jffs2 on top of mtd0 with

mount -t jffs2 mtd0 /media/jffs2

--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

2010-12-16 15:25:41

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Tue, 2010-12-14 at 11:51 -0800, Jason Lunz wrote:
> On Tue, Dec 14, 2010 at 06:24:38PM +0200, Artem Bityutskiy wrote:
> > But I think your solution is a bit dirty, because it adds a great deal
> > of little 'if HAS_IOMEM' and '#ifdef CONFIG_HAS_IOMEM' to many places.
> > This is error-prone.
>
> The intent of that patch was to allow as much of the mtd subsystem to
> compile as possible. My thinking was to try and rectify the fact that
> uml has gone without mtd (and hence jffs2) support for years even though
> much of it works just fine. I think the entire subsystem being marked
> BROKEN in kconfig kept anyone from experimenting with it.
>
> The patch I sent was actually a reaction to feedback I got from Sam
> Ravnborg on my last attempt (um, three years ago :/ ) in which he
> suggested pushing down the ifdefs closer to their points of use. But I
> agree, the minimal version has a much smaller footprint.
>
> The version below still meets the goal of allowing jffs2-on-block2mtd
> usage under uml but is much smaller because only the mtd core is
> included. Compile-tested on i386, x86_64, um/i386, and um/x86_64.
>
> > Instead, you should solve this problem in UML code. I do not know how,
> > but may be you can add readb/writeb there which actually do nothing or
> > print a scary warning, or do BUG(), and let things which use them just
> > fail run-time.
>
> Something like this could work, but it would be error-prone for anyone
> else who attempts using iomem-requiring drivers on uml. Instead of
> getting obvious compile failures we'd have broken drivers that BUG() or
> emit scary warnings. That doesn't seem to me like an improvement.

OK, pushed this patch to l2-mtd-2.6.git.

--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

2010-12-16 22:01:15

by Anatolij Gustschin

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Tue, 14 Dec 2010 11:51:24 -0800
Jason Lunz <[email protected]> wrote:
...
> diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
> index a9e6ba4..3d9f7e0 100644
> --- a/include/linux/mtd/map.h
> +++ b/include/linux/mtd/map.h
> @@ -388,6 +388,15 @@ static inline map_word map_word_ff(struct map_info *map)
> return r;
> }
>
> +#ifdef CONFIG_MTD_COMPLEX_MAPPINGS
> +#define map_read(map, ofs) (map)->read(map, ofs)
> +#define map_copy_from(map, to, from, len) (map)->copy_from(map, to, from, len)
> +#define map_write(map, datum, ofs) (map)->write(map, datum, ofs)
> +#define map_copy_to(map, to, from, len) (map)->copy_to(map, to, from, len)
> +
> +extern void simple_map_init(struct map_info *);
> +#define map_is_linear(map) (map->phys != NO_XIP)
> +
> static inline map_word inline_map_read(struct map_info *map, unsigned long ofs)
> {
> map_word r;
> @@ -440,15 +449,6 @@ static inline void inline_map_copy_to(struct map_info *map, unsigned long to, co
> memcpy_toio(map->virt + to, from, len);
> }
>
> -#ifdef CONFIG_MTD_COMPLEX_MAPPINGS
> -#define map_read(map, ofs) (map)->read(map, ofs)
> -#define map_copy_from(map, to, from, len) (map)->copy_from(map, to, from, len)
> -#define map_write(map, datum, ofs) (map)->write(map, datum, ofs)
> -#define map_copy_to(map, to, from, len) (map)->copy_to(map, to, from, len)
> -
> -extern void simple_map_init(struct map_info *);
> -#define map_is_linear(map) (map->phys != NO_XIP)
> -
> #else
> #define map_read(map, ofs) inline_map_read(map, ofs)
> #define map_copy_from(map, to, from, len) inline_map_copy_from(map, to, from, len)

This change breaks compiling when CONFIG_MTD_COMPLEX_MAPPINGS is not
defined in the kernel configuration. Please fix!

Thanks,
Anatolij

2010-12-17 04:28:46

by Jason Lunz

[permalink] [raw]
Subject: mtd: fix CONFIG_MTD_COMPLEX_MAPPINGS=n compile

On Thu, Dec 16, 2010 at 11:01:10PM +0100, Anatolij Gustschin wrote:
> This change breaks compiling when CONFIG_MTD_COMPLEX_MAPPINGS is not
> defined in the kernel configuration. Please fix!

Sorry, sloppy of me. This reverts all changes to mtd.h while keeping the
ability to compile mtd on ARCH=um, with the exception mtdchar.

Jason

--

Revert hiding of inline_map_* functions in linux/mtd.h, and mark
MTD_CHAR as incompatible with uml until a better solution can be found
there.

Signed-off-by: Jason Lunz <[email protected]>

---
drivers/mtd/Kconfig | 1 +
include/linux/mtd/map.h | 18 +++++++++---------
2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 7537654..51471a5 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -174,6 +174,7 @@ comment "User Modules And Translation Layers"

config MTD_CHAR
tristate "Direct char device access to MTD devices"
+ depends on HAS_IOMEM
help
This provides a character device for each MTD device present in
the system, allowing the user to read and write directly to the
diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
index 3d9f7e0..a9e6ba4 100644
--- a/include/linux/mtd/map.h
+++ b/include/linux/mtd/map.h
@@ -388,15 +388,6 @@ static inline map_word map_word_ff(struct map_info *map)
return r;
}

-#ifdef CONFIG_MTD_COMPLEX_MAPPINGS
-#define map_read(map, ofs) (map)->read(map, ofs)
-#define map_copy_from(map, to, from, len) (map)->copy_from(map, to, from, len)
-#define map_write(map, datum, ofs) (map)->write(map, datum, ofs)
-#define map_copy_to(map, to, from, len) (map)->copy_to(map, to, from, len)
-
-extern void simple_map_init(struct map_info *);
-#define map_is_linear(map) (map->phys != NO_XIP)
-
static inline map_word inline_map_read(struct map_info *map, unsigned long ofs)
{
map_word r;
@@ -449,6 +440,15 @@ static inline void inline_map_copy_to(struct map_info *map, unsigned long to, co
memcpy_toio(map->virt + to, from, len);
}

+#ifdef CONFIG_MTD_COMPLEX_MAPPINGS
+#define map_read(map, ofs) (map)->read(map, ofs)
+#define map_copy_from(map, to, from, len) (map)->copy_from(map, to, from, len)
+#define map_write(map, datum, ofs) (map)->write(map, datum, ofs)
+#define map_copy_to(map, to, from, len) (map)->copy_to(map, to, from, len)
+
+extern void simple_map_init(struct map_info *);
+#define map_is_linear(map) (map->phys != NO_XIP)
+
#else
#define map_read(map, ofs) inline_map_read(map, ofs)
#define map_copy_from(map, to, from, len) inline_map_copy_from(map, to, from, len)
--
1.7.2.3

2010-12-18 04:08:25

by Rob Landley

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Thursday 16 December 2010 09:18:31 Artem Bityutskiy wrote:
> On Wed, 2010-12-15 at 00:31 -0600, Rob Landley wrote:
> > That is awesome and I'm not finding any documentation on it... Ah:
> >
> >
> > http://wiki.maemo.org/Modifying_the_root_image#Block_device_emulating_an_
> >MTD_device
> >
> > Wow that's awkward. Let's see, that says...
> >
> > mknod /tmp/mtdblock0 b 31 0
> > modprobe loop
> > losetup /dev/loop0 rootfs.jffs2
> > modprobe mtdblock
> > modprobe block2mtd
> > # Note the ,128KiB is needed (on 2.6.26 at least) to set the
> > # eraseblock size.
> > echo "/dev/loop0,128KiB" > /sys/module/block2mtd/parameters/block2mtd
> > modprobe jffs2
> > mount -t jffs2 /tmp/mtdblock0 /media/jffs2
>
> You should not need mtdblock in modern kernels, it is legacy. You should
> be abole to mount jffs2 on top of mtd0 with
>
> mount -t jffs2 mtd0 /media/jffs2

How does one associate the mtd0 with the loopback device? (I thought mtd0 was
for actual flash memory.)

Rob
--
GPLv3: as worthy a successor as The Phantom Menace, as timely as Duke Nukem
Forever, and as welcome as New Coke.

2010-12-19 16:54:15

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: mtd: fix CONFIG_MTD_COMPLEX_MAPPINGS=n compile

On Thu, 2010-12-16 at 20:27 -0800, Jason Lunz wrote:
> On Thu, Dec 16, 2010 at 11:01:10PM +0100, Anatolij Gustschin wrote:
> > This change breaks compiling when CONFIG_MTD_COMPLEX_MAPPINGS is not
> > defined in the kernel configuration. Please fix!
>
> Sorry, sloppy of me. This reverts all changes to mtd.h while keeping the
> ability to compile mtd on ARCH=um, with the exception mtdchar.

Merged with the previous patch, thanks.

--
Best Regards,
Artem Bityutskiy (Битюцкий Артём)

2010-12-19 17:08:29

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Fri, 2010-12-17 at 22:08 -0600, Rob Landley wrote:
> On Thursday 16 December 2010 09:18:31 Artem Bityutskiy wrote:
> > On Wed, 2010-12-15 at 00:31 -0600, Rob Landley wrote:
> > > That is awesome and I'm not finding any documentation on it... Ah:
> > >
> > >
> > > http://wiki.maemo.org/Modifying_the_root_image#Block_device_emulating_an_
> > >MTD_device
> > >
> > > Wow that's awkward. Let's see, that says...
> > >
> > > mknod /tmp/mtdblock0 b 31 0
> > > modprobe loop
> > > losetup /dev/loop0 rootfs.jffs2
> > > modprobe mtdblock
> > > modprobe block2mtd
> > > # Note the ,128KiB is needed (on 2.6.26 at least) to set the
> > > # eraseblock size.
> > > echo "/dev/loop0,128KiB" > /sys/module/block2mtd/parameters/block2mtd
> > > modprobe jffs2
> > > mount -t jffs2 /tmp/mtdblock0 /media/jffs2
> >
> > You should not need mtdblock in modern kernels, it is legacy. You should
> > be abole to mount jffs2 on top of mtd0 with
> >
> > mount -t jffs2 mtd0 /media/jffs2
>
> How does one associate the mtd0 with the loopback device? (I thought mtd0 was
> for actual flash memory.)

You do not need loopback devices, just flash your rootfs.jffs2 directly
to /dev/mtd0, e.g., with nandwrite. You can emulate nand with nandsim.

But your method should also work, I just wanted to point that JFFS2 does
not depend on mtdblock in any way.

--
Best Regards,
Artem Bityutskiy (Битюцкий Артём)

2010-12-19 19:07:32

by Jason Lunz

[permalink] [raw]
Subject: Re: mtd: fix CONFIG_MTD_COMPLEX_MAPPINGS=n compile


You should also drop the changes that
7bc3265a9e9a09d6a9a3cfaaf53ccf3af5271a93 made to drivers/mtd/mtdchar.c -
there's no point changing that when mtdchar is disabled on ARCH=um.

Jason

On Sun, Dec 19, 2010 at 06:47:56PM +0200, Artem Bityutskiy wrote:
> On Thu, 2010-12-16 at 20:27 -0800, Jason Lunz wrote:
> > On Thu, Dec 16, 2010 at 11:01:10PM +0100, Anatolij Gustschin wrote:
> > > This change breaks compiling when CONFIG_MTD_COMPLEX_MAPPINGS is not
> > > defined in the kernel configuration. Please fix!
> >
> > Sorry, sloppy of me. This reverts all changes to mtd.h while keeping the
> > ability to compile mtd on ARCH=um, with the exception mtdchar.
>
> Merged with the previous patch, thanks.
>
> --
> Best Regards,
> Artem Bityutskiy (Битюцкий Артём)
>
>

2010-12-20 11:23:42

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: mtd: fix CONFIG_MTD_COMPLEX_MAPPINGS=n compile

On Sun, 2010-12-19 at 14:07 -0500, Jason Lunz wrote:
> You should also drop the changes that
> 7bc3265a9e9a09d6a9a3cfaaf53ccf3af5271a93 made to drivers/mtd/mtdchar.c -
> there's no point changing that when mtdchar is disabled on ARCH=um.

Ok, could you please re-sent the final patch with the commit message
etc?

--
Best Regards,
Artem Bityutskiy (Битюцкий Артём)

2010-12-20 14:05:01

by Jason Lunz

[permalink] [raw]
Subject: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Mon, Dec 20, 2010 at 01:23:36PM +0200, Artem Bityutskiy wrote:
> Ok, could you please re-sent the final patch with the commit message
> etc?

Sure, here's everything as a single patch.

------------------------------------->8
Allow parts of drivers/mtd to compile on uml by pushing the HAS_IOMEM
dependencies down closer to the parts of mtd that actually need it.
This allows enough of mtd to build to let jffs2 be used on uml.

Signed-off-by: Jason Lunz <[email protected]>
---
arch/um/Kconfig.rest | 4 +---
drivers/mtd/Kconfig | 8 ++++++--
drivers/mtd/Makefile | 3 ++-
3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/arch/um/Kconfig.rest b/arch/um/Kconfig.rest
index 0ccad0f..e34f399 100644
--- a/arch/um/Kconfig.rest
+++ b/arch/um/Kconfig.rest
@@ -28,9 +28,7 @@ source "drivers/scsi/Kconfig"

source "drivers/md/Kconfig"

-if BROKEN
- source "drivers/mtd/Kconfig"
-endif
+source "drivers/mtd/Kconfig"

source "drivers/leds/Kconfig"

diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 7741470..603e447 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -1,6 +1,5 @@
menuconfig MTD
tristate "Memory Technology Device (MTD) support"
- depends on HAS_IOMEM
help
Memory Technology Devices are flash, RAM and similar chips, often
used for solid state file systems on embedded devices. This option
@@ -178,6 +177,7 @@ comment "User Modules And Translation Layers"

config MTD_CHAR
tristate "Direct char device access to MTD devices"
+ depends on HAS_IOMEM
help
This provides a character device for each MTD device present in
the system, allowing the user to read and write directly to the
@@ -310,7 +310,7 @@ config SSFDC

config SM_FTL
tristate "SmartMedia/xD new translation layer"
- depends on EXPERIMENTAL && BLOCK
+ depends on EXPERIMENTAL && BLOCK && HAS_IOMEM
select MTD_BLKDEVS
select MTD_NAND_ECC
help
@@ -333,6 +333,8 @@ config MTD_OOPS
To use, add console=ttyMTDx to the kernel command line,
where x is the MTD device number to use.

+if HAS_IOMEM
+
source "drivers/mtd/chips/Kconfig"

source "drivers/mtd/maps/Kconfig"
@@ -345,6 +347,8 @@ source "drivers/mtd/onenand/Kconfig"

source "drivers/mtd/lpddr/Kconfig"

+endif # HAS_IOMEM
+
source "drivers/mtd/ubi/Kconfig"

endif # MTD
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index d4e7f25..c83eee4 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_MTD_OOPS) += mtdoops.o
nftl-objs := nftlcore.o nftlmount.o
inftl-objs := inftlcore.o inftlmount.o

-obj-y += chips/ lpddr/ maps/ devices/ nand/ onenand/ tests/
+obj-y += tests/
+obj-$(CONFIG_HAS_IOMEM) += chips/ lpddr/ maps/ devices/ nand/ onenand/

obj-$(CONFIG_MTD_UBI) += ubi/
--
1.7.2.3

2010-12-22 14:42:31

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um

On Mon, 2010-12-20 at 09:04 -0500, Jason Lunz wrote:
> On Mon, Dec 20, 2010 at 01:23:36PM +0200, Artem Bityutskiy wrote:
> > Ok, could you please re-sent the final patch with the commit message
> > etc?
>
> Sure, here's everything as a single patch.
>
> ------------------------------------->8
> Allow parts of drivers/mtd to compile on uml by pushing the HAS_IOMEM
> dependencies down closer to the parts of mtd that actually need it.
> This allows enough of mtd to build to let jffs2 be used on uml.
>
> Signed-off-by: Jason Lunz <[email protected]>

OK, taken this one, thanks.

--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)