Skip to content

Commit cf62a0a

Browse files
Sumant PatroJames Bottomley
authored andcommitted
[SCSI] megaraid_sas: add bios_param in scsi_host_template
Signed-off-by: Sumant Patro <sumant.patro@lsi.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
1 parent af37acf commit cf62a0a

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

drivers/scsi/megaraid/megaraid_sas.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <asm/uaccess.h>
3636
#include <linux/fs.h>
3737
#include <linux/compat.h>
38+
#include <linux/blkdev.h>
3839
#include <linux/mutex.h>
3940

4041
#include <scsi/scsi.h>
@@ -1014,6 +1015,49 @@ static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
10141015
return ret;
10151016
}
10161017

1018+
/**
1019+
* megasas_bios_param - Returns disk geometry for a disk
1020+
* @sdev: device handle
1021+
* @bdev: block device
1022+
* @capacity: drive capacity
1023+
* @geom: geometry parameters
1024+
*/
1025+
static int
1026+
megasas_bios_param(struct scsi_device *sdev, struct block_device *bdev,
1027+
sector_t capacity, int geom[])
1028+
{
1029+
int heads;
1030+
int sectors;
1031+
sector_t cylinders;
1032+
unsigned long tmp;
1033+
/* Default heads (64) & sectors (32) */
1034+
heads = 64;
1035+
sectors = 32;
1036+
1037+
tmp = heads * sectors;
1038+
cylinders = capacity;
1039+
1040+
sector_div(cylinders, tmp);
1041+
1042+
/*
1043+
* Handle extended translation size for logical drives > 1Gb
1044+
*/
1045+
1046+
if (capacity >= 0x200000) {
1047+
heads = 255;
1048+
sectors = 63;
1049+
tmp = heads*sectors;
1050+
cylinders = capacity;
1051+
sector_div(cylinders, tmp);
1052+
}
1053+
1054+
geom[0] = heads;
1055+
geom[1] = sectors;
1056+
geom[2] = cylinders;
1057+
1058+
return 0;
1059+
}
1060+
10171061
/**
10181062
* megasas_service_aen - Processes an event notification
10191063
* @instance: Adapter soft state
@@ -1054,6 +1098,7 @@ static struct scsi_host_template megasas_template = {
10541098
.eh_device_reset_handler = megasas_reset_device,
10551099
.eh_bus_reset_handler = megasas_reset_bus_host,
10561100
.eh_host_reset_handler = megasas_reset_bus_host,
1101+
.bios_param = megasas_bios_param,
10571102
.use_clustering = ENABLE_CLUSTERING,
10581103
};
10591104

0 commit comments

Comments
 (0)