diff mbox

mtd: allow mtd and jffs2 when ARCH=um

Message ID 20101207072919.GA8511@falooley.org
State New, archived
Headers show

Commit Message

Jason Lunz Dec. 7, 2010, 7:29 a.m. UTC
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 <lunz@acm.org>
---
 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(-)

Comments

Richard Weinberger Dec. 7, 2010, 9:39 a.m. UTC | #1
On Tue, Dec 7, 2010 at 8:29 AM, Jason Lunz <lunz@acm.org> 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 <lunz@acm.org>
> ---
>  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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
Jason Lunz Dec. 7, 2010, 6:20 p.m. UTC | #2
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 <lunz@acm.org> 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 <lunz@acm.org>
> > ---
> >  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
Artem Bityutskiy Dec. 14, 2010, 4:24 p.m. UTC | #3
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 <lunz@acm.org> 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 <lunz@acm.org>
> > > ---
> > >  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!
diff mbox

Patch

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)