linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] firmware: arm_scmi: fix notifications macros argument reuse
@ 2020-06-30 16:25 Cristian Marussi
  2020-07-03 23:01 ` kernel test robot
  0 siblings, 1 reply; 3+ messages in thread
From: Cristian Marussi @ 2020-06-30 16:25 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: cristian.marussi, sudeep.holla

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 <cristian.marussi@arm.com>
---
 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
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-06 13:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-30 16:25 [PATCH] firmware: arm_scmi: fix notifications macros argument reuse Cristian Marussi
2020-07-03 23:01 ` kernel test robot
2020-07-06 13:20   ` Cristian Marussi

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).