Instead of custom approach let's use recently introduced seq_hex_dump() helper.

Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 .../unisys/visorchannel/visorchannel_funcs.c       | 26 ++++------------------
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c 
b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
index 947b23c..d8345a6 100644
--- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
+++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
@@ -633,15 +633,11 @@ void
 visorchannel_dump_section(VISORCHANNEL *chan, char *s,
                          int off, int len, struct seq_file *seq)
 {
-       char *buf, *tbuf, *fmtbuf;
-       int fmtbufsize = 0;
-       int i;
+       char *buf;
        int errcode = 0;
 
-       fmtbufsize = 100 * COVQ(len, 16);
        buf = kmalloc(len, GFP_KERNEL|__GFP_NORETRY);
-       fmtbuf = kmalloc(fmtbufsize, GFP_KERNEL|__GFP_NORETRY);
-       if (buf == NULL || fmtbuf == NULL)
+       if (buf == NULL)
                goto Away;
 
        errcode = visorchannel_read(chan, off, buf, len);
@@ -651,23 +647,9 @@ visorchannel_dump_section(VISORCHANNEL *chan, char *s,
                goto Away;
        }
        seq_printf(seq, "channel %s:\n", s);
-       tbuf = buf;
-       while (len > 0) {
-               i = (len < 16) ? len : 16;
-               hex_dump_to_buffer(tbuf, i, 16, 1, fmtbuf, fmtbufsize, TRUE);
-               seq_printf(seq, "%s\n", fmtbuf);
-               tbuf += 16;
-               len -= 16;
-       }
+       seq_hex_dump(seq, "", DUMP_PREFIX_NONE, 16, 1, buf, len, true);
 
 Away:
-       if (buf != NULL) {
-               kfree(buf);
-               buf = NULL;
-       }
-       if (fmtbuf != NULL) {
-               kfree(fmtbuf);
-               fmtbuf = NULL;
-       }
+       kfree(buf);
 }
 EXPORT_SYMBOL_GPL(visorchannel_dump_section);
-- 
2.1.0

--
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/

Reply via email to