Skip to content

Commit 3b72fe5

Browse files
jukkarnashif
authored andcommitted
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: Jukka Rissanen <[email protected]>
1 parent c95f61f commit 3b72fe5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

drivers/ethernet/eth_e1000.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,27 +371,27 @@ static int ptp_clock_e1000_rate_adjust(const struct device *dev, double ratio)
371371
float val;
372372

373373
/* No change needed. */
374-
if (ratio == 1.0f) {
374+
if (ratio == 1.0) {
375375
return 0;
376376
}
377377

378378
ratio *= context->clk_ratio;
379379

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

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

389-
if (ratio < 1.0f) {
389+
if (ratio < 1.0) {
390390
corr = hw_inc - 1;
391-
val = 1.0f / (hw_inc * (1.0f - ratio));
392-
} else if (ratio > 1.0f) {
391+
val = 1.0 / (hw_inc * (1.0 - ratio));
392+
} else if (ratio > 1.0) {
393393
corr = hw_inc + 1;
394-
val = 1.0f / (hw_inc * (ratio - 1.0f));
394+
val = 1.0 / (hw_inc * (ratio - 1.0));
395395
} else {
396396
val = 0;
397397
corr = hw_inc;

drivers/ethernet/eth_e1000_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct e1000_dev {
9292
uint8_t rxb[NET_ETH_MTU];
9393
#if defined(CONFIG_ETH_E1000_PTP_CLOCK)
9494
const struct device *ptp_clock;
95-
float clk_ratio;
95+
double clk_ratio;
9696
#endif
9797
};
9898

0 commit comments

Comments
 (0)