Skip to content

Commit e60da1b

Browse files
drivers: can: fake: install default core clock delegate at driver init
Install the default delegate for reporting the CAN core clock frequency at driver instance initialization. This allows using the default clock configuration when not using ztest. Signed-off-by: Henrik Brix Andersen <[email protected]>
1 parent a8a000d commit e60da1b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/can/can_fake.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ static void fake_can_reset_rule_before(const struct ztest_unit_test *test, void
9595
ZTEST_RULE(fake_can_reset_rule, fake_can_reset_rule_before, NULL);
9696
#endif /* CONFIG_ZTEST */
9797

98+
static int fake_can_init(const struct device *dev)
99+
{
100+
/* Install default delegate for reporting the core clock */
101+
fake_can_get_core_clock_fake.custom_fake = fake_can_get_core_clock_delegate;
102+
103+
return 0;
104+
}
105+
98106
static const struct can_driver_api fake_can_driver_api = {
99107
.start = fake_can_start,
100108
.stop = fake_can_stop,
@@ -159,7 +167,7 @@ static const struct can_driver_api fake_can_driver_api = {
159167
\
160168
static struct fake_can_data fake_can_data_##inst; \
161169
\
162-
CAN_DEVICE_DT_INST_DEFINE(inst, NULL, NULL, &fake_can_data_##inst, \
170+
CAN_DEVICE_DT_INST_DEFINE(inst, fake_can_init, NULL, &fake_can_data_##inst, \
163171
&fake_can_config_##inst, POST_KERNEL, \
164172
CONFIG_CAN_INIT_PRIORITY, \
165173
&fake_can_driver_api);

0 commit comments

Comments
 (0)