Author: pfg
Date: Sat Apr 30 14:41:18 2016
New Revision: 298848
URL: https://svnweb.freebsd.org/changeset/base/298848

Log:
  sys: Make use of our rounddown() macro when sys/param.h is available.
  
  No functional change.

Modified:
  head/sys/arm/at91/at91_pmc.c
  head/sys/ddb/db_output.c
  head/sys/dev/acpi_support/acpi_hp.c
  head/sys/dev/cxgbe/t4_netmap.c
  head/sys/dev/fb/fb.c
  head/sys/dev/fb/vesa.c
  head/sys/dev/fb/vga.c
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/kbd/kbd.c
  head/sys/dev/syscons/scmouse.c
  head/sys/dev/syscons/scvgarndr.c
  head/sys/dev/vt/hw/vga/vt_vga.c
  head/sys/dev/vt/vt_core.c
  head/sys/dev/wpi/if_wpi.c
  head/sys/fs/nandfs/nandfs_vfsops.c
  head/sys/geom/virstor/g_virstor.c
  head/sys/libkern/crc32.c
  head/sys/mips/atheros/ar934x_chip.c
  head/sys/mips/atheros/qca953x_chip.c
  head/sys/mips/atheros/qca955x_chip.c
  head/sys/rpc/clnt_dg.c

Modified: head/sys/arm/at91/at91_pmc.c
==============================================================================
--- head/sys/arm/at91/at91_pmc.c        Sat Apr 30 14:25:00 2016        
(r298847)
+++ head/sys/arm/at91/at91_pmc.c        Sat Apr 30 14:41:18 2016        
(r298848)
@@ -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.

Modified: head/sys/ddb/db_output.c
==============================================================================
--- head/sys/ddb/db_output.c    Sat Apr 30 14:25:00 2016        (r298847)
+++ head/sys/ddb/db_output.c    Sat Apr 30 14:41:18 2016        (r298848)
@@ -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 */

Modified: head/sys/dev/acpi_support/acpi_hp.c
==============================================================================
--- head/sys/dev/acpi_support/acpi_hp.c Sat Apr 30 14:25:00 2016        
(r298847)
+++ head/sys/dev/acpi_support/acpi_hp.c Sat Apr 30 14:41:18 2016        
(r298848)
@@ -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)) {

Modified: head/sys/dev/cxgbe/t4_netmap.c
==============================================================================
--- head/sys/dev/cxgbe/t4_netmap.c      Sat Apr 30 14:25:00 2016        
(r298847)
+++ head/sys/dev/cxgbe/t4_netmap.c      Sat Apr 30 14:41:18 2016        
(r298848)
@@ -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;

Modified: head/sys/dev/fb/fb.c
==============================================================================
--- head/sys/dev/fb/fb.c        Sat Apr 30 14:25:00 2016        (r298847)
+++ head/sys/dev/fb/fb.c        Sat Apr 30 14:41:18 2016        (r298848)
@@ -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);

