Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf62a0a5 authored by Sumant Patro's avatar Sumant Patro Committed by James Bottomley
Browse files

[SCSI] megaraid_sas: add bios_param in scsi_host_template

parent af37acfb
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <asm/uaccess.h>
#include <linux/fs.h>
#include <linux/compat.h>
#include <linux/blkdev.h>
#include <linux/mutex.h>

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

/**
 * megasas_bios_param - Returns disk geometry for a disk
 * @sdev: 		device handle
 * @bdev:		block device
 * @capacity:		drive capacity
 * @geom:		geometry parameters
 */
static int
megasas_bios_param(struct scsi_device *sdev, struct block_device *bdev,
		 sector_t capacity, int geom[])
{
	int heads;
	int sectors;
	sector_t cylinders;
	unsigned long tmp;
	/* Default heads (64) & sectors (32) */
	heads = 64;
	sectors = 32;

	tmp = heads * sectors;
	cylinders = capacity;

	sector_div(cylinders, tmp);

	/*
	 * Handle extended translation size for logical drives > 1Gb
	 */

	if (capacity >= 0x200000) {
		heads = 255;
		sectors = 63;
		tmp = heads*sectors;
		cylinders = capacity;
		sector_div(cylinders, tmp);
	}

	geom[0] = heads;
	geom[1] = sectors;
	geom[2] = cylinders;

	return 0;
}

/**
 * megasas_service_aen -	Processes an event notification
 * @instance:			Adapter soft state
@@ -1054,6 +1098,7 @@ static struct scsi_host_template megasas_template = {
	.eh_device_reset_handler = megasas_reset_device,
	.eh_bus_reset_handler = megasas_reset_bus_host,
	.eh_host_reset_handler = megasas_reset_bus_host,
	.bios_param = megasas_bios_param,
	.use_clustering = ENABLE_CLUSTERING,
};