Staging: hv: Simplify the code for blkvsc_getgeo()
We are making up the geometry anyway, keep it simple. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Hank Janssen <hjanssen@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Родитель
7b04cd089e
Коммит
ea50245ffa
|
@ -278,82 +278,20 @@ static int blkvsc_open(struct block_device *bdev, fmode_t mode)
|
||||||
|
|
||||||
static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg)
|
static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg)
|
||||||
{
|
{
|
||||||
sector_t total_sectors = get_capacity(bd->bd_disk);
|
sector_t nsect = get_capacity(bd->bd_disk);
|
||||||
sector_t cylinder_times_heads = 0;
|
sector_t cylinders = nsect;
|
||||||
sector_t temp = 0;
|
|
||||||
|
|
||||||
int sectors_per_track = 0;
|
/*
|
||||||
int heads = 0;
|
* We are making up these values; let us keep it simple.
|
||||||
int cylinders = 0;
|
*/
|
||||||
int rem = 0;
|
hg->heads = 0xff;
|
||||||
|
hg->sectors = 0x3f;
|
||||||
if (total_sectors > (65535 * 16 * 255))
|
sector_div(cylinders, hg->heads * hg->sectors);
|
||||||
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
|
|
||||||
* cylinder_times_heads
|
|
||||||
*/
|
|
||||||
rem = sector_div(cylinder_times_heads,
|
|
||||||
sectors_per_track);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cylinder_times_heads >= (heads * 1024)) {
|
|
||||||
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;
|
|
||||||
|
|
||||||
hg->heads = heads;
|
|
||||||
hg->sectors = sectors_per_track;
|
|
||||||
hg->cylinders = cylinders;
|
hg->cylinders = cylinders;
|
||||||
|
if ((sector_t)(hg->cylinders + 1) * hg->heads * hg->sectors < nsect)
|
||||||
DPRINT_INFO(BLKVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads,
|
hg->cylinders = 0xffff;
|
||||||
sectors_per_track);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче