Author: pfg
Date: Tue Apr 26 14:51:58 2016
New Revision: 298645
URL: https://svnweb.freebsd.org/changeset/base/298645

Log:
  sys/boot: make 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/boot/common/part.c
  head/sys/boot/powerpc/ps3/main.c
  head/sys/boot/sparc64/boot1/boot1.c

Modified: head/sys/boot/common/part.c
==============================================================================
--- head/sys/boot/common/part.c Tue Apr 26 14:48:58 2016        (r298644)
+++ head/sys/boot/common/part.c Tue Apr 26 14:51:58 2016        (r298645)
@@ -257,8 +257,9 @@ ptable_gptread(struct ptable *table, voi
            table->sectorsize);
        if (phdr != NULL) {
                /* Read the primary GPT table. */
-               size = MIN(MAXTBLSZ, (phdr->hdr_entries * phdr->hdr_entsz +
-                   table->sectorsize - 1) / table->sectorsize);
+               size = MIN(MAXTBLSZ,
+                   howmany(phdr->hdr_entries * phdr->hdr_entsz,
+                       table->sectorsize));
                if (dread(dev, tbl, size, phdr->hdr_lba_table) == 0 &&
                    gpt_checktbl(phdr, tbl, size * table->sectorsize,
                    table->sectors - 1) == 0) {
@@ -290,9 +291,9 @@ ptable_gptread(struct ptable *table, voi
                    hdr.hdr_entsz != phdr->hdr_entsz ||
                    hdr.hdr_crc_table != phdr->hdr_crc_table) {
                        /* Read the backup GPT table. */
-                       size = MIN(MAXTBLSZ, (phdr->hdr_entries *
-                           phdr->hdr_entsz + table->sectorsize - 1) /
-                           table->sectorsize);
+                       size = MIN(MAXTBLSZ,
+                                  howmany(phdr->hdr_entries * phdr->hdr_entsz,
+                                      table->sectorsize));
                        if (dread(dev, tbl, size, phdr->hdr_lba_table) == 0 &&
                            gpt_checktbl(phdr, tbl, size * table->sectorsize,
                            table->sectors - 1) == 0) {

Modified: head/sys/boot/powerpc/ps3/main.c
==============================================================================
--- head/sys/boot/powerpc/ps3/main.c    Tue Apr 26 14:48:58 2016        
(r298644)
+++ head/sys/boot/powerpc/ps3/main.c    Tue Apr 26 14:51:58 2016        
(r298645)
@@ -174,7 +174,7 @@ delay(int usecs)
        uint64_t tb,ttb;
        tb = mftb();
 
-       ttb = tb + (usecs * 1000 + ns_per_tick - 1) / ns_per_tick;
+       ttb = tb + howmany(usecs * 1000, ns_per_tick);
        while (tb < ttb)
                tb = mftb();
 }

Modified: head/sys/boot/sparc64/boot1/boot1.c
==============================================================================
--- head/sys/boot/sparc64/boot1/boot1.c Tue Apr 26 14:48:58 2016        
(r298644)
+++ head/sys/boot/sparc64/boot1/boot1.c Tue Apr 26 14:51:58 2016        
(r298645)
@@ -390,7 +390,7 @@ zbread(char *buf, off_t off, size_t byte
 
        p = buf;
        soff = VDEV_BOOT_OFFSET + off;
-       lb = (soff + bytes + DEV_BSIZE - 1) / DEV_BSIZE;
+       lb = howmany(soff + bytes, DEV_BSIZE);
        poff = soff;
        while (poff < soff + bytes) {
                nb = lb - poff / DEV_BSIZE;
_______________________________________________
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