Commit 11b9cebf authored by James Bottomley's avatar James Bottomley

correct compile warnings without Large Block Device support

Based on a patch from Andrew Morton.

Also checks to see if the sd device is bigger than the kernel can
support and prints out a warning in that case
parent 8c977c50
...@@ -301,10 +301,10 @@ static int sd_init_command(struct scsi_cmnd * SCpnt) ...@@ -301,10 +301,10 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
if (block > 0xffffffff) { if (block > 0xffffffff) {
SCpnt->cmnd[0] += READ_16 - READ_6; SCpnt->cmnd[0] += READ_16 - READ_6;
SCpnt->cmnd[2] = (unsigned char) (block >> 56) & 0xff; SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0;
SCpnt->cmnd[3] = (unsigned char) (block >> 48) & 0xff; SCpnt->cmnd[3] = sizeof(block) > 4 ? (unsigned char) (block >> 48) & 0xff : 0;
SCpnt->cmnd[4] = (unsigned char) (block >> 40) & 0xff; SCpnt->cmnd[4] = sizeof(block) > 4 ? (unsigned char) (block >> 40) & 0xff : 0;
SCpnt->cmnd[5] = (unsigned char) (block >> 32) & 0xff; SCpnt->cmnd[5] = sizeof(block) > 4 ? (unsigned char) (block >> 32) & 0xff : 0;
SCpnt->cmnd[6] = (unsigned char) (block >> 24) & 0xff; SCpnt->cmnd[6] = (unsigned char) (block >> 24) & 0xff;
SCpnt->cmnd[7] = (unsigned char) (block >> 16) & 0xff; SCpnt->cmnd[7] = (unsigned char) (block >> 16) & 0xff;
SCpnt->cmnd[8] = (unsigned char) (block >> 8) & 0xff; SCpnt->cmnd[8] = (unsigned char) (block >> 8) & 0xff;
...@@ -931,7 +931,7 @@ sd_read_capacity(struct scsi_disk *sdkp, char *diskname, ...@@ -931,7 +931,7 @@ sd_read_capacity(struct scsi_disk *sdkp, char *diskname,
if (longrc) { if (longrc) {
memset((void *) cmd, 0, 16); memset((void *) cmd, 0, 16);
cmd[0] = SERVICE_ACTION_IN; cmd[0] = SERVICE_ACTION_IN;
cmd[1] = 0x10; /* READ CAPACITY (16) */ cmd[1] = SAI_READ_CAPACITY_16;
cmd[13] = 12; cmd[13] = 12;
memset((void *) buffer, 0, 12); memset((void *) buffer, 0, 12);
} else { } else {
...@@ -1003,20 +1003,24 @@ sd_read_capacity(struct scsi_disk *sdkp, char *diskname, ...@@ -1003,20 +1003,24 @@ sd_read_capacity(struct scsi_disk *sdkp, char *diskname,
(buffer[5] << 16) | (buffer[6] << 8) | buffer[7]; (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
if (buffer[0] == 0xff && buffer[1] == 0xff && if (buffer[0] == 0xff && buffer[1] == 0xff &&
buffer[2] == 0xff && buffer[3] == 0xff) { buffer[2] == 0xff && buffer[3] == 0xff) {
if(sizeof(sdkp->capacity) > 4) {
printk(KERN_NOTICE "%s : very big device. try to use" printk(KERN_NOTICE "%s : very big device. try to use"
" READ CAPACITY(16).\n", diskname); " READ CAPACITY(16).\n", diskname);
longrc = 1; longrc = 1;
goto repeat; goto repeat;
} else {
printk(KERN_ERR "%s: too big for kernel. Assuming maximum 2Tb\n", diskname);
}
} }
sdkp->capacity = 1 + (((sector_t)buffer[0] << 24) | sdkp->capacity = 1 + (((sector_t)buffer[0] << 24) |
(buffer[1] << 16) | (buffer[1] << 16) |
(buffer[2] << 8) | (buffer[2] << 8) |
buffer[3]); buffer[3]);
} else { } else {
sdkp->capacity = 1 + (((sector_t)buffer[0] << 56) | sdkp->capacity = 1 + (((u64)buffer[0] << 56) |
((sector_t)buffer[1] << 48) | ((u64)buffer[1] << 48) |
((sector_t)buffer[2] << 40) | ((u64)buffer[2] << 40) |
((sector_t)buffer[3] << 32) | ((u64)buffer[3] << 32) |
((sector_t)buffer[4] << 24) | ((sector_t)buffer[4] << 24) |
((sector_t)buffer[5] << 16) | ((sector_t)buffer[5] << 16) |
((sector_t)buffer[6] << 8) | ((sector_t)buffer[6] << 8) |
......
...@@ -99,6 +99,8 @@ extern const unsigned char scsi_command_size[8]; ...@@ -99,6 +99,8 @@ extern const unsigned char scsi_command_size[8];
#define READ_16 0x88 #define READ_16 0x88
#define WRITE_16 0x8a #define WRITE_16 0x8a
#define SERVICE_ACTION_IN 0x9e #define SERVICE_ACTION_IN 0x9e
/* values for service action in */
#define SAI_READ_CAPACITY_16 0x10
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment