Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src-draft/trunk]: src/sys/dev/scsipi use powerof2() rather than rolling our ...



details:   https://anonhg.NetBSD.org/src-all/rev/5f3302cb1f7c
branches:  trunk
changeset: 939757:5f3302cb1f7c
user:      Jonathan A. Kollasch <jakllsch%NetBSD.org@localhost>
date:      Fri Sep 25 08:42:57 2020 -0500

description:
use powerof2() rather than rolling our own versions

diffstat:

 sys/dev/scsipi/sd.c |  9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diffs (25 lines):

diff -r ed7c22c17457 -r 5f3302cb1f7c sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c       Tue Sep 29 12:04:48 2020 +0000
+++ b/sys/dev/scsipi/sd.c       Fri Sep 25 08:42:57 2020 -0500
@@ -1310,19 +1310,14 @@
 sd_validate_blksize(struct scsipi_periph *periph, int len)
 {
 
-       switch (len) {
-       case 256:
-       case 512:
-       case 1024:
-       case 2048:
-       case 4096:
+       if (len >= 256 && powerof2(len) && len <= 4096) {
                return 1;
        }
 
        if (periph) {
                scsipi_printaddr(periph);
                printf("%s sector size: 0x%x.  Defaulting to %d bytes.\n",
-                   (len ^ (1 << (ffs(len) - 1))) ?
+                   !powerof2(len) ?
                    "preposterous" : "unsupported",
                    len, SD_DEFAULT_BLKSIZE);
        }



Home | Main Index | Thread Index | Old Index