public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Three change suggestions to nand.c and friends.
@ 2000-10-13 15:26 Bjorn Eriksson
  2000-10-13 15:35 ` David Woodhouse
  0 siblings, 1 reply; 2+ messages in thread
From: Bjorn Eriksson @ 2000-10-13 15:26 UTC (permalink / raw)
  To: mtd


 1) Right now the code needs the moddi3() helper to perform it's checks. I
suggest adding the requirement that {.oobblock} must be a power of two.

 Also, the '(to + len)' part can be rewritten as 'len' since (a+b)%c ->
(a%c+b%c)%c.

+++ mtd/nand.c  Fri Oct 13 16:50:37 2000
@@ -30,13 +31,69 @@
 #define set_current_state(x) current->state = (x);
 #endif

+#ifdef CONFIG_MTD_OOBBLOCK_POWOf2
+#define OOBblockMOD(numer, denom) ((numer) & (denom-1))
+#else
+#define OOBblockMOD(numer, denom) ((numer) % (denom))
+#endif

@@ -350,7 +411,7 @@
 #endif

        /* Do not allow unaligned writes */
-       if ((to % mtd->oobblock) || ((to + len) % mtd->oobblock)) {
+       if (OOBblockMOD(to, mtd->oobblock) || OOBblockMOD(len,
mtd->oobblock)) {
                DEBUG (MTD_DEBUG_LEVEL1,
                        "nand_write_ecc: Unaligned address\n");
                return -EINVAL;
=============================================

 2) I've also rewritten nand.c changing all 'NAND_CTRL |= this->CLE;' ->
NAND_SET_CMD et.al. Different hardware different support code.

=====================

 3) I moved nand_flash_ids[] to a new file, nand_ids.h since nand.h is
included in several different places and not all .c-files that #include it
needs nand_flash_ids[] (thus creating dups).


 Opinions, ideas? Shall I commit?


//Björnen.




To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

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

* Re: Three change suggestions to nand.c and friends.
  2000-10-13 15:26 Three change suggestions to nand.c and friends Bjorn Eriksson
@ 2000-10-13 15:35 ` David Woodhouse
  0 siblings, 0 replies; 2+ messages in thread
From: David Woodhouse @ 2000-10-13 15:35 UTC (permalink / raw)
  To: Bjorn Eriksson; +Cc: mtd




mdeans@algonet.se said:
>  1) Right now the code needs the moddi3() helper to perform it's
> checks. I suggest adding the requirement that {.oobblock} must be a
> power of two. 

That's sensible, but best just to require it. Don't piss about with config
options.

>  2) I've also rewritten nand.c changing all 'NAND_CTRL |= this->CLE;'
> -> NAND_SET_CMD et.al. Different hardware different support code. 

Check with sjhill but that sounds reasonable.

>  3) I moved nand_flash_ids[] to a new file, nand_ids.h since nand.h is
> included in several different places and not all .c-files that
> #include it needs nand_flash_ids[] (thus creating dups). 

OK.



--
dwmw2




To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

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

end of thread, other threads:[~2000-10-13 15:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-10-13 15:26 Three change suggestions to nand.c and friends Bjorn Eriksson
2000-10-13 15:35 ` David Woodhouse

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