@@ -186,7 +186,6 @@ extern long __static_call_return0(void);
DECLARE_STATIC_CALL(name, _func); \
struct static_call_key STATIC_CALL_KEY(name) = { \
.func = _func, \
- .type = 1, \
}; \
ARCH_DEFINE_STATIC_CALL_TRAMP(name, _func)
@@ -194,7 +193,6 @@ extern long __static_call_return0(void);
DECLARE_STATIC_CALL(name, _func); \
struct static_call_key STATIC_CALL_KEY(name) = { \
.func = NULL, \
- .type = 1, \
}; \
ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name)
@@ -202,7 +200,6 @@ extern long __static_call_return0(void);
DECLARE_STATIC_CALL(name, _func); \
struct static_call_key STATIC_CALL_KEY(name) = { \
.func = __static_call_return0, \
- .type = 1, \
}; \
ARCH_DEFINE_STATIC_CALL_RET0_TRAMP(name)
@@ -61,10 +61,10 @@ struct static_call_site {
struct static_call_key {
void *func;
union {
- /* bit 0: 0 = mods, 1 = sites */
+ /* bit 0: 0 = sites, 1 = mods */
unsigned long type;
- struct static_call_mod *_mods;
struct static_call_site *_sites;
+ struct static_call_mod *_mods;
};
};
@@ -112,7 +112,7 @@ static inline void static_call_sort_entries(struct static_call_site *start,
static inline bool static_call_key_has_mods(struct static_call_key *key)
{
- return !(key->type & 1);
+ return !!(key->type & 1);
}
static inline struct static_call_mod *static_call_key_mods(struct static_call_key *key)
@@ -120,12 +120,13 @@ static inline struct static_call_mod *static_call_key_mods(struct static_call_ke
if (!static_call_key_has_mods(key))
return NULL;
- return key->_mods;
+ return (struct static_call_mod *)(key->type & ~1);
}
static inline void static_call_key_set_mods(struct static_call_key *key, struct static_call_mod *mods)
{
key->_mods = mods;
+ key->type |= 1;
}
static inline struct static_call_site *static_call_key_sites(struct static_call_key *key)
@@ -133,13 +134,12 @@ static inline struct static_call_site *static_call_key_sites(struct static_call_
if (static_call_key_has_mods(key))
return NULL;
- return (struct static_call_site *)(key->type & ~1);
+ return key->_sites;
}
static inline void static_call_key_set_sites(struct static_call_key *key, struct static_call_site *sites)
{
key->_sites = sites;
- key->type |= 1;
}
void __static_call_update(struct static_call_key *key, void *tramp, void *func)
@@ -61,10 +61,10 @@ struct static_call_site {
struct static_call_key {
void *func;
union {
- /* bit 0: 0 = mods, 1 = sites */
+ /* bit 0: 0 = sites, 1 = mods */
unsigned long type;
- struct static_call_mod *_mods;
struct static_call_site *_sites;
+ struct static_call_mod *_mods;
};
};
Flip the meaning of the key->type union field. This will make it easier to converge some of the DECLARE_STATIC_CALL() macros. Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> --- include/linux/static_call.h | 3 --- include/linux/static_call_types.h | 4 ++-- kernel/static_call_inline.c | 8 ++++---- tools/include/linux/static_call_types.h | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-)