Modified: head/sys/dev/fb/vesa.c
==============================================================================
--- head/sys/dev/fb/vesa.c      Sat Apr 30 14:25:00 2016        (r298847)
+++ head/sys/dev/fb/vesa.c      Sat Apr 30 14:41:18 2016        (r298848)
@@ -1581,7 +1581,7 @@ vesa_set_origin(video_adapter_t *adp, of
        regs.R_DX = offset / adp->va_window_gran;
        x86bios_intr(&regs, 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 */
 }
 

Modified: head/sys/dev/fb/vga.c
==============================================================================
--- head/sys/dev/fb/vga.c       Sat Apr 30 14:25:00 2016        (r298847)
+++ head/sys/dev/fb/vga.c       Sat Apr 30 14:41:18 2016        (r298848)
@@ -1252,7 +1252,7 @@ set_line_length(video_adapter_t *adp, in
        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 */

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c   Sat Apr 30 14:25:00 2016        (r298847)
+++ head/sys/dev/iwn/if_iwn.c   Sat Apr 30 14:41:18 2016        (r298848)
@@ -6335,7 +6335,7 @@ iwn_set_pslevel(struct iwn_softc *sc, in
                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++)

Modified: head/sys/dev/kbd/kbd.c
==============================================================================
--- head/sys/dev/kbd/kbd.c      Sat Apr 30 14:25:00 2016        (r298847)
+++ head/sys/dev/kbd/kbd.c      Sat Apr 30 14:41:18 2016        (r298848)
@@ -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);

Modified: head/sys/dev/syscons/scmouse.c
==============================================================================
--- head/sys/dev/syscons/scmouse.c      Sat Apr 30 14:25:00 2016        
(r298847)
+++ head/sys/dev/syscons/scmouse.c      Sat Apr 30 14:41:18 2016        
(r298848)
@@ -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')

Modified: head/sys/dev/syscons/scvgarndr.c
==============================================================================
--- head/sys/dev/syscons/scvgarndr.c    Sat Apr 30 14:25:00 2016        
(r298847)
+++ head/sys/dev/syscons/scvgarndr.c    Sat Apr 30 14:41:18 2016        
(r298848)
@@ -1035,7 +1035,7 @@ draw_pxlmouse_planar(scr_stat *scp, int 
 
        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 */

Modified: head/sys/dev/vt/hw/vga/vt_vga.c
==============================================================================
--- head/sys/dev/vt/hw/vga/vt_vga.c     Sat Apr 30 14:25:00 2016        
(r298847)
+++ head/sys/dev/vt/hw/vga/vt_vga.c     Sat Apr 30 14:41:18 2016        
(r298848)
@@ -912,7 +912,7 @@ vga_bitblt_bitmap(struct vt_device *vd, 
        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);

Modified: head/sys/dev/vt/vt_core.c
==============================================================================
--- head/sys/dev/vt/vt_core.c   Sat Apr 30 14:25:00 2016        (r298847)
+++ head/sys/dev/vt/vt_core.c   Sat Apr 30 14:41:18 2016        (r298848)
@@ -640,9 +640,9 @@ vt_compute_drawable_area(struct vt_windo
        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

Modified: head/sys/dev/wpi/if_wpi.c
==============================================================================
--- head/sys/dev/wpi/if_wpi.c   Sat Apr 30 14:25:00 2016        (r298847)
+++ head/sys/dev/wpi/if_wpi.c   Sat Apr 30 14:41:18 2016        (r298848)
@@ -3814,7 +3814,7 @@ wpi_set_pslevel(struct wpi_softc *sc, ui
                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;
 

Modified: head/sys/fs/nandfs/nandfs_vfsops.c
==============================================================================
--- head/sys/fs/nandfs/nandfs_vfsops.c  Sat Apr 30 14:25:00 2016        
(r298847)
+++ head/sys/fs/nandfs/nandfs_vfsops.c  Sat Apr 30 14:41:18 2016        
(r298848)
@@ -331,8 +331,8 @@ nandfs_write_superblock_at(struct nandfs
            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));
 

Modified: head/sys/geom/virstor/g_virstor.c
==============================================================================
--- head/sys/geom/virstor/g_virstor.c   Sat Apr 30 14:25:00 2016        
(r298847)
+++ head/sys/geom/virstor/g_virstor.c   Sat Apr 30 14:41:18 2016        
(r298848)
@@ -1257,7 +1257,7 @@ virstor_check_and_run(struct g_virstor_s
                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;

Modified: head/sys/libkern/crc32.c
==============================================================================
--- head/sys/libkern/crc32.c    Sat Apr 30 14:25:00 2016        (r298847)
+++ head/sys/libkern/crc32.c    Sat Apr 30 14:41:18 2016        (r298848)
@@ -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++)

Modified: head/sys/mips/atheros/ar934x_chip.c
==============================================================================
--- head/sys/mips/atheros/ar934x_chip.c Sat Apr 30 14:25:00 2016        
(r298847)
+++ head/sys/mips/atheros/ar934x_chip.c Sat Apr 30 14:41:18 2016        
(r298848)
@@ -437,7 +437,7 @@ ar934x_chip_gpio_output_configure(int gp
        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 */

Modified: head/sys/mips/atheros/qca953x_chip.c
==============================================================================
--- head/sys/mips/atheros/qca953x_chip.c        Sat Apr 30 14:25:00 2016        
(r298847)
+++ head/sys/mips/atheros/qca953x_chip.c        Sat Apr 30 14:41:18 2016        
(r298848)
@@ -360,7 +360,7 @@ qca953x_chip_gpio_output_configure(int g
        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 */

Modified: head/sys/mips/atheros/qca955x_chip.c
==============================================================================
--- head/sys/mips/atheros/qca955x_chip.c        Sat Apr 30 14:25:00 2016        
(r298847)
+++ head/sys/mips/atheros/qca955x_chip.c        Sat Apr 30 14:41:18 2016        
(r298848)
@@ -369,7 +369,7 @@ qca955x_chip_gpio_output_configure(int g
        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 */

Modified: head/sys/rpc/clnt_dg.c
==============================================================================
--- head/sys/rpc/clnt_dg.c      Sat Apr 30 14:25:00 2016        (r298847)
+++ head/sys/rpc/clnt_dg.c      Sat Apr 30 14:41:18 2016        (r298848)
@@ -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;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to