Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1232874 > unrolled thread
| Started by | Boris Brezillon <boris.brezillon@free-electrons.com> |
|---|---|
| First post | 2015-09-25 17:20 +0200 |
| Last post | 2015-09-28 07:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 1/5] mtd: nand: add basic stuff to support power-cut emulation Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-09-25 17:20 +0200
Re: [PATCH 1/5] mtd: nand: add basic stuff to support power-cut emulation kbuild test robot <lkp@intel.com> - 2015-09-28 07:50 +0200
| From | Boris Brezillon <boris.brezillon@free-electrons.com> |
|---|---|
| Date | 2015-09-25 17:20 +0200 |
| Subject | [PATCH 1/5] mtd: nand: add basic stuff to support power-cut emulation |
| Message-ID | <qcCWZ-58P-1@gated-at.bofh.it> |
Add a new status flag to support power-cut emulation. Since real NAND
status is limited to 8bits, we can safely use higher bits for something
else. The NAND_STATUS_POWER_CUT is assigned bit 30 to avoid integer
overflow (not sure this is necessary).
The NAND status is currently retrieved using ->read_byte() after sending
a NAND_CMD_STATUS command, which prevents the nandsim (or any other
implementation that wants to support power-cut emulation) to return a
value with the NAND_STATUS_POWER_CUT flag set.
Add a ->get_status() method returning an int, and provide a default
implementation.
Also note that ->get_status() could be used for other cases than power-cut
emulation. For example, some NAND controllers are able to retrieve the
NAND status by their own after launching a specific command, and this
status is then stored in a specific register, thus preventing the extra
->cmdfunc() + ->read_byte() calls.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
drivers/mtd/nand/nand_base.c | 17 ++++++++++++++---
include/linux/mtd/nand.h | 4 ++++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 37c0d9d..a621814 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -478,8 +478,7 @@ static int nand_check_wp(struct mtd_info *mtd)
return 0;
/* Check the WP bit */
- chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
- return (chip->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1;
+ return (chip->get_status(mtd) & NAND_STATUS_WP) ? 0 : 1;
}
/**
@@ -880,6 +879,15 @@ static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip,
}
}
+static int nand_get_status(struct mtd_info *mtd)
+{
+ struct nand_chip *chip = mtd->priv;
+
+ chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
+
+ return (int)chip->read_byte(mtd);
+}
+
/**
* nand_wait - [DEFAULT] wait until the command is done
* @mtd: MTD device structure
@@ -922,7 +930,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)
}
led_trigger_event(nand_led_trigger, LED_OFF);
- status = (int)chip->read_byte(mtd);
+ status = chip->get_status(mtd);
/* This can happen if in case of timeout or buggy dev_ready */
WARN_ON(!(status & NAND_STATUS_READY));
return status;
@@ -3106,6 +3114,9 @@ static void nand_set_defaults(struct nand_chip *chip, int busw)
if (chip->cmdfunc == NULL)
chip->cmdfunc = nand_command;
+ if (!chip->get_status)
+ chip->get_status = nand_get_status;
+
/* check, if a user supplied wait function given */
if (chip->waitfunc == NULL)
chip->waitfunc = nand_wait;
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index c4d8e30..075d7b8 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -107,6 +107,9 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
#define NAND_STATUS_READY 0x40
#define NAND_STATUS_WP 0x80
+/* Status bits reserved for NAND emulation */
+#define NAND_STATUS_POWER_CUT 0x40000000
+
/*
* Constants for ECC_MODES
*/
@@ -661,6 +664,7 @@ struct nand_chip {
int (*init_size)(struct mtd_info *mtd, struct nand_chip *this,
u8 *id_data);
int (*dev_ready)(struct mtd_info *mtd);
+ int (*get_status)(struct mtd_info *mtd);
void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column,
int page_addr);
int(*waitfunc)(struct mtd_info *mtd, struct nand_chip *this);
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | kbuild test robot <lkp@intel.com> |
|---|---|
| Date | 2015-09-28 07:50 +0200 |
| Subject | Re: [PATCH 1/5] mtd: nand: add basic stuff to support power-cut emulation |
| Message-ID | <qdzu2-52B-19@gated-at.bofh.it> |
| In reply to | #1232874 |
[Multipart message — attachments visible in raw view] — view raw
Hi Boris, [auto build test results on v4.3-rc2 -- if it's inappropriate base, please ignore] config: i386-allnoconfig (attached as .config) reproduce: git checkout f3924c26b426d59134751b046f403f3f66e16ed7 # save the attached .config to linux build tree make ARCH=i386 All warnings (new ones prefixed by >>): >> include/linux/mtd/nand.h:730: warning: No description found for parameter 'get_status' vim +/get_status +730 include/linux/mtd/nand.h 30631cb8 Alessandro Rubini 2009-09-20 714 flstate_t state; f75e5097 Thomas Gleixner 2006-05-26 715 f75e5097 Thomas Gleixner 2006-05-26 716 uint8_t *oob_poi; f75e5097 Thomas Gleixner 2006-05-26 717 struct nand_hw_control *controller; f75e5097 Thomas Gleixner 2006-05-26 718 f75e5097 Thomas Gleixner 2006-05-26 719 struct nand_ecc_ctrl ecc; 4bf63fcb David Woodhouse 2006-09-25 720 struct nand_buffers *buffers; f75e5097 Thomas Gleixner 2006-05-26 721 struct nand_hw_control hwcontrol; f75e5097 Thomas Gleixner 2006-05-26 722 ^1da177e Linus Torvalds 2005-04-16 723 uint8_t *bbt; ^1da177e Linus Torvalds 2005-04-16 724 struct nand_bbt_descr *bbt_td; ^1da177e Linus Torvalds 2005-04-16 725 struct nand_bbt_descr *bbt_md; f75e5097 Thomas Gleixner 2006-05-26 726 ^1da177e Linus Torvalds 2005-04-16 727 struct nand_bbt_descr *badblock_pattern; f75e5097 Thomas Gleixner 2006-05-26 728 ^1da177e Linus Torvalds 2005-04-16 729 void *priv; ^1da177e Linus Torvalds 2005-04-16 @730 }; ^1da177e Linus Torvalds 2005-04-16 731 ^1da177e Linus Torvalds 2005-04-16 732 /* ^1da177e Linus Torvalds 2005-04-16 733 * NAND Flash Manufacturer ID Codes ^1da177e Linus Torvalds 2005-04-16 734 */ ^1da177e Linus Torvalds 2005-04-16 735 #define NAND_MFR_TOSHIBA 0x98 ^1da177e Linus Torvalds 2005-04-16 736 #define NAND_MFR_SAMSUNG 0xec ^1da177e Linus Torvalds 2005-04-16 737 #define NAND_MFR_FUJITSU 0x04 ^1da177e Linus Torvalds 2005-04-16 738 #define NAND_MFR_NATIONAL 0x8f :::::: The code at line 730 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2 :::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org> :::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web