aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2006-10-21 13:24:19 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-21 16:35:06 -0400
commit3f7705eab6722ad1a346d748c4aad55755d6c241 (patch)
treed6284a55119568e4a53ce31e35f91245a613d09e /drivers
parent8a7822a61ca9c22f464c0b79f455e62cccee747e (diff)
[PATCH] cciss: Fix warnings (and bug on 1TB discs)
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. Signed-off-by: Matthew Wilcox <matthew@wil.cx> Acked-by: Mike Miller <mike.miller@hp.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/cciss.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index dcccaf2782f3..bc6602606fb5 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1923,7 +1923,6 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
1923{ 1923{
1924 int return_code; 1924 int return_code;
1925 unsigned long t; 1925 unsigned long t;
1926 unsigned long rem;
1927 1926
1928 memset(inq_buff, 0, sizeof(InquiryData_struct)); 1927 memset(inq_buff, 0, sizeof(InquiryData_struct));
1929 if (withirq) 1928 if (withirq)
@@ -1939,26 +1938,23 @@ static void cciss_geometry_inquiry(int ctlr, int logvol,
1939 printk(KERN_WARNING 1938 printk(KERN_WARNING
1940 "cciss: reading geometry failed, volume " 1939 "cciss: reading geometry failed, volume "
1941 "does not support reading geometry\n"); 1940 "does not support reading geometry\n");
1942 drv->block_size = block_size;
1943 drv->nr_blocks = total_size;
1944 drv->heads = 255; 1941 drv->heads = 255;
1945 drv->sectors = 32; // Sectors per track 1942 drv->sectors = 32; // Sectors per track
1946 t = drv->heads * drv->sectors;
1947 drv->cylinders = total_size;
1948 rem = do_div(drv->cylinders, t);
1949 } else { 1943 } else {
1950 drv->block_size = block_size;
1951 drv->nr_blocks = total_size;
1952 drv->heads = inq_buff->data_byte[6]; 1944 drv->heads = inq_buff->data_byte[6];
1953 drv->sectors = inq_buff->data_byte[7]; 1945 drv->sectors = inq_buff->data_byte[7];
1954 drv->cylinders = (inq_buff->data_byte[4] & 0xff) << 8; 1946 drv->cylinders = (inq_buff->data_byte[4] & 0xff) << 8;
1955 drv->cylinders += inq_buff->data_byte[5]; 1947 drv->cylinders += inq_buff->data_byte[5];
1956 drv->raid_level = inq_buff->data_byte[8]; 1948 drv->raid_level = inq_buff->data_byte[8];
1957 t = drv->heads * drv->sectors; 1949 }
1958 if (t > 1) { 1950 drv->block_size = block_size;
1959 drv->cylinders = total_size; 1951 drv->nr_blocks = total_size;
1960 rem = do_div(drv->cylinders, t); 1952 t = drv->heads * drv->sectors;
1961 } 1953 if (t > 1) {
1954 unsigned rem = sector_div(total_size, t);
1955 if (rem)
1956 total_size++;
1957 drv->cylinders = total_size;
1962 } 1958 }
1963 } else { /* Get geometry failed */ 1959 } else { /* Get geometry failed */
1964 printk(KERN_WARNING "cciss: reading geometry failed\n"); 1960 printk(KERN_WARNING "cciss: reading geometry failed\n");