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: 10677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp908389wru; Tue, 25 Oct 2022 02:53:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7NXhn0ew3VSYdudScIH5He7SvaZRQ8WddcgNlAJOlTq9eEOtqGsX8vUrX8syKnNPooY6K1 X-Received: by 2002:a63:2b4b:0:b0:440:2963:5863 with SMTP id r72-20020a632b4b000000b0044029635863mr31232907pgr.28.1666691637050; Tue, 25 Oct 2022 02:53:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691637; cv=none; d=google.com; s=arc-20160816; b=ffji+nPwyDsSLQOVq025qV9zEfPZTNTPKIAWWdleykJlxFh36VBk4J61UohDHi++5v GCyVs0uy7wViVr/yS21EWFBcttMceBPaLiXr/uYWU6VkZVVI/+vC7wyu63FIiodvjblD Q8OwCoZIFqwxv+6JlkR5gJ/5KqqQyagdMc8SExurbpziEDWGYhLNBsSERuhFo/MknP+k dKlFj/kO7H/j/ifrxd4dXy/r5XWjd+9AJexvyCn3ZKfjmk7j+EGT3SDqKQJvVCPQnMqw 1D0SRGcQa+XGPlDLaru8G1EKezLQ4Pmy8MPzmA2FEa95rNwzXu2yd+0F+H3HfhQHULS+ tDSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=f9M/pMK1HoIPqrf9mmuCPB+5Y5O7w0SxVlCVWFtLohE=; b=e3QuifgOoj1QP04d/7DFvhOazx+VRJn+wvBl80s9N3R7wkV0BzEywBoF5jqyZb8UqC zQZpbVp61MiHRiOQ5jw99sDnYJ9PkK71s30o2uZvILq9G7GtonGhG0N8Lg1rb/8cCcG0 qb6zHJ1uucr6rZbZtDB/QMDseO+V54I10fZ0/lt1KGydml/PWM3FBFmeQdW6Tcw9r5Q2 Ogfye21FYFOmQWwOKJB2k3Qro8T2nTFlMbDbMvBc9hRAhnH0lINvlLng7jJGcMEEmiWL uFcVPAg7VrM31RmhdYghtRYGycDdYjCFWp4fiT+PsuqTK6iK56xX5NT2Ur0p8XQRL16b XoAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h128-20020a625386000000b0053e3cf68da1si2555388pfb.74.2022.10.25.02.53.43; Tue, 25 Oct 2022 02:53:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232089AbiJYJwZ (ORCPT + 99 others); Tue, 25 Oct 2022 05:52:25 -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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747652850176186342?= X-GMAIL-MSGID: =?utf-8?q?1747652850176186342?= 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 = {