From patchwork Tue Jun 30 16:25:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 11634375 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3642D739 for ; Tue, 30 Jun 2020 16:28:30 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0BBE4206BE for ; Tue, 30 Jun 2020 16:28:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yGoeNGWg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0BBE4206BE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Wt94hRyArhoybXB/lmIJKg7dxrosz4l9HAlpiBZhWvY=; b=yGoeNGWgFz74f0JwtNyzc4WlDv 2Iq+0XaRMl6Lbk5c6skWst4JR3Q/b5p+FLxtSucMGswTd6kBP95JPsg1TSqY+/BrQrfnxl2hks6eV /qr+8j3CemgjazV+kJKAt71P+BNcqxImT/Z58haqXXYwgciKAuBzMS8ByGbnuwnkpSYZXBKkVjGUJ PbVuY4OMiV8i9STEacCVlC8Dkk+tKvmQuXa8WwwCQ7nsj3/LerLwHogUAbPuNUMKLvylmyCLxrraT 9o2LAfAN+kmaXtpMzYU4ptNYObalUbG4aTqRPlPRZIxeG/unQqYnsPgGpPguKAWPmmKknrQzA/hpb OyFvR5rA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqJ5V-0000gt-FK; Tue, 30 Jun 2020 16:26:25 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqJ5M-0000el-Ri for linux-arm-kernel@lists.infradead.org; Tue, 30 Jun 2020 16:26:22 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D828330E; Tue, 30 Jun 2020 09:26:14 -0700 (PDT) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 28A1C3F68F; Tue, 30 Jun 2020 09:26:14 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] firmware: arm_scmi: fix notifications macros argument reuse Date: Tue, 30 Jun 2020 17:25:47 +0100 Message-Id: <20200630162547.40824-1-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200630_122617_028619_F4DF1C03 X-CRM114-Status: GOOD ( 10.01 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cristian.marussi@arm.com, sudeep.holla@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Checkpatch --strict reports some possible side-effects related to argument reuse in some SCMI Notification Core macros: these are indeed false flags in the context of actual macros invocations. Nevertheless cleanup fixing all the warnings. No functional change. Signed-off-by: Cristian Marussi Reported-by: kernel test robot --- drivers/firmware/arm_scmi/notify.c | 48 ++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c index b5b449f70605..bf8b3430c801 100644 --- a/drivers/firmware/arm_scmi/notify.c +++ b/drivers/firmware/arm_scmi/notify.c @@ -122,10 +122,13 @@ */ #define KEY_FIND(__ht, __obj, __k) \ ({ \ - hash_for_each_possible((__ht), (__obj), hash, (__k)) \ - if (likely((__obj)->key == (__k))) \ + typeof(__k) k_ = __k; \ + typeof(__obj) obj_; \ + \ + hash_for_each_possible((__ht), obj_, hash, k_) \ + if (likely(obj_->key == k_)) \ break; \ - __obj; \ + __obj = obj_; \ }) #define KEY_XTRACT_PROTO_ID(key) FIELD_GET(PROTO_ID_MASK, (key)) @@ -140,19 +143,22 @@ */ #define SCMI_GET_PROTO(__ni, __pid) \ ({ \ + typeof(__ni) ni_ = __ni; \ struct scmi_registered_events_desc *__pd = NULL; \ \ - if ((__ni)) \ - __pd = READ_ONCE((__ni)->registered_protocols[(__pid)]);\ + if (ni_) \ + __pd = READ_ONCE(ni_->registered_protocols[(__pid)]); \ __pd; \ }) #define SCMI_GET_REVT_FROM_PD(__pd, __eid) \ ({ \ + typeof(__pd) pd_ = __pd; \ + typeof(__eid) eid_ = __eid; \ struct scmi_registered_event *__revt = NULL; \ \ - if ((__pd) && (__eid) < (__pd)->num_events) \ - __revt = READ_ONCE((__pd)->registered_events[(__eid)]); \ + if (pd_ && eid_ < pd_->num_events) \ + __revt = READ_ONCE(pd_->registered_events[eid_]); \ __revt; \ }) @@ -167,15 +173,25 @@ }) /* A couple of utility macros to limit cruft when calling protocols' helpers */ -#define REVT_NOTIFY_ENABLE(revt, eid, sid) \ - ((revt)->proto->ops->set_notify_enabled((revt)->proto->ni->handle, \ - (eid), (sid), true)) -#define REVT_NOTIFY_DISABLE(revt, eid, sid) \ - ((revt)->proto->ops->set_notify_enabled((revt)->proto->ni->handle, \ - (eid), (sid), false)) -#define REVT_FILL_REPORT(revt, ...) \ - ((revt)->proto->ops->fill_custom_report((revt)->proto->ni->handle, \ - __VA_ARGS__)) +#define REVT_NOTIFY_SET_STATUS(revt, eid, sid, state) \ +({ \ + typeof(revt) r = revt; \ + r->proto->ops->set_notify_enabled(r->proto->ni->handle, \ + (eid), (sid), (state)); \ +}) + +#define REVT_NOTIFY_ENABLE(revt, eid, sid) \ + REVT_NOTIFY_SET_STATUS((revt), (eid), (sid), true) + +#define REVT_NOTIFY_DISABLE(revt, eid, sid) \ + REVT_NOTIFY_SET_STATUS((revt), (eid), (sid), false) + +#define REVT_FILL_REPORT(revt, ...) \ +({ \ + typeof(revt) r = revt; \ + r->proto->ops->fill_custom_report(r->proto->ni->handle, \ + __VA_ARGS__); \ +}) #define SCMI_PENDING_HASH_SZ 4 #define SCMI_REGISTERED_HASH_SZ 6