drivers: move to timepoint API
Remove sys_clock_timeout_end_calc() usage. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
parent
77b7eb1199
commit
531aa5786d
6 changed files with 16 additions and 17 deletions
|
@ -566,7 +566,7 @@ int dwmac_probe(const struct device *dev)
|
|||
struct dwmac_priv *p = dev->data;
|
||||
int ret;
|
||||
uint32_t reg_val;
|
||||
int64_t timeout;
|
||||
k_timepoint_t timeout;
|
||||
|
||||
ret = dwmac_bus_init(p);
|
||||
if (ret != 0) {
|
||||
|
@ -580,9 +580,9 @@ int dwmac_probe(const struct device *dev)
|
|||
|
||||
/* resets all of the MAC internal registers and logic */
|
||||
REG_WRITE(DMA_MODE, DMA_MODE_SWR);
|
||||
timeout = sys_clock_timeout_end_calc(K_MSEC(100));
|
||||
timeout = sys_timepoint_calc(K_MSEC(100));
|
||||
while (REG_READ(DMA_MODE) & DMA_MODE_SWR) {
|
||||
if (timeout - sys_clock_tick_get() < 0) {
|
||||
if (sys_timepoint_expired(timeout)) {
|
||||
LOG_ERR("unable to reset hardware");
|
||||
return -EIO;
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ static int w5500_writebuf(const struct device *dev, uint16_t offset, uint8_t *bu
|
|||
static int w5500_command(const struct device *dev, uint8_t cmd)
|
||||
{
|
||||
uint8_t reg;
|
||||
uint64_t end = sys_clock_timeout_end_calc(K_MSEC(100));
|
||||
k_timepoint_t end = sys_timepoint_calc(K_MSEC(100));
|
||||
|
||||
w5500_spi_write(dev, W5500_S0_CR, &cmd, 1);
|
||||
while (1) {
|
||||
|
@ -165,8 +165,7 @@ static int w5500_command(const struct device *dev, uint8_t cmd)
|
|||
if (!reg) {
|
||||
break;
|
||||
}
|
||||
int64_t remaining = end - sys_clock_tick_get();
|
||||
if (remaining <= 0) {
|
||||
if (sys_timepoint_expired(end)) {
|
||||
return -EIO;
|
||||
}
|
||||
k_busy_wait(W5500_PHY_ACCESS_DELAY);
|
||||
|
|
|
@ -64,15 +64,15 @@ int sc18im704_transfer(const struct device *dev,
|
|||
}
|
||||
|
||||
if (rx_data != NULL) {
|
||||
uint64_t end;
|
||||
k_timepoint_t end;
|
||||
|
||||
for (uint8_t i = 0; i < rx_len && ret == 0; ++i) {
|
||||
/* Make sure we don't wait forever */
|
||||
end = sys_clock_timeout_end_calc(K_SECONDS(1));
|
||||
end = sys_timepoint_calc(K_SECONDS(1));
|
||||
|
||||
do {
|
||||
ret = uart_poll_in(cfg->bus, &rx_data[i]);
|
||||
} while (ret == -1 && end > k_uptime_ticks());
|
||||
} while (ret == -1 && !sys_timepoint_expired(end));
|
||||
}
|
||||
|
||||
/* -1 indicates we timed out */
|
||||
|
|
|
@ -325,7 +325,7 @@ static bool check_key_events(const struct device *dev)
|
|||
static void kbd_matrix_poll(const struct device *dev)
|
||||
{
|
||||
struct input_npcx_kbd_data *const data = dev->data;
|
||||
uint64_t poll_time_end = sys_clock_timeout_end_calc(K_USEC(data->poll_timeout_us));
|
||||
k_timepoint_t poll_time_end = sys_timepoint_calc(K_USEC(data->poll_timeout_us));
|
||||
uint32_t current_cycles;
|
||||
uint32_t cycles_diff;
|
||||
uint32_t wait_period;
|
||||
|
@ -334,8 +334,8 @@ static void kbd_matrix_poll(const struct device *dev)
|
|||
uint32_t start_period_cycles = k_cycle_get_32();
|
||||
|
||||
if (check_key_events(dev)) {
|
||||
poll_time_end = sys_clock_timeout_end_calc(K_USEC(data->poll_timeout_us));
|
||||
} else if (start_period_cycles > poll_time_end) {
|
||||
poll_time_end = sys_timepoint_calc(K_USEC(data->poll_timeout_us));
|
||||
} else if (sys_timepoint_expired(poll_time_end)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ static int serial_tx_rx(const struct device *dev, const uint8_t *tx_data,
|
|||
uint8_t *rx_data, size_t len, uint32_t timeout)
|
||||
{
|
||||
const struct w1_serial_config *cfg = dev->config;
|
||||
uint64_t end;
|
||||
k_timepoint_t end;
|
||||
uint8_t dummy;
|
||||
int ret = 0;
|
||||
|
||||
|
@ -83,11 +83,11 @@ static int serial_tx_rx(const struct device *dev, const uint8_t *tx_data,
|
|||
}
|
||||
|
||||
uart_poll_out(cfg->uart_dev, tx_data[i]);
|
||||
end = sys_clock_timeout_end_calc(K_USEC(timeout));
|
||||
end = sys_timepoint_calc(K_USEC(timeout));
|
||||
|
||||
do {
|
||||
ret = uart_poll_in(cfg->uart_dev, &rx_data[i]);
|
||||
} while (ret != 0 && end > k_uptime_ticks());
|
||||
} while (ret != 0 && !sys_timepoint_expired(end));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -1369,7 +1369,7 @@ static inline int z_impl_rtio_cqe_copy_out(struct rtio *r,
|
|||
{
|
||||
size_t copied = 0;
|
||||
struct rtio_cqe *cqe;
|
||||
int64_t end = sys_clock_timeout_end_calc(timeout);
|
||||
k_timepoint_t end = sys_timepoint_calc(timeout);
|
||||
|
||||
do {
|
||||
cqe = K_TIMEOUT_EQ(timeout, K_FOREVER) ? rtio_cqe_consume_block(r)
|
||||
|
@ -1385,7 +1385,7 @@ static inline int z_impl_rtio_cqe_copy_out(struct rtio *r,
|
|||
}
|
||||
cqes[copied++] = *cqe;
|
||||
rtio_cqe_release(r, cqe);
|
||||
} while (copied < cqe_count && end > k_uptime_ticks());
|
||||
} while (copied < cqe_count && !sys_timepoint_expired(end));
|
||||
|
||||
return copied;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue