pkarashchenko commented on code in PR #9154:
URL: https://github.com/apache/nuttx/pull/9154#discussion_r1183575541


##########
drivers/mtd/mtd_nand.c:
##########
@@ -110,6 +111,48 @@ static int     nand_ioctl(FAR struct mtd_dev_s *dev, int 
cmd,
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: nand_markblock
+ *
+ * Description:
+ *   Mark a block as bad.
+ *
+ * Input Parameters:
+ *   nand  - Pointer to a struct nand_dev_s instance.
+ *   block - Number of block to mark.
+ *
+ * Returned Value:
+ *   Returns negated errno value on any failure.
+ *
+ ****************************************************************************/
+
+static int nand_markblock(FAR struct nand_dev_s *nand, off_t block)
+{
+  uint8_t spare[CONFIG_MTD_NAND_MAXPAGESPARESIZE];
+  FAR const struct nand_scheme_s *scheme;
+  FAR struct nand_model_s *model;
+  FAR struct nand_raw_s *raw;
+  int ret;
+
+  /* Retrieve the model and scheme */
+
+  raw    = nand->raw;
+  model  = &raw->model;
+  scheme = nandmodel_getscheme(model);
+
+  /* Try to mark the block as BAD */
+
+  memset(spare, 0xff, CONFIG_MTD_NAND_MAXPAGESPARESIZE);
+  nandscheme_writebadblockmarker(scheme, spare, NAND_BLOCKSTATUS_BAD);
+  ret = NAND_WRITEPAGE(nand->raw, block, 0, 0, spare);
+  if (ret < 0)
+    {
+      ferr("ERROR: Failed bo marke block %" PRIdOFF " as BAD\n", block);

Review Comment:
   Add `#include <inttypes.h>`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to