Skip to content

Commit 0a7ec80

Browse files
geertuSudeep Holla
authored andcommitted
firmware: arm_scmi: Support loop control in quirk code snippets
Each SCMI firmware quirk contains a code snippet, which handles the quirk, and has full access to the surrounding context. When this context is (part of) a loop body, the code snippet may want to use loop control statements like "break" and "continue". Unfortunately the SCMI_QUIRK() macro implementation contains a dummy loop, taking precedence over any outer loops. Hence quirk code cannot use loop control statements, but has to resort to polluting the surrounding context with a label, and use goto. Fix this by replacing the "do { ... } while (0)" construct in the SCMI_QUIRK() implementation by "({ ... })". Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> Reviewed-by: Peng Fan <peng.fan@nxp.com> Message-Id: <51de914cddef8fa86c2e7dd5397e5df759c45464.1773675224.git.geert+renesas@glider.be> Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
1 parent 09bb95d commit 0a7ec80

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/firmware/arm_scmi/quirks.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
* named as _qn.
2121
*/
2222
#define SCMI_QUIRK(_qn, _blk) \
23-
do { \
23+
({ \
2424
if (static_branch_unlikely(&(scmi_quirk_ ## _qn))) \
2525
(_blk); \
26-
} while (0)
26+
})
2727

2828
void scmi_quirks_initialize(void);
2929
void scmi_quirks_enable(struct device *dev, const char *vend,
@@ -34,10 +34,10 @@ void scmi_quirks_enable(struct device *dev, const char *vend,
3434
#define DECLARE_SCMI_QUIRK(_qn)
3535
/* Force quirks compilation even when SCMI Quirks are disabled */
3636
#define SCMI_QUIRK(_qn, _blk) \
37-
do { \
37+
({ \
3838
if (0) \
3939
(_blk); \
40-
} while (0)
40+
})
4141

4242
static inline void scmi_quirks_initialize(void) { }
4343
static inline void scmi_quirks_enable(struct device *dev, const char *vend,

0 commit comments

Comments
 (0)