Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1067444pxb; Tue, 8 Feb 2022 08:32:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwO/x3FqB6f3D8YjpfW+HEV/NKTEWLusCNITiw2nPHoBLJ3SBH2azgYxiDSe7Bpvkh+Jh07 X-Received: by 2002:a17:90a:564f:: with SMTP id d15mr2261596pji.238.1644337978029; Tue, 08 Feb 2022 08:32:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644337978; cv=none; d=google.com; s=arc-20160816; b=N3YNHAOUbZzzZLtzbBU4fcjliFoxtS+tp9sX2PAZBu/6XqGPXZq9vyHmZIYOj6qLlO yWI9lEBDmGu+dRiZOl/LoGN3qW0lUmlSC++Bq8/fLwbP5+uFCnztibvNzBpWxZtTc78w ljNxb2pXn70ZDqRtJIi7WCiD8tO2VuGetAck/RfXBLoLuzym5ZcQSXD2HVDX87daVqWI 8zs2Bo8rU/FourLncMO/L0hfqFPVj0sdyDwnbeCFYdZG1ZRBCkQT21PvZW26vMb5cEUE Pt7mb/gYIhqwklp3k6zY/gc9iEC35qkge73OdgRUWUrKvKoGfP0YsG1H8BgvSix7C4eT knBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=mWb85YfYtqBybOr3HGOkDZ0e4hNZWUsl8TuW5Yomo08=; b=O1mx8BktIdcJTf7CBXcc+bnZBStBkQv4TyeBQrX1Dl8AmnwdRg2Evq3H6XaWVA4Xsz FsRtyccQ3Q20LC7kufVPz8VVO9FpcYWHT830/iLMQzFAZsgClvhrq6zcjKff748tiQUS p0wNSzbLdWY8BVtwv3msXUSAj8L91ImfT848P/gxU+8xCaDFCK24/zl8Sfzf0vBAKLph mAiLVQPYUdyZLsI6jnnwJOdXl4oyC1oIjjK+ApO894frOqlphLkHGa7ul305AdaNcTlz BPnkGelghDGkZ18PpOw6cUriNzfrMSIRSsLiEYQ54N/0/noB2m+Nr4l2fGxzTzlCkEmm ImVQ== 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=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf2si12418072plb.440.2022.02.08.08.32.42; Tue, 08 Feb 2022 08:32:58 -0800 (PST) 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=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346678AbiBHECw (ORCPT + 99 others); Mon, 7 Feb 2022 23:02:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237051AbiBHECq (ORCPT ); Mon, 7 Feb 2022 23:02:46 -0500 Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BADD9C0401E5; Mon, 7 Feb 2022 20:02:45 -0800 (PST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 2CA9D1A0C45; Tue, 8 Feb 2022 04:57:01 +0100 (CET) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E8BA91A0C34; Tue, 8 Feb 2022 04:57:00 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id B5ECD183AC8A; Tue, 8 Feb 2022 11:56:59 +0800 (+08) From: Richard Zhu To: l.stach@pengutronix.de, bhelgaas@google.com, broonie@kernel.org, lorenzo.pieralisi@arm.com, jingoohan1@gmail.com, festevam@gmail.com Cc: hongxing.zhu@nxp.com, linux-pci@vger.kernel.org, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH v6 5/8] PCI: imx6: Refine the regulator usage Date: Tue, 8 Feb 2022 11:25:32 +0800 Message-Id: <1644290735-3797-6-git-send-email-hongxing.zhu@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1644290735-3797-1-git-send-email-hongxing.zhu@nxp.com> References: <1644290735-3797-1-git-send-email-hongxing.zhu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 The driver should undo any enables it did itself. The regulator disable shouldn't be basing decisions on regulator_is_enabled(). Signed-off-by: Richard Zhu --- drivers/pci/controller/dwc/pci-imx6.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 0aca762d88a3..e165ad00989c 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -369,8 +369,6 @@ static int imx6_pcie_attach_pd(struct device *dev) static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) { - struct device *dev = imx6_pcie->pci->dev; - switch (imx6_pcie->drvdata->variant) { case IMX7D: case IMX8MQ: @@ -400,14 +398,6 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) IMX6Q_GPR1_PCIE_REF_CLK_EN, 0 << 16); break; } - - if (imx6_pcie->vpcie && regulator_is_enabled(imx6_pcie->vpcie) > 0) { - int ret = regulator_disable(imx6_pcie->vpcie); - - if (ret) - dev_err(dev, "failed to disable vpcie regulator: %d\n", - ret); - } } static unsigned int imx6_pcie_grp_offset(const struct imx6_pcie *imx6_pcie) @@ -583,7 +573,7 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) struct device *dev = pci->dev; int ret, err; - if (imx6_pcie->vpcie && !regulator_is_enabled(imx6_pcie->vpcie)) { + if (imx6_pcie->vpcie) { ret = regulator_enable(imx6_pcie->vpcie); if (ret) { dev_err(dev, "failed to enable vpcie regulator: %d\n", @@ -656,7 +646,7 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) return 0; err_clks: - if (imx6_pcie->vpcie && regulator_is_enabled(imx6_pcie->vpcie) > 0) { + if (imx6_pcie->vpcie) { ret = regulator_disable(imx6_pcie->vpcie); if (ret) dev_err(dev, "failed to disable vpcie regulator: %d\n", -- 2.25.1