lkml.org 
[lkml]   [2022]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH RFC v2 05/18] scsi: core: Allocate SCSI host sdev when required
Date
When the shost supports reserved commands then allocate the SCSI host sdev.

As noted later, we need to use this for libata internal commands.

Signed-off-by: John Garry <john.garry@huawei.com>
---
drivers/scsi/hosts.c | 5 +++++
include/scsi/scsi_host.h | 1 +
2 files changed, 6 insertions(+)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 5c9b05a8fec8..67930a61b222 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -298,6 +298,8 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,

scsi_proc_host_add(shost);
scsi_autopm_put_host(shost);
+ if (shost->nr_reserved_cmds)
+ shost->sdev = scsi_get_host_dev(shost); // TODO: Add error handling
return error;

/*
@@ -360,6 +362,9 @@ static void scsi_host_dev_release(struct device *dev)

if (shost->shost_state != SHOST_CREATED)
put_device(parent);
+ if (shost->sdev)
+ scsi_free_host_dev(shost->sdev);
+
kfree(shost);
}

diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 88c8504395c8..2e14d65b7444 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -566,6 +566,7 @@ struct Scsi_Host {
wait_queue_head_t host_wait;
struct scsi_host_template *hostt;
struct scsi_transport_template *transportt;
+ struct scsi_device *sdev;

/* Area to keep a shared tag map */
struct blk_mq_tag_set tag_set;
--
2.26.2
\
 
 \ /
  Last update: 2022-06-09 12:38    [W:0.247 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site