Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2879442rwb; Mon, 15 Aug 2022 13:10:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR71QG+fVdlES/Hbq1zloe2kEGAm2JjXIuzmsrlUzYrCesJ6fLZfd+iw3BlyS7giuLhCySOH X-Received: by 2002:aa7:939a:0:b0:52d:a258:3f35 with SMTP id t26-20020aa7939a000000b0052da2583f35mr17513200pfe.14.1660594240556; Mon, 15 Aug 2022 13:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594240; cv=none; d=google.com; s=arc-20160816; b=AyGZ6JC1qlm4yx39LHmaHSZs9op7QXQP8ojC282dstJlwG67yg5UwIdKtGEekyaQ0t 1TgZWZIMu9wIJTZ2gGkbrgslqEw8sxF4mUHQPGMcsne48syl61coK+UBOZubNgLN9clg Ev3xcqwobkXxrIME8QVkNa4wem6LtuMkty6rGZY0PO6K8vIfuaujzDKrnwhA2cVj0Y0K txp8/CeM3Gd6O/7978n6iwW+iUmWhYq/1zMAZtpuPXiu7PPeQdAmgFfEYfV8xCsi3rO7 xJ0/jgVplDI3qByJn/bJlE0zQFtVyUNUL311RUxH4ryo8YiFJM8H5Pdg5FiWav78PuAv fPmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oR1tEsGMjTR7+stmh9Wx4MQ5cHv62WXkB3U2/OM3/Oc=; b=Os8eK9/DVVm8ECtT4rYPjVJUhdVEJa7LdlK+247FXTXqEVuvhBenK1iXPG78jZwX60 0eICIXUHgT8FgdahyTkiYTBOiYBovSCYCauQe5N4sMM+yO0fE6px9f41gQtj++jK/jRf kswYd34jq+lPzdpXo3/9y1hsvSqBQXjI1z9oIERLlecX5+JFiOuook3asLwx2+r1TMIK 3At3vNyVEjLLxi0U8SOlecumR+B2c7S1yeJ1+Dn0YWRJiaHB2+Gbs9+EwXWuCUSioqoy cIg3Ur+LqZD5x/Tr77OYgfGNY5Z5qFSYJD7nz1r/KwJvyMlK9rh7Gsj1HALvKlxHthcQ HVYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kxdR84Oo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y124-20020a62ce82000000b0052c5e4d5b4fsi8746954pfg.246.2022.08.15.13.10.29; Mon, 15 Aug 2022 13:10:40 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kxdR84Oo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243479AbiHOSci (ORCPT + 99 others); Mon, 15 Aug 2022 14:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242426AbiHOSbi (ORCPT ); Mon, 15 Aug 2022 14:31:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56DA43340D; Mon, 15 Aug 2022 11:21:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B085A60BE9; Mon, 15 Aug 2022 18:21:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75EF6C433C1; Mon, 15 Aug 2022 18:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587685; bh=GvM3E+AZZX7lYhFn5NiVlC4zztilrefSRbhsRU5CcIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kxdR84Ookw3ZBT8NAk/2sUiYH9U2A6rTCsZ+1qDNtDRVM2oE6FvK+OlfuPMS3X/zo 6/1yOMhxjwG/Shn7JZo/xDBzDVpTru5Sy7fUeYiWJe1X3Lb2hjPAAukFSORGKB25oM Q1bvAZ0pN/h+dAbVAFm9Df08oF0oTzzDGWDpQGa0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiang Chen , John Garry , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.15 163/779] scsi: hisi_sas: Use managed PCI functions Date: Mon, 15 Aug 2022 19:56:47 +0200 Message-Id: <20220815180344.291473149@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Xiang Chen [ Upstream commit 4f6094f1663e2ed26a940f1842cdaa15c1dd649a ] Use managed PCI functions such as pcim_enable_device() and pcim_iomap_regions() to simplify exception handling code. Link: https://lore.kernel.org/r/1629799260-120116-2-git-send-email-john.garry@huawei.com Signed-off-by: Xiang Chen Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 15c7451fb30f..fa22cb712be5 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -518,6 +518,8 @@ struct hisi_sas_err_record_v3 { #define CHNL_INT_STS_INT2_MSK BIT(3) #define CHNL_WIDTH 4 +#define BAR_NO_V3_HW 5 + enum { DSM_FUNC_ERR_HANDLE_MSI = 0, }; @@ -4740,15 +4742,15 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) struct sas_ha_struct *sha; int rc, phy_nr, port_nr, i; - rc = pci_enable_device(pdev); + rc = pcim_enable_device(pdev); if (rc) goto err_out; pci_set_master(pdev); - rc = pci_request_regions(pdev, DRV_NAME); + rc = pcim_iomap_regions(pdev, 1 << BAR_NO_V3_HW, DRV_NAME); if (rc) - goto err_out_disable_device; + goto err_out; rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); if (rc) @@ -4756,20 +4758,20 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (rc) { dev_err(dev, "No usable DMA addressing method\n"); rc = -ENODEV; - goto err_out_regions; + goto err_out; } shost = hisi_sas_shost_alloc_pci(pdev); if (!shost) { rc = -ENOMEM; - goto err_out_regions; + goto err_out; } sha = SHOST_TO_SAS_HA(shost); hisi_hba = shost_priv(shost); dev_set_drvdata(dev, sha); - hisi_hba->regs = pcim_iomap(pdev, 5, 0); + hisi_hba->regs = pcim_iomap_table(pdev)[BAR_NO_V3_HW]; if (!hisi_hba->regs) { dev_err(dev, "cannot map register\n"); rc = -ENOMEM; @@ -4861,10 +4863,6 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) err_out_ha: hisi_sas_free(hisi_hba); scsi_host_put(shost); -err_out_regions: - pci_release_regions(pdev); -err_out_disable_device: - pci_disable_device(pdev); err_out: return rc; } @@ -4901,8 +4899,6 @@ static void hisi_sas_v3_remove(struct pci_dev *pdev) sas_remove_host(sha->core.shost); hisi_sas_v3_destroy_irqs(pdev, hisi_hba); - pci_release_regions(pdev); - pci_disable_device(pdev); hisi_sas_free(hisi_hba); debugfs_exit_v3_hw(hisi_hba); scsi_host_put(shost); -- 2.35.1