[PATCH v5 24/32] tools/testing/nvdimm: Convert to printbuf

2022-08-07 Thread Matthew Wilcox (Oracle)
From: Kent Overstreet 

This converts from seq_buf to printbuf. Here we're using printbuf with
an external buffer, meaning it's a direct conversion.

Signed-off-by: Kent Overstreet 
Cc: Dan Williams 
Cc: Dave Hansen 
Cc: nvd...@lists.linux.dev
---
 tools/testing/nvdimm/test/ndtest.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/tools/testing/nvdimm/test/ndtest.c 
b/tools/testing/nvdimm/test/ndtest.c
index 4d1a947367f9..a2097955dace 100644
--- a/tools/testing/nvdimm/test/ndtest.c
+++ b/tools/testing/nvdimm/test/ndtest.c
@@ -12,7 +12,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "../watermark.h"
 #include "nfit_test.h"
@@ -740,32 +740,30 @@ static ssize_t flags_show(struct device *dev,
 {
struct nvdimm *nvdimm = to_nvdimm(dev);
struct ndtest_dimm *dimm = nvdimm_provider_data(nvdimm);
-   struct seq_buf s;
+   struct printbuf s = PRINTBUF_EXTERN(buf, PAGE_SIZE);
u64 flags;
 
flags = dimm->flags;
 
-   seq_buf_init(, buf, PAGE_SIZE);
if (flags & PAPR_PMEM_UNARMED_MASK)
-   seq_buf_printf(, "not_armed ");
+   prt_printf(, "not_armed ");
 
if (flags & PAPR_PMEM_BAD_SHUTDOWN_MASK)
-   seq_buf_printf(, "flush_fail ");
+   prt_printf(, "flush_fail ");
 
if (flags & PAPR_PMEM_BAD_RESTORE_MASK)
-   seq_buf_printf(, "restore_fail ");
+   prt_printf(, "restore_fail ");
 
if (flags & PAPR_PMEM_SAVE_MASK)
-   seq_buf_printf(, "save_fail ");
+   prt_printf(, "save_fail ");
 
if (flags & PAPR_PMEM_SMART_EVENT_MASK)
-   seq_buf_printf(, "smart_notify ");
+   prt_printf(, "smart_notify ");
 
+   if (printbuf_written())
+   prt_printf(, "\n");
 
-   if (seq_buf_used())
-   seq_buf_printf(, "\n");
-
-   return seq_buf_used();
+   return printbuf_written();
 }
 static DEVICE_ATTR_RO(flags);
 
-- 
2.35.1




[PATCH] tools/testing/nvdimm: Fix typo in comments

2022-08-07 Thread shaomin Deng
Remove the repeated word "from" in comments.

Signed-off-by: shaomin Deng 
---
 tools/testing/nvdimm/test/nfit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index c75abb497a1a..1694b89aa4a3 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -59,7 +59,7 @@
  * *) The first portion of dimm0 and dimm1 are interleaved as REGION0.
  *A single PMEM namespace "pm0.0" is created using half of the
  *REGION0 SPA-range.  REGION0 spans dimm0 and dimm1.  PMEM namespace
- *allocate from from the bottom of a region.  The unallocated
+ *allocate from the bottom of a region.  The unallocated
  *portion of REGION0 aliases with REGION2 and REGION3.  That
  *unallacted capacity is reclaimed as BLK namespaces ("blk2.0" and
  *"blk3.0") starting at the base of each DIMM to offset (a) in those
-- 
2.35.1