diff mbox series

[12/24] mpi3mr: add bios_param shost template hook

Message ID 20201222101156.98308-13-kashyap.desai@broadcom.com (mailing list archive)
State Changes Requested
Headers show
Series Introducing mpi3mr driver | expand

Commit Message

Kashyap Desai Dec. 22, 2020, 10:11 a.m. UTC
Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: sathya.prakash@broadcom.com
---
 drivers/scsi/mpi3mr/mpi3mr_os.c | 40 +++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

Comments

Hannes Reinecke March 1, 2021, 7 a.m. UTC | #1
On 12/22/20 11:11 AM, Kashyap Desai wrote:
> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
> Cc: sathya.prakash@broadcom.com
> ---
>   drivers/scsi/mpi3mr/mpi3mr_os.c | 40 +++++++++++++++++++++++++++++++++
>   1 file changed, 40 insertions(+)
> 
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
> index 4d94352a4d48..7e0eacf45d84 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
> @@ -2078,6 +2078,45 @@ static int mpi3mr_build_sg_scmd(struct mpi3mr_ioc *mrioc,
>   	return ret;
>   }
>   
> +/**
> + * mpi3mr_bios_param - BIOS param callback
> + * @sdev: SCSI device reference
> + * @bdev: Block device reference
> + * @capacity: Capacity in logical sectors
> + * @params: Parameter array
> + *
> + * Just the parameters with heads/secots/cylinders.
> + *
> + * Return: 0 always
> + */
> +static int mpi3mr_bios_param(struct scsi_device *sdev,
> +	struct block_device *bdev, sector_t capacity, int params[])
> +{
> +	int heads;
> +	int sectors;
> +	sector_t cylinders;
> +	ulong dummy;
> +
> +	heads = 64;
> +	sectors = 32;
> +
> +	dummy = heads * sectors;
> +	cylinders = capacity;
> +	sector_div(cylinders, dummy);
> +
> +	if ((ulong)capacity >= 0x200000) {
> +		heads = 255;
> +		sectors = 63;
> +		dummy = heads * sectors;
> +		cylinders = capacity;
> +		sector_div(cylinders, dummy);
> +	}
> +
> +	params[0] = heads;
> +	params[1] = sectors;
> +	params[2] = cylinders;
> +	return 0;
> +}
>   
>   /**
>    * mpi3mr_map_queues - Map queues callback handler
> @@ -2511,6 +2550,7 @@ static struct scsi_host_template mpi3mr_driver_template = {
>   	.slave_destroy			= mpi3mr_slave_destroy,
>   	.scan_finished			= mpi3mr_scan_finished,
>   	.scan_start			= mpi3mr_scan_start,
> +	.bios_param			= mpi3mr_bios_param,
>   	.map_queues			= mpi3mr_map_queues,
>   	.no_write_same			= 1,
>   	.can_queue			= 1,
> 
OMG. I had hoped we could kill this eventually.
Oh well.

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
diff mbox series

Patch

diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index 4d94352a4d48..7e0eacf45d84 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -2078,6 +2078,45 @@  static int mpi3mr_build_sg_scmd(struct mpi3mr_ioc *mrioc,
 	return ret;
 }
 
+/**
+ * mpi3mr_bios_param - BIOS param callback
+ * @sdev: SCSI device reference
+ * @bdev: Block device reference
+ * @capacity: Capacity in logical sectors
+ * @params: Parameter array
+ *
+ * Just the parameters with heads/secots/cylinders.
+ *
+ * Return: 0 always
+ */
+static int mpi3mr_bios_param(struct scsi_device *sdev,
+	struct block_device *bdev, sector_t capacity, int params[])
+{
+	int heads;
+	int sectors;
+	sector_t cylinders;
+	ulong dummy;
+
+	heads = 64;
+	sectors = 32;
+
+	dummy = heads * sectors;
+	cylinders = capacity;
+	sector_div(cylinders, dummy);
+
+	if ((ulong)capacity >= 0x200000) {
+		heads = 255;
+		sectors = 63;
+		dummy = heads * sectors;
+		cylinders = capacity;
+		sector_div(cylinders, dummy);
+	}
+
+	params[0] = heads;
+	params[1] = sectors;
+	params[2] = cylinders;
+	return 0;
+}
 
 /**
  * mpi3mr_map_queues - Map queues callback handler
@@ -2511,6 +2550,7 @@  static struct scsi_host_template mpi3mr_driver_template = {
 	.slave_destroy			= mpi3mr_slave_destroy,
 	.scan_finished			= mpi3mr_scan_finished,
 	.scan_start			= mpi3mr_scan_start,
+	.bios_param			= mpi3mr_bios_param,
 	.map_queues			= mpi3mr_map_queues,
 	.no_write_same			= 1,
 	.can_queue			= 1,