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/f85d32d7c786
branches:  trunk
changeset: 939373:f85d32d7c786
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 aa6c9ae22c90 -r f85d32d7c786 sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c       Sat Sep 26 08:02:35 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