From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16B0DC5478C for ; Fri, 1 Mar 2024 19:39:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Y7vwgXHx4MGNQ1p4JtnNtkf+ids/lwB6jBy7Qv4suYM=; b=ArvFr/+BJPmwtg 115T8M1LSDun2xHRDYNhFHc6NAIqo79HilVgW4OGz11UluKcY+M+DVo1OVY+Q/dgGzgmbb7QbeDbY ajl7bgYCtr0npQTRUDxtmEeC6AKLk5AxpszvGjLeLVUTBul6QtZvk0zZcDEZtS8+/nnPTW35OinNI ki0A2IgOorbHwNPvZAjX4ZuXy4zqbvQgWJUQi7RiDMBkNhjCnvKtszJIoXN18ka/IiIatmus35FK0 guSKvnNwfBcAHWF7F9/as+PYOfamS6+A5WHGNKluvfWzDU0ZxSCuHZVuI+1GIQ6chWxdUizG9TZbr zf4XRtd5NJxGwEC7eehA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rg8iv-00000001kpy-0MgL; Fri, 01 Mar 2024 19:39:13 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rg8is-00000001kpG-08tH for linux-arm-kernel@lists.infradead.org; Fri, 01 Mar 2024 19:39:11 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1dc13fb0133so20893245ad.3 for ; Fri, 01 Mar 2024 11:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709321949; x=1709926749; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+XmK1KXUIgEldgLQ9Dj7dEfcJRP25Vkl9HU6FEdalXs=; b=BLnwF82PvkqG6pdi18JFpaphPWjxYgTeSGnRQB+NAARpTsimv6ablySkQoNcGDYJ9s y7chls3PeVk5HHRkAXpPFH3JhwX1ExZbPK2+gENQwkhrRewhX7gKzIo1vuCgjbZRuT0F XGqgsWriaJGfLqc5T0at/mDznNguOKSzopJSRJTr/2NaM5VAUxkrTAnnt1AlEf7ZcZ49 Cb4GZ5KI/X27EC9tv8Dec/yidhwfDmfyXIN74G1xQZLZ9hdEJWDVgr3ndE4pJZ6xugBe XnpbjV236UrVhR+RMynuH9VhOJ/HtfdbJJBngUdpcd/sh99fyV5Rqb52/ue569NCaP9o Rh+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709321949; x=1709926749; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+XmK1KXUIgEldgLQ9Dj7dEfcJRP25Vkl9HU6FEdalXs=; b=RM/kTuBRfeWfVK0e4eON40I4Eu4V6Qeq6s3MS/5h1cNSNNQQC2oYAThhx5RdSus5Ni WaYG+ailoLM7TQYicOif/S9nNyEMn8KbSchHIqf/OKJ7U9CwlwHQSXaDBM+qOrs59SgU qgw4vCwZ9dalBzibb7NMBW1J0s4zGgj41kYZagvyzEw+edtnpSBRCnJc5aTzvQ1k+M64 ywWfcP6qkdKEnc05kbCLiMHHF2GFxvViMKiyKBNzAHq4YCA8SbKiCdgJbz6Q4d8VgpGQ xg1nkgr/DtPHEsTv/XPJFDpUc3XKRO4mFAkT0ywC+dJMWq22tz+W3wwd+MPWNovxeH6n LfLQ== X-Forwarded-Encrypted: i=1; AJvYcCXV9IiQyJoGFZAamtwlbeRmuc4s93HA1oURvZtQU57P3g7Ha+phEMNCdU6BLIbGzsXpcVfcy7LM7sDFMZMiULs75/W1buEBcrhkZ4Gbo99fU+pUMHM= X-Gm-Message-State: AOJu0Yz0xurBXVtf2EWqhyDU2uKqlVOW5RaWk5Ndp/pgNUofNc1ARsmW tmvvOpGEjibKnbhBr8yY/aGT5IlAi/jBVG/lTEwj+29/RPU+1Z0EgYCtENLV X-Google-Smtp-Source: AGHT+IFe/jusPETkAIAJswHE+vTyxv3T1WsrpeHoubCmcfJB1aHT1VfWeAn2Cx/qrh1L+SPHWwbrkg== X-Received: by 2002:a17:902:fe82:b0:1db:8fd9:ba0d with SMTP id x2-20020a170902fe8200b001db8fd9ba0dmr2177685plm.23.1709321948602; Fri, 01 Mar 2024 11:39:08 -0800 (PST) Received: from localhost.localdomain ([113.30.217.222]) by smtp.gmail.com with ESMTPSA id u8-20020a170902e5c800b001dca6d1d572sm3837474plf.63.2024.03.01.11.39.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:39:08 -0800 (PST) From: Anand Moon To: Alan Stern , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar Cc: Anand Moon , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/4] usb: ehci-exynos: Use devm_clk_get_enabled() helpers Date: Sat, 2 Mar 2024 01:08:08 +0530 Message-ID: <20240301193831.3346-2-linux.amoon@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240301193831.3346-1-linux.amoon@gmail.com> References: <20240301193831.3346-1-linux.amoon@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240301_113910_119387_12A8947A X-CRM114-Status: GOOD ( 18.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The devm_clk_get_enabled() helpers: - call devm_clk_get() - call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code and avoids the calls to clk_disable_unprepare(). While at it, use dev_err_probe consistently, and use its return value to return the error code. Signed-off-by: Anand Moon --- drivers/usb/host/ehci-exynos.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index f644b131cc0b..05aa3d9c2a3b 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -159,19 +159,12 @@ static int exynos_ehci_probe(struct platform_device *pdev) err = exynos_ehci_get_phy(&pdev->dev, exynos_ehci); if (err) - goto fail_clk; - - exynos_ehci->clk = devm_clk_get(&pdev->dev, "usbhost"); - - if (IS_ERR(exynos_ehci->clk)) { - dev_err(&pdev->dev, "Failed to get usbhost clock\n"); - err = PTR_ERR(exynos_ehci->clk); - goto fail_clk; - } + goto fail_io; - err = clk_prepare_enable(exynos_ehci->clk); - if (err) - goto fail_clk; + exynos_ehci->clk = devm_clk_get_enabled(&pdev->dev, "usbhost"); + if (IS_ERR(exynos_ehci->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(exynos_ehci->clk), + "Failed to get usbhost clock\n"); hcd->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(hcd->regs)) { @@ -223,8 +216,6 @@ static int exynos_ehci_probe(struct platform_device *pdev) exynos_ehci_phy_disable(&pdev->dev); pdev->dev.of_node = exynos_ehci->of_node; fail_io: - clk_disable_unprepare(exynos_ehci->clk); -fail_clk: usb_put_hcd(hcd); return err; } @@ -240,8 +231,6 @@ static void exynos_ehci_remove(struct platform_device *pdev) exynos_ehci_phy_disable(&pdev->dev); - clk_disable_unprepare(exynos_ehci->clk); - usb_put_hcd(hcd); } @@ -249,7 +238,6 @@ static void exynos_ehci_remove(struct platform_device *pdev) static int exynos_ehci_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); - struct exynos_ehci_hcd *exynos_ehci = to_exynos_ehci(hcd); bool do_wakeup = device_may_wakeup(dev); int rc; @@ -260,25 +248,17 @@ static int exynos_ehci_suspend(struct device *dev) exynos_ehci_phy_disable(dev); - clk_disable_unprepare(exynos_ehci->clk); - return rc; } static int exynos_ehci_resume(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); - struct exynos_ehci_hcd *exynos_ehci = to_exynos_ehci(hcd); int ret; - ret = clk_prepare_enable(exynos_ehci->clk); - if (ret) - return ret; - ret = exynos_ehci_phy_enable(dev); if (ret) { dev_err(dev, "Failed to enable USB phy\n"); - clk_disable_unprepare(exynos_ehci->clk); return ret; } -- 2.43.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel