linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <natechancellor@gmail.com>
To: Sudeep Holla <sudeep.holla@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com,
	Nathan Chancellor <natechancellor@gmail.com>
Subject: [PATCH] firmware: arm_scmi: Eliminate local db variable in SCMI_PERF_FC_RING_DB
Date: Fri,  9 Aug 2019 21:49:10 -0700	[thread overview]
Message-ID: <20190810044910.114015-1-natechancellor@gmail.com> (raw)

clang warns four times:

drivers/firmware/arm_scmi/perf.c:320:24: warning: variable 'db' is
uninitialized when used within its own initialization [-Wuninitialized]
                SCMI_PERF_FC_RING_DB(db, 64);
                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~
drivers/firmware/arm_scmi/perf.c:300:31: note: expanded from macro
'SCMI_PERF_FC_RING_DB'
        struct scmi_fc_db_info *db = doorbell;          \
                                ~~   ^~~~~~~~

This happens because the doorbell identifier becomes db after
preprocessing:

        if (db->width == 1)
                do {
                        u8 val = 0;
                        struct scmi_fc_db_info *db = db;
                        if (db->mask)
                                val = ioread8(db->addr) & db->mask;
                        iowrite8((u8)db->set | val, db->addr);
                } while (0);

We could swap the doorbell and db identifiers within the macro and that
would resolve the issue; however, there doesn't appear to be a good
reason for having two copies of the same variable. Eliminate the one in
the do while loop to prevent this warning and make the code clearer.

Fixes: 8f12cbcb6abc ("firmware: arm_scmi: Make use SCMI v2.0 fastchannel for performance protocol")
Link: https://github.com/ClangBuiltLinux/linux/issues/635
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/firmware/arm_scmi/perf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c
index 2c5201c8354c..ab946ef6b914 100644
--- a/drivers/firmware/arm_scmi/perf.c
+++ b/drivers/firmware/arm_scmi/perf.c
@@ -294,10 +294,9 @@ scmi_perf_describe_levels_get(const struct scmi_handle *handle, u32 domain,
 	return ret;
 }
 
-#define SCMI_PERF_FC_RING_DB(doorbell, w)		\
+#define SCMI_PERF_FC_RING_DB(db, w)			\
 do {							\
 	u##w val = 0;					\
-	struct scmi_fc_db_info *db = doorbell;		\
 							\
 	if (db->mask)					\
 		val = ioread##w(db->addr) & db->mask;	\
-- 
2.23.0.rc2


             reply	other threads:[~2019-08-10  4:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-10  4:49 Nathan Chancellor [this message]
2019-08-12 10:32 ` [PATCH] firmware: arm_scmi: Eliminate local db variable in SCMI_PERF_FC_RING_DB Sudeep Holla

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=20190810044910.114015-1-natechancellor@gmail.com \
    --to=natechancellor@gmail.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sudeep.holla@arm.com \
    /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;
as well as URLs for NNTP newsgroup(s).