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/e826d943dd09
branches:  trunk
changeset: 939668:e826d943dd09
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 d47435c35dd7 -r e826d943dd09 sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c       Sun Sep 27 13:59:24 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