public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Samarth Parikh <samarthp@ymail.com>
To: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Cc: "dwmw2@infradead.org" <dwmw2@infradead.org>
Subject: [PATCH] Drivers: MTD: Fixed checkpatch seq_printf warnings
Date: Tue, 22 Jul 2014 02:49:30 +0800	[thread overview]
Message-ID: <1405968570.83800.YahooMailNeo@web192501.mail.sg3.yahoo.com> (raw)
In-Reply-To: <1405519230-48409-1-git-send-email-samarthp@ymail.com>

Fixed checkpatch warnings: "WARNING: Prefer seq_puts to seq_printf"




This patch is created with reference to the ongoing lkml thread
https://lkml.org/lkml/2014/7/15/646
where Andrew Morton wrote:

"
- puts is presumably faster

- puts doesn't go rogue if you accidentally pass it a "%".

- this patch would actually make compiled object files few bytes smaller.
  Perhaps because seq_printf() is a varargs function, forcing the
  caller to pass args on the stack instead of in registers.
"

Signed-off-by: Samarth Parikh <samarthp@ymail.com>
---
drivers/mtd/devices/docg3.c | 26 +++++++++++++-------------
drivers/mtd/mtdswap.c       |  4 ++--
2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index 91a169c..21cc4b6 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -1697,16 +1697,16 @@ static int dbg_asicmode_show(struct seq_file *s, void *p)

    switch (mode) {
    case DOC_ASICMODE_RESET:
-        pos += seq_printf(s, "reset");
+        pos += seq_puts(s, "reset");
        break;
    case DOC_ASICMODE_NORMAL:
-        pos += seq_printf(s, "normal");
+        pos += seq_puts(s, "normal");
        break;
    case DOC_ASICMODE_POWERDOWN:
-        pos += seq_printf(s, "powerdown");
+        pos += seq_puts(s, "powerdown");
        break;
    }
-    pos += seq_printf(s, ")\n");
+    pos += seq_puts(s, ")\n");
    return pos;
}
DEBUGFS_RO_ATTR(asic_mode, dbg_asicmode_show);
@@ -1745,22 +1745,22 @@ static int dbg_protection_show(struct seq_file *s, void *p)
    pos += seq_printf(s, "Protection = 0x%02x (",
             protect);
    if (protect & DOC_PROTECT_FOUNDRY_OTP_LOCK)
-        pos += seq_printf(s, "FOUNDRY_OTP_LOCK,");
+        pos += seq_puts(s, "FOUNDRY_OTP_LOCK,");
    if (protect & DOC_PROTECT_CUSTOMER_OTP_LOCK)
-        pos += seq_printf(s, "CUSTOMER_OTP_LOCK,");
+        pos += seq_puts(s, "CUSTOMER_OTP_LOCK,");
    if (protect & DOC_PROTECT_LOCK_INPUT)
-        pos += seq_printf(s, "LOCK_INPUT,");
+        pos += seq_puts(s, "LOCK_INPUT,");
    if (protect & DOC_PROTECT_STICKY_LOCK)
-        pos += seq_printf(s, "STICKY_LOCK,");
+        pos += seq_puts(s, "STICKY_LOCK,");
    if (protect & DOC_PROTECT_PROTECTION_ENABLED)
-        pos += seq_printf(s, "PROTECTION ON,");
+        pos += seq_puts(s, "PROTECTION ON,");
    if (protect & DOC_PROTECT_IPL_DOWNLOAD_LOCK)
-        pos += seq_printf(s, "IPL_DOWNLOAD_LOCK,");
+        pos += seq_puts(s, "IPL_DOWNLOAD_LOCK,");
    if (protect & DOC_PROTECT_PROTECTION_ERROR)
-        pos += seq_printf(s, "PROTECT_ERR,");
+        pos += seq_puts(s, "PROTECT_ERR,");
    else
-        pos += seq_printf(s, "NO_PROTECT_ERR");
-    pos += seq_printf(s, ")\n");
+        pos += seq_puts(s, "NO_PROTECT_ERR");
+    pos += seq_puts(s, ")\n");

    pos += seq_printf(s, "DPS0 = 0x%02x : "
             "Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, "
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
index 8b33b26..0ec96cd 100644
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -1287,7 +1287,7 @@ static int mtdswap_show(struct seq_file *s, void *data)

    seq_printf(s, "total erasures: %lu\n", sum);

-    seq_printf(s, "\n");
+    seq_puts(s, "\n");

    seq_printf(s, "mtdswap_readsect count: %llu\n", d->sect_read_count);
    seq_printf(s, "mtdswap_writesect count: %llu\n", d->sect_write_count);
@@ -1296,7 +1296,7 @@ static int mtdswap_show(struct seq_file *s, void *data)
    seq_printf(s, "mtd write count: %llu\n", d->mtd_write_count);
    seq_printf(s, "discarded pages count: %llu\n", d->discard_page_count);

-    seq_printf(s, "\n");
+    seq_puts(s, "\n");
    seq_printf(s, "total pages: %u\n", pages);
    seq_printf(s, "pages mapped: %u\n", mapped);

--
1.9.1

       reply	other threads:[~2014-07-21 18:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1405519230-48409-1-git-send-email-samarthp@ymail.com>
2014-07-21 18:49 ` Samarth Parikh [this message]
2014-08-04 21:27   ` [PATCH] Drivers: MTD: Fixed checkpatch seq_printf warnings Brian Norris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405968570.83800.YahooMailNeo@web192501.mail.sg3.yahoo.com \
    --to=samarthp@ymail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox