mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-04 08:09:08 +00:00
sys: Make use of our rounddown() macro when sys/param.h is available.
No functional change.
This commit is contained in:
parent
7154bf4a41
commit
4ed3c0e713
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298848
@ -506,7 +506,7 @@ at91_pmc_sense_main_clock(void)
|
||||
* AT91C_MAIN_CLOCK in the kernel config file.
|
||||
*/
|
||||
if (ckgr_val >= 21000000)
|
||||
return ((ckgr_val + 250) / 500 * 500);
|
||||
return (rounddown(ckgr_val + 250, 500));
|
||||
|
||||
/*
|
||||
* Try to find the standard frequency that match best.
|
||||
|
@ -71,8 +71,7 @@ struct dbputchar_arg {
|
||||
static int db_output_position = 0; /* output column */
|
||||
static int db_last_non_space = 0; /* last non-space character */
|
||||
db_expr_t db_tab_stop_width = 8; /* how wide are tab stops? */
|
||||
#define NEXT_TAB(i) \
|
||||
((((i) + db_tab_stop_width) / db_tab_stop_width) * db_tab_stop_width)
|
||||
#define NEXT_TAB(i) rounddown((i) + db_tab_stop_width, db_tab_stop_width)
|
||||
db_expr_t db_max_width = 79; /* output line width */
|
||||
db_expr_t db_lines_per_page = 20; /* lines per page */
|
||||
volatile int db_pager_quit; /* user requested quit */
|
||||
|
@ -1033,7 +1033,8 @@ acpi_hp_hex_decode(char* buffer)
|
||||
UINT8 *uin;
|
||||
UINT8 uout;
|
||||
|
||||
if (((int)length/2)*2 == length || length < 10) return;
|
||||
if (rounddown((int)length, 2) == length || length < 10)
|
||||
return;
|
||||
|
||||
for (i = 0; i<length; ++i) {
|
||||
if (!((i+1)%3)) {
|
||||
|
@ -1119,7 +1119,7 @@ ncxgbe_attach(device_t dev)
|
||||
* freelist, and not the number of entries in the iq. (These two are
|
||||
* not exactly the same due to the space taken up by the status page).
|
||||
*/
|
||||
na.num_rx_desc = (vi->qsize_rxq / 8) * 8;
|
||||
na.num_rx_desc = rounddown(vi->qsize_rxq, 8);
|
||||
na.nm_txsync = cxgbe_netmap_txsync;
|
||||
na.nm_rxsync = cxgbe_netmap_rxsync;
|
||||
na.nm_register = cxgbe_netmap_reg;
|
||||
|
@ -86,7 +86,7 @@ vid_realloc_array(void)
|
||||
return ENOMEM;
|
||||
|
||||
s = spltty();
|
||||
newsize = ((adapters + ARRAY_DELTA)/ARRAY_DELTA)*ARRAY_DELTA;
|
||||
newsize = rounddown(adapters + ARRAY_DELTA, ARRAY_DELTA);
|
||||
new_adp = malloc(sizeof(*new_adp)*newsize, M_DEVBUF, M_WAITOK | M_ZERO);
|
||||
new_vidsw = malloc(sizeof(*new_vidsw)*newsize, M_DEVBUF,
|
||||
M_WAITOK | M_ZERO);
|
||||
|
@ -1581,7 +1581,7 @@ vesa_set_origin(video_adapter_t *adp, off_t offset)
|
||||
regs.R_DX = offset / adp->va_window_gran;
|
||||
x86bios_intr(®s, 0x10);
|
||||
|
||||
adp->va_window_orig = (offset/adp->va_window_gran)*adp->va_window_gran;
|
||||
adp->va_window_orig = rounddown(offset, adp->va_window_gran);
|
||||
return (0); /* XXX */
|
||||
}
|
||||
|
||||
|
@ -1252,7 +1252,7 @@ set_line_length(video_adapter_t *adp, int pixel)
|
||||
break;
|
||||
case V_INFO_MM_PACKED:
|
||||
count = (pixel + 7)/8;
|
||||
bpl = ((pixel + 7)/8)*8;
|
||||
bpl = rounddown(pixel + 7, 8);
|
||||
break;
|
||||
case V_INFO_MM_TEXT:
|
||||
count = (pixel + 7)/8; /* columns */
|
||||
|
@ -6335,7 +6335,7 @@ iwn_set_pslevel(struct iwn_softc *sc, int dtim, int level, int async)
|
||||
if (max == (uint32_t)-1)
|
||||
max = dtim * (skip_dtim + 1);
|
||||
else if (max > dtim)
|
||||
max = (max / dtim) * dtim;
|
||||
max = rounddown(max, dtim);
|
||||
} else
|
||||
max = dtim;
|
||||
for (i = 0; i < 5; i++)
|
||||
|
@ -96,7 +96,7 @@ kbd_realloc_array(void)
|
||||
int s;
|
||||
|
||||
s = spltty();
|
||||
newsize = ((keyboards + ARRAY_DELTA)/ARRAY_DELTA)*ARRAY_DELTA;
|
||||
newsize = rounddown(keyboards + ARRAY_DELTA, ARRAY_DELTA);
|
||||
new_kbd = malloc(sizeof(*new_kbd)*newsize, M_DEVBUF, M_NOWAIT|M_ZERO);
|
||||
if (new_kbd == NULL) {
|
||||
splx(s);
|
||||
|
@ -495,7 +495,7 @@ mouse_cut_start(scr_stat *scp)
|
||||
i = skip_spc_left(scp, scp->mouse_pos) + 1;
|
||||
s = spltty();
|
||||
scp->mouse_cut_start =
|
||||
(scp->mouse_pos / scp->xsize) * scp->xsize + i;
|
||||
rounddown(scp->mouse_pos, scp->xsize) + i;
|
||||
scp->mouse_cut_end =
|
||||
(scp->mouse_pos / scp->xsize + 1) * scp->xsize - 1;
|
||||
splx(s);
|
||||
@ -540,7 +540,7 @@ mouse_cut_word(scr_stat *scp)
|
||||
* unless user specified SC_CUT_SEPCHARS in his kernel config file.
|
||||
*/
|
||||
if (scp->status & MOUSE_VISIBLE) {
|
||||
sol = (scp->mouse_pos / scp->xsize) * scp->xsize;
|
||||
sol = rounddown(scp->mouse_pos, scp->xsize);
|
||||
eol = sol + scp->xsize;
|
||||
c = sc_vtb_getc(&scp->vtb, scp->mouse_pos);
|
||||
if (IS_SEP_CHAR(c)) {
|
||||
@ -589,7 +589,7 @@ mouse_cut_line(scr_stat *scp)
|
||||
int from;
|
||||
|
||||
if (scp->status & MOUSE_VISIBLE) {
|
||||
from = (scp->mouse_pos / scp->xsize) * scp->xsize;
|
||||
from = rounddown(scp->mouse_pos, scp->xsize);
|
||||
mouse_do_cut(scp, from, from + scp->xsize - 1);
|
||||
len = strlen(cut_buffer);
|
||||
if (cut_buffer[len - 1] == '\r')
|
||||
|
@ -1035,7 +1035,7 @@ draw_pxlmouse_planar(scr_stat *scp, int x, int y)
|
||||
|
||||
line_width = scp->sc->adp->va_line_width;
|
||||
xoff = (x - scp->xoff*8)%8;
|
||||
yoff = y - (y/line_width)*line_width;
|
||||
yoff = y - rounddown(y, line_width);
|
||||
ymax = imin(y + 16, scp->ypixel);
|
||||
|
||||
outw(GDCIDX, 0x0805); /* read mode 1, write mode 0 */
|
||||
|
@ -912,7 +912,7 @@ vga_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw,
|
||||
uint8_t pattern_2colors;
|
||||
|
||||
/* Align coordinates with the 8-pxels grid. */
|
||||
x1 = x / VT_VGA_PIXELS_BLOCK * VT_VGA_PIXELS_BLOCK;
|
||||
x1 = rounddown(x, VT_VGA_PIXELS_BLOCK);
|
||||
y1 = y;
|
||||
|
||||
x2 = roundup(x + width, VT_VGA_PIXELS_BLOCK);
|
||||
|
@ -640,9 +640,9 @@ vt_compute_drawable_area(struct vt_window *vw)
|
||||
if (vt_draw_logo_cpus)
|
||||
vw->vw_draw_area.tr_begin.tp_row += vt_logo_sprite_height;
|
||||
vw->vw_draw_area.tr_end.tp_col = vw->vw_draw_area.tr_begin.tp_col +
|
||||
vd->vd_width / vf->vf_width * vf->vf_width;
|
||||
rounddown(vd->vd_width, vf->vf_width);
|
||||
vw->vw_draw_area.tr_end.tp_row = vw->vw_draw_area.tr_begin.tp_row +
|
||||
height / vf->vf_height * vf->vf_height;
|
||||
rounddown(height, vf->vf_height);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -3814,7 +3814,7 @@ wpi_set_pslevel(struct wpi_softc *sc, uint8_t dtim, int level, int async)
|
||||
if (max == (uint32_t)-1)
|
||||
max = dtim * (skip_dtim + 1);
|
||||
else if (max > dtim)
|
||||
max = (max / dtim) * dtim;
|
||||
max = rounddown(max, dtim);
|
||||
} else
|
||||
max = dtim;
|
||||
|
||||
|
@ -331,8 +331,8 @@ nandfs_write_superblock_at(struct nandfs_device *fsdev,
|
||||
super->s_last_pseg, super->s_last_cno, super->s_last_seq,
|
||||
super->s_wtime, index));
|
||||
|
||||
read_block = btodb(offset + ((index / sb_per_sector) * sb_per_sector)
|
||||
* sizeof(struct nandfs_super_block));
|
||||
read_block = btodb(offset + rounddown(index, sb_per_sector) *
|
||||
sizeof(struct nandfs_super_block));
|
||||
|
||||
DPRINTF(SYNC, ("%s: read_block %#x\n", __func__, read_block));
|
||||
|
||||
|
@ -1257,7 +1257,7 @@ virstor_check_and_run(struct g_virstor_softc *sc)
|
||||
bs = MIN(MAXPHYS, sc->map_size - count);
|
||||
if (bs % sc->sectorsize != 0) {
|
||||
/* Check for alignment errors */
|
||||
bs = (bs / sc->sectorsize) * sc->sectorsize;
|
||||
bs = rounddown(bs, sc->sectorsize);
|
||||
if (bs == 0)
|
||||
break;
|
||||
LOG_MSG(LVL_ERROR, "Trouble: map is not sector-aligned "
|
||||
@ -1723,13 +1723,12 @@ g_virstor_start(struct bio *b)
|
||||
* sc_offset will end up pointing to the drive
|
||||
* sector. */
|
||||
s_offset = chunk_index * sizeof *me;
|
||||
s_offset = (s_offset / sc->sectorsize) *
|
||||
sc->sectorsize;
|
||||
s_offset = rounddown(s_offset, sc->sectorsize);
|
||||
|
||||
/* data_me points to map entry sector
|
||||
* in memory (analoguos to offset) */
|
||||
data_me = &sc->map[(chunk_index /
|
||||
sc->me_per_sector) * sc->me_per_sector];
|
||||
* in memory (analogous to offset) */
|
||||
data_me = &sc->map[rounddown(chunk_index,
|
||||
sc->me_per_sector)];
|
||||
|
||||
/* Commit sector with map entry to storage */
|
||||
cb->bio_to = sc->components[0].gcons->provider;
|
||||
|
@ -684,7 +684,7 @@ crc32c_sb8_64_bit(uint32_t crc,
|
||||
uint32_t running_length;
|
||||
uint32_t end_bytes;
|
||||
|
||||
running_length = ((length - init_bytes) / 8) * 8;
|
||||
running_length = rounddown(length - init_bytes, 8);
|
||||
end_bytes = length - init_bytes - running_length;
|
||||
|
||||
for (li = 0; li < init_bytes; li++)
|
||||
|
@ -437,7 +437,7 @@ ar934x_chip_gpio_output_configure(int gpio, uint8_t func)
|
||||
if (gpio > AR934X_GPIO_COUNT)
|
||||
return;
|
||||
|
||||
reg = AR934X_GPIO_REG_OUT_FUNC0 + 4 * (gpio / 4);
|
||||
reg = AR934X_GPIO_REG_OUT_FUNC0 + rounddown(gpio, 4);
|
||||
s = 8 * (gpio % 4);
|
||||
|
||||
/* read-modify-write */
|
||||
|
@ -360,7 +360,7 @@ qca953x_chip_gpio_output_configure(int gpio, uint8_t func)
|
||||
if (gpio > QCA953X_GPIO_COUNT)
|
||||
return;
|
||||
|
||||
reg = QCA953X_GPIO_REG_OUT_FUNC0 + 4 * (gpio / 4);
|
||||
reg = QCA953X_GPIO_REG_OUT_FUNC0 + rounddown(gpio, 4);
|
||||
s = 8 * (gpio % 4);
|
||||
|
||||
/* read-modify-write */
|
||||
|
@ -369,7 +369,7 @@ qca955x_chip_gpio_output_configure(int gpio, uint8_t func)
|
||||
if (gpio > QCA955X_GPIO_COUNT)
|
||||
return;
|
||||
|
||||
reg = QCA955X_GPIO_REG_OUT_FUNC0 + 4 * (gpio / 4);
|
||||
reg = QCA955X_GPIO_REG_OUT_FUNC0 + rounddown(gpio, 4);
|
||||
s = 8 * (gpio % 4);
|
||||
|
||||
/* read-modify-write */
|
||||
|
@ -219,8 +219,8 @@ clnt_dg_create(
|
||||
/*
|
||||
* Should be multiple of 4 for XDR.
|
||||
*/
|
||||
sendsz = ((sendsz + 3) / 4) * 4;
|
||||
recvsz = ((recvsz + 3) / 4) * 4;
|
||||
sendsz = rounddown(sendsz + 3, 4);
|
||||
recvsz = rounddown(recvsz + 3, 4);
|
||||
cu = mem_alloc(sizeof (*cu));
|
||||
cu->cu_threads = 0;
|
||||
cu->cu_closing = FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user