mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] Cleanup of mtd->type and mtd->flags
@ 2006-04-13 16:51 Jörn Engel
  2006-04-13 16:53 ` [PATCH 1/4] Simplify test for RAM devices Jörn Engel
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Jörn Engel @ 2006-04-13 16:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David Woodhouse, Thomas Gleixner, linux-kernel, linux-mtd

Currently, there appears to be a great confusion surrounding mtd->type
and mtd->flags.  Various combinations of type and flags are used by
device drivers to give some hints to users.  Some users interpret
these hints as seems to be intended by the drivers, others don't.
Mismatches are caused by both drivers and users being confused and the
whole system being less than clear.

This patchset is part of a larger work trying to clean things up.
Patches are fairly simple and shouldn't need any discussion.

Jörn

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] Simplify test for RAM devices
  2006-04-13 16:51 [PATCH 0/4] Cleanup of mtd->type and mtd->flags Jörn Engel
@ 2006-04-13 16:53 ` Jörn Engel
  2006-04-13 16:53 ` [PATCH 2/4] Make mtdblock_ro unconditionally readonly Jörn Engel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Jörn Engel @ 2006-04-13 16:53 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David Woodhouse, Thomas Gleixner, linux-kernel, linux-mtd

mtdblock is the only user of aggregate capabilities in mtd.  This is clearly
bogus and should be changed.  In particular, it tries to determine whether
the device in question is a piece of RAM.  For every single driver that fits
the current criteria, an easier test would be to check for the type being
MTD_RAM.

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
---

 drivers/mtd/mtdblock.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)


--- mtd_type/drivers/mtd/mtdblock.c~mtdblock_ram_test	2006-04-13 18:03:41.000000000 +0200
+++ mtd_type/drivers/mtd/mtdblock.c	2006-04-13 18:19:19.000000000 +0200
@@ -288,8 +288,7 @@ static int mtdblock_open(struct mtd_blkt
 
 	mutex_init(&mtdblk->cache_mutex);
 	mtdblk->cache_state = STATE_EMPTY;
-	if ((mtdblk->mtd->flags & MTD_CAP_RAM) != MTD_CAP_RAM &&
-	    mtdblk->mtd->erasesize) {
+	if (mtdblk->mtd->type != MTD_RAM && mtdblk->mtd->erasesize) {
 		mtdblk->cache_size = mtdblk->mtd->erasesize;
 		mtdblk->cache_data = NULL;
 	}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/4] Make mtdblock_ro unconditionally readonly
  2006-04-13 16:51 [PATCH 0/4] Cleanup of mtd->type and mtd->flags Jörn Engel
  2006-04-13 16:53 ` [PATCH 1/4] Simplify test for RAM devices Jörn Engel
@ 2006-04-13 16:53 ` Jörn Engel
  2006-04-13 16:54 ` [PATCH 3/4] Remove unchecked flags Jörn Engel
  2006-04-13 16:55 ` [PATCH 4/4] Remove unused types Jörn Engel
  3 siblings, 0 replies; 8+ messages in thread
From: Jörn Engel @ 2006-04-13 16:53 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David Woodhouse, Thomas Gleixner, linux-kernel, linux-mtd

mtdblock_ro is by definition readonly.  Remove the silly checks.

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
---

 drivers/mtd/mtdblock_ro.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- mtd_type/drivers/mtd/mtdblock_ro.c~mtdblock_ro	2006-04-13 17:56:54.000000000 +0200
+++ mtd_type/drivers/mtd/mtdblock_ro.c	2006-04-13 17:57:31.000000000 +0200
@@ -45,9 +45,7 @@ static void mtdblock_add_mtd(struct mtd_
 	dev->blksize = 512;
 	dev->size = mtd->size >> 9;
 	dev->tr = tr;
-	if ((mtd->flags & (MTD_CLEAR_BITS|MTD_SET_BITS|MTD_WRITEABLE)) !=
-	    (MTD_CLEAR_BITS|MTD_SET_BITS|MTD_WRITEABLE))
-		dev->readonly = 1;
+	dev->readonly = 1;
 
 	add_mtd_blktrans_dev(dev);
 }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/4] Remove unchecked flags
  2006-04-13 16:51 [PATCH 0/4] Cleanup of mtd->type and mtd->flags Jörn Engel
  2006-04-13 16:53 ` [PATCH 1/4] Simplify test for RAM devices Jörn Engel
  2006-04-13 16:53 ` [PATCH 2/4] Make mtdblock_ro unconditionally readonly Jörn Engel
@ 2006-04-13 16:54 ` Jörn Engel
  2006-04-13 18:08   ` Josh Boyer
  2006-04-13 16:55 ` [PATCH 4/4] Remove unused types Jörn Engel
  3 siblings, 1 reply; 8+ messages in thread
From: Jörn Engel @ 2006-04-13 16:54 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David Woodhouse, Thomas Gleixner, linux-kernel, linux-mtd

