Skip to content

Commit 52be669

Browse files
ainguraXmarquieguidleach02
authored andcommitted
net: gptp: convert clock sync ratio from float to double
Using clock sync ratio as double instead of float improves synchronization smoothness Signed-off-by: Xabier Marquiegui <[email protected]>
1 parent 62db8ca commit 52be669

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

drivers/ethernet/eth_e1000.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static int ptp_clock_e1000_adjust(const struct device *dev, int increment)
380380
return 0;
381381
}
382382

383-
static int ptp_clock_e1000_rate_adjust(const struct device *dev, float ratio)
383+
static int ptp_clock_e1000_rate_adjust(const struct device *dev, double ratio)
384384
{
385385
const int hw_inc = NSEC_PER_SEC / CONFIG_ETH_E1000_PTP_CLOCK_SRC_HZ;
386386
struct ptp_context *ptp_context = dev->data;

drivers/ethernet/eth_mcux.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ struct eth_context {
164164
struct net_pkt *ts_tx_pkt;
165165
const struct device *ptp_clock;
166166
enet_ptp_config_t ptp_config;
167-
float clk_ratio;
167+
double clk_ratio;
168168
struct k_mutex ptp_mutex;
169169
#endif
170170
struct k_sem tx_buf_sem;
@@ -1646,14 +1646,14 @@ static int ptp_clock_mcux_adjust(const struct device *dev, int increment)
16461646
return ret;
16471647
}
16481648

1649-
static int ptp_clock_mcux_rate_adjust(const struct device *dev, float ratio)
1649+
static int ptp_clock_mcux_rate_adjust(const struct device *dev, double ratio)
16501650
{
16511651
const int hw_inc = NSEC_PER_SEC / CONFIG_ETH_MCUX_PTP_CLOCK_SRC_HZ;
16521652
struct ptp_context *ptp_context = dev->data;
16531653
struct eth_context *context = ptp_context->eth_context;
16541654
int corr;
16551655
int32_t mul;
1656-
float val;
1656+
double val;
16571657

16581658
/* No change needed. */
16591659
if ((ratio > 1.0 && ratio - 1.0 < 0.00000001) ||

drivers/ethernet/eth_native_posix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ static int ptp_clock_adjust_native_posix(const struct device *clk,
695695
}
696696

697697
static int ptp_clock_rate_adjust_native_posix(const struct device *clk,
698-
float ratio)
698+
double ratio)
699699
{
700700
ARG_UNUSED(clk);
701701
ARG_UNUSED(ratio);

drivers/ethernet/eth_sam_gmac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2448,7 +2448,7 @@ static int ptp_clock_sam_gmac_adjust(const struct device *dev, int increment)
24482448
}
24492449

24502450
static int ptp_clock_sam_gmac_rate_adjust(const struct device *dev,
2451-
float ratio)
2451+
double ratio)
24522452
{
24532453
return -ENOTSUP;
24542454
}

drivers/ethernet/eth_stm32_hal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ static int ptp_clock_stm32_adjust(const struct device *dev, int increment)
12671267
return ret;
12681268
}
12691269

1270-
static int ptp_clock_stm32_rate_adjust(const struct device *dev, float ratio)
1270+
static int ptp_clock_stm32_rate_adjust(const struct device *dev, double ratio)
12711271
{
12721272
struct ptp_context *ptp_context = dev->data;
12731273
struct eth_stm32_hal_dev_data *eth_dev_data = ptp_context->eth_dev_data;

include/drivers/ptp_clock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ __subsystem struct ptp_clock_driver_api {
2626
int (*set)(const struct device *dev, struct net_ptp_time *tm);
2727
int (*get)(const struct device *dev, struct net_ptp_time *tm);
2828
int (*adjust)(const struct device *dev, int increment);
29-
int (*rate_adjust)(const struct device *dev, float ratio);
29+
int (*rate_adjust)(const struct device *dev, double ratio);
3030
};
3131

3232
/**
@@ -89,7 +89,7 @@ static inline int ptp_clock_adjust(const struct device *dev, int increment)
8989
*
9090
* @return 0 if ok, <0 if error
9191
*/
92-
static inline int ptp_clock_rate_adjust(const struct device *dev, float rate)
92+
static inline int ptp_clock_rate_adjust(const struct device *dev, double rate)
9393
{
9494
const struct ptp_clock_driver_api *api =
9595
(const struct ptp_clock_driver_api *)dev->api;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static int my_ptp_clock_adjust(const struct device *dev, int increment)
218218
return 0;
219219
}
220220

221-
static int my_ptp_clock_rate_adjust(const struct device *dev, float ratio)
221+
static int my_ptp_clock_rate_adjust(const struct device *dev, double ratio)
222222
{
223223
return 0;
224224
}

0 commit comments

Comments
 (0)