diff mbox series

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

Message ID 20220808024128.3219082-25-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Matthew Wilcox Aug. 8, 2022, 2:41 a.m. UTC
From: Kent Overstreet <kent.overstreet@gmail.com>

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 <kent.overstreet@gmail.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: nvdimm@lists.linux.dev
---
 tools/testing/nvdimm/test/ndtest.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

Comments

Dan Williams Aug. 8, 2022, 6:30 p.m. UTC | #1
Matthew Wilcox (Oracle) wrote:
> From: Kent Overstreet <kent.overstreet@gmail.com>
> 
> 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 <kent.overstreet@gmail.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: nvdimm@lists.linux.dev

My Acked-by still applies:

https://lore.kernel.org/all/62b61165348f4_a7a2f294d0@dwillia2-xfh.notmuch/

...and Shivaprasad's Tested-by should still apply:

https://lore.kernel.org/all/b299ebe2-88e5-c2bd-bad0-bef62d4acdfe@linux.ibm.com/
Kent Overstreet Aug. 8, 2022, 6:33 p.m. UTC | #2
On 8/8/22 14:30, Dan Williams wrote:
> Matthew Wilcox (Oracle) wrote:
>> From: Kent Overstreet <kent.overstreet@gmail.com>
>>
>> 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 <kent.overstreet@gmail.com>
>> Cc: Dan Williams <dan.j.williams@intel.com>
>> Cc: Dave Hansen <dave.hansen@linux.intel.com>
>> Cc: nvdimm@lists.linux.dev
> 
> My Acked-by still applies:
> 
> https://lore.kernel.org/all/62b61165348f4_a7a2f294d0@dwillia2-xfh.notmuch/
> 
> ...and Shivaprasad's Tested-by should still apply:
> 
> https://lore.kernel.org/all/b299ebe2-88e5-c2bd-bad0-bef62d4acdfe@linux.ibm.com/

Whoops - got them now, thanks!
diff mbox series

Patch

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 <linux/ndctl.h>
 #include <nd-core.h>
 #include <linux/printk.h>
-#include <linux/seq_buf.h>
+#include <linux/printbuf.h>
 
 #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(&s, buf, PAGE_SIZE);
 	if (flags & PAPR_PMEM_UNARMED_MASK)
-		seq_buf_printf(&s, "not_armed ");
+		prt_printf(&s, "not_armed ");
 
 	if (flags & PAPR_PMEM_BAD_SHUTDOWN_MASK)
-		seq_buf_printf(&s, "flush_fail ");
+		prt_printf(&s, "flush_fail ");
 
 	if (flags & PAPR_PMEM_BAD_RESTORE_MASK)
-		seq_buf_printf(&s, "restore_fail ");
+		prt_printf(&s, "restore_fail ");
 
 	if (flags & PAPR_PMEM_SAVE_MASK)
-		seq_buf_printf(&s, "save_fail ");
+		prt_printf(&s, "save_fail ");
 
 	if (flags & PAPR_PMEM_SMART_EVENT_MASK)
-		seq_buf_printf(&s, "smart_notify ");
+		prt_printf(&s, "smart_notify ");
 
+	if (printbuf_written(&s))
+		prt_printf(&s, "\n");
 
-	if (seq_buf_used(&s))
-		seq_buf_printf(&s, "\n");
-
-	return seq_buf_used(&s);
+	return printbuf_written(&s);
 }
 static DEVICE_ATTR_RO(flags);