Re: [PATCH v2 08/12] mtd: nand_bbt: remove struct nand_chip from nand_bbt.c
On Tue, 15 Dec 2015 05:59:34 + Peter Pan wrote: > From: Brian Norris > > This commit contains most of modification. But the job is quite > simple --- replace struct nand_chip with struct nand_bbt. There > is no algorithm change, just replacement. > > Signed-off-by: Brian Norris > Signed-off-by: Peter Pan > --- > drivers/mtd/nand/nand_bbt.c | 391 > ++-- > 1 file changed, 193 insertions(+), 198 deletions(-) > > diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c > index a5c8ab5..b46b4ae 100644 > --- a/drivers/mtd/nand/nand_bbt.c > +++ b/drivers/mtd/nand/nand_bbt.c [...] > /** > * nand_scan_bbt - [NAND Interface] scan, find, read and maybe create bad > block table(s) > - * @mtd: MTD device structure > + * @bbt: NAND BBT structure > * > * The function checks, if a bad block table(s) is/are already available. If > * not it scans the device for manufacturer marked good / bad blocks and > writes > @@ -1000,21 +1000,21 @@ static void verify_bbt_descr(struct mtd_info *mtd, > struct nand_bbt_descr *bd) > * The bad block table memory is allocated here. It must be freed by calling > * the nand_free_bbt function. > */ > -static int nand_scan_bbt(struct mtd_info *mtd) > +static int nand_scan_bbt(struct nand_bbt *bbt) > { > - struct nand_chip *this = mtd_to_nand(mtd); > - int len, res; > + struct mtd_info *mtd = bbt->mtd; > + int len, res = 0; > uint8_t *buf; > - struct nand_bbt_descr *td = this->bbt_td; > - struct nand_bbt_descr *md = this->bbt_md; > + struct nand_bbt_descr *td = bbt->bbt_td; > + struct nand_bbt_descr *md = bbt->bbt_md; > > len = (mtd->size >> (this->bbt_erase_shift + 2)) ? : 1; 'this' is gone, which generates a compilation error. len = (mtd->size >> (bbt->bbt_erase_shift + 2)) ? : 1; -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 08/12] mtd: nand_bbt: remove struct nand_chip from nand_bbt.c
On Tue, 15 Dec 2015 05:59:34 + Peter Panwrote: > From: Brian Norris > > This commit contains most of modification. But the job is quite > simple --- replace struct nand_chip with struct nand_bbt. There > is no algorithm change, just replacement. > > Signed-off-by: Brian Norris > Signed-off-by: Peter Pan > --- > drivers/mtd/nand/nand_bbt.c | 391 > ++-- > 1 file changed, 193 insertions(+), 198 deletions(-) > > diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c > index a5c8ab5..b46b4ae 100644 > --- a/drivers/mtd/nand/nand_bbt.c > +++ b/drivers/mtd/nand/nand_bbt.c [...] > /** > * nand_scan_bbt - [NAND Interface] scan, find, read and maybe create bad > block table(s) > - * @mtd: MTD device structure > + * @bbt: NAND BBT structure > * > * The function checks, if a bad block table(s) is/are already available. If > * not it scans the device for manufacturer marked good / bad blocks and > writes > @@ -1000,21 +1000,21 @@ static void verify_bbt_descr(struct mtd_info *mtd, > struct nand_bbt_descr *bd) > * The bad block table memory is allocated here. It must be freed by calling > * the nand_free_bbt function. > */ > -static int nand_scan_bbt(struct mtd_info *mtd) > +static int nand_scan_bbt(struct nand_bbt *bbt) > { > - struct nand_chip *this = mtd_to_nand(mtd); > - int len, res; > + struct mtd_info *mtd = bbt->mtd; > + int len, res = 0; > uint8_t *buf; > - struct nand_bbt_descr *td = this->bbt_td; > - struct nand_bbt_descr *md = this->bbt_md; > + struct nand_bbt_descr *td = bbt->bbt_td; > + struct nand_bbt_descr *md = bbt->bbt_md; > > len = (mtd->size >> (this->bbt_erase_shift + 2)) ? : 1; 'this' is gone, which generates a compilation error. len = (mtd->size >> (bbt->bbt_erase_shift + 2)) ? : 1; -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 08/12] mtd: nand_bbt: remove struct nand_chip from nand_bbt.c
From: Brian Norris This commit contains most of modification. But the job is quite simple --- replace struct nand_chip with struct nand_bbt. There is no algorithm change, just replacement. Signed-off-by: Brian Norris Signed-off-by: Peter Pan --- drivers/mtd/nand/nand_bbt.c | 391 ++-- 1 file changed, 193 insertions(+), 198 deletions(-) diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index a5c8ab5..b46b4ae 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c @@ -60,8 +60,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -76,20 +75,20 @@ #define BBT_ENTRY_MASK 0x03 #define BBT_ENTRY_SHIFT2 -static int nand_update_bbt(struct mtd_info *mtd, loff_t offs); +static int nand_update_bbt(struct nand_bbt *bbt, loff_t offs); -static inline uint8_t bbt_get_entry(struct nand_chip *chip, int block) +static inline uint8_t bbt_get_entry(struct nand_bbt *bbt, int block) { - uint8_t entry = chip->bbt[block >> BBT_ENTRY_SHIFT]; + uint8_t entry = bbt->bbt[block >> BBT_ENTRY_SHIFT]; entry >>= (block & BBT_ENTRY_MASK) * 2; return entry & BBT_ENTRY_MASK; } -static inline void bbt_mark_entry(struct nand_chip *chip, int block, +static inline void bbt_mark_entry(struct nand_bbt *bbt, int block, uint8_t mark) { uint8_t msk = (mark & BBT_ENTRY_MASK) << ((block & BBT_ENTRY_MASK) * 2); - chip->bbt[block >> BBT_ENTRY_SHIFT] |= msk; + bbt->bbt[block >> BBT_ENTRY_SHIFT] |= msk; } static int check_pattern_no_oob(uint8_t *buf, struct nand_bbt_descr *td) @@ -142,7 +141,7 @@ static u32 add_marker_len(struct nand_bbt_descr *td) /** * read_bbt - [GENERIC] Read the bad block table starting from page - * @mtd: MTD device structure + * @bbt: NAND BBT structure * @buf: temporary buffer * @page: the starting page * @num: the number of bbt descriptors to read @@ -151,11 +150,11 @@ static u32 add_marker_len(struct nand_bbt_descr *td) * * Read the bad block table starting from page. */ -static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, +static int read_bbt(struct nand_bbt *bbt, uint8_t *buf, int page, int num, struct nand_bbt_descr *td, int offs) { + struct mtd_info *mtd = bbt->mtd; int res, ret = 0, i, j, act = 0; - struct nand_chip *this = mtd_to_nand(mtd); size_t retlen, len, totlen; loff_t from; int bits = td->options & NAND_BBT_NRBITS_MSK; @@ -165,10 +164,10 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, totlen = (num * bits) >> 3; marker_len = add_marker_len(td); - from = ((loff_t)page) << this->page_shift; + from = ((loff_t)page) << bbt->page_shift; while (totlen) { - len = min(totlen, (size_t)(1 << this->bbt_erase_shift)); + len = min(totlen, (size_t)(1 << bbt->bbt_erase_shift)); if (marker_len) { /* * In case the BBT marker is not in the OOB area it @@ -204,8 +203,8 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, if (reserved_block_code && (tmp == reserved_block_code)) { pr_info("nand_read_bbt: reserved block at 0x%012llx\n", (loff_t)(offs + act) << -this->bbt_erase_shift); - bbt_mark_entry(this, offs + act, +bbt->bbt_erase_shift); + bbt_mark_entry(bbt, offs + act, BBT_BLOCK_RESERVED); mtd->ecc_stats.bbtblocks++; continue; @@ -216,13 +215,13 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, */ pr_info("nand_read_bbt: bad block at 0x%012llx\n", (loff_t)(offs + act) << -this->bbt_erase_shift); +bbt->bbt_erase_shift); /* Factory marked bad or worn out? */ if (tmp == 0) - bbt_mark_entry(this, offs + act, + bbt_mark_entry(bbt, offs + act, BBT_BLOCK_FACTORY_BAD); else - bbt_mark_entry(this, offs + act, + bbt_mark_entry(bbt, offs + act,
[PATCH v2 08/12] mtd: nand_bbt: remove struct nand_chip from nand_bbt.c
From: Brian NorrisThis commit contains most of modification. But the job is quite simple --- replace struct nand_chip with struct nand_bbt. There is no algorithm change, just replacement. Signed-off-by: Brian Norris Signed-off-by: Peter Pan --- drivers/mtd/nand/nand_bbt.c | 391 ++-- 1 file changed, 193 insertions(+), 198 deletions(-) diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index a5c8ab5..b46b4ae 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c @@ -60,8 +60,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -76,20 +75,20 @@ #define BBT_ENTRY_MASK 0x03 #define BBT_ENTRY_SHIFT2 -static int nand_update_bbt(struct mtd_info *mtd, loff_t offs); +static int nand_update_bbt(struct nand_bbt *bbt, loff_t offs); -static inline uint8_t bbt_get_entry(struct nand_chip *chip, int block) +static inline uint8_t bbt_get_entry(struct nand_bbt *bbt, int block) { - uint8_t entry = chip->bbt[block >> BBT_ENTRY_SHIFT]; + uint8_t entry = bbt->bbt[block >> BBT_ENTRY_SHIFT]; entry >>= (block & BBT_ENTRY_MASK) * 2; return entry & BBT_ENTRY_MASK; } -static inline void bbt_mark_entry(struct nand_chip *chip, int block, +static inline void bbt_mark_entry(struct nand_bbt *bbt, int block, uint8_t mark) { uint8_t msk = (mark & BBT_ENTRY_MASK) << ((block & BBT_ENTRY_MASK) * 2); - chip->bbt[block >> BBT_ENTRY_SHIFT] |= msk; + bbt->bbt[block >> BBT_ENTRY_SHIFT] |= msk; } static int check_pattern_no_oob(uint8_t *buf, struct nand_bbt_descr *td) @@ -142,7 +141,7 @@ static u32 add_marker_len(struct nand_bbt_descr *td) /** * read_bbt - [GENERIC] Read the bad block table starting from page - * @mtd: MTD device structure + * @bbt: NAND BBT structure * @buf: temporary buffer * @page: the starting page * @num: the number of bbt descriptors to read @@ -151,11 +150,11 @@ static u32 add_marker_len(struct nand_bbt_descr *td) * * Read the bad block table starting from page. */ -static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, +static int read_bbt(struct nand_bbt *bbt, uint8_t *buf, int page, int num, struct nand_bbt_descr *td, int offs) { + struct mtd_info *mtd = bbt->mtd; int res, ret = 0, i, j, act = 0; - struct nand_chip *this = mtd_to_nand(mtd); size_t retlen, len, totlen; loff_t from; int bits = td->options & NAND_BBT_NRBITS_MSK; @@ -165,10 +164,10 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, totlen = (num * bits) >> 3; marker_len = add_marker_len(td); - from = ((loff_t)page) << this->page_shift; + from = ((loff_t)page) << bbt->page_shift; while (totlen) { - len = min(totlen, (size_t)(1 << this->bbt_erase_shift)); + len = min(totlen, (size_t)(1 << bbt->bbt_erase_shift)); if (marker_len) { /* * In case the BBT marker is not in the OOB area it @@ -204,8 +203,8 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, if (reserved_block_code && (tmp == reserved_block_code)) { pr_info("nand_read_bbt: reserved block at 0x%012llx\n", (loff_t)(offs + act) << -this->bbt_erase_shift); - bbt_mark_entry(this, offs + act, +bbt->bbt_erase_shift); + bbt_mark_entry(bbt, offs + act, BBT_BLOCK_RESERVED); mtd->ecc_stats.bbtblocks++; continue; @@ -216,13 +215,13 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, */ pr_info("nand_read_bbt: bad block at 0x%012llx\n", (loff_t)(offs + act) << -this->bbt_erase_shift); +bbt->bbt_erase_shift); /* Factory marked bad or worn out? */ if (tmp == 0) - bbt_mark_entry(this, offs + act, + bbt_mark_entry(bbt, offs + act, BBT_BLOCK_FACTORY_BAD); else - bbt_mark_entry(this, offs + act, +