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 <xmarquiegui@ainguraiiot.com>
This commit is contained in:
Xabier Marquiegui 2022-01-27 09:49:20 +01:00 committed by David Leach
parent 62db8ca0e6
commit 52be66919e
7 changed files with 10 additions and 10 deletions

View file

@ -380,7 +380,7 @@ static int ptp_clock_e1000_adjust(const struct device *dev, int increment)
return 0;
}
static int ptp_clock_e1000_rate_adjust(const struct device *dev, float ratio)
static int ptp_clock_e1000_rate_adjust(const struct device *dev, double ratio)
{
const int hw_inc = NSEC_PER_SEC / CONFIG_ETH_E1000_PTP_CLOCK_SRC_HZ;
struct ptp_context *ptp_context = dev->data;

View file

@ -164,7 +164,7 @@ struct eth_context {
struct net_pkt *ts_tx_pkt;
const struct device *ptp_clock;
enet_ptp_config_t ptp_config;
float clk_ratio;
double clk_ratio;
struct k_mutex ptp_mutex;
#endif
struct k_sem tx_buf_sem;
@ -1646,14 +1646,14 @@ static int ptp_clock_mcux_adjust(const struct device *dev, int increment)
return ret;
}
static int ptp_clock_mcux_rate_adjust(const struct device *dev, float ratio)
static int ptp_clock_mcux_rate_adjust(const struct device *dev, double ratio)
{
const int hw_inc = NSEC_PER_SEC / CONFIG_ETH_MCUX_PTP_CLOCK_SRC_HZ;
struct ptp_context *ptp_context = dev->data;
struct eth_context *context = ptp_context->eth_context;
int corr;
int32_t mul;
float val;
double val;
/* No change needed. */
if ((ratio > 1.0 && ratio - 1.0 < 0.00000001) ||

View file

@ -695,7 +695,7 @@ static int ptp_clock_adjust_native_posix(const struct device *clk,
}
static int ptp_clock_rate_adjust_native_posix(const struct device *clk,
float ratio)
double ratio)
{
ARG_UNUSED(clk);
ARG_UNUSED(ratio);

View file

@ -2448,7 +2448,7 @@ static int ptp_clock_sam_gmac_adjust(const struct device *dev, int increment)
}
static int ptp_clock_sam_gmac_rate_adjust(const struct device *dev,
float ratio)
double ratio)
{
return -ENOTSUP;
}

View file

@ -1267,7 +1267,7 @@ static int ptp_clock_stm32_adjust(const struct device *dev, int increment)
return ret;
}
static int ptp_clock_stm32_rate_adjust(const struct device *dev, float ratio)
static int ptp_clock_stm32_rate_adjust(const struct device *dev, double ratio)
{
struct ptp_context *ptp_context = dev->data;
struct eth_stm32_hal_dev_data *eth_dev_data = ptp_context->eth_dev_data;

View file

@ -26,7 +26,7 @@ __subsystem struct ptp_clock_driver_api {
int (*set)(const struct device *dev, struct net_ptp_time *tm);
int (*get)(const struct device *dev, struct net_ptp_time *tm);
int (*adjust)(const struct device *dev, int increment);
int (*rate_adjust)(const struct device *dev, float ratio);
int (*rate_adjust)(const struct device *dev, double ratio);
};
/**
@ -89,7 +89,7 @@ static inline int ptp_clock_adjust(const struct device *dev, int increment)
*
* @return 0 if ok, <0 if error
*/
static inline int ptp_clock_rate_adjust(const struct device *dev, float rate)
static inline int ptp_clock_rate_adjust(const struct device *dev, double rate)
{
const struct ptp_clock_driver_api *api =
(const struct ptp_clock_driver_api *)dev->api;

View file

@ -218,7 +218,7 @@ static int my_ptp_clock_adjust(const struct device *dev, int increment)
return 0;
}
static int my_ptp_clock_rate_adjust(const struct device *dev, float ratio)
static int my_ptp_clock_rate_adjust(const struct device *dev, double ratio)
{
return 0;
}