public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] drivers/mtd: docg3 lessen read alignement burden
@ 2012-03-11 10:28 Robert Jarzmik
  2012-03-11 10:28 ` [PATCH] drivers/mtd: docg3 fix writebufsize Robert Jarzmik
  2012-03-13 11:47 ` [PATCH] drivers/mtd: docg3 lessen read alignement burden Artem Bityutskiy
  0 siblings, 2 replies; 5+ messages in thread
From: Robert Jarzmik @ 2012-03-11 10:28 UTC (permalink / raw)
  To: linux-mtd; +Cc: Robert Jarzmik

The read function was so far requiring the reads to be aligned on page
boundaries, and be page length multiples in size. Relieve these
constraints to ease the userspace ubifs programs runs, which read ubifs
headers of 64 bytes.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 drivers/mtd/devices/docg3.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index a0f4087..bd9e992 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -734,7 +734,7 @@ err:
  * doc_read_page_getbytes - Reads bytes from a prepared page
  * @docg3: the device
  * @len: the number of bytes to be read (must be a multiple of 4)
- * @buf: the buffer to be filled in
+ * @buf: the buffer to be filled in (or NULL is forget bytes)
  * @first: 1 if first time read, DOC_READADDRESS should be set
  *
  */
@@ -849,7 +849,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
 			struct mtd_oob_ops *ops)
 {
 	struct docg3 *docg3 = mtd->priv;
-	int block0, block1, page, ret, ofs = 0;
+	int block0, block1, page, ret, skip, ofs = 0;
 	u8 *oobbuf = ops->oobbuf;
 	u8 *buf = ops->datbuf;
 	size_t len, ooblen, nbdata, nboob;
@@ -869,8 +869,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
 
 	doc_dbg("doc_read_oob(from=%lld, mode=%d, data=(%p:%zu), oob=(%p:%zu))\n",
 		from, ops->mode, buf, len, oobbuf, ooblen);
-	if ((len % DOC_LAYOUT_PAGE_SIZE) || (ooblen % DOC_LAYOUT_OOB_SIZE) ||
-	    (from % DOC_LAYOUT_PAGE_SIZE))
+	if (ooblen % DOC_LAYOUT_OOB_SIZE)
 		return -EINVAL;
 
 	ret = -EINVAL;
@@ -882,10 +881,11 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
 	ops->oobretlen = 0;
 	ops->retlen = 0;
 	ret = 0;
+	skip = from % DOC_LAYOUT_PAGE_SIZE;
 	while (!ret && (len > 0 || ooblen > 0)) {
-		calc_block_sector(from, &block0, &block1, &page, &ofs,
+		calc_block_sector(from - skip, &block0, &block1, &page, &ofs,
 			docg3->reliable);
-		nbdata = min_t(size_t, len, (size_t)DOC_LAYOUT_PAGE_SIZE);
+		nbdata = min_t(size_t, len, DOC_LAYOUT_PAGE_SIZE - skip);
 		nboob = min_t(size_t, ooblen, (size_t)DOC_LAYOUT_OOB_SIZE);
 		ret = doc_read_page_prepare(docg3, block0, block1, page, ofs);
 		if (ret < 0)
@@ -893,7 +893,10 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
 		ret = doc_read_page_ecc_init(docg3, DOC_ECC_BCH_TOTAL_BYTES);
 		if (ret < 0)
 			goto err_in_read;
-		ret = doc_read_page_getbytes(docg3, nbdata, buf, 1);
+		ret = doc_read_page_getbytes(docg3, skip, NULL, 1);
+		if (ret < skip)
+			goto err_in_read;
+		ret = doc_read_page_getbytes(docg3, nbdata, buf, 0);
 		if (ret < nbdata)
 			goto err_in_read;
 		doc_read_page_getbytes(docg3, DOC_LAYOUT_PAGE_SIZE - nbdata,
@@ -950,6 +953,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
 		len -= nbdata;
 		ooblen -= nboob;
 		from += DOC_LAYOUT_PAGE_SIZE;
+		skip = 0;
 	}
 
 	return ret;
-- 
1.7.5.4

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

* [PATCH] drivers/mtd: docg3 fix writebufsize
  2012-03-11 10:28 [PATCH] drivers/mtd: docg3 lessen read alignement burden Robert Jarzmik
@ 2012-03-11 10:28 ` Robert Jarzmik
  2012-03-13 11:48   ` Artem Bityutskiy
  2012-03-13 11:47 ` [PATCH] drivers/mtd: docg3 lessen read alignement burden Artem Bityutskiy
  1 sibling, 1 reply; 5+ messages in thread
From: Robert Jarzmik @ 2012-03-11 10:28 UTC (permalink / raw)
  To: linux-mtd; +Cc: Robert Jarzmik

The docg3 drivers lacked mtd writebufsize initialization. Without it,
ubifs cannot work.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 drivers/mtd/devices/docg3.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index bd9e992..c30b56a 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -1822,6 +1822,7 @@ static void __init doc_set_driver_info(int chip_id, struct mtd_info *mtd)
 	if (docg3->reliable == 2)
 		mtd->erasesize /= 2;
 	mtd->writesize = DOC_LAYOUT_PAGE_SIZE;
+	mtd->writebufsize = DOC_LAYOUT_PAGE_SIZE;
 	mtd->oobsize = DOC_LAYOUT_OOB_SIZE;
 	mtd->owner = THIS_MODULE;
 	mtd->erase = doc_erase;
-- 
1.7.5.4

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

* Re: [PATCH] drivers/mtd: docg3 lessen read alignement burden
  2012-03-11 10:28 [PATCH] drivers/mtd: docg3 lessen read alignement burden Robert Jarzmik
  2012-03-11 10:28 ` [PATCH] drivers/mtd: docg3 fix writebufsize Robert Jarzmik
@ 2012-03-13 11:47 ` Artem Bityutskiy
  1 sibling, 0 replies; 5+ messages in thread
From: Artem Bityutskiy @ 2012-03-13 11:47 UTC (permalink / raw)
  To: Robert Jarzmik; +Cc: linux-mtd

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

On Sun, 2012-03-11 at 11:28 +0100, Robert Jarzmik wrote:
> The read function was so far requiring the reads to be aligned on page
> boundaries, and be page length multiples in size. Relieve these
> constraints to ease the userspace ubifs programs runs, which read ubifs
> headers of 64 bytes.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

Pushed to l2-mtd.git, thanks!

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] drivers/mtd: docg3 fix writebufsize
  2012-03-11 10:28 ` [PATCH] drivers/mtd: docg3 fix writebufsize Robert Jarzmik
@ 2012-03-13 11:48   ` Artem Bityutskiy
  2012-03-13 20:50     ` Robert Jarzmik
  0 siblings, 1 reply; 5+ messages in thread
From: Artem Bityutskiy @ 2012-03-13 11:48 UTC (permalink / raw)
  To: Robert Jarzmik; +Cc: linux-mtd

[-- Attachment #1: Type: text/plain, Size: 406 bytes --]

On Sun, 2012-03-11 at 11:28 +0100, Robert Jarzmik wrote:
> The docg3 drivers lacked mtd writebufsize initialization. Without it,
> ubifs cannot work.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

I think I've already done this in the l2-mtd.git tree. I strongly
recommend you to test on top of the l2-mtd.git because it has the latest
stuff.

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] drivers/mtd: docg3 fix writebufsize
  2012-03-13 11:48   ` Artem Bityutskiy
@ 2012-03-13 20:50     ` Robert Jarzmik
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Jarzmik @ 2012-03-13 20:50 UTC (permalink / raw)
  To: dedekind1; +Cc: linux-mtd

Artem Bityutskiy <dedekind1@gmail.com> writes:

> On Sun, 2012-03-11 at 11:28 +0100, Robert Jarzmik wrote:
>> The docg3 drivers lacked mtd writebufsize initialization. Without it,
>> ubifs cannot work.
>> 
>> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
>
> I think I've already done this in the l2-mtd.git tree. I strongly
> recommend you to test on top of the l2-mtd.git because it has the latest
> stuff.

OK, will do.

Cheers.


-- 
Robert

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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-11 10:28 [PATCH] drivers/mtd: docg3 lessen read alignement burden Robert Jarzmik
2012-03-11 10:28 ` [PATCH] drivers/mtd: docg3 fix writebufsize Robert Jarzmik
2012-03-13 11:48   ` Artem Bityutskiy
2012-03-13 20:50     ` Robert Jarzmik
2012-03-13 11:47 ` [PATCH] drivers/mtd: docg3 lessen read alignement burden Artem Bityutskiy

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