From: Matthew Wilcox <matthew@wil.cx>
To: Mike Miller <mike.miller@hp.com>
Cc: iss_storagedev@hp.com, linux-scsi@vger.kernel.org
Subject: [PATCH] cciss: Fix warnings (and bug on 1TB discs)
Date: Thu, 19 Oct 2006 21:23:36 -0600 [thread overview]
Message-ID: <20061020032336.GP2602@parisc-linux.org> (raw)
CCISS was producing warnings about shifts being greater than the size
of the type and pointers being of incompatible type. Turns out this
is because it's calling do_div on a 32-bit quantity. Upon further
investigation, the sector_t total_size is being assigned to an int,
and then we're calling do_div on that int. Obviously, sector_div is
called for here, and I took the chance to refactor the code a little.
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index dcccaf2..bc66026 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1923,7 +1923,6 @@ static void cciss_geometry_inquiry(int c
{
int return_code;
unsigned long t;
- unsigned long rem;
memset(inq_buff, 0, sizeof(InquiryData_struct));
if (withirq)
@@ -1939,26 +1938,23 @@ static void cciss_geometry_inquiry(int c
printk(KERN_WARNING
"cciss: reading geometry failed, volume "
"does not support reading geometry\n");
- drv->block_size = block_size;
- drv->nr_blocks = total_size;
drv->heads = 255;
drv->sectors = 32; // Sectors per track
- t = drv->heads * drv->sectors;
- drv->cylinders = total_size;
- rem = do_div(drv->cylinders, t);
} else {
- drv->block_size = block_size;
- drv->nr_blocks = total_size;
drv->heads = inq_buff->data_byte[6];
drv->sectors = inq_buff->data_byte[7];
drv->cylinders = (inq_buff->data_byte[4] & 0xff) << 8;
drv->cylinders += inq_buff->data_byte[5];
drv->raid_level = inq_buff->data_byte[8];
- t = drv->heads * drv->sectors;
- if (t > 1) {
- drv->cylinders = total_size;
- rem = do_div(drv->cylinders, t);
- }
+ }
+ drv->block_size = block_size;
+ drv->nr_blocks = total_size;
+ t = drv->heads * drv->sectors;
+ if (t > 1) {
+ unsigned rem = sector_div(total_size, t);
+ if (rem)
+ total_size++;
+ drv->cylinders = total_size;
}
} else { /* Get geometry failed */
printk(KERN_WARNING "cciss: reading geometry failed\n");
next reply other threads:[~2006-10-20 3:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-20 3:23 Matthew Wilcox [this message]
2006-10-20 3:27 ` [PATCH] cciss: Fix warnings (and bug on 1TB discs) Matthew Wilcox
2006-10-20 14:53 ` Miller, Mike (OS Dev)
2006-10-20 14:53 ` Miller, Mike (OS Dev)
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=20061020032336.GP2602@parisc-linux.org \
--to=matthew@wil.cx \
--cc=iss_storagedev@hp.com \
--cc=linux-scsi@vger.kernel.org \
--cc=mike.miller@hp.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.