Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/scsipi use powerof2() in sd_validate_blksize()
details: https://anonhg.NetBSD.org/src/rev/189ffa494e94
branches: trunk
changeset: 359855:189ffa494e94
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Thu Jan 27 18:44:49 2022 +0000
description:
use powerof2() in sd_validate_blksize()
diffstat:
sys/dev/scsipi/sd.c | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)
diffs (40 lines):
diff -r 1f2e33d15599 -r 189ffa494e94 sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c Thu Jan 27 18:38:07 2022 +0000
+++ b/sys/dev/scsipi/sd.c Thu Jan 27 18:44:49 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sd.c,v 1.332 2021/05/30 06:46:46 dholland Exp $ */
+/* $NetBSD: sd.c,v 1.333 2022/01/27 18:44:49 jakllsch Exp $ */
/*-
* Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.332 2021/05/30 06:46:46 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.333 2022/01/27 18:44:49 jakllsch Exp $");
#ifdef _KERNEL_OPT
#include "opt_scsi.h"
@@ -1311,19 +1311,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