Skip to content

Commit b30ae46

Browse files
danieldegrassecfriedt
authored andcommitted
tests: ptp: Fixed PTP clock test failure on frdm_k64f
ptp_clock_test was failing when trying to access the ptp clock from user mode. This was due to an arbitrary initialization priority between the virtual PTP clock devices created by the ptp clocking test and the physical PTP clock on the frdm_k64f board. Since the ptp test initializes the virtual clock with the same device name as the physical clock, if the physical clock was initialized first this test would incorrectly reference the physical device during testing, instead of the virtual one. This fix simply defines the virtual ptp clock with a custom name, so that the test will always locate the correct ptp clock. Fixes #38731 Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent e1eb55d commit b30ae46

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/net/ptp/clock/src/main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88

99
#define NET_LOG_LEVEL CONFIG_NET_L2_ETHERNET_LOG_LEVEL
10+
/* Custom PTP device name to avoid conflicts with PTP devices on SOC */
11+
#define PTP_VIRT_CLOCK_NAME "PTP_CLOCK_VIRT"
1012

1113
#include <logging/log.h>
1214
LOG_MODULE_REGISTER(net_test, NET_LOG_LEVEL);
@@ -243,7 +245,7 @@ static int ptp_test_1_init(const struct device *port)
243245
return 0;
244246
}
245247

246-
DEVICE_DEFINE(ptp_clock_1, PTP_CLOCK_NAME, ptp_test_1_init,
248+
DEVICE_DEFINE(ptp_clock_1, PTP_VIRT_CLOCK_NAME, ptp_test_1_init,
247249
NULL, &ptp_test_1_context, NULL,
248250
POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY, &api);
249251

@@ -259,7 +261,7 @@ static int ptp_test_2_init(const struct device *port)
259261
return 0;
260262
}
261263

262-
DEVICE_DEFINE(ptp_clock_2, PTP_CLOCK_NAME, ptp_test_2_init,
264+
DEVICE_DEFINE(ptp_clock_2, PTP_VIRT_CLOCK_NAME, ptp_test_2_init,
263265
NULL, &ptp_test_2_context, NULL,
264266
POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY, &api);
265267

@@ -564,7 +566,7 @@ void test_main(void)
564566
{
565567
const struct device *clk;
566568

567-
clk = device_get_binding(PTP_CLOCK_NAME);
569+
clk = device_get_binding(PTP_VIRT_CLOCK_NAME);
568570
if (clk != NULL) {
569571
k_object_access_grant(clk, k_current_get());
570572
}

0 commit comments

Comments
 (0)