From: "H. Peter Anvin" <hpa@zytor.com>
To: jejb@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, hpa@zytor.com
Subject: [PATCH 1/2] scsi: fix computation of the full size of the device
Date: Tue, 14 Oct 2008 11:34:20 -0700 [thread overview]
Message-ID: <1224009261-31247-1-git-send-email-hpa@zytor.com> (raw)
In-Reply-To: <48F4DF3E.2050903@zytor.com>
When computing the full size of the device, we need to cast
sdkp->capacity before shifting, since in some configurations sector_t
can be a 32-bit number.
Also, change ffz(~x) to the more idiomatic ilog2(x).
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
drivers/scsi/sd.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a7b53be..151fc68 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1438,7 +1438,7 @@ got_data:
{
char cap_str_2[10], cap_str_10[10];
- u64 sz = sdkp->capacity << ffz(~sector_size);
+ u64 sz = (u64)sdkp->capacity << ilog2(sector_size);
string_get_size(sz, STRING_UNITS_2, cap_str_2,
sizeof(cap_str_2));
--
1.6.0.2
next prev parent reply other threads:[~2008-10-14 18:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-14 0:03 Checkin 7404ad3b6d04efbd918e9e2e776bf560fbedf47d breaks boot on KVM H. Peter Anvin
2008-10-14 13:23 ` James Bottomley
2008-10-14 16:00 ` H. Peter Anvin
2008-10-14 18:00 ` Marcin Slusarz
2008-10-14 18:04 ` H. Peter Anvin
2008-10-14 18:34 ` H. Peter Anvin [this message]
2008-10-14 18:34 ` [PATCH 2/2] string_get_size(): don't hang on zero; no decimals on exact H. Peter Anvin
2008-10-14 18:35 ` Checkin 7404ad3b6d04efbd918e9e2e776bf560fbedf47d breaks boot on KVM James Bottomley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1224009261-31247-1-git-send-email-hpa@zytor.com \
--to=hpa@zytor.com \
--cc=jejb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®