From 96555d383362c30d444593333d60a4588416db62 Mon Sep 17 00:00:00 2001 From: pfg Date: Tue, 26 Apr 2016 15:03:15 +0000 Subject: sys/dev: extend use of the howmany() macro when available. We have a howmany() macro in the header that is convenient to re-use as it makes things easier to read. --- sys/dev/age/if_age.c | 2 +- sys/dev/amr/amr.c | 2 +- sys/dev/bwn/if_bwn.c | 2 +- sys/dev/cy/cy.c | 2 +- sys/dev/fatm/if_fatm.c | 4 ++-- sys/dev/fb/vga.c | 4 ++-- sys/dev/jme/if_jme.c | 2 +- sys/dev/mcd/mcd.c | 2 +- sys/dev/mfi/mfi.c | 8 ++++---- sys/dev/mlx/mlx.c | 2 +- sys/dev/mmc/host/dwmmc.c | 2 +- sys/dev/ncr/ncr.c | 4 ++-- sys/dev/patm/if_patm_tx.c | 4 ++-- sys/dev/ral/rt2560.c | 2 +- sys/dev/ral/rt2661.c | 2 +- sys/dev/sbni/if_sbni.c | 2 +- sys/dev/scd/scd.c | 2 +- sys/dev/sfxge/sfxge_tx.c | 2 +- sys/dev/siba/siba_core.c | 4 ++-- sys/dev/sound/usb/uaudio.c | 8 ++++---- sys/dev/sym/sym_hipd.c | 4 ++-- sys/dev/usb/controller/ehci.c | 3 +-- sys/dev/usb/controller/ohci.c | 2 +- sys/dev/usb/controller/xhci.c | 9 ++++----- sys/dev/usb/usb_transfer.c | 2 +- sys/dev/usb/wlan/if_rum.c | 2 +- sys/dev/usb/wlan/if_ural.c | 2 +- sys/dev/vt/hw/vga/vt_vga.c | 8 +++----- sys/dev/xen/grant_table/grant_table.c | 3 +-- sys/dev/xen/netback/netback.c | 2 +- 30 files changed, 47 insertions(+), 52 deletions(-) diff --git a/sys/dev/age/if_age.c b/sys/dev/age/if_age.c index 8ed176e..ff3b8c6 100644 --- a/sys/dev/age/if_age.c +++ b/sys/dev/age/if_age.c @@ -2486,7 +2486,7 @@ age_rxintr(struct age_softc *sc, int rr_prod, int count) * I'm not sure whether this check is really needed. */ pktlen = AGE_RX_BYTES(le32toh(rxrd->len)); - if (nsegs != (pktlen + (AGE_RX_BUF_SIZE - 1)) / AGE_RX_BUF_SIZE) + if (nsegs != howmany(pktlen, AGE_RX_BUF_SIZE)) break; /* Received a frame. */ diff --git a/sys/dev/amr/amr.c b/sys/dev/amr/amr.c index 0b52d9f8..16cbeec 100644 --- a/sys/dev/amr/amr.c +++ b/sys/dev/amr/amr.c @@ -1316,7 +1316,7 @@ amr_bio_command(struct amr_softc *sc, struct amr_command **acp) } amrd = (struct amrd_softc *)bio->bio_disk->d_drv1; driveno = amrd->amrd_drive - sc->amr_drive; - blkcount = (bio->bio_bcount + AMR_BLKSIZE - 1) / AMR_BLKSIZE; + blkcount = howmany(bio->bio_bcount, AMR_BLKSIZE); ac->ac_mailbox.mb_command = cmd; if (bio->bio_cmd == BIO_READ || bio->bio_cmd == BIO_WRITE) { diff --git a/sys/dev/bwn/if_bwn.c b/sys/dev/bwn/if_bwn.c index a7b0480..644bb2d 100644 --- a/sys/dev/bwn/if_bwn.c +++ b/sys/dev/bwn/if_bwn.c @@ -11166,7 +11166,7 @@ bwn_phy_lp_b2063_switch_channel(struct bwn_mac *mac, uint8_t chan) tmp[2] = ((41 * (val[2] - 3000)) /1200) + 27; tmp[3] = bwn_phy_lp_roundup(132000 * tmp[0], 8451, 16); - if ((tmp[3] + tmp[2] - 1) / tmp[2] > 60) { + if (howmany(tmp[3], tmp[2]) > 60) { scale = 1; tmp[4] = ((tmp[3] + tmp[2]) / (tmp[2] << 1)) - 8; } else { diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c index bfb83df..ad4fa14 100644 --- a/sys/dev/cy/cy.c +++ b/sys/dev/cy/cy.c @@ -1347,7 +1347,7 @@ cyparam(struct tty *tp, struct termios *t) /* * Set receive time-out period, normally to max(one char time, 5 ms). */ - itimeout = (1000 * bits + t->c_ispeed - 1) / t->c_ispeed; + itimeout = howmany(1000 * bits, t->c_ispeed); #ifdef SOFT_HOTCHAR #define MIN_RTP 1 #else diff --git a/sys/dev/fatm/if_fatm.c b/sys/dev/fatm/if_fatm.c index 9a42b93..83f43fd 100644 --- a/sys/dev/fatm/if_fatm.c +++ b/sys/dev/fatm/if_fatm.c @@ -1085,7 +1085,7 @@ fatm_supply_small_buffers(struct fatm_softc *sc) nbufs = min(nbufs, SMALL_POOL_SIZE); nbufs -= sc->small_cnt; - nblocks = (nbufs + SMALL_SUPPLY_BLKSIZE - 1) / SMALL_SUPPLY_BLKSIZE; + nblocks = howmany(nbufs, SMALL_SUPPLY_BLKSIZE); for (cnt = 0; cnt < nblocks; cnt++) { q = GET_QUEUE(sc->s1queue, struct supqueue, sc->s1queue.head); @@ -1174,7 +1174,7 @@ fatm_supply_large_buffers(struct fatm_softc *sc) nbufs = min(nbufs, LARGE_POOL_SIZE); nbufs -= sc->large_cnt; - nblocks = (nbufs + LARGE_SUPPLY_BLKSIZE - 1) / LARGE_SUPPLY_BLKSIZE; + nblocks = howmany(nbufs, LARGE_SUPPLY_BLKSIZE); for (cnt = 0; cnt < nblocks; cnt++) { q = GET_QUEUE(sc->l1queue, struct supqueue, sc->l1queue.head); diff --git a/sys/dev/fb/vga.c b/sys/dev/fb/vga.c index 365fca4..d0239b3 100644 --- a/sys/dev/fb/vga.c +++ b/sys/dev/fb/vga.c @@ -1247,8 +1247,8 @@ set_line_length(video_adapter_t *adp, int pixel) switch (adp->va_info.vi_mem_model) { case V_INFO_MM_PLANAR: ppw = 16/(adp->va_info.vi_depth/adp->va_info.vi_planes); - count = (pixel + ppw - 1)/ppw/2; - bpl = ((pixel + ppw - 1)/ppw/2)*4; + count = howmany(pixel, ppw)/2; + bpl = (howmany(pixel, ppw)/2)*4; break; case V_INFO_MM_PACKED: count = (pixel + 7)/8; diff --git a/sys/dev/jme/if_jme.c b/sys/dev/jme/if_jme.c index f2567cc..6474470 100644 --- a/sys/dev/jme/if_jme.c +++ b/sys/dev/jme/if_jme.c @@ -2664,7 +2664,7 @@ jme_rxintr(struct jme_softc *sc, int count) * sure whether this check is needed. */ pktlen = JME_RX_BYTES(le32toh(desc->buflen)); - if (nsegs != ((pktlen + (MCLBYTES - 1)) / MCLBYTES)) + if (nsegs != howmany(pktlen, MCLBYTES)) break; prog++; /* Received a frame. */ diff --git a/sys/dev/mcd/mcd.c b/sys/dev/mcd/mcd.c index 4d2acd1..dacbb3d 100644 --- a/sys/dev/mcd/mcd.c +++ b/sys/dev/mcd/mcd.c @@ -922,7 +922,7 @@ retry_mode: RDELAY_WAITMODE-mbx->count); modedone: /* for first block */ - mbx->nblk = (bp->bio_bcount + (mbx->sz-1)) / mbx->sz; + mbx->nblk = howmany(bp->bio_bcount, mbx->sz); mbx->skip = 0; nextblock: diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c index c224186..05751ba 100644 --- a/sys/dev/mfi/mfi.c +++ b/sys/dev/mfi/mfi.c @@ -2156,7 +2156,7 @@ mfi_build_syspdio(struct mfi_softc *sc, struct bio *bio) } /* Cheat with the sector length to avoid a non-constant division */ - blkcount = (bio->bio_bcount + MFI_SECTOR_LEN - 1) / MFI_SECTOR_LEN; + blkcount = howmany(bio->bio_bcount, MFI_SECTOR_LEN); /* Fill the LBA and Transfer length in CDB */ cdb_len = mfi_build_cdb(readop, 0, bio->bio_pblkno, blkcount, pass->cdb); @@ -2215,7 +2215,7 @@ mfi_build_ldio(struct mfi_softc *sc, struct bio *bio) } /* Cheat with the sector length to avoid a non-constant division */ - blkcount = (bio->bio_bcount + MFI_SECTOR_LEN - 1) / MFI_SECTOR_LEN; + blkcount = howmany(bio->bio_bcount, MFI_SECTOR_LEN); io->header.target_id = (uintptr_t)bio->bio_driver1; io->header.timeout = 0; io->header.flags = 0; @@ -2622,7 +2622,7 @@ mfi_dump_blocks(struct mfi_softc *sc, int id, uint64_t lba, void *virt, io->header.flags = 0; io->header.scsi_status = 0; io->header.sense_len = MFI_SENSE_LEN; - io->header.data_len = (len + MFI_SECTOR_LEN - 1) / MFI_SECTOR_LEN; + io->header.data_len = howmany(len, MFI_SECTOR_LEN); io->sense_addr_lo = (uint32_t)cm->cm_sense_busaddr; io->sense_addr_hi = (uint32_t)((uint64_t)cm->cm_sense_busaddr >> 32); io->lba_hi = (lba & 0xffffffff00000000) >> 32; @@ -2660,7 +2660,7 @@ mfi_dump_syspd_blocks(struct mfi_softc *sc, int id, uint64_t lba, void *virt, pass->header.cmd = MFI_CMD_PD_SCSI_IO; readop = 0; - blkcount = (len + MFI_SECTOR_LEN - 1) / MFI_SECTOR_LEN; + blkcount = howmany(len, MFI_SECTOR_LEN); cdb_len = mfi_build_cdb(readop, 0, lba, blkcount, pass->cdb); pass->header.target_id = id; pass->header.timeout = 0; diff --git a/sys/dev/mlx/mlx.c b/sys/dev/mlx/mlx.c index 6d9c49b..970053c 100644 --- a/sys/dev/mlx/mlx.c +++ b/sys/dev/mlx/mlx.c @@ -1868,7 +1868,7 @@ mlx_startio_cb(void *arg, bus_dma_segment_t *segs, int nsegments, int error) /* build a suitable I/O command (assumes 512-byte rounded transfers) */ mlxd = bp->bio_disk->d_drv1; driveno = mlxd->mlxd_drive - sc->mlx_sysdrive; - blkcount = (bp->bio_bcount + MLX_BLKSIZE - 1) / MLX_BLKSIZE; + blkcount = howmany(bp->bio_bcount, MLX_BLKSIZE); if ((bp->bio_pblkno + blkcount) > sc->mlx_sysdrive[driveno].ms_size) device_printf(sc->mlx_dev, diff --git a/sys/dev/mmc/host/dwmmc.c b/sys/dev/mmc/host/dwmmc.c index f55d3e6..f96eff6 100644 --- a/sys/dev/mmc/host/dwmmc.c +++ b/sys/dev/mmc/host/dwmmc.c @@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$"); #define WRITE4(_sc, _reg, _val) \ bus_write_4((_sc)->res[0], _reg, _val) -#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) +#define DIV_ROUND_UP(n, d) howmany(n, d) #define DWMMC_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) #define DWMMC_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) diff --git a/sys/dev/ncr/ncr.c b/sys/dev/ncr/ncr.c index 7a1c1d2..8f02ef0 100644 --- a/sys/dev/ncr/ncr.c +++ b/sys/dev/ncr/ncr.c @@ -3468,11 +3468,11 @@ ncr_attach (device_t dev) * Btw, 'period' is in tenths of nanoseconds. */ - period = (4 * div_10M[0] + np->clock_khz - 1) / np->clock_khz; + period = howmany(4 * div_10M[0], np->clock_khz); if (period <= 250) np->minsync = 10; else if (period <= 303) np->minsync = 11; else if (period <= 500) np->minsync = 12; - else np->minsync = (period + 40 - 1) / 40; + else np->minsync = howmany(period, 40); /* * Check against chip SCSI standard support (SCSI-2,ULTRA,ULTRA2). diff --git a/sys/dev/patm/if_patm_tx.c b/sys/dev/patm/if_patm_tx.c index d38d078..1b9a8a5 100644 --- a/sys/dev/patm/if_patm_tx.c +++ b/sys/dev/patm/if_patm_tx.c @@ -119,8 +119,8 @@ cbr2slots(struct patm_softc *sc, struct patm_vcc *vcc) { /* compute the number of slots we need, make sure to get at least * the specified PCR */ - return ((u_int)(((uint64_t)(sc->mmap->tst_size - 1) * - vcc->vcc.tparam.pcr + IFP2IFATM(sc->ifp)->mib.pcr - 1) / IFP2IFATM(sc->ifp)->mib.pcr)); + return ((u_int)howmany((uint64_t)(sc->mmap->tst_size - 1) * + vcc->vcc.tparam.pcr, IFP2IFATM(sc->ifp)->mib.pcr)); } static __inline u_int diff --git a/sys/dev/ral/rt2560.c b/sys/dev/ral/rt2560.c index 1ba2791..5ac753c 100644 --- a/sys/dev/ral/rt2560.c +++ b/sys/dev/ral/rt2560.c @@ -1425,7 +1425,7 @@ rt2560_setup_tx_desc(struct rt2560_softc *sc, struct rt2560_tx_desc *desc, desc->plcp_length_hi = plcp_length >> 6; desc->plcp_length_lo = plcp_length & 0x3f; } else { - plcp_length = (16 * len + rate - 1) / rate; + plcp_length = howmany(16 * len, rate); if (rate == 22) { remainder = (16 * len) % 22; if (remainder != 0 && remainder < 7) diff --git a/sys/dev/ral/rt2661.c b/sys/dev/ral/rt2661.c index a53d509..2e9ceec 100644 --- a/sys/dev/ral/rt2661.c +++ b/sys/dev/ral/rt2661.c @@ -1246,7 +1246,7 @@ rt2661_setup_tx_desc(struct rt2661_softc *sc, struct rt2661_tx_desc *desc, desc->plcp_length_hi = plcp_length >> 6; desc->plcp_length_lo = plcp_length & 0x3f; } else { - plcp_length = (16 * len + rate - 1) / rate; + plcp_length = howmany(16 * len, rate); if (rate == 22) { remainder = (16 * len) % 22; if (remainder != 0 && remainder < 7) diff --git a/sys/dev/sbni/if_sbni.c b/sys/dev/sbni/if_sbni.c index 03200ef..6281e7d 100644 --- a/sys/dev/sbni/if_sbni.c +++ b/sys/dev/sbni/if_sbni.c @@ -738,7 +738,7 @@ prepare_to_send(struct sbni_softc *sc) len = SBNI_MIN_LEN; sc->pktlen = len; - sc->tx_frameno = (len + sc->maxframe - 1) / sc->maxframe; + sc->tx_frameno = howmany(len, sc->maxframe); sc->framelen = min(len, sc->maxframe); sbni_outb(sc, CSR0, sbni_inb(sc, CSR0) | TR_REQ); diff --git a/sys/dev/scd/scd.c b/sys/dev/scd/scd.c index 3959d646..e84a707 100644 --- a/sys/dev/scd/scd.c +++ b/sys/dev/scd/scd.c @@ -751,7 +751,7 @@ trystat: mbx->sz = sc->data.blksize; /* for first block */ - mbx->nblk = (bp->bio_bcount + (mbx->sz-1)) / mbx->sz; + mbx->nblk = howmany(bp->bio_bcount, mbx->sz); mbx->skip = 0; nextblock: diff --git a/sys/dev/sfxge/sfxge_tx.c b/sys/dev/sfxge/sfxge_tx.c index e729360..6e93b12 100644 --- a/sys/dev/sfxge/sfxge_tx.c +++ b/sys/dev/sfxge/sfxge_tx.c @@ -906,7 +906,7 @@ static const struct tcphdr *tso_tcph(const struct sfxge_tso_state *tso) #define TSOH_COUNT(_txq_entries) ((_txq_entries) / 2u) #define TSOH_PER_PAGE (PAGE_SIZE / TSOH_STD_SIZE) #define TSOH_PAGE_COUNT(_txq_entries) \ - ((TSOH_COUNT(_txq_entries) + TSOH_PER_PAGE - 1) / TSOH_PER_PAGE) + howmany(TSOH_COUNT(_txq_entries), TSOH_PER_PAGE) static int tso_init(struct sfxge_txq *txq) { diff --git a/sys/dev/siba/siba_core.c b/sys/dev/siba/siba_core.c index 6d32531..92c54d2 100644 --- a/sys/dev/siba/siba_core.c +++ b/sys/dev/siba/siba_core.c @@ -1058,8 +1058,8 @@ siba_cc_powerup_delay(struct siba_cc *scc) min = siba_cc_clockfreq(scc, 0); scc->scc_powerup_delay = - (((SIBA_CC_READ32(scc, SIBA_CC_PLLONDELAY) + 2) * 1000000) + - (min - 1)) / min; + howmany((SIBA_CC_READ32(scc, SIBA_CC_PLLONDELAY) + 2) * 1000000, + min); } static int diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c index c3baf7f..6329f81 100644 --- a/sys/dev/sound/usb/uaudio.c +++ b/sys/dev/sound/usb/uaudio.c @@ -1173,8 +1173,8 @@ uaudio_get_buffer_size(struct uaudio_chan *ch, uint8_t alt) { struct uaudio_chan_alt *chan_alt = &ch->usb_alt[alt]; /* We use 2 times 8ms of buffer */ - uint32_t buf_size = (((chan_alt->sample_rate * (UAUDIO_NFRAMES / 8)) + - 1000 - 1) / 1000) * chan_alt->sample_size; + uint32_t buf_size = chan_alt->sample_size * + howmany(chan_alt->sample_rate * (UAUDIO_NFRAMES / 8), 1000); return (buf_size); } @@ -1292,8 +1292,8 @@ uaudio_configure_msg_sub(struct uaudio_softc *sc, /* bytes per frame should not be zero */ chan->bytes_per_frame[0] = ((chan_alt->sample_rate / fps) * chan_alt->sample_size); - chan->bytes_per_frame[1] = - (((chan_alt->sample_rate + fps - 1) / fps) * chan_alt->sample_size); + chan->bytes_per_frame[1] = howmany(chan_alt->sample_rate, fps) * + chan_alt->sample_size; /* setup data rate dithering, if any */ chan->frames_per_second = fps; diff --git a/sys/dev/sym/sym_hipd.c b/sys/dev/sym/sym_hipd.c index 0d0afdf..53c66bb 100644 --- a/sys/dev/sym/sym_hipd.c +++ b/sys/dev/sym/sym_hipd.c @@ -2526,11 +2526,11 @@ static int sym_prepare_setting(hcb_p np, struct sym_nvram *nvram) * Minimum synchronous period factor supported by the chip. * Btw, 'period' is in tenths of nanoseconds. */ - period = (4 * div_10M[0] + np->clock_khz - 1) / np->clock_khz; + period = howmany(4 * div_10M[0], np->clock_khz); if (period <= 250) np->minsync = 10; else if (period <= 303) np->minsync = 11; else if (period <= 500) np->minsync = 12; - else np->minsync = (period + 40 - 1) / 40; + else np->minsync = howmany(period, 40); /* * Check against chip SCSI standard support (SCSI-2,ULTRA,ULTRA2). diff --git a/sys/dev/usb/controller/ehci.c b/sys/dev/usb/controller/ehci.c index eb4ccb9..7f9547c 100644 --- a/sys/dev/usb/controller/ehci.c +++ b/sys/dev/usb/controller/ehci.c @@ -1659,8 +1659,7 @@ restart: /* update data toggle */ - if (((average + temp->max_frame_size - 1) / - temp->max_frame_size) & 1) { + if (howmany(average, temp->max_frame_size) & 1) { temp->qtd_status ^= htohc32(temp->sc, EHCI_QTD_TOGGLE_MASK); } diff --git a/sys/dev/usb/controller/ohci.c b/sys/dev/usb/controller/ohci.c index 206c753..93785c0 100644 --- a/sys/dev/usb/controller/ohci.c +++ b/sys/dev/usb/controller/ohci.c @@ -2437,7 +2437,7 @@ ohci_xfer_setup(struct usb_setup_params *parm) usbd_transfer_setup_sub(parm); nitd = ((xfer->max_data_length / OHCI_PAGE_SIZE) + - ((xfer->nframes + OHCI_ITD_NOFFSET - 1) / OHCI_ITD_NOFFSET) + + howmany(xfer->nframes, OHCI_ITD_NOFFSET) + 1 /* EXTRA */ ); ntd = 0; nqh = 1; diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 0739e28..6c58e6d 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -1830,8 +1830,8 @@ restart: } /* set up npkt */ - npkt = (len_old - npkt_off + temp->max_packet_size - 1) / - temp->max_packet_size; + npkt = howmany(len_old - npkt_off, + temp->max_packet_size); if (npkt == 0) npkt = 1; @@ -2185,10 +2185,9 @@ xhci_setup_generic_chain(struct usb_xfer *xfer) temp.len = xfer->max_frame_size; /* compute TD packet count */ - tdpc = (temp.len + xfer->max_packet_size - 1) / - xfer->max_packet_size; + tdpc = howmany(temp.len, xfer->max_packet_size); - temp.tbc = ((tdpc + mult - 1) / mult) - 1; + temp.tbc = howmany(tdpc, mult) - 1; temp.tlbpc = (tdpc % mult); if (temp.tlbpc == 0) diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c index 17b9367..e3f388d8 100644 --- a/sys/dev/usb/usb_transfer.c +++ b/sys/dev/usb/usb_transfer.c @@ -246,7 +246,7 @@ usbd_transfer_setup_sub_malloc(struct usb_setup_params *parm, * Compute number of DMA chunks, rounded up * to nearest one: */ - n_dma_pc = ((count + n_obj - 1) / n_obj); + n_dma_pc = howmany(count, n_obj); n_dma_pg = 1; } diff --git a/sys/dev/usb/wlan/if_rum.c b/sys/dev/usb/wlan/if_rum.c index 08be717..323de8d 100644 --- a/sys/dev/usb/wlan/if_rum.c +++ b/sys/dev/usb/wlan/if_rum.c @@ -1336,7 +1336,7 @@ rum_setup_tx_desc(struct rum_softc *sc, struct rum_tx_desc *desc, } else { if (rate == 0) rate = 2; /* avoid division by zero */ - plcp_length = (16 * len + rate - 1) / rate; + plcp_length = howmany(16 * len, rate); if (rate == 22) { remainder = (16 * len) % 22; if (remainder != 0 && remainder < 7) diff --git a/sys/dev/usb/wlan/if_ural.c b/sys/dev/usb/wlan/if_ural.c index 53cfbbd..259c158 100644 --- a/sys/dev/usb/wlan/if_ural.c +++ b/sys/dev/usb/wlan/if_ural.c @@ -1002,7 +1002,7 @@ ural_setup_tx_desc(struct ural_softc *sc, struct ural_tx_desc *desc, } else { if (rate == 0) rate = 2; /* avoid division by zero */ - plcp_length = (16 * len + rate - 1) / rate; + plcp_length = howmany(16 * len, rate); if (rate == 22) { remainder = (16 * len) % 22; if (remainder != 0 && remainder < 7) diff --git a/sys/dev/vt/hw/vga/vt_vga.c b/sys/dev/vt/hw/vga/vt_vga.c index 62c9bf3..e81dcba 100644 --- a/sys/dev/vt/hw/vga/vt_vga.c +++ b/sys/dev/vt/hw/vga/vt_vga.c @@ -815,9 +815,8 @@ vga_bitblt_text_gfxmode(struct vt_device *vd, const struct vt_window *vw, col = area->tr_end.tp_col; row = area->tr_end.tp_row; - x2 = (int)((col * vf->vf_width + vw->vw_draw_area.tr_begin.tp_col - + VT_VGA_PIXELS_BLOCK - 1) - / VT_VGA_PIXELS_BLOCK) + x2 = (int)howmany(col * vf->vf_width + vw->vw_draw_area.tr_begin.tp_col, + VT_VGA_PIXELS_BLOCK) * VT_VGA_PIXELS_BLOCK; y2 = row * vf->vf_height + vw->vw_draw_area.tr_begin.tp_row; @@ -916,8 +915,7 @@ vga_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw, x1 = x / VT_VGA_PIXELS_BLOCK * VT_VGA_PIXELS_BLOCK; y1 = y; - x2 = (x + width + VT_VGA_PIXELS_BLOCK - 1) / - VT_VGA_PIXELS_BLOCK * VT_VGA_PIXELS_BLOCK; + x2 = roundup(x + width, VT_VGA_PIXELS_BLOCK); y2 = y + height; x2 = min(x2, vd->vd_width - 1); y2 = min(y2, vd->vd_height - 1); diff --git a/sys/dev/xen/grant_table/grant_table.c b/sys/dev/xen/grant_table/grant_table.c index 87e5676..2a5c427 100644 --- a/sys/dev/xen/grant_table/grant_table.c +++ b/sys/dev/xen/grant_table/grant_table.c @@ -573,8 +573,7 @@ gnttab_expand(unsigned int req_entries) unsigned int cur, extra; cur = nr_grant_frames; - extra = ((req_entries + (GREFS_PER_GRANT_FRAME-1)) / - GREFS_PER_GRANT_FRAME); + extra = howmany(req_entries, GREFS_PER_GRANT_FRAME); if (cur + extra > max_nr_grant_frames()) return (ENOSPC); diff --git a/sys/dev/xen/netback/netback.c b/sys/dev/xen/netback/netback.c index fb5d73c..4b4fdb9 100644 --- a/sys/dev/xen/netback/netback.c +++ b/sys/dev/xen/netback/netback.c @@ -1931,7 +1931,7 @@ xnb_mbufc2pkt(const struct mbuf *mbufc, struct xnb_pkt *pkt, * into responses so that each response but the last uses all * PAGE_SIZE bytes. */ - pkt->list_len = (pkt->size + PAGE_SIZE - 1) / PAGE_SIZE; + pkt->list_len = howmany(pkt->size, PAGE_SIZE); if (pkt->list_len > 1) { pkt->flags |= NETRXF_more_data; -- cgit v1.1