Commit 3b72fe55 authored by Jukka Rissanen's avatar Jukka Rissanen Committed by Anas Nashif
Browse files

drivers: eth: e1000: Use double with PTP clock

Instead of mixing floats and doubles, convert the code to
use double so that we avoid float->double conversion warning
from compiler.

Signed-off-by: default avatarJukka Rissanen <jukka.rissanen@nordicsemi.no>
parent c95f61f6
Loading
Loading
Loading
Loading
+7 −7
Changes for drivers/ethernet/eth_e1000.c: 7 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -371,27 +371,27 @@ static int ptp_clock_e1000_rate_adjust(const struct device *dev, double ratio)
	float val;

	/* No change needed. */
	if (ratio == 1.0f) {
	if (ratio == 1.0) {
		return 0;
	}

	ratio *= context->clk_ratio;

	/* Limit possible ratio. */
	if ((ratio > 1.0f + 1.0f/(2 * hw_inc)) ||
			(ratio < 1.0f - 1.0f/(2 * hw_inc))) {
	if ((ratio > 1.0 + 1.0/(2.0 * hw_inc)) ||
			(ratio < 1.0 - 1.0/(2.0 * hw_inc))) {
		return -EINVAL;
	}

	/* Save new ratio. */
	context->clk_ratio = ratio;

	if (ratio < 1.0f) {
	if (ratio < 1.0) {
		corr = hw_inc - 1;
		val = 1.0f / (hw_inc * (1.0f - ratio));
	} else if (ratio > 1.0f) {
		val = 1.0 / (hw_inc * (1.0 - ratio));
	} else if (ratio > 1.0) {
		corr = hw_inc + 1;
		val = 1.0f / (hw_inc * (ratio - 1.0f));
		val = 1.0 / (hw_inc * (ratio - 1.0));
	} else {
		val = 0;
		corr = hw_inc;
+1 −1
Changes for drivers/ethernet/eth_e1000_priv.h: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ struct e1000_dev {
	uint8_t rxb[NET_ETH_MTU];
#if defined(CONFIG_ETH_E1000_PTP_CLOCK)
	const struct device *ptp_clock;
	float clk_ratio;
	double clk_ratio;
#endif
};