diff mbox

mtd: nand: add support for Samsung K9LCG08U0B

Message ID 1387963135-22142-1-git-send-email-b32955@freescale.com
State New, archived
Headers show

Commit Message

Huang Shijie Dec. 25, 2013, 9:18 a.m. UTC
Assume that:
          tmp = ((extid >> 2) & 0x04) | (extid & 0x03));

From the K9LCG08U0B's datasheet, we know that:
  the oob size is 640 when tmp is 6;
  the oob size is 1024 when tmp is 7;

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 drivers/mtd/nand/nand_base.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Comments

Brian Norris Jan. 16, 2014, 9:36 p.m. UTC | #1
On Wed, Dec 25, 2013 at 05:18:55PM +0800, Huang Shijie wrote:
> Assume that:
>           tmp = ((extid >> 2) & 0x04) | (extid & 0x03));
> 
> From the K9LCG08U0B's datasheet, we know that:
>   the oob size is 640 when tmp is 6;
>   the oob size is 1024 when tmp is 7;
> 
> Signed-off-by: Huang Shijie <b32955@freescale.com>
> ---
>  drivers/mtd/nand/nand_base.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index ce4dec7..0d113cc 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -3242,9 +3242,11 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip,
>  			mtd->oobsize = 512;
>  			break;
>  		case 6:
> -		default: /* Other cases are "reserved" (unknown) */
>  			mtd->oobsize = 640;
>  			break;
> +		case 7:
> +			mtd->oobsize = SZ_1K;

#include <linux/sizes.h>

Did you compile this?

Anyway, I think just using the literal 1024 is better. I can fix it up
and push myself in a bit.

> +			break;
>  		}
>  		extid >>= 2;
>  		/* Calc blocksize */

Brian
Huang Shijie Jan. 17, 2014, 1:40 a.m. UTC | #2
On Thu, Jan 16, 2014 at 01:36:37PM -0800, Brian Norris wrote:
> > +		case 7:
> > +			mtd->oobsize = SZ_1K;
> 
> #include <linux/sizes.h>
> 
> Did you compile this?
we do not need this header.
I had already tested this patch with the l2-mtd tree.

> 
> Anyway, I think just using the literal 1024 is better. I can fix it up
> and push myself in a bit.
Different person has different taste. :)

It is okay to me if you the literal 1024.

thanks
Huang Shijie
Huang Shijie Jan. 17, 2014, 5:14 a.m. UTC | #3
On Thu, Jan 16, 2014 at 09:41:38PM -0800, Brian Norris wrote:
> On Thu, Jan 16, 2014 at 5:40 PM, Huang Shijie <b32955@freescale.com> wrote:
> > On Thu, Jan 16, 2014 at 01:36:37PM -0800, Brian Norris wrote:
> >> > +           case 7:
> >> > +                   mtd->oobsize = SZ_1K;
> >>
> >> #include <linux/sizes.h>
> >>
> >> Did you compile this?
> > we do not need this header.
> 
> My compiler begs to differ :)
> 
>   CC [M]  drivers/mtd/nand/nand_base.o
> drivers/mtd/nand/nand_base.c: In function ‘nand_decode_ext_id’:
> drivers/mtd/nand/nand_base.c:3159:19: error: ‘SZ_1K’ undeclared (first
> use in this function)
>     mtd->oobsize = SZ_1K;
>                    ^
> drivers/mtd/nand/nand_base.c:3159:19: note: each undeclared identifier
> is reported only once for each function it appears in
> make[3]: *** [drivers/mtd/nand/nand_base.o] Error 1
> make[2]: *** [drivers/mtd/nand] Error 2
> make[1]: *** [drivers/mtd] Error 2
> make: *** [drivers] Error 2
> 
> Maybe different ARCH's have implicit includes. But in any case, it's

yes. i only tested in my imx6 board. 
> standard practice to explicitly include the headers you're using.
got it.


> 
> > I had already tested this patch with the l2-mtd tree.
> >
> >>
> >> Anyway, I think just using the literal 1024 is better. I can fix it up
> >> and push myself in a bit.
> > Different person has different taste. :)
> 
> Well, all the other sizes are literals.
> 
> > It is okay to me if you the literal 1024.
> 
> You also dropped the 'default' case, which leaves out the 0 case. I'll
> reintroduce the default, to go along with case 7. I'll post the
> complete patch here when/if I push it.
should i resend a new patch? or you fix it yourself?

thanks
Huang Shijie
Brian Norris Jan. 17, 2014, 5:41 a.m. UTC | #4
On Thu, Jan 16, 2014 at 5:40 PM, Huang Shijie <b32955@freescale.com> wrote:
> On Thu, Jan 16, 2014 at 01:36:37PM -0800, Brian Norris wrote:
>> > +           case 7:
>> > +                   mtd->oobsize = SZ_1K;
>>
>> #include <linux/sizes.h>
>>
>> Did you compile this?
> we do not need this header.

My compiler begs to differ :)

  CC [M]  drivers/mtd/nand/nand_base.o
drivers/mtd/nand/nand_base.c: In function ‘nand_decode_ext_id’:
drivers/mtd/nand/nand_base.c:3159:19: error: ‘SZ_1K’ undeclared (first
use in this function)
    mtd->oobsize = SZ_1K;
                   ^
drivers/mtd/nand/nand_base.c:3159:19: note: each undeclared identifier
is reported only once for each function it appears in
make[3]: *** [drivers/mtd/nand/nand_base.o] Error 1
make[2]: *** [drivers/mtd/nand] Error 2
make[1]: *** [drivers/mtd] Error 2
make: *** [drivers] Error 2

Maybe different ARCH's have implicit includes. But in any case, it's
standard practice to explicitly include the headers you're using.

> I had already tested this patch with the l2-mtd tree.
>
>>
>> Anyway, I think just using the literal 1024 is better. I can fix it up
>> and push myself in a bit.
> Different person has different taste. :)

Well, all the other sizes are literals.

> It is okay to me if you the literal 1024.

You also dropped the 'default' case, which leaves out the 0 case. I'll
reintroduce the default, to go along with case 7. I'll post the
complete patch here when/if I push it.

Brian
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index ce4dec7..0d113cc 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3242,9 +3242,11 @@  static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip,
 			mtd->oobsize = 512;
 			break;
 		case 6:
-		default: /* Other cases are "reserved" (unknown) */
 			mtd->oobsize = 640;
 			break;
+		case 7:
+			mtd->oobsize = SZ_1K;
+			break;
 		}
 		extid >>= 2;
 		/* Calc blocksize */