Commit 5326fd5c authored by K. Y. Srinivasan's avatar K. Y. Srinivasan Committed by Greg Kroah-Hartman

Staging: hv: storvsc_drv: Simplify the code for getting the drive parameters

We are making up the drive parameters; simplify the code.
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarAbhishek Kane <v-abkane@microsoft.com>
Signed-off-by: default avatarHank Janssen <hjanssen@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6f64e5ff
...@@ -381,79 +381,25 @@ static int storvsc_remove(struct hv_device *dev) ...@@ -381,79 +381,25 @@ static int storvsc_remove(struct hv_device *dev)
static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev, static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev,
sector_t capacity, int *info) sector_t capacity, int *info)
{ {
sector_t total_sectors = capacity; sector_t nsect = capacity;
sector_t cylinder_times_heads = 0; sector_t cylinders = nsect;
sector_t temp = 0; int heads, sectors_pt;
int sectors_per_track = 0;
int heads = 0;
int cylinders = 0;
int rem = 0;
if (total_sectors > (65535 * 16 * 255))
total_sectors = (65535 * 16 * 255);
if (total_sectors >= (65535 * 16 * 63)) {
sectors_per_track = 255;
heads = 16;
cylinder_times_heads = total_sectors;
/* sector_div stores the quotient in cylinder_times_heads */
rem = sector_div(cylinder_times_heads, sectors_per_track);
} else {
sectors_per_track = 17;
cylinder_times_heads = total_sectors;
/* sector_div stores the quotient in cylinder_times_heads */
rem = sector_div(cylinder_times_heads, sectors_per_track);
temp = cylinder_times_heads + 1023;
/* sector_div stores the quotient in temp */
rem = sector_div(temp, 1024);
heads = temp;
if (heads < 4)
heads = 4;
if (cylinder_times_heads >= (heads * 1024) || (heads > 16)) {
sectors_per_track = 31;
heads = 16;
cylinder_times_heads = total_sectors;
/* /*
* sector_div stores the quotient in * We are making up these values; let us keep it simple.
* cylinder_times_heads
*/ */
rem = sector_div(cylinder_times_heads, heads = 0xff;
sectors_per_track); sectors_pt = 0x3f; /* Sectors per track */
} sector_div(cylinders, heads * sectors_pt);
if ((sector_t)(cylinders + 1) * heads * sectors_pt < nsect)
if (cylinder_times_heads >= (heads * 1024)) { cylinders = 0xffff;
sectors_per_track = 63;
heads = 16;
cylinder_times_heads = total_sectors;
/*
* sector_div stores the quotient in
* cylinder_times_heads
*/
rem = sector_div(cylinder_times_heads,
sectors_per_track);
}
}
temp = cylinder_times_heads;
/* sector_div stores the quotient in temp */
rem = sector_div(temp, heads);
cylinders = temp;
info[0] = heads; info[0] = heads;
info[1] = sectors_per_track; info[1] = sectors_pt;
info[2] = cylinders; info[2] = (int)cylinders;
DPRINT_INFO(STORVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads, DPRINT_INFO(STORVSC_DRV, "CHS (%d, %d, %d)", (int)cylinders, heads,
sectors_per_track); sectors_pt);
return 0; return 0;
} }
......
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