[PATCH RFC v2 05/18] scsi: core: Allocate SCSI host sdev when required

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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




[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux