Skip to content

Commit

Permalink
drivers: can: fake: install default core clock delegate at driver init
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit e60da1b)

Original-Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
GitOrigin-RevId: e60da1b
Cr-Build-Id: 8739091610579900001
Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8739091610579900001
Copybot-Job-Name: zephyr-main-copybot-downstream
Change-Id: I260901cc1cc7c3664ad176fcd57db8a36de4ae51
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5800148
Reviewed-by: Eric Yilun Lin <yllin@google.com>
Tested-by: Eric Yilun Lin <yllin@google.com>
Commit-Queue: Eric Yilun Lin <yllin@google.com>
  • Loading branch information
henrikbrixandersen authored and Chromeos LUCI committed Aug 21, 2024
1 parent aa363d0 commit fa77d29
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/can/can_fake.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ static void fake_can_reset_rule_before(const struct ztest_unit_test *test, void
ZTEST_RULE(fake_can_reset_rule, fake_can_reset_rule_before, NULL);
#endif /* CONFIG_ZTEST */

static int fake_can_init(const struct device *dev)
{
/* Install default delegate for reporting the core clock */
fake_can_get_core_clock_fake.custom_fake = fake_can_get_core_clock_delegate;

return 0;
}

static const struct can_driver_api fake_can_driver_api = {
.start = fake_can_start,
.stop = fake_can_stop,
Expand Down Expand Up @@ -159,7 +167,7 @@ static const struct can_driver_api fake_can_driver_api = {
\
static struct fake_can_data fake_can_data_##inst; \
\
CAN_DEVICE_DT_INST_DEFINE(inst, NULL, NULL, &fake_can_data_##inst, \
CAN_DEVICE_DT_INST_DEFINE(inst, fake_can_init, NULL, &fake_can_data_##inst, \
&fake_can_config_##inst, POST_KERNEL, \
CONFIG_CAN_INIT_PRIORITY, \
&fake_can_driver_api);
Expand Down

0 comments on commit fa77d29

Please sign in to comment.