Several flags are set by some devices, but never checked.  Remove them.

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
---

 drivers/mtd/chips/map_ram.c |    2 +-
 drivers/mtd/devices/phram.c |    2 +-
 drivers/mtd/devices/slram.c |    3 +--
 include/mtd/mtd-abi.h       |   12 +++---------
 4 files changed, 6 insertions(+), 13 deletions(-)


--- mtd_type/include/mtd/mtd-abi.h~unchecked_flags	2006-04-13 18:30:42.000000000 +0200
+++ mtd_type/include/mtd/mtd-abi.h	2006-04-13 18:32:42.000000000 +0200
@@ -35,20 +35,14 @@ struct mtd_oob_buf {
 
 #define MTD_CLEAR_BITS		1       // Bits can be cleared (flash)
 #define MTD_SET_BITS		2       // Bits can be set
-#define MTD_ERASEABLE		4       // Has an erase function
-#define MTD_WRITEB_WRITEABLE	8       // Direct IO is possible
-#define MTD_VOLATILE		16      // Set for RAMs
-#define MTD_XIP			32	// eXecute-In-Place possible
-#define MTD_OOB			64	// Out-of-band data (NAND flash)
 #define MTD_ECC			128	// Device capable of automatic ECC
-#define MTD_NO_VIRTBLOCKS	256	// Virtual blocks not allowed
 #define MTD_PROGRAM_REGIONS	512	// Configurable Programming Regions
 
 // Some common devices / combinations of capabilities
 #define MTD_CAP_ROM		0
-#define MTD_CAP_RAM		(MTD_CLEAR_BITS|MTD_SET_BITS|MTD_WRITEB_WRITEABLE)
-#define MTD_CAP_NORFLASH        (MTD_CLEAR_BITS|MTD_ERASEABLE)
-#define MTD_CAP_NANDFLASH       (MTD_CLEAR_BITS|MTD_ERASEABLE|MTD_OOB)
+#define MTD_CAP_RAM		(MTD_CLEAR_BITS|MTD_SET_BITS)
+#define MTD_CAP_NORFLASH	(MTD_CLEAR_BITS)
+#define MTD_CAP_NANDFLASH	(MTD_CLEAR_BITS)
 #define MTD_WRITEABLE		(MTD_CLEAR_BITS|MTD_SET_BITS)
 
 
--- mtd_type/drivers/mtd/devices/phram.c~unchecked_flags	2006-04-13 18:30:42.000000000 +0200
+++ mtd_type/drivers/mtd/devices/phram.c	2006-04-13 18:31:00.000000000 +0200
@@ -142,7 +142,7 @@ static int register_device(char *name, u
 
 	new->mtd.name = name;
 	new->mtd.size = len;
-	new->mtd.flags = MTD_CAP_RAM | MTD_ERASEABLE | MTD_VOLATILE;
+	new->mtd.flags = MTD_CAP_RAM;
         new->mtd.erase = phram_erase;
 	new->mtd.point = phram_point;
 	new->mtd.unpoint = phram_unpoint;
--- mtd_type/drivers/mtd/chips/map_ram.c~unchecked_flags	2006-04-13 18:30:42.000000000 +0200
+++ mtd_type/drivers/mtd/chips/map_ram.c	2006-04-13 18:31:00.000000000 +0200
@@ -70,7 +70,7 @@ static struct mtd_info *map_ram_probe(st
 	mtd->read = mapram_read;
 	mtd->write = mapram_write;
 	mtd->sync = mapram_nop;
-	mtd->flags = MTD_CAP_RAM | MTD_VOLATILE;
+	mtd->flags = MTD_CAP_RAM;
 
 	mtd->erasesize = PAGE_SIZE;
  	while(mtd->size & (mtd->erasesize - 1))
--- mtd_type/drivers/mtd/devices/slram.c~unchecked_flags	2006-04-13 18:30:42.000000000 +0200
+++ mtd_type/drivers/mtd/devices/slram.c	2006-04-13 18:31:00.000000000 +0200
@@ -200,8 +200,7 @@ static int register_device(char *name, u
 
 	(*curmtd)->mtdinfo->name = name;
 	(*curmtd)->mtdinfo->size = length;
-	(*curmtd)->mtdinfo->flags = MTD_CLEAR_BITS | MTD_SET_BITS |
-					MTD_WRITEB_WRITEABLE | MTD_VOLATILE | MTD_CAP_RAM;
+	(*curmtd)->mtdinfo->flags = MTD_CAP_RAM;
         (*curmtd)->mtdinfo->erase = slram_erase;
 	(*curmtd)->mtdinfo->point = slram_point;
 	(*curmtd)->mtdinfo->unpoint = slram_unpoint;

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/4] Remove unused types
  2006-04-13 16:51 [PATCH 0/4] Cleanup of mtd->type and mtd->flags Jörn Engel
                   ` (2 preceding siblings ...)
  2006-04-13 16:54 ` [PATCH 3/4] Remove unchecked flags Jörn Engel
@ 2006-04-13 16:55 ` Jörn Engel
  3 siblings, 0 replies; 8+ messages in thread
From: Jörn Engel @ 2006-04-13 16:55 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David Woodhouse, Thomas Gleixner, linux-kernel, linux-mtd

Three types are never set or checked for.  Remove.

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
---

 include/mtd/mtd-abi.h |    3 ---
 1 file changed, 3 deletions(-)


--- mtd_type/include/mtd/mtd-abi.h~unused_types	2006-04-13 18:32:42.000000000 +0200
+++ mtd_type/include/mtd/mtd-abi.h	2006-04-13 18:34:14.000000000 +0200
@@ -28,10 +28,7 @@ struct mtd_oob_buf {
 #define MTD_ROM			2
 #define MTD_NORFLASH		3
 #define MTD_NANDFLASH		4
-#define MTD_PEROM		5
 #define MTD_DATAFLASH		6
-#define MTD_OTHER		14
-#define MTD_UNKNOWN		15
 
 #define MTD_CLEAR_BITS		1       // Bits can be cleared (flash)
 #define MTD_SET_BITS		2       // Bits can be set

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] Remove unchecked flags
  2006-04-13 16:54 ` [PATCH 3/4] Remove unchecked flags Jörn Engel
@ 2006-04-13 18:08   ` Josh Boyer
  2006-04-13 19:18     ` David Woodhouse
  0 siblings, 1 reply; 8+ messages in thread
From: Josh Boyer @ 2006-04-13 18:08 UTC (permalink / raw)
  To: Jörn Engel
  Cc: Andrew Morton, David Woodhouse, Thomas Gleixner, linux-kernel, linux-mtd

On 4/13/06, Jörn Engel <joern@wohnheim.fh-wedel.de> wrote:
> Several flags are set by some devices, but never checked.  Remove them.

As a side note, these will also need to be removed from the mtd-utils
tree.  The switch to git meant that mtd-utils has it's own copy of the
sanitized headers.  The patch for mtd-abi.h should apply there as
well.

josh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] Remove unchecked flags
  2006-04-13 18:08   ` Josh Boyer
@ 2006-04-13 19:18     ` David Woodhouse
  2006-04-13 21:50       ` Josh Boyer
  0 siblings, 1 reply; 8+ messages in thread
From: David Woodhouse @ 2006-04-13 19:18 UTC (permalink / raw)
  To: Josh Boyer
  Cc: Jörn Engel, Andrew Morton, Thomas Gleixner, linux-kernel, linux-mtd

On Thu, 2006-04-13 at 13:08 -0500, Josh Boyer wrote:
> As a side note, these will also need to be removed from the mtd-utils
> tree.  The switch to git meant that mtd-utils has it's own copy of the
> sanitized headers.  The patch for mtd-abi.h should apply there as
> well. 

The idea is that include/mtd/ is sanitised for userspace, and those
headers should be identical. Having switched to git and separated the
userspace and kernel repositories, I hadn't yet worked out how to
address that.

-- 
dwmw2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] Remove unchecked flags
  2006-04-13 19:18     ` David Woodhouse
@ 2006-04-13 21:50       ` Josh Boyer
  0 siblings, 0 replies; 8+ messages in thread
From: Josh Boyer @ 2006-04-13 21:50 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Jörn Engel, Andrew Morton, Thomas Gleixner, linux-kernel, linux-mtd

On 4/13/06, David Woodhouse <dwmw2@infradead.org> wrote:
> On Thu, 2006-04-13 at 13:08 -0500, Josh Boyer wrote:
> > As a side note, these will also need to be removed from the mtd-utils
> > tree.  The switch to git meant that mtd-utils has it's own copy of the
> > sanitized headers.  The patch for mtd-abi.h should apply there as
> > well.
>
> The idea is that include/mtd/ is sanitised for userspace, and those
> headers should be identical. Having switched to git and separated the
> userspace and kernel repositories, I hadn't yet worked out how to
> address that.

We sorta addressed it already.  The repositories each have their own
copy of those files.  They should still be identical, which means
double maintenance on them.  That sucks, but I don't know of a better
way to do it offhand.

josh

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-04-13 21:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-13 16:51 [PATCH 0/4] Cleanup of mtd->type and mtd->flags Jörn Engel
2006-04-13 16:53 ` [PATCH 1/4] Simplify test for RAM devices Jörn Engel
2006-04-13 16:53 ` [PATCH 2/4] Make mtdblock_ro unconditionally readonly Jörn Engel
2006-04-13 16:54 ` [PATCH 3/4] Remove unchecked flags Jörn Engel
2006-04-13 18:08   ` Josh Boyer
2006-04-13 19:18     ` David Woodhouse
2006-04-13 21:50       ` Josh Boyer
2006-04-13 16:55 ` [PATCH 4/4] Remove unused types Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®