public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] move mtd_fake_writev where it belongs
@ 2006-03-17 15:12 Jörn Engel
  2006-03-17 16:59 ` Todd Poynor
  0 siblings, 1 reply; 3+ messages in thread
From: Jörn Engel @ 2006-03-17 15:12 UTC (permalink / raw)
  To: David Woodhouse; +Cc: linux-mtd

Patch applies to current -linus.  Should I send it to akpm?

Jörn

-- 
With a PC, I always felt limited by the software available. On Unix, 
I am limited only by my knowledge.
-- Peter J. Schoenster

diff -Nur git/drivers/mtd/mtdcore.c writev/drivers/mtd/mtdcore.c
--- git/drivers/mtd/mtdcore.c	2006-03-17 16:03:55.000000000 +0100
+++ writev/drivers/mtd/mtdcore.c	2006-03-17 16:10:15.000000000 +0100
@@ -35,6 +35,27 @@
 
 static LIST_HEAD(mtd_notifiers);
 
+static int mtd_fake_writev(struct mtd_info *mtd, const struct kvec *vecs,
+		unsigned long count, loff_t to, size_t *retlen)
+{
+	unsigned long i;
+	size_t totlen = 0, thislen;
+	int ret = 0;
+
+	for (i=0; i<count; i++) {
+		if (!vecs[i].iov_len)
+			continue;
+		ret = mtd->write(mtd, to, vecs[i].iov_len, &thislen, vecs[i].iov_base);
+		totlen += thislen;
+		if (ret || thislen != vecs[i].iov_len)
+			break;
+		to += vecs[i].iov_len;
+	}
+	if (retlen)
+		*retlen = totlen;
+	return ret;
+}
+
 /**
  *	add_mtd_device - register an MTD device
  *	@mtd: pointer to new MTD device info structure
@@ -49,6 +70,9 @@
 {
 	int i;
 
+	if (!mtd->writev)
+		mtd->writev = mtd_fake_writev;
+
 	down(&mtd_table_mutex);
 
 	for (i=0; i < MAX_MTD_DEVICES; i++)
diff -Nur git/fs/jffs2/writev.c writev/fs/jffs2/writev.c
--- git/fs/jffs2/writev.c	2006-03-17 16:04:05.000000000 +0100
+++ writev/fs/jffs2/writev.c	2006-03-17 16:09:43.000000000 +0100
@@ -15,30 +15,6 @@
 #include <linux/mtd/mtd.h>
 #include "nodelist.h"
 
-/* This ought to be in core MTD code. All registered MTD devices
-   without writev should have this put in place. Bug the MTD
-   maintainer */
-static inline int mtd_fake_writev(struct mtd_info *mtd, const struct kvec *vecs,
-				  unsigned long count, loff_t to, size_t *retlen)
-{
-	unsigned long i;
-	size_t totlen = 0, thislen;
-	int ret = 0;
-
-	for (i=0; i<count; i++) {
-		if (!vecs[i].iov_len)
-			continue;
-		ret = mtd->write(mtd, to, vecs[i].iov_len, &thislen, vecs[i].iov_base);
-		totlen += thislen;
-		if (ret || thislen != vecs[i].iov_len)
-			break;
-		to += vecs[i].iov_len;
-	}
-	if (retlen)
-		*retlen = totlen;
-	return ret;
-}
-
 int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs,
 			      unsigned long count, loff_t to, size_t *retlen)
 {
@@ -52,11 +28,8 @@
 		}
 	}
 
-	if (c->mtd->writev)
-		return c->mtd->writev(c->mtd, vecs, count, to, retlen);
-	else {
-		return mtd_fake_writev(c->mtd, vecs, count, to, retlen);
-	}
+	BUG_ON(!c->mtd->writev);
+	return c->mtd->writev(c->mtd, vecs, count, to, retlen);
 }
 
 int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len,

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

* Re: [PATCH] move mtd_fake_writev where it belongs
  2006-03-17 15:12 [PATCH] move mtd_fake_writev where it belongs Jörn Engel
@ 2006-03-17 16:59 ` Todd Poynor
  2006-03-20 13:11   ` Jörn Engel
  0 siblings, 1 reply; 3+ messages in thread
From: Todd Poynor @ 2006-03-17 16:59 UTC (permalink / raw)
  To: Jörn Engel; +Cc: linux-mtd, David Woodhouse

Jörn Engel wrote:
> Patch applies to current -linus.  Should I send it to akpm?

But now it is no longer "fake" but in fact "default", no?


-- 
Todd

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

* Re: [PATCH] move mtd_fake_writev where it belongs
  2006-03-17 16:59 ` Todd Poynor
@ 2006-03-20 13:11   ` Jörn Engel
  0 siblings, 0 replies; 3+ messages in thread
From: Jörn Engel @ 2006-03-20 13:11 UTC (permalink / raw)
  To: Todd Poynor; +Cc: linux-mtd, David Woodhouse

On Fri, 17 March 2006 08:59:12 -0800, Todd Poynor wrote:
> Jörn Engel wrote:
> >Patch applies to current -linus.  Should I send it to akpm?
> 
> But now it is no longer "fake" but in fact "default", no?

Or "generic", yeah.  I was lazy.  Do you care enough to send an
updated patch?

Jörn

-- 
This above all: to thine own self be true.
-- Shakespeare

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

end of thread, other threads:[~2006-03-20 13:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-17 15:12 [PATCH] move mtd_fake_writev where it belongs Jörn Engel
2006-03-17 16:59 ` Todd Poynor
2006-03-20 13:11   ` 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