From patchwork Tue Oct 25 10:18:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 619466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACAECC04A95 for ; Tue, 25 Oct 2022 09:52:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232071AbiJYJwX (ORCPT ); Tue, 25 Oct 2022 05:52:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231688AbiJYJux (ORCPT ); Tue, 25 Oct 2022 05:50:53 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D606F134A83; Tue, 25 Oct 2022 02:48:59 -0700 (PDT) Received: from frapeml100004.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRtw68SCz689QR; Tue, 25 Oct 2022 17:47:36 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml100004.china.huawei.com (7.182.85.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 11:48:57 +0200 Received: from localhost.localdomain (10.69.192.58) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 10:48:53 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 15/22] scsi: libsas: Add sas_ata_setup_device() Date: Tue, 25 Oct 2022 18:18:09 +0800 Message-ID: <1666693096-180008-16-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1666693096-180008-1-git-send-email-john.garry@huawei.com> References: <1666693096-180008-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 --- 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 78e6046fb55a..a46a2d345422 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 = {