patch-1.3.46 linux/drivers/scsi/scsicam.c

Next file: linux/drivers/scsi/sg.c
Previous file: linux/drivers/scsi/scsi_syms.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.45/linux/drivers/scsi/scsicam.c linux/drivers/scsi/scsicam.c
@@ -86,8 +86,8 @@
     unsigned int  *cyls, unsigned int *hds, unsigned int *secs) {
     struct partition *p, *largest = NULL;
     int i, largest_cyl;
-    int cyl, end_head, end_cyl, end_sector;
-    unsigned int logical_end, physical_end;
+    int cyl, ext_cyl, end_head, end_cyl, end_sector;
+    unsigned int logical_end, physical_end, ext_physical_end;
     
 
     if (*(unsigned short *) (bh->b_data+510) == 0xAA55) {
@@ -111,6 +111,7 @@
     	end_cyl = largest->end_cyl + ((largest->end_sector & 0xc0) << 2);
     	end_head = largest->end_head;
     	end_sector = largest->end_sector & 0x3f;
+
 #ifdef DEBUG
 	printk ("scsicam_bios_param : end at h = %d, c = %d, s = %d\n",
 	    end_head, end_cyl, end_sector);
@@ -122,12 +123,25 @@
 	/* This is the actual _sector_ number at the end */
 	logical_end = largest->start_sect + largest->nr_sects;
 
-    	if (logical_end == physical_end) {
+	/* This is for >1023 cylinders */
+        ext_cyl= (logical_end-(end_head * end_sector + end_sector))
+                                        /(end_head + 1) / end_sector;
+	ext_physical_end = ext_cyl * (end_head + 1) * end_sector +
+            end_head * end_sector + end_sector;
+
+#ifdef DEBUG
+	printk("scsicam_bios_param : logical_end=%d physical_end=%d ext_physical_end=%d ext_cyl=%d\n"
+			,logical_end,physical_end,ext_physical_end,ext_cyl);
+#endif
+
+    	if ((logical_end == physical_end) ||
+	    (end_cyl==1023 && ext_physical_end==logical_end)) {
     	    *secs = end_sector;
     	    *hds = end_head + 1;
     	    *cyls = capacity / ((end_head + 1) * end_sector);
     	    return 0;
     	}
+	
 #ifdef DEBUG
 	printk ("scsicam_bios_param : logical (%u) != physical (%u)\n",
 	    logical_end, physical_end);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this