Skip to contentSkip to conversation

mtd: nand: Fix nanddev_neraseblocks()

PATCH Applied Boris Brezillon 2 participants 3 messages Oct 28, 2018 – Nov 5, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: nand: Fix nanddev_neraseblocks()

nanddev_neraseblocks() currently returns the number pages per LUN instead of the total number of eraseblocks.

Fixes 9c3736a3de21 ("mtd: nand: Add core infrastructure to deal with NAND devices")
---
 include/linux/mtd/nand.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/linux/mtd/nand.h +2 -3
index abe975c87b90..78b86dea2f29 100644
@@ -324,9 +324,8 @@ static inline unsigned int nanddev_ntargets(const struct nand_device *nand)
  */
 static inline unsigned int nanddev_neraseblocks(const struct nand_device *nand)
 {
-	return (u64)nand->memorg.luns_per_target *
-	       nand->memorg.eraseblocks_per_lun *
-	       nand->memorg.pages_per_eraseblock;
+	return nand->memorg.ntargets * nand->memorg.luns_per_target *
+	       nand->memorg.eraseblocks_per_lun;
 }
 
 /**
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Boris,

Boris Brezillon <[email protected]> wrote on Sun, 28 Oct 2018 12:29:55 +0100:

Quoted 16 lines

nanddev_neraseblocks() currently returns the number pages per LUN instead of the total number of eraseblocks.

Fixes 9c3736a3de21 ("mtd: nand: Add core infrastructure to deal with NAND devices")
---
 include/linux/mtd/nand.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/linux/mtd/nand.h +0 -0
index abe975c87b90..78b86dea2f29 100644
@@ -324,9 +324,8 @@ static inline unsigned int nanddev_ntargets(const struct nand_device *nand)
  */

include/linux/mtd/nand.h static inline unsigned int nanddev_ntargets(const struct nand_device *nand) · line 331

Quoted 10 lines
include/linux/mtd/nand.h +2 -3
 static inline unsigned int nanddev_neraseblocks(const struct nand_device *nand)
 {
-	return (u64)nand->memorg.luns_per_target *
-	       nand->memorg.eraseblocks_per_lun *
-	       nand->memorg.pages_per_eraseblock;
+	return nand->memorg.ntargets * nand->memorg.luns_per_target *
+	       nand->memorg.eraseblocks_per_lun;
 }
 
 /**

Thanks,
Miquèl

author Applied
#2 lore raw
In reply to Boris Brezillon
Quoted 6 lines · On Sun, 28 Oct 2018 12:29:55 +0100 Boris Brezillon…

nanddev_neraseblocks() currently returns the number pages per LUN instead of the total number of eraseblocks.

Fixes 9c3736a3de21 ("mtd: nand: Add core infrastructure to deal with NAND devices")

Queued to the fixes branch.

Quoted 20 lines
---
 include/linux/mtd/nand.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/linux/mtd/nand.h +2 -3
index abe975c87b90..78b86dea2f29 100644
@@ -324,9 +324,8 @@ static inline unsigned int nanddev_ntargets(const struct nand_device *nand)
  */
 static inline unsigned int nanddev_neraseblocks(const struct nand_device *nand)
 {
-	return (u64)nand->memorg.luns_per_target *
-	       nand->memorg.eraseblocks_per_lun *
-	       nand->memorg.pages_per_eraseblock;
+	return nand->memorg.ntargets * nand->memorg.luns_per_target *
+	       nand->memorg.eraseblocks_per_lun;
 }
 
 /**