* [PATCH 1/2] firmware: turris-mox-rwtm: fix building without CONFIG_KEYS
@ 2025-04-04 13:55 Arnd Bergmann
2025-04-04 13:55 ` [PATCH 2/2] platform: turris: use ffs() instead of __bf_shf() Arnd Bergmann
2025-04-06 20:13 ` [PATCH 1/2] firmware: turris-mox-rwtm: fix building without CONFIG_KEYS Marek Behún
0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2025-04-04 13:55 UTC (permalink / raw)
To: Marek Behún; +Cc: Arnd Bergmann, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
"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];
| ^~
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
include/linux/turris-signing-key.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/turris-signing-key.h b/include/linux/turris-signing-key.h
index 032ca8cbf636..8a435b73c3a9 100644
--- a/include/linux/turris-signing-key.h
+++ b/include/linux/turris-signing-key.h
@@ -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 */
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] platform: turris: use ffs() instead of __bf_shf()
2025-04-04 13:55 [PATCH 1/2] firmware: turris-mox-rwtm: fix building without CONFIG_KEYS Arnd Bergmann
@ 2025-04-04 13:55 ` Arnd Bergmann
2025-04-06 20:12 ` Marek Behún
2025-04-06 20:13 ` [PATCH 1/2] firmware: turris-mox-rwtm: fix building without CONFIG_KEYS Marek Behún
1 sibling, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2025-04-04 13:55 UTC (permalink / raw)
To: Marek Behún
Cc: Arnd Bergmann, Bartosz Golaszewski, Al Viro, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
__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 <arnd@arndb.de>
---
drivers/platform/cznic/turris-omnia-mcu-gpio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/cznic/turris-omnia-mcu-gpio.c b/drivers/platform/cznic/turris-omnia-mcu-gpio.c
index 932383f7491a..c2df24ea8686 100644
--- a/drivers/platform/cznic/turris-omnia-mcu-gpio.c
+++ b/drivers/platform/cznic/turris-omnia-mcu-gpio.c
@@ -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;
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] platform: turris: use ffs() instead of __bf_shf()
2025-04-04 13:55 ` [PATCH 2/2] platform: turris: use ffs() instead of __bf_shf() Arnd Bergmann
@ 2025-04-06 20:12 ` Marek Behún
0 siblings, 0 replies; 4+ messages in thread
From: Marek Behún @ 2025-04-06 20:12 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Marek Behún, Arnd Bergmann, Bartosz Golaszewski, Al Viro,
linux-kernel
On Fri, Apr 04, 2025 at 03:55:26PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> __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 <arnd@arndb.de>
> ---
> drivers/platform/cznic/turris-omnia-mcu-gpio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/cznic/turris-omnia-mcu-gpio.c b/drivers/platform/cznic/turris-omnia-mcu-gpio.c
> index 932383f7491a..c2df24ea8686 100644
> --- a/drivers/platform/cznic/turris-omnia-mcu-gpio.c
> +++ b/drivers/platform/cznic/turris-omnia-mcu-gpio.c
> @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] firmware: turris-mox-rwtm: fix building without CONFIG_KEYS
2025-04-04 13:55 [PATCH 1/2] firmware: turris-mox-rwtm: fix building without CONFIG_KEYS Arnd Bergmann
2025-04-04 13:55 ` [PATCH 2/2] platform: turris: use ffs() instead of __bf_shf() Arnd Bergmann
@ 2025-04-06 20:13 ` Marek Behún
1 sibling, 0 replies; 4+ messages in thread
From: Marek Behún @ 2025-04-06 20:13 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Arnd Bergmann, linux-kernel
ack
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-06 20:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-04 13:55 [PATCH 1/2] firmware: turris-mox-rwtm: fix building without CONFIG_KEYS Arnd Bergmann
2025-04-04 13:55 ` [PATCH 2/2] platform: turris: use ffs() instead of __bf_shf() Arnd Bergmann
2025-04-06 20:12 ` Marek Behún
2025-04-06 20:13 ` [PATCH 1/2] firmware: turris-mox-rwtm: fix building without CONFIG_KEYS Marek Behún
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®