lkml.org 
[lkml]   [2020]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] firmware: arm_scmi: fix notifications macros argument reuse
Date
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
\
 
 \ /
  Last update: 2020-06-30 18:27    [W:0.063 / U:98.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site