Skip to content

Commit c7da0d4

Browse files
elkabloarndb
authored andcommitted
platform: cznic: turris-omnia-mcu: Make TRNG code optional
Make the TRNG part of the driver optional, under a boolean config option. This makes the driver turris-omnia-mcu available for compilation even if HW_RANDOM is disabled. Fixes: ed46f1f ("platform: cznic: turris-omnia-mcu: fix Kconfig dependencies") Signed-off-by: Marek Behún <kabel@kernel.org> Link: https://lore.kernel.org/r/20240719085756.30598-3-kabel@kernel.org Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 019f87f commit c7da0d4

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

drivers/platform/cznic/Kconfig

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ config TURRIS_OMNIA_MCU
1818
depends on I2C
1919
depends on OF
2020
depends on GPIOLIB
21-
depends on HW_RANDOM
2221
depends on RTC_CLASS
2322
select GPIOLIB_IRQCHIP
2423
help
@@ -28,7 +27,6 @@ config TURRIS_OMNIA_MCU
2827
- board poweroff into true low power mode (with voltage regulators
2928
disabled) and the ability to configure wake up from this mode (via
3029
rtcwake)
31-
- true random number generator (if available on the MCU)
3230
- GPIO pins
3331
- to get front button press events (the front button can be
3432
configured either to generate press events to the CPU or to change
@@ -56,6 +54,14 @@ config TURRIS_OMNIA_MCU_WATCHDOG
5654
Say Y here to add support for watchdog provided by CZ.NIC's Turris
5755
Omnia MCU.
5856

57+
config TURRIS_OMNIA_MCU_TRNG
58+
bool "Turris Omnia MCU true random number generator"
59+
default y
60+
depends on HW_RANDOM
61+
help
62+
Say Y here to add support for the true random number generator
63+
provided by CZ.NIC's Turris Omnia MCU.
64+
5965
endif # TURRIS_OMNIA_MCU
6066

6167
endif # CZNIC_PLATFORMS

drivers/platform/cznic/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ obj-$(CONFIG_TURRIS_OMNIA_MCU) += turris-omnia-mcu.o
44
turris-omnia-mcu-y := turris-omnia-mcu-base.o
55
turris-omnia-mcu-y += turris-omnia-mcu-gpio.o
66
turris-omnia-mcu-y += turris-omnia-mcu-sys-off-wakeup.o
7-
turris-omnia-mcu-y += turris-omnia-mcu-trng.o
7+
turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_TRNG) += turris-omnia-mcu-trng.o
88
turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_WATCHDOG) += turris-omnia-mcu-watchdog.o

drivers/platform/cznic/turris-omnia-mcu.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ struct omnia_mcu {
5252
struct watchdog_device wdt;
5353
#endif
5454

55+
#ifdef CONFIG_TURRIS_OMNIA_MCU_TRNG
5556
/* true random number generator */
5657
struct hwrng trng;
5758
struct completion trng_entropy_ready;
59+
#endif
5860
};
5961

6062
int omnia_cmd_write_read(const struct i2c_client *client,
@@ -190,7 +192,15 @@ extern const struct attribute_group omnia_mcu_poweroff_group;
190192

191193
int omnia_mcu_register_gpiochip(struct omnia_mcu *mcu);
192194
int omnia_mcu_register_sys_off_and_wakeup(struct omnia_mcu *mcu);
195+
196+
#ifdef CONFIG_TURRIS_OMNIA_MCU_TRNG
193197
int omnia_mcu_register_trng(struct omnia_mcu *mcu);
198+
#else
199+
static inline int omnia_mcu_register_trng(struct omnia_mcu *mcu)
200+
{
201+
return 0;
202+
}
203+
#endif
194204

195205
#ifdef CONFIG_TURRIS_OMNIA_MCU_WATCHDOG
196206
int omnia_mcu_register_watchdog(struct omnia_mcu *mcu);

0 commit comments

Comments
 (0)