cciss: Fix warnings (and bug on 1TB discs)
Subsystems (2)
PATCH 1/1 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.
drivers/block/cciss.c +9 -13
@@ -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 cprintk (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" );
Quoted 6 lines · Matthew Wilcox
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_divon a 32-bit quantity. Upon further investigation, thesector_ttotal_sizeis being assigned to an int, and then we're callingdo_divon that int. Obviously,sector_divis called for here, and I took the chance to refactor the code a little.
Oops, forgot:
Quoted 52 lines
drivers/block/cciss.c +9
-14@@ -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 cprintk (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" ); -To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Miller, Mike (OS Dev)
Acked-byQuoted 10 lines · Matthew Wilcox
Quoted 1 line
CCISS was producing warnings about shifts being greater
than the size
Quoted 1 line
of the type and pointers being of incompatible type. Turns
out this
Quoted 3 lines
is because it's calling
do_divon a 32-bit quantity. Upon further investigation, thesector_ttotal_sizeis being assigned to an int, and then we're callingdo_divon that int. Obviously,
Quoted 6 lines
sector_divisQuoted 1 line
called for here, and I took the chance to refactor the code
a little.
Oops, forgot:
Signed-off-by Matthew Wilcox <[email protected]>
Quoted 56 lines
Quoted 19 lines
drivers/block/cciss.c index renamed from drivers/block/cciss.c +0
-0dcccaf2..bc66026 100644
drivers/block/cciss.c +0
-3@@ -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 cprintk (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 ;drivers/block/cciss.c static void cciss_geometry_inquiry(int c · line 1946
Quoted 10 lines
drivers/block/cciss.c +0
-5drv->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;Quoted 20 lines
drivers/block/cciss.c +9
-6drv->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" ); -Quoted 1 line
To unsubscribe from this list: send the line "unsubscribe
linux-scsi"
Quoted 1 line
in the body of a message to [email protected] More
majordomo
Quoted 1 line