From patchwork Tue Dec 14 19:51:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Lunz X-Patchwork-Id: 75529 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from canuck.infradead.org (canuck.infradead.org [134.117.69.58]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D51EAB6F2B for ; Wed, 15 Dec 2010 06:56:46 +1100 (EST) Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1PSav5-0004yu-0F; Tue, 14 Dec 2010 19:52:19 +0000 Received: from smtp.falooley.org ([66.180.170.91]) by canuck.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1PSauw-0004xm-GJ for linux-mtd@lists.infradead.org; Tue, 14 Dec 2010 19:52:13 +0000 Received: from dsl231-043-027.sea1.dsl.speakeasy.net ([216.231.43.27] helo=fig) by smtp.falooley.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PSavC-0001N7-AW; Tue, 14 Dec 2010 11:52:26 -0800 Received: by fig (Postfix, from userid 1000) id 7D805B6F54; Tue, 14 Dec 2010 11:51:24 -0800 (PST) Date: Tue, 14 Dec 2010 11:51:24 -0800 From: Jason Lunz To: Artem Bityutskiy Subject: Re: [PATCH] mtd: allow mtd and jffs2 when ARCH=um Message-ID: <20101214195124.GA6010@falooley.org> References: <22c797d00709272118i33d32b9dy93d5f5ec8f8edd30@mail.gmail.com> <20071024011712.GA3762@falooley.org> <1193208689.26096.48.camel@pmac.infradead.org> <20071227181524.GA19051@falooley.org> <20071228174853.GA4252@uranus.ravnborg.org> <20101207072919.GA8511@falooley.org> <20101207182012.GA10546@falooley.org> <1292343878.2538.80.camel@localhost> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1292343878.2538.80.camel@localhost> User-Agent: Mutt/1.5.20 (2009-06-14) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20101214_145210_741900_90D7B8D2 X-CRM114-Status: GOOD ( 23.45 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: atom ota , user-mode-linux-devel@lists.sourceforge.net, richard -rw- weinberger , Sam Ravnborg , Jeff Dike , lkml , linux-mtd@lists.infradead.org, Rob Landley , David Woodhouse X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 --- 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)