sys: util: migrate all files to DIV_ROUND_UP
ceiling_fraction is deprecated, use DIV_ROUND_UP. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
53da110dbf
commit
0ebe14beb4
54 changed files with 99 additions and 99 deletions
|
@ -270,7 +270,7 @@ static void block_set(struct bt_mesh_blob_cli *cli, uint16_t block_idx)
|
|||
cli->block.size = blob_block_size(cli->xfer->size, cli->xfer->block_size_log,
|
||||
block_idx);
|
||||
cli->block.chunk_count =
|
||||
ceiling_fraction(cli->block.size, cli->xfer->chunk_size);
|
||||
DIV_ROUND_UP(cli->block.size, cli->xfer->chunk_size);
|
||||
|
||||
if (cli->xfer->mode == BT_MESH_BLOB_XFER_MODE_PUSH) {
|
||||
blob_chunk_missing_set_all(&cli->block);
|
||||
|
@ -1352,7 +1352,7 @@ static int handle_block_status(struct bt_mesh_model *mod, struct bt_mesh_msg_ctx
|
|||
status.block.number = net_buf_simple_pull_le16(buf);
|
||||
chunk_size = net_buf_simple_pull_le16(buf);
|
||||
status.block.chunk_count =
|
||||
ceiling_fraction(cli->block.size, chunk_size);
|
||||
DIV_ROUND_UP(cli->block.size, chunk_size);
|
||||
|
||||
LOG_DBG("status: %u block: %u encoding: %u", status.status,
|
||||
status.block.number, status.missing);
|
||||
|
@ -1531,7 +1531,7 @@ int bt_mesh_blob_cli_send(struct bt_mesh_blob_cli *cli,
|
|||
cli->xfer = xfer;
|
||||
cli->inputs = inputs;
|
||||
cli->io = io;
|
||||
cli->block_count = ceiling_fraction(cli->xfer->size,
|
||||
cli->block_count = DIV_ROUND_UP(cli->xfer->size,
|
||||
(1U << cli->xfer->block_size_log));
|
||||
|
||||
block_set(cli, 0);
|
||||
|
|
|
@ -83,7 +83,7 @@ static int block_start(const struct bt_mesh_blob_io *io,
|
|||
return err;
|
||||
}
|
||||
|
||||
erase_size = page.size * ceiling_fraction(block->size, page.size);
|
||||
erase_size = page.size * DIV_ROUND_UP(block->size, page.size);
|
||||
#else
|
||||
erase_size = block->size;
|
||||
#endif
|
||||
|
|
|
@ -47,7 +47,7 @@ static void suspend(struct bt_mesh_blob_srv *srv);
|
|||
|
||||
static inline uint32_t block_count_get(const struct bt_mesh_blob_srv *srv)
|
||||
{
|
||||
return ceiling_fraction(srv->state.xfer.size,
|
||||
return DIV_ROUND_UP(srv->state.xfer.size,
|
||||
(1U << srv->state.xfer.block_size_log));
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ static void store_state(const struct bt_mesh_blob_srv *srv)
|
|||
}
|
||||
|
||||
/* Convert bit count to byte count: */
|
||||
uint32_t block_len = ceiling_fraction(block_count_get(srv), 8);
|
||||
uint32_t block_len = DIV_ROUND_UP(block_count_get(srv), 8);
|
||||
|
||||
bt_mesh_model_data_store(
|
||||
srv->mod, false, NULL, &srv->state,
|
||||
|
@ -149,7 +149,7 @@ static int pull_req_max(const struct bt_mesh_blob_srv *srv)
|
|||
#if defined(CONFIG_BT_MESH_LOW_POWER)
|
||||
/* No point in requesting more than the friend node can hold: */
|
||||
if (bt_mesh_lpn_established()) {
|
||||
uint32_t segments_per_chunk = ceiling_fraction(
|
||||
uint32_t segments_per_chunk = DIV_ROUND_UP(
|
||||
BLOB_CHUNK_SDU_LEN(srv->state.xfer.chunk_size),
|
||||
BT_MESH_APP_SEG_SDU_MAX);
|
||||
|
||||
|
@ -310,7 +310,7 @@ static void xfer_status_rsp(struct bt_mesh_blob_srv *srv,
|
|||
net_buf_simple_add_u8(&buf, srv->state.xfer.block_size_log);
|
||||
net_buf_simple_add_le16(&buf, srv->state.mtu_size);
|
||||
net_buf_simple_add_mem(&buf, srv->state.blocks,
|
||||
ceiling_fraction(block_count_get(srv), 8));
|
||||
DIV_ROUND_UP(block_count_get(srv), 8));
|
||||
|
||||
send:
|
||||
ctx->send_ttl = srv->state.ttl;
|
||||
|
@ -356,12 +356,12 @@ static void block_status_rsp(struct bt_mesh_blob_srv *srv,
|
|||
|
||||
if (format == BT_MESH_BLOB_CHUNKS_MISSING_SOME) {
|
||||
net_buf_simple_add_mem(&buf, srv->block.missing,
|
||||
ceiling_fraction(srv->block.chunk_count,
|
||||
DIV_ROUND_UP(srv->block.chunk_count,
|
||||
8));
|
||||
|
||||
LOG_DBG("Bits: %s",
|
||||
bt_hex(srv->block.missing,
|
||||
ceiling_fraction(srv->block.chunk_count, 8)));
|
||||
DIV_ROUND_UP(srv->block.chunk_count, 8)));
|
||||
|
||||
} else if (format == BT_MESH_BLOB_CHUNKS_MISSING_ENCODED) {
|
||||
int count = pull_req_max(srv);
|
||||
|
@ -619,11 +619,11 @@ static int handle_block_start(struct bt_mesh_model *mod, struct bt_mesh_msg_ctx
|
|||
}
|
||||
|
||||
if (!chunk_size || chunk_size > max_chunk_size(srv) ||
|
||||
(ceiling_fraction((1 << srv->state.xfer.block_size_log), chunk_size) >
|
||||
(DIV_ROUND_UP((1 << srv->state.xfer.block_size_log), chunk_size) >
|
||||
max_chunk_count(srv))) {
|
||||
LOG_WRN("Invalid chunk size: (chunk size: %u, max: %u, ceil: %u, count: %u)",
|
||||
chunk_size, max_chunk_size(srv),
|
||||
ceiling_fraction((1 << srv->state.xfer.block_size_log), chunk_size),
|
||||
DIV_ROUND_UP((1 << srv->state.xfer.block_size_log), chunk_size),
|
||||
max_chunk_count(srv));
|
||||
status = BT_MESH_BLOB_ERR_INVALID_CHUNK_SIZE;
|
||||
goto rsp;
|
||||
|
@ -632,7 +632,7 @@ static int handle_block_start(struct bt_mesh_model *mod, struct bt_mesh_msg_ctx
|
|||
srv->block.size = blob_block_size(
|
||||
srv->state.xfer.size, srv->state.xfer.block_size_log, block_number);
|
||||
srv->block.number = block_number;
|
||||
srv->block.chunk_count = ceiling_fraction(srv->block.size, chunk_size);
|
||||
srv->block.chunk_count = DIV_ROUND_UP(srv->block.size, chunk_size);
|
||||
srv->state.xfer.chunk_size = chunk_size;
|
||||
srv->block.offset = block_number * (1UL << srv->state.xfer.block_size_log);
|
||||
|
||||
|
|
|
@ -134,9 +134,9 @@ static uint8_t get_progress(const struct bt_mesh_blob_xfer_info *info)
|
|||
uint8_t blocks_not_rxed_size;
|
||||
int i;
|
||||
|
||||
total_blocks = ceiling_fraction(info->size, 1U << info->block_size_log);
|
||||
total_blocks = DIV_ROUND_UP(info->size, 1U << info->block_size_log);
|
||||
|
||||
blocks_not_rxed_size = ceiling_fraction(total_blocks, 8);
|
||||
blocks_not_rxed_size = DIV_ROUND_UP(total_blocks, 8);
|
||||
|
||||
for (i = 0; i < blocks_not_rxed_size; i++) {
|
||||
blocks_not_rxed += info->missing_blocks[i % 8] & (1 << (i % 8));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue