firmware: turris-mox-rwtm: fix building without CONFIG_KEYS
PATCH 1/2 firmware: turris-mox-rwtm: fix building without CONFIG_KEYS
From: Arnd Bergmann <[email protected]>
"struct key" is defined conditionally, so the code referencing it must be made conditional as well:
In file included from drivers/firmware/turris-mox-rwtm.c:29:include/linux/turris-signing-key.h: In function 'turris_signing_key_get_dev':include/linux/turris-signing-key.h:26:19: error: invalid use of undefined type 'const struct key'
26 | return key->payload.data[1];
| ^~
--- include/linux/turris-signing-key.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/turris-signing-key.h +2 -0
@@ -11,6 +11,7 @@struct device ; +#ifdef CONFIG_KEYS struct turris_signing_key_subtype { u16 key_size; u8 data_size;
@@ -29,5 +30,6 @@ static inline struct device *turris_signing_key_get_dev(const struct key *key)int devm_turris_signing_key_create (struct device *dev,const struct turris_signing_key_subtype *subtype,const char *desc); +#endif #endif /* __TURRIS_SIGNING_KEY_H */
Signature · 1 line
2.39.5
PATCH 2/2 platform: turris: use ffs() instead of __bf_shf()
From: Arnd Bergmann <[email protected]>
__bf_shf() on a 64-bit variable causes a link failure during compile-testing:
drivers-platform-cznic-turris-omnia-mcu-gpio.c:(.text):undefined-reference-to-__ffsdi2
Open-code this using ffs()-1, which has the same result but avoids the library call.
--- drivers/platform/cznic/turris-omnia-mcu-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/cznic/turris-omnia-mcu-gpio.c +1 -1
@@ -1104,7 +1104,7 @@ int omnia_mcu_request_irq(struct omnia_mcu *mcu, u32 spec,if (!spec)return -EINVAL ; - irq_idx = omnia_int_to_gpio_idx[__bf_shf (spec)]; + irq_idx = omnia_int_to_gpio_idx[ffs (spec) -1 ]; irq =gpiod_to_irq (gpio_device_get_desc (mcu->gc.gpiodev, irq_idx));if (irq <0 )return irq;
Signature · 1 line
2.39.5
Marek Behún
maintainerRe: [PATCH 2/2] platform: turris: use ffs() instead of __bf_shf()
Quoted 20 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
__bf_shf()on a 64-bit variable causes a link failure during compile-testing:drivers-platform-cznic-turris-omnia-mcu-gpio.c:(.text):undefined-reference-to-__ffsdi2
Open-code this using ffs()-1, which has the same result but avoids the library call.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/platform/cznic/turris-omnia-mcu-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/platform/cznic/turris-omnia-mcu-gpio.c +0
-0
drivers/platform/cznic/turris-omnia-mcu-gpio.c int omnia_mcu_request_irq(struct omnia_mcu *mcu, u32 spec, · line 1107
Quoted 5 lines
drivers/platform/cznic/turris-omnia-mcu-gpio.c +1
-1@@ -1104,7 +1104,7 @@ int omnia_mcu_request_irq(struct omnia_mcu *mcu, u32 spec,if (!spec)return -EINVAL ; - irq_idx = omnia_int_to_gpio_idx[__bf_shf (spec)]; + irq_idx = omnia_int_to_gpio_idx[ffs (spec) -1 ];
Weird that __bf_shf() procudes this error on non-constant input. But I guess a variant of ffs() makes more sense semantically, since the spec arugment isn't semantically a bitfield.
Shouldn't we consider using __ffs(), though?
With __ffs() we can drop the "- 1", i.e.:
irq_idx = omnia_int_to_gpio_idx[__ffs(spec)];
Both __ffs() and ffs() are used within the drivers/ subdir. Of the 649 usages of ffs(), 482 are ffs(x) - 1, so they could be converted to __ffs(x).
But I don't particularly care.
Marek
Marek Behún
maintainerack