Date: Tue, 26 Apr 2016 15:03:15 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298646 - in head/sys/dev: age amr bwn cy fatm fb jme mcd mfi mlx mmc/host ncr patm ral sbni scd sfxge siba sound/usb sym usb usb/controller usb/wlan vt/hw/vga xen/grant_table xen/netback Message-ID: <201604261503.u3QF3FNp037438@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Tue Apr 26 15:03:15 2016 New Revision: 298646 URL: https://svnweb.freebsd.org/changeset/base/298646 Log: sys/dev: extend use of the howmany() macro when available. We have a howmany() macro in the <sys/param.h> header that is convenient to re-use as it makes things easier to read. Modified: head/sys/dev/age/if_age.c head/sys/dev/amr/amr.c head/sys/dev/bwn/if_bwn.c head/sys/dev/cy/cy.c head/sys/dev/fatm/if_fatm.c head/sys/dev/fb/vga.c head/sys/dev/jme/if_jme.c head/sys/dev/mcd/mcd.c head/sys/dev/mfi/mfi.c head/sys/dev/mlx/mlx.c head/sys/dev/mmc/host/dwmmc.c head/sys/dev/ncr/ncr.c head/sys/dev/patm/if_patm_tx.c head/sys/dev/ral/rt2560.c head/sys/dev/ral/rt2661.c head/sys/dev/sbni/if_sbni.c head/sys/dev/scd/scd.c head/sys/dev/sfxge/sfxge_tx.c head/sys/dev/siba/siba_core.c head/sys/dev/sound/usb/uaudio.c head/sys/dev/sym/sym_hipd.c head/sys/dev/usb/controller/ehci.c head/sys/dev/usb/controller/ohci.c head/sys/dev/usb/controller/xhci.c head/sys/dev/usb/usb_transfer.c head/sys/dev/usb/wlan/if_rum.c head/sys/dev/usb/wlan/if_ural.c head/sys/dev/vt/hw/vga/vt_vga.c head/sys/dev/xen/grant_table/grant_table.c head/sys/dev/xen/netback/netback.c Modified: head/sys/dev/age/if_age.c ============================================================================== --- head/sys/dev/age/if_age.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/age/if_age.c Tue Apr 26 15:03:15 2016 (r298646) @@ -2486,7 +2486,7 @@ age_rxintr(struct age_softc *sc, int rr_ * 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. */ Modified: head/sys/dev/amr/amr.c ============================================================================== --- head/sys/dev/amr/amr.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/amr/amr.c Tue Apr 26 15:03:15 2016 (r298646) @@ -1316,7 +1316,7 @@ amr_bio_command(struct amr_softc *sc, st } 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) { Modified: head/sys/dev/bwn/if_bwn.c ============================================================================== --- head/sys/dev/bwn/if_bwn.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/bwn/if_bwn.c Tue Apr 26 15:03:15 2016 (r298646) @@ -11166,7 +11166,7 @@ bwn_phy_lp_b2063_switch_channel(struct b 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 { Modified: head/sys/dev/cy/cy.c ============================================================================== --- head/sys/dev/cy/cy.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/cy/cy.c Tue Apr 26 15:03:15 2016 (r298646) @@ -1347,7 +1347,7 @@ cyparam(struct tty *tp, struct termios * /* * 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 Modified: head/sys/dev/fatm/if_fatm.c ============================================================================== --- head/sys/dev/fatm/if_fatm.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/fatm/if_fatm.c Tue Apr 26 15:03:15 2016 (r298646) @@ -1085,7 +1085,7 @@ fatm_supply_small_buffers(struct fatm_so 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_so 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); Modified: head/sys/dev/fb/vga.c ============================================================================== --- head/sys/dev/fb/vga.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/fb/vga.c Tue Apr 26 15:03:15 2016 (r298646) @@ -1247,8 +1247,8 @@ set_line_length(video_adapter_t *adp, in 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; Modified: head/sys/dev/jme/if_jme.c ============================================================================== --- head/sys/dev/jme/if_jme.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/jme/if_jme.c Tue Apr 26 15:03:15 2016 (r298646) @@ -2664,7 +2664,7 @@ jme_rxintr(struct jme_softc *sc, int cou * 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. */ Modified: head/sys/dev/mcd/mcd.c ============================================================================== --- head/sys/dev/mcd/mcd.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/mcd/mcd.c Tue Apr 26 15:03:15 2016 (r298646) @@ -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: Modified: head/sys/dev/mfi/mfi.c ============================================================================== --- head/sys/dev/mfi/mfi.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/mfi/mfi.c Tue Apr 26 15:03:15 2016 (r298646) @@ -2156,7 +2156,7 @@ mfi_build_syspdio(struct mfi_softc *sc, } /* 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, str } /* 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, in 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 * 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; Modified: head/sys/dev/mlx/mlx.c ============================================================================== --- head/sys/dev/mlx/mlx.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/mlx/mlx.c Tue Apr 26 15:03:15 2016 (r298646) @@ -1868,7 +1868,7 @@ mlx_startio_cb(void *arg, bus_dma_segmen /* 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, Modified: head/sys/dev/mmc/host/dwmmc.c ============================================================================== --- head/sys/dev/mmc/host/dwmmc.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/mmc/host/dwmmc.c Tue Apr 26 15:03:15 2016 (r298646) @@ -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) Modified: head/sys/dev/ncr/ncr.c ============================================================================== --- head/sys/dev/ncr/ncr.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/ncr/ncr.c Tue Apr 26 15:03:15 2016 (r298646) @@ -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). Modified: head/sys/dev/patm/if_patm_tx.c ============================================================================== --- head/sys/dev/patm/if_patm_tx.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/patm/if_patm_tx.c Tue Apr 26 15:03:15 2016 (r298646) @@ -119,8 +119,8 @@ cbr2slots(struct patm_softc *sc, struct { /* 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 Modified: head/sys/dev/ral/rt2560.c ============================================================================== --- head/sys/dev/ral/rt2560.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/ral/rt2560.c Tue Apr 26 15:03:15 2016 (r298646) @@ -1425,7 +1425,7 @@ rt2560_setup_tx_desc(struct rt2560_softc 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) Modified: head/sys/dev/ral/rt2661.c ============================================================================== --- head/sys/dev/ral/rt2661.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/ral/rt2661.c Tue Apr 26 15:03:15 2016 (r298646) @@ -1246,7 +1246,7 @@ rt2661_setup_tx_desc(struct rt2661_softc 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) Modified: head/sys/dev/sbni/if_sbni.c ============================================================================== --- head/sys/dev/sbni/if_sbni.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/sbni/if_sbni.c Tue Apr 26 15:03:15 2016 (r298646) @@ -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); Modified: head/sys/dev/scd/scd.c ============================================================================== --- head/sys/dev/scd/scd.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/scd/scd.c Tue Apr 26 15:03:15 2016 (r298646) @@ -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: Modified: head/sys/dev/sfxge/sfxge_tx.c ============================================================================== --- head/sys/dev/sfxge/sfxge_tx.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/sfxge/sfxge_tx.c Tue Apr 26 15:03:15 2016 (r298646) @@ -906,7 +906,7 @@ static const struct tcphdr *tso_tcph(con #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) { Modified: head/sys/dev/siba/siba_core.c ============================================================================== --- head/sys/dev/siba/siba_core.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/siba/siba_core.c Tue Apr 26 15:03:15 2016 (r298646) @@ -1058,8 +1058,8 @@ siba_cc_powerup_delay(struct siba_cc *sc 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 Modified: head/sys/dev/sound/usb/uaudio.c ============================================================================== --- head/sys/dev/sound/usb/uaudio.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/sound/usb/uaudio.c Tue Apr 26 15:03:15 2016 (r298646) @@ -1173,8 +1173,8 @@ uaudio_get_buffer_size(struct uaudio_cha { 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_s /* 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; Modified: head/sys/dev/sym/sym_hipd.c ============================================================================== --- head/sys/dev/sym/sym_hipd.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/sym/sym_hipd.c Tue Apr 26 15:03:15 2016 (r298646) @@ -2526,11 +2526,11 @@ static int sym_prepare_setting(hcb_p np, * 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). Modified: head/sys/dev/usb/controller/ehci.c ============================================================================== --- head/sys/dev/usb/controller/ehci.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/usb/controller/ehci.c Tue Apr 26 15:03:15 2016 (r298646) @@ -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); } Modified: head/sys/dev/usb/controller/ohci.c ============================================================================== --- head/sys/dev/usb/controller/ohci.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/usb/controller/ohci.c Tue Apr 26 15:03:15 2016 (r298646) @@ -2437,7 +2437,7 @@ ohci_xfer_setup(struct usb_setup_params 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; Modified: head/sys/dev/usb/controller/xhci.c ============================================================================== --- head/sys/dev/usb/controller/xhci.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/usb/controller/xhci.c Tue Apr 26 15:03:15 2016 (r298646) @@ -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 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) Modified: head/sys/dev/usb/usb_transfer.c ============================================================================== --- head/sys/dev/usb/usb_transfer.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/usb/usb_transfer.c Tue Apr 26 15:03:15 2016 (r298646) @@ -246,7 +246,7 @@ usbd_transfer_setup_sub_malloc(struct us * 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; } Modified: head/sys/dev/usb/wlan/if_rum.c ============================================================================== --- head/sys/dev/usb/wlan/if_rum.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/usb/wlan/if_rum.c Tue Apr 26 15:03:15 2016 (r298646) @@ -1336,7 +1336,7 @@ rum_setup_tx_desc(struct rum_softc *sc, } 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) Modified: head/sys/dev/usb/wlan/if_ural.c ============================================================================== --- head/sys/dev/usb/wlan/if_ural.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/usb/wlan/if_ural.c Tue Apr 26 15:03:15 2016 (r298646) @@ -1002,7 +1002,7 @@ ural_setup_tx_desc(struct ural_softc *sc } 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) Modified: head/sys/dev/vt/hw/vga/vt_vga.c ============================================================================== --- head/sys/dev/vt/hw/vga/vt_vga.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/vt/hw/vga/vt_vga.c Tue Apr 26 15:03:15 2016 (r298646) @@ -815,9 +815,8 @@ vga_bitblt_text_gfxmode(struct vt_device 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, 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); Modified: head/sys/dev/xen/grant_table/grant_table.c ============================================================================== --- head/sys/dev/xen/grant_table/grant_table.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/xen/grant_table/grant_table.c Tue Apr 26 15:03:15 2016 (r298646) @@ -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); Modified: head/sys/dev/xen/netback/netback.c ============================================================================== --- head/sys/dev/xen/netback/netback.c Tue Apr 26 14:51:58 2016 (r298645) +++ head/sys/dev/xen/netback/netback.c Tue Apr 26 15:03:15 2016 (r298646) @@ -1931,7 +1931,7 @@ xnb_mbufc2pkt(const struct mbuf *mbufc, * 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604261503.u3QF3FNp037438>