lkml.org 
[lkml]   [2022]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH RFC 5/6] scsi: libsas: Add sas_ata_setup_device()
Date
Add a function which does a custom sdev alloc - essentially replicates
what we do in sas_rphy_add() in terms of sdev parent and id.

Signed-off-by: John Garry <john.garry@huawei.com>
---
drivers/scsi/libsas/sas_ata.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index d35c9296f738..6d3535a4bfbb 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -523,6 +523,25 @@ static int sas_ata_prereset(struct ata_link *link, unsigned long deadline)
return res;
}

+static int sas_ata_setup_device(struct ata_device *dev)
+{
+ u64 lun = 0;
+ int channel = 0;
+ struct ata_link *link = dev->link;
+ struct ata_port *ap = link->ap;
+ struct scsi_device *sdev;
+ struct domain_device *ddev = ap->private_data;
+ struct sas_rphy *rphy = ddev->rphy;
+ struct device *parent = &rphy->dev;
+ uint id = rphy->scsi_target_id;
+
+ sdev = scsi_get_dev(parent, channel, id, lun);
+ if (!sdev)
+ return -ENODEV;
+ dev->sdev = sdev;
+ return 0;
+}
+
static struct ata_port_operations sas_sata_ops = {
.prereset = sas_ata_prereset,
.hardreset = sas_ata_hard_reset,
@@ -537,6 +556,7 @@ static struct ata_port_operations sas_sata_ops = {
.set_dmamode = sas_ata_set_dmamode,
.sched_eh = sas_ata_sched_eh,
.end_eh = sas_ata_end_eh,
+ .setup_scsi_device = sas_ata_setup_device,
};

static struct ata_port_info sata_port_info = {
--
2.35.3
\
 
 \ /
  Last update: 2022-09-20 12:37    [W:0.109 / U:0.596 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site