Files
linux/drivers/firmware/arm_scmi/quirks.h
Geert Uytterhoeven 0a7ec808ab 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>
2026-03-17 07:30:22 +00:00

53 lines
1.3 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* System Control and Management Interface (SCMI) Message Protocol Quirks
*
* Copyright (C) 2025 ARM Ltd.
*/
#ifndef _SCMI_QUIRKS_H
#define _SCMI_QUIRKS_H
#include <linux/static_key.h>
#include <linux/types.h>
#ifdef CONFIG_ARM_SCMI_QUIRKS
#define DECLARE_SCMI_QUIRK(_qn) \
DECLARE_STATIC_KEY_FALSE(scmi_quirk_ ## _qn)
/*
* A helper to associate the actual code snippet to use as a quirk
* named as _qn.
*/
#define SCMI_QUIRK(_qn, _blk) \
({ \
if (static_branch_unlikely(&(scmi_quirk_ ## _qn))) \
(_blk); \
})
void scmi_quirks_initialize(void);
void scmi_quirks_enable(struct device *dev, const char *vend,
const char *subv, const u32 impl);
#else
#define DECLARE_SCMI_QUIRK(_qn)
/* Force quirks compilation even when SCMI Quirks are disabled */
#define SCMI_QUIRK(_qn, _blk) \
({ \
if (0) \
(_blk); \
})
static inline void scmi_quirks_initialize(void) { }
static inline void scmi_quirks_enable(struct device *dev, const char *vend,
const char *sub_vend, const u32 impl) { }
#endif /* CONFIG_ARM_SCMI_QUIRKS */
/* Quirk delarations */
DECLARE_SCMI_QUIRK(clock_rates_triplet_out_of_spec);
DECLARE_SCMI_QUIRK(perf_level_get_fc_force);
#endif /* _SCMI_QUIRKS_